mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-24 20:18:53 +03:00
Add configuration to display room's parent in room switcher
This commit is contained in:
parent
46a8019913
commit
7582c6d3a8
3 changed files with 45 additions and 4 deletions
|
@ -249,10 +249,13 @@ Control {
|
|||
text: model.roomName
|
||||
textFormat: Text.RichText
|
||||
}
|
||||
|
||||
Label {
|
||||
text: model.roomParent === "" ? "" : ("[" + model.roomParent + "]")
|
||||
font.pixelSize: popup.avatarHeight * 0.5
|
||||
Loader {
|
||||
active: Settings.displayParentInSwitcher && model.roomParent !== ""
|
||||
sourceComponent: Label {
|
||||
color: model.index == popup.currentIndex ? palette.highlightedText : palette.text
|
||||
text: "[" + model.roomParent + "]"
|
||||
font.pixelSize: popup.avatarHeight * 0.5
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@ UserSettings::load(std::optional<QString> profile)
|
|||
sortByAlphabet_ = settings.value("user/sort_by_alphabet", false).toBool();
|
||||
readReceipts_ = settings.value("user/read_receipts", true).toBool();
|
||||
theme_ = settings.value("user/theme", defaultTheme_).toString();
|
||||
displayParentInSwitcher_ = settings.value("user/display_parent_on_room_switch", true).toBool();
|
||||
|
||||
font_ = settings.value("user/font_family", "").toString();
|
||||
|
||||
|
@ -857,6 +858,16 @@ UserSettings::setOpenVideoExternal(bool state)
|
|||
save();
|
||||
}
|
||||
|
||||
void
|
||||
UserSettings::setDisplayParentInSwitcher(bool state)
|
||||
{
|
||||
if (state == displayParentInSwitcher_)
|
||||
return;
|
||||
displayParentInSwitcher_ = state;
|
||||
emit displayParentInSwitcherChanged(displayParentInSwitcher_);
|
||||
save();
|
||||
}
|
||||
|
||||
void
|
||||
UserSettings::applyTheme()
|
||||
{
|
||||
|
@ -931,6 +942,7 @@ UserSettings::save()
|
|||
settings.setValue("expose_dbus_api", exposeDBusApi_);
|
||||
settings.setValue("space_background_maintenance", updateSpaceVias_);
|
||||
settings.setValue("expired_events_background_maintenance", expireEvents_);
|
||||
settings.setValue("display_parent_on_room_switch", displayParentInSwitcher_);
|
||||
|
||||
settings.endGroup(); // user
|
||||
|
||||
|
@ -1014,6 +1026,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
|||
return tr("Communities sidebar");
|
||||
case ScrollbarsInRoomlist:
|
||||
return tr("Scrollbars in room list");
|
||||
case DisplayParentInSwitcher:
|
||||
return tr("Display room's parent in room switcher");
|
||||
case Markdown:
|
||||
return tr("Send messages as Markdown");
|
||||
case InvertEnterKey:
|
||||
|
@ -1172,6 +1186,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
|||
return i->groupView();
|
||||
case ScrollbarsInRoomlist:
|
||||
return i->scrollbarsInRoomlist();
|
||||
case DisplayParentInSwitcher:
|
||||
return i->displayParentInSwitcher();
|
||||
case Markdown:
|
||||
return i->markdown();
|
||||
case InvertEnterKey:
|
||||
|
@ -1334,6 +1350,10 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
|||
return tr("Show a column containing communities and tags next to the room list.");
|
||||
case ScrollbarsInRoomlist:
|
||||
return tr("Shows scrollbars in the room list and communities list.");
|
||||
case DisplayParentInSwitcher:
|
||||
return tr("Display a room's parent in the room switcher. "
|
||||
"Enabling this option allows distinguishing multiple rooms "
|
||||
"with the same name");
|
||||
case Markdown:
|
||||
return tr(
|
||||
"Allow using markdown in messages.\nWhen disabled, all messages are sent as a plain "
|
||||
|
@ -1516,6 +1536,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
|||
case StartInTray:
|
||||
case GroupView:
|
||||
case ScrollbarsInRoomlist:
|
||||
case DisplayParentInSwitcher:
|
||||
case Markdown:
|
||||
case InvertEnterKey:
|
||||
case Bubbles:
|
||||
|
@ -1758,6 +1779,13 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int
|
|||
} else
|
||||
return false;
|
||||
}
|
||||
case DisplayParentInSwitcher: {
|
||||
if (value.userType() == QMetaType::Bool) {
|
||||
i->setDisplayParentInSwitcher(value.toBool());
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
case Markdown: {
|
||||
if (value.userType() == QMetaType::Bool) {
|
||||
i->setMarkdown(value.toBool());
|
||||
|
@ -2253,6 +2281,9 @@ UserSettingsModel::UserSettingsModel(QObject *p)
|
|||
connect(s.get(), &UserSettings::scrollbarsInRoomlistChanged, this, [this]() {
|
||||
emit dataChanged(index(ScrollbarsInRoomlist), index(ScrollbarsInRoomlist), {Value});
|
||||
});
|
||||
connect(s.get(), &UserSettings::displayParentInSwitcherChanged, this, [this]() {
|
||||
emit dataChanged(index(DisplayParentInSwitcher), index(DisplayParentInSwitcher), {Value});
|
||||
});
|
||||
connect(s.get(), &UserSettings::roomSortingChangedImportance, this, [this]() {
|
||||
emit dataChanged(index(SortByImportance), index(SortByImportance), {Value});
|
||||
});
|
||||
|
|
|
@ -121,6 +121,8 @@ class UserSettings final : public QObject
|
|||
Q_PROPERTY(bool updateSpaceVias READ updateSpaceVias WRITE setUpdateSpaceVias NOTIFY
|
||||
updateSpaceViasChanged)
|
||||
Q_PROPERTY(bool expireEvents READ expireEvents WRITE setExpireEvents NOTIFY expireEventsChanged)
|
||||
Q_PROPERTY(bool displayParentInSwitcher READ displayParentInSwitcher WRITE
|
||||
setDisplayParentInSwitcher NOTIFY displayParentInSwitcherChanged)
|
||||
|
||||
UserSettings();
|
||||
|
||||
|
@ -228,6 +230,7 @@ public:
|
|||
void setExposeDBusApi(bool state);
|
||||
void setUpdateSpaceVias(bool state);
|
||||
void setExpireEvents(bool state);
|
||||
void setDisplayParentInSwitcher(bool state);
|
||||
|
||||
QString theme() const { return !theme_.isEmpty() ? theme_ : defaultTheme_; }
|
||||
bool messageHoverHighlight() const { return messageHoverHighlight_; }
|
||||
|
@ -305,6 +308,7 @@ public:
|
|||
bool exposeDBusApi() const { return exposeDBusApi_; }
|
||||
bool updateSpaceVias() const { return updateSpaceVias_; }
|
||||
bool expireEvents() const { return expireEvents_; }
|
||||
bool displayParentInSwitcher() const { return displayParentInSwitcher_; }
|
||||
|
||||
signals:
|
||||
void groupViewStateChanged(bool state);
|
||||
|
@ -371,6 +375,7 @@ signals:
|
|||
void exposeDBusApiChanged(bool state);
|
||||
void updateSpaceViasChanged(bool state);
|
||||
void expireEventsChanged(bool state);
|
||||
void displayParentInSwitcherChanged(bool state);
|
||||
|
||||
private:
|
||||
// Default to system theme if QT_QPA_PLATFORMTHEME var is set.
|
||||
|
@ -447,6 +452,7 @@ private:
|
|||
bool exposeDBusApi_;
|
||||
bool updateSpaceVias_;
|
||||
bool expireEvents_;
|
||||
bool displayParentInSwitcher_;
|
||||
|
||||
QSettings settings;
|
||||
|
||||
|
@ -476,6 +482,7 @@ class UserSettingsModel : public QAbstractListModel
|
|||
PrivacyScreen,
|
||||
PrivacyScreenTimeout,
|
||||
ScrollbarsInRoomlist,
|
||||
DisplayParentInSwitcher,
|
||||
#ifdef NHEKO_DBUS_SYS
|
||||
ExposeDBusApi,
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue