Skip to content

Commit

Permalink
Merge PR #6158: FEAT(client): Add setting to always show user in Talk…
Browse files Browse the repository at this point in the history
…ing UI

Added checkbox to specify whether all users should always be visible in the TalkingUI window

Change user display state dependant on settings on startup and settings change

Prevent user display timeout if new bool "Always keep users visible" setting is checked

Fixed restrictLifetime in TalkingUIEntry.cpp to actually stop the timer if restrict is set to false and the timer is running
  • Loading branch information
Krzmbrzl authored Jan 1, 2024
2 parents d748235 + d855326 commit 7bc05b3
Show file tree
Hide file tree
Showing 53 changed files with 615 additions and 23 deletions.
11 changes: 11 additions & 0 deletions src/mumble/LookConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ void LookConfig::load(const Settings &r) {
const boost::optional< ThemeInfo::StyleInfo > configuredStyle = Themes::getConfiguredStyle(r);
reloadThemes(configuredStyle);

loadCheckBox(qcbUsersAlwaysVisible, r.talkingUI_UsersAlwaysVisible);
loadCheckBox(qcbLocalUserVisible, r.bTalkingUI_LocalUserStaysVisible);
loadCheckBox(qcbAbbreviateChannelNames, r.bTalkingUI_AbbreviateChannelNames);
loadCheckBox(qcbAbbreviateCurrentChannel, r.bTalkingUI_AbbreviateCurrentChannel);
Expand Down Expand Up @@ -276,6 +277,7 @@ void LookConfig::save() const {
Themes::setConfiguredStyle(s, themeData.value< ThemeInfo::StyleInfo >(), s.requireRestartToApply);
}

s.talkingUI_UsersAlwaysVisible = qcbUsersAlwaysVisible->isChecked();
s.bTalkingUI_LocalUserStaysVisible = qcbLocalUserVisible->isChecked();
s.bTalkingUI_AbbreviateChannelNames = qcbAbbreviateChannelNames->isChecked();
s.bTalkingUI_AbbreviateCurrentChannel = qcbAbbreviateCurrentChannel->isChecked();
Expand Down Expand Up @@ -321,3 +323,12 @@ void LookConfig::on_qcbAbbreviateChannelNames_stateChanged(int state) {
qsbPostfixCharCount->setEnabled(abbreviateNames);
qleAbbreviationReplacement->setEnabled(abbreviateNames);
}

void LookConfig::on_qcbUsersAlwaysVisible_stateChanged(int state) {
bool usersAlwaysVisible = state == Qt::Checked;

// Only enable the local user visibility setting when all users are not always visible
qcbLocalUserVisible->setEnabled(!usersAlwaysVisible);
// Only enable the user visibility timeout settings when all users are not always visible
qsbSilentUserLifetime->setEnabled(!usersAlwaysVisible);
}
1 change: 1 addition & 0 deletions src/mumble/LookConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public slots:
void load(const Settings &r) Q_DECL_OVERRIDE;
void themeDirectoryChanged();
void on_qcbAbbreviateChannelNames_stateChanged(int state);
void on_qcbUsersAlwaysVisible_stateChanged(int state);

private:
/// Reload themes combobox and select given configuredStyle in it
Expand Down
49 changes: 31 additions & 18 deletions src/mumble/LookConfig.ui
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@
<property name="horizontalSpacing">
<number>6</number>
</property>
<item row="11" column="0">
<item row="12" column="0">
<widget class="QLabel" name="qlPostfixCharCount">
<property name="toolTip">
<string>How many characters from the original name to display at the end of an abbreviated name.</string>
Expand All @@ -575,14 +575,14 @@
</property>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<widget class="QSpinBox" name="qsbMaxNameLength">
<property name="toolTip">
<string>The preferred maximum length of a channel (hierarchy) name in the Talking UI. Note that this is not a hard limit though.</string>
</property>
</widget>
</item>
<item row="13" column="1">
<item row="14" column="1">
<widget class="QLineEdit" name="qleAbbreviationReplacement">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
Expand All @@ -595,14 +595,14 @@
</property>
</widget>
</item>
<item row="11" column="1">
<item row="12" column="1">
<widget class="QSpinBox" name="qsbPostfixCharCount">
<property name="toolTip">
<string>How many characters from the original name to display at the end of an abbreviated name.</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QSpinBox" name="qsbRelFontSize">
<property name="toolTip">
<string>Relative font size to use in the Talking UI in percent.</string>
Expand All @@ -615,7 +615,7 @@
</property>
</widget>
</item>
<item row="9" column="0">
<item row="10" column="0">
<widget class="QLabel" name="qlMaxNameLength">
<property name="toolTip">
<string>The preferred maximum length of a channel (hierarchy) name in the Talking UI. Note that this is not a hard limit though.</string>
Expand All @@ -625,7 +625,7 @@
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QSpinBox" name="qsbSilentUserLifetime">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
Expand All @@ -636,12 +636,15 @@
<property name="toolTip">
<string>A user that is silent for the given amount of seconds will be removed from the Talkin UI.</string>
</property>
<property name="suffix">
<string> seconds</string>
</property>
<property name="maximum">
<number>999</number>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="qcbAbbreviateCurrentChannel">
<property name="toolTip">
<string>Whether to also allow abbreviating the current channel of a user (instead of only its parent channels).</string>
Expand All @@ -651,7 +654,7 @@
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="qlSilentUserLifetime">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
Expand All @@ -667,7 +670,7 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="qcbAbbreviateChannelNames">
<property name="toolTip">
<string>Whether the channel (hierarchy) name should be abbreviated, if it exceeds the specified maximum length.</string>
Expand All @@ -677,14 +680,14 @@
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QSpinBox" name="qsbChannelHierarchyDepth">
<property name="toolTip">
<string>The names of how many parent channels should be included in the channel's name when displaying it in the TalkingUI?</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="qcbShowLocalListeners">
<property name="toolTip">
<string>Whether to show all of the local user's listeners (ears) in the TalkingUI (and thereby also the channels they are in). </string>
Expand All @@ -694,7 +697,7 @@
</property>
</widget>
</item>
<item row="13" column="0">
<item row="14" column="0">
<widget class="QLabel" name="qlAbbreviationReplacement">
<property name="toolTip">
<string>String that gets used instead of the cut-out part of an abbreviated name.</string>
Expand All @@ -704,7 +707,7 @@
</property>
</widget>
</item>
<item row="10" column="0">
<item row="11" column="0">
<widget class="QLabel" name="qlPrefixCharCount">
<property name="toolTip">
<string>How many characters from the original name to display at the beginning of an abbreviated name.</string>
Expand All @@ -714,7 +717,7 @@
</property>
</widget>
</item>
<item row="0" column="0">
<item row="1" column="0">
<widget class="QCheckBox" name="qcbLocalUserVisible">
<property name="toolTip">
<string>If this is checked, the local user (yourself) will always be visible in the TalkingUI (regardless of talking state).</string>
Expand All @@ -724,14 +727,14 @@
</property>
</widget>
</item>
<item row="10" column="1">
<item row="11" column="1">
<widget class="QSpinBox" name="qsbPrefixCharCount">
<property name="toolTip">
<string>How many characters from the original name to display at the beginning of an abbreviated name.</string>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="qlRelFontSize">
<property name="toolTip">
<string>Relative font size to use in the Talking UI in percent.</string>
Expand All @@ -741,7 +744,7 @@
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="qlChannelHierarchyDepth">
<property name="toolTip">
<string>The names of how many parent channels should be included in the channel's name when displaying it in the TalkingUI?</string>
Expand All @@ -751,6 +754,16 @@
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="qcbUsersAlwaysVisible">
<property name="toolTip">
<string>If this is checked, users will always be visible in the TalkingUI (regardless of talking state).</string>
</property>
<property name="text">
<string>Always keep users visible</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
1 change: 1 addition & 0 deletions src/mumble/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ struct Settings {

QPoint qpTalkingUI_Position = UNSPECIFIED_POSITION;
bool bShowTalkingUI = false;
bool talkingUI_UsersAlwaysVisible = false;
bool bTalkingUI_LocalUserStaysVisible = false;
bool bTalkingUI_AbbreviateChannelNames = true;
bool bTalkingUI_AbbreviateCurrentChannel = false;
Expand Down
1 change: 1 addition & 0 deletions src/mumble/SettingsKeys.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ const SettingsKey CRASH_EMAIL_ADDRESS_KEY = { "crash_report_email
// TalkingUI
const SettingsKey TALKINGUI_POSITION_KEY = { "talkingui_position" };
const SettingsKey SHOW_TALKINGUI_KEY = { "display_talkingui" };
const SettingsKey TALKINGUI_USERS_ALWAYS_VISIBLE_KEY = { "users_always_visible" };
const SettingsKey TALKINGUI_LOCAL_USER_STAYS_VISIBLE_KEY = { "local_user_stays_visible" };
const SettingsKey TALKINGUI_ABBREVIATE_CHANNEL_NAMES_KEY = { "abbreviate_channel_names" };
const SettingsKey TALKINGUI_ABBREVIATE_CURRENT_CHANNEL_KEY = { "abbreviate_current_channel_name" };
Expand Down
1 change: 1 addition & 0 deletions src/mumble/SettingsMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
#define TALKINGUI_SETTINGS \
PROCESS(talkingui, TALKINGUI_POSITION_KEY, qpTalkingUI_Position) \
PROCESS(talkingui, SHOW_TALKINGUI_KEY, bShowTalkingUI) \
PROCESS(talkingui, TALKINGUI_USERS_ALWAYS_VISIBLE_KEY, talkingUI_UsersAlwaysVisible) \
PROCESS(talkingui, TALKINGUI_LOCAL_USER_STAYS_VISIBLE_KEY, bTalkingUI_LocalUserStaysVisible) \
PROCESS(talkingui, TALKINGUI_ABBREVIATE_CHANNEL_NAMES_KEY, bTalkingUI_AbbreviateChannelNames) \
PROCESS(talkingui, TALKINGUI_ABBREVIATE_CURRENT_CHANNEL_KEY, bTalkingUI_AbbreviateCurrentChannel) \
Expand Down
32 changes: 28 additions & 4 deletions src/mumble/TalkingUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,10 @@ TalkingUIUser *TalkingUI::findOrAddUser(const ClientUser *user) {
// * 1000 as the setting is in seconds whereas the timer expects milliseconds
userEntry->setLifeTime(Global::get().s.iTalkingUI_SilentUserLifeTime * 1000);

userEntry->restrictLifetime(!isSelf || !Global::get().s.bTalkingUI_LocalUserStaysVisible);
bool isLocalUserAndLocalUserAlwaysVisible = isSelf && Global::get().s.bTalkingUI_LocalUserStaysVisible;
bool usersAlwaysVisible = Global::get().s.talkingUI_UsersAlwaysVisible;
bool isUserAlwaysVisible = usersAlwaysVisible || isLocalUserAndLocalUserAlwaysVisible;
userEntry->restrictLifetime(!isUserAlwaysVisible);

userEntry->setPriority(isSelf ? EntryPriority::HIGH : EntryPriority::DEFAULT);

Expand Down Expand Up @@ -678,6 +681,14 @@ void TalkingUI::on_serverSynchronized() {
findOrAddUser(self);
}

// According to the settings the all users should always be visible and as we
// can't count on users to change their talking state right after our user has connected
// to a server, we have to add them manually.
if (Global::get().s.talkingUI_UsersAlwaysVisible) {
for (auto &user : ClientUser::c_qmUsers) {
findOrAddUser(user);
}
}
// The client may have received add listener messages for the user before the
// sync was complete. So we do this to ensure that they appear in the
// TalkingUI. Removing all listeners is probably not necessary but could
Expand Down Expand Up @@ -761,6 +772,8 @@ void TalkingUI::on_settingsChanged() {
}
}

int silentUserLifeTime = Global::get().s.iTalkingUI_SilentUserLifeTime;
bool usersAlwaysVisible = Global::get().s.talkingUI_UsersAlwaysVisible;
// If the font has changed, we have to update the icon size as well
for (auto &currentContainer : m_containers) {
for (auto &currentEntry : currentContainer->getEntries()) {
Expand All @@ -771,20 +784,31 @@ void TalkingUI::on_settingsChanged() {

// The time that a silent user may stick around might have changed as well
// * 1000 as the setting is in seconds whereas the timer expects milliseconds
userEntry->setLifeTime(Global::get().s.iTalkingUI_SilentUserLifeTime * 1000);
userEntry->setLifeTime(silentUserLifeTime * 1000);
userEntry->restrictLifetime(!usersAlwaysVisible);
}
}
}

// According to the settings the all users should always be visible and as we
// can't count on users to change their talking state right after settings where changed
// we have to add them manually.
if (usersAlwaysVisible) {
for (auto &user : ClientUser::c_qmUsers) {
findOrAddUser(user);
}
}

const ClientUser *self = ClientUser::get(Global::get().uiSession);

// Whether or not the current user should always be displayed might also have changed,
// so we'll have to update that as well.
TalkingUIUser *localUserEntry = findUser(Global::get().uiSession);
if (localUserEntry) {
localUserEntry->restrictLifetime(!Global::get().s.bTalkingUI_LocalUserStaysVisible);
bool localUserAlwaysVisible = usersAlwaysVisible || Global::get().s.bTalkingUI_LocalUserStaysVisible;
localUserEntry->restrictLifetime(!localUserAlwaysVisible);
} else {
if (self && Global::get().s.bTalkingUI_LocalUserStaysVisible) {
if (self && (Global::get().s.bTalkingUI_LocalUserStaysVisible || usersAlwaysVisible)) {
// Add the local user as it is requested to be displayed
findOrAddUser(self);
}
Expand Down
2 changes: 1 addition & 1 deletion src/mumble/TalkingUIEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void TalkingUIUser::restrictLifetime(bool restrict) {
if (restrict && !m_timer.isActive()) {
// Start timer
m_timer.start();
} else if (!restrict && !m_timer.isActive()) {
} else if (!restrict && m_timer.isActive()) {
// Stop timer
m_timer.stop();
}
Expand Down
12 changes: 12 additions & 0 deletions src/mumble/mumble_ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4564,6 +4564,18 @@ The setting only applies for new messages, the already shown ones will retain th
<source>Always Quit</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> seconds</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>If this is checked, users will always be visible in the TalkingUI (regardless of talking state).</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Always keep users visible</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainWindow</name>
Expand Down
12 changes: 12 additions & 0 deletions src/mumble/mumble_bg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4561,6 +4561,18 @@ The setting only applies for new messages, the already shown ones will retain th
<source>Always Quit</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> seconds</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>If this is checked, users will always be visible in the TalkingUI (regardless of talking state).</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Always keep users visible</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainWindow</name>
Expand Down
12 changes: 12 additions & 0 deletions src/mumble/mumble_br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4560,6 +4560,18 @@ The setting only applies for new messages, the already shown ones will retain th
<source>Always Quit</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> seconds</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>If this is checked, users will always be visible in the TalkingUI (regardless of talking state).</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Always keep users visible</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainWindow</name>
Expand Down
12 changes: 12 additions & 0 deletions src/mumble/mumble_ca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4586,6 +4586,18 @@ The setting only applies for new messages, the already shown ones will retain th
<source>Always Quit</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> seconds</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>If this is checked, users will always be visible in the TalkingUI (regardless of talking state).</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Always keep users visible</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainWindow</name>
Expand Down
Loading

0 comments on commit 7bc05b3

Please sign in to comment.