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
|
text: model.roomName
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
}
|
}
|
||||||
|
Loader {
|
||||||
Label {
|
active: Settings.displayParentInSwitcher && model.roomParent !== ""
|
||||||
text: model.roomParent === "" ? "" : ("[" + model.roomParent + "]")
|
sourceComponent: Label {
|
||||||
font.pixelSize: popup.avatarHeight * 0.5
|
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();
|
sortByAlphabet_ = settings.value("user/sort_by_alphabet", false).toBool();
|
||||||
readReceipts_ = settings.value("user/read_receipts", true).toBool();
|
readReceipts_ = settings.value("user/read_receipts", true).toBool();
|
||||||
theme_ = settings.value("user/theme", defaultTheme_).toString();
|
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();
|
font_ = settings.value("user/font_family", "").toString();
|
||||||
|
|
||||||
|
@ -857,6 +858,16 @@ UserSettings::setOpenVideoExternal(bool state)
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
UserSettings::setDisplayParentInSwitcher(bool state)
|
||||||
|
{
|
||||||
|
if (state == displayParentInSwitcher_)
|
||||||
|
return;
|
||||||
|
displayParentInSwitcher_ = state;
|
||||||
|
emit displayParentInSwitcherChanged(displayParentInSwitcher_);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
UserSettings::applyTheme()
|
UserSettings::applyTheme()
|
||||||
{
|
{
|
||||||
|
@ -931,6 +942,7 @@ UserSettings::save()
|
||||||
settings.setValue("expose_dbus_api", exposeDBusApi_);
|
settings.setValue("expose_dbus_api", exposeDBusApi_);
|
||||||
settings.setValue("space_background_maintenance", updateSpaceVias_);
|
settings.setValue("space_background_maintenance", updateSpaceVias_);
|
||||||
settings.setValue("expired_events_background_maintenance", expireEvents_);
|
settings.setValue("expired_events_background_maintenance", expireEvents_);
|
||||||
|
settings.setValue("display_parent_on_room_switch", displayParentInSwitcher_);
|
||||||
|
|
||||||
settings.endGroup(); // user
|
settings.endGroup(); // user
|
||||||
|
|
||||||
|
@ -1014,6 +1026,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
||||||
return tr("Communities sidebar");
|
return tr("Communities sidebar");
|
||||||
case ScrollbarsInRoomlist:
|
case ScrollbarsInRoomlist:
|
||||||
return tr("Scrollbars in room list");
|
return tr("Scrollbars in room list");
|
||||||
|
case DisplayParentInSwitcher:
|
||||||
|
return tr("Display room's parent in room switcher");
|
||||||
case Markdown:
|
case Markdown:
|
||||||
return tr("Send messages as Markdown");
|
return tr("Send messages as Markdown");
|
||||||
case InvertEnterKey:
|
case InvertEnterKey:
|
||||||
|
@ -1172,6 +1186,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
||||||
return i->groupView();
|
return i->groupView();
|
||||||
case ScrollbarsInRoomlist:
|
case ScrollbarsInRoomlist:
|
||||||
return i->scrollbarsInRoomlist();
|
return i->scrollbarsInRoomlist();
|
||||||
|
case DisplayParentInSwitcher:
|
||||||
|
return i->displayParentInSwitcher();
|
||||||
case Markdown:
|
case Markdown:
|
||||||
return i->markdown();
|
return i->markdown();
|
||||||
case InvertEnterKey:
|
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.");
|
return tr("Show a column containing communities and tags next to the room list.");
|
||||||
case ScrollbarsInRoomlist:
|
case ScrollbarsInRoomlist:
|
||||||
return tr("Shows scrollbars in the room list and communities list.");
|
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:
|
case Markdown:
|
||||||
return tr(
|
return tr(
|
||||||
"Allow using markdown in messages.\nWhen disabled, all messages are sent as a plain "
|
"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 StartInTray:
|
||||||
case GroupView:
|
case GroupView:
|
||||||
case ScrollbarsInRoomlist:
|
case ScrollbarsInRoomlist:
|
||||||
|
case DisplayParentInSwitcher:
|
||||||
case Markdown:
|
case Markdown:
|
||||||
case InvertEnterKey:
|
case InvertEnterKey:
|
||||||
case Bubbles:
|
case Bubbles:
|
||||||
|
@ -1758,6 +1779,13 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
case DisplayParentInSwitcher: {
|
||||||
|
if (value.userType() == QMetaType::Bool) {
|
||||||
|
i->setDisplayParentInSwitcher(value.toBool());
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
case Markdown: {
|
case Markdown: {
|
||||||
if (value.userType() == QMetaType::Bool) {
|
if (value.userType() == QMetaType::Bool) {
|
||||||
i->setMarkdown(value.toBool());
|
i->setMarkdown(value.toBool());
|
||||||
|
@ -2253,6 +2281,9 @@ UserSettingsModel::UserSettingsModel(QObject *p)
|
||||||
connect(s.get(), &UserSettings::scrollbarsInRoomlistChanged, this, [this]() {
|
connect(s.get(), &UserSettings::scrollbarsInRoomlistChanged, this, [this]() {
|
||||||
emit dataChanged(index(ScrollbarsInRoomlist), index(ScrollbarsInRoomlist), {Value});
|
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]() {
|
connect(s.get(), &UserSettings::roomSortingChangedImportance, this, [this]() {
|
||||||
emit dataChanged(index(SortByImportance), index(SortByImportance), {Value});
|
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
|
Q_PROPERTY(bool updateSpaceVias READ updateSpaceVias WRITE setUpdateSpaceVias NOTIFY
|
||||||
updateSpaceViasChanged)
|
updateSpaceViasChanged)
|
||||||
Q_PROPERTY(bool expireEvents READ expireEvents WRITE setExpireEvents NOTIFY expireEventsChanged)
|
Q_PROPERTY(bool expireEvents READ expireEvents WRITE setExpireEvents NOTIFY expireEventsChanged)
|
||||||
|
Q_PROPERTY(bool displayParentInSwitcher READ displayParentInSwitcher WRITE
|
||||||
|
setDisplayParentInSwitcher NOTIFY displayParentInSwitcherChanged)
|
||||||
|
|
||||||
UserSettings();
|
UserSettings();
|
||||||
|
|
||||||
|
@ -228,6 +230,7 @@ public:
|
||||||
void setExposeDBusApi(bool state);
|
void setExposeDBusApi(bool state);
|
||||||
void setUpdateSpaceVias(bool state);
|
void setUpdateSpaceVias(bool state);
|
||||||
void setExpireEvents(bool state);
|
void setExpireEvents(bool state);
|
||||||
|
void setDisplayParentInSwitcher(bool state);
|
||||||
|
|
||||||
QString theme() const { return !theme_.isEmpty() ? theme_ : defaultTheme_; }
|
QString theme() const { return !theme_.isEmpty() ? theme_ : defaultTheme_; }
|
||||||
bool messageHoverHighlight() const { return messageHoverHighlight_; }
|
bool messageHoverHighlight() const { return messageHoverHighlight_; }
|
||||||
|
@ -305,6 +308,7 @@ public:
|
||||||
bool exposeDBusApi() const { return exposeDBusApi_; }
|
bool exposeDBusApi() const { return exposeDBusApi_; }
|
||||||
bool updateSpaceVias() const { return updateSpaceVias_; }
|
bool updateSpaceVias() const { return updateSpaceVias_; }
|
||||||
bool expireEvents() const { return expireEvents_; }
|
bool expireEvents() const { return expireEvents_; }
|
||||||
|
bool displayParentInSwitcher() const { return displayParentInSwitcher_; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void groupViewStateChanged(bool state);
|
void groupViewStateChanged(bool state);
|
||||||
|
@ -371,6 +375,7 @@ signals:
|
||||||
void exposeDBusApiChanged(bool state);
|
void exposeDBusApiChanged(bool state);
|
||||||
void updateSpaceViasChanged(bool state);
|
void updateSpaceViasChanged(bool state);
|
||||||
void expireEventsChanged(bool state);
|
void expireEventsChanged(bool state);
|
||||||
|
void displayParentInSwitcherChanged(bool state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Default to system theme if QT_QPA_PLATFORMTHEME var is set.
|
// Default to system theme if QT_QPA_PLATFORMTHEME var is set.
|
||||||
|
@ -447,6 +452,7 @@ private:
|
||||||
bool exposeDBusApi_;
|
bool exposeDBusApi_;
|
||||||
bool updateSpaceVias_;
|
bool updateSpaceVias_;
|
||||||
bool expireEvents_;
|
bool expireEvents_;
|
||||||
|
bool displayParentInSwitcher_;
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
|
@ -476,6 +482,7 @@ class UserSettingsModel : public QAbstractListModel
|
||||||
PrivacyScreen,
|
PrivacyScreen,
|
||||||
PrivacyScreenTimeout,
|
PrivacyScreenTimeout,
|
||||||
ScrollbarsInRoomlist,
|
ScrollbarsInRoomlist,
|
||||||
|
DisplayParentInSwitcher,
|
||||||
#ifdef NHEKO_DBUS_SYS
|
#ifdef NHEKO_DBUS_SYS
|
||||||
ExposeDBusApi,
|
ExposeDBusApi,
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue