This commit is contained in:
Loren Burkholder 2024-11-17 19:29:50 +01:00 committed by GitHub
commit ddc284f06d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 71 additions and 13 deletions

View file

@ -132,7 +132,7 @@ Pane {
ImageButton { ImageButton {
id: pinButton id: pinButton
property bool pinsShown: !Settings.hiddenPins.includes(roomId) property bool pinsShown: Settings.hideAllPins ? Settings.shownPins.includes(roomId) : !Settings.hiddenPins.includes(roomId)
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
Layout.column: 3 Layout.column: 3
@ -146,16 +146,23 @@ Pane {
visible: !!room && room.pinnedMessages.length > 0 visible: !!room && room.pinnedMessages.length > 0
onClicked: { onClicked: {
var ps = Settings.hiddenPins; var hidden = Settings.hiddenPins;
var shown = Settings.shownPins;
if (pinsShown) { if (pinsShown) {
ps.push(roomId); hidden.push(roomId);
} else { const index = shown.indexOf(roomId);
const index = ps.indexOf(roomId);
if (index > -1) { if (index > -1) {
ps.splice(index, 1); shown.splice(index, 1);
}
} else {
shown.push(roomId);
const index = hidden.indexOf(roomId);
if (index > -1) {
hidden.splice(index, 1);
} }
} }
Settings.hiddenPins = ps; Settings.hiddenPins = hidden;
Settings.shownPins = shown;
} }
} }
AbstractButton { AbstractButton {
@ -272,7 +279,9 @@ Pane {
Layout.row: 3 Layout.row: 3
ScrollBar.horizontal.visible: false ScrollBar.horizontal.visible: false
clip: true clip: true
visible: !!room && room.pinnedMessages.length > 0 && !Settings.hiddenPins.includes(roomId) visible: !!room
&& room.pinnedMessages.length > 0
&& (Settings.hideAllPins ? Settings.shownPins.includes(roomId) : !Settings.hiddenPins.includes(roomId))
contentWidth: availableWidth contentWidth: availableWidth
ListView { ListView {

View file

@ -123,7 +123,9 @@ UserSettings::load(std::optional<QString> profile)
currentTagId_ = settings.value(prefix + "user/current_tag_id", "").toString(); currentTagId_ = settings.value(prefix + "user/current_tag_id", "").toString();
hiddenTags_ = settings.value(prefix + "user/hidden_tags", QStringList{}).toStringList(); hiddenTags_ = settings.value(prefix + "user/hidden_tags", QStringList{}).toStringList();
mutedTags_ = settings.value(prefix + "user/muted_tags", QStringList{"global"}).toStringList(); mutedTags_ = settings.value(prefix + "user/muted_tags", QStringList{"global"}).toStringList();
hideAllPins_ = settings.value(prefix + "user/hide_all_pins", false).toBool();
hiddenPins_ = settings.value(prefix + "user/hidden_pins", QStringList{}).toStringList(); hiddenPins_ = settings.value(prefix + "user/hidden_pins", QStringList{}).toStringList();
shownPins_ = settings.value(prefix + "user/shown_pins", QStringList{}).toStringList();
hiddenWidgets_ = settings.value(prefix + "user/hidden_widgets", QStringList{}).toStringList(); hiddenWidgets_ = settings.value(prefix + "user/hidden_widgets", QStringList{}).toStringList();
recentReactions_ = recentReactions_ =
settings.value(prefix + "user/recent_reactions", QStringList{}).toStringList(); settings.value(prefix + "user/recent_reactions", QStringList{}).toStringList();
@ -260,13 +262,29 @@ UserSettings::setMutedTags(const QStringList &mutedTags)
} }
void void
UserSettings::setHiddenPins(const QStringList &hiddenTags) UserSettings::setHideAllPins(bool state)
{ {
hiddenPins_ = hiddenTags; hideAllPins_ = state;
save();
emit hideAllPinsChanged(state);
}
void
UserSettings::setHiddenPins(const QStringList &hiddenPins)
{
hiddenPins_ = hiddenPins;
save(); save();
emit hiddenPinsChanged(); emit hiddenPinsChanged();
} }
void
UserSettings::setShownPins(const QStringList &shownPins)
{
shownPins_ = shownPins;
save();
emit shownPinsChanged();
}
void void
UserSettings::setHiddenWidgets(const QStringList &hiddenTags) UserSettings::setHiddenWidgets(const QStringList &hiddenTags)
{ {
@ -965,7 +983,9 @@ UserSettings::save()
settings.setValue(prefix + "user/online_key_backup", useOnlineKeyBackup_); settings.setValue(prefix + "user/online_key_backup", useOnlineKeyBackup_);
settings.setValue(prefix + "user/hidden_tags", hiddenTags_); settings.setValue(prefix + "user/hidden_tags", hiddenTags_);
settings.setValue(prefix + "user/muted_tags", mutedTags_); settings.setValue(prefix + "user/muted_tags", mutedTags_);
settings.setValue(prefix + "user/hide_all_pins", hideAllPins_);
settings.setValue(prefix + "user/hidden_pins", hiddenPins_); settings.setValue(prefix + "user/hidden_pins", hiddenPins_);
settings.setValue(prefix + "user/shown_pins", shownPins_);
settings.setValue(prefix + "user/hidden_widgets", hiddenWidgets_); settings.setValue(prefix + "user/hidden_widgets", hiddenWidgets_);
settings.setValue(prefix + "user/recent_reactions", recentReactions_); settings.setValue(prefix + "user/recent_reactions", recentReactions_);
settings.setValue( settings.setValue(
@ -1033,6 +1053,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 HideAllPins:
return tr("Hide pinned messages by default");
case Markdown: case Markdown:
return tr("Send messages as Markdown"); return tr("Send messages as Markdown");
case InvertEnterKey: case InvertEnterKey:
@ -1193,6 +1215,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 HideAllPins:
return i->hideAllPins();
case Markdown: case Markdown:
return i->markdown(); return i->markdown();
case InvertEnterKey: case InvertEnterKey:
@ -1357,6 +1381,9 @@ 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 HideAllPins:
return tr(
"Pinned messages will be hidden by default and will need to be manually viewed.");
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 "
@ -1545,6 +1572,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
case StartInTray: case StartInTray:
case GroupView: case GroupView:
case ScrollbarsInRoomlist: case ScrollbarsInRoomlist:
case HideAllPins:
case Markdown: case Markdown:
case InvertEnterKey: case InvertEnterKey:
case Bubbles: case Bubbles:
@ -1803,6 +1831,13 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int
} else } else
return false; return false;
} }
case HideAllPins: {
if (value.userType() == QMetaType::Bool) {
i->setHideAllPins(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());
@ -2315,6 +2350,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::hideAllPinsChanged, this, [this]() {
emit dataChanged(index(HideAllPins), index(HideAllPins), {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});
}); });

View file

@ -112,7 +112,9 @@ class UserSettings final : public QObject
Q_PROPERTY(bool openVideoExternal READ openVideoExternal WRITE setOpenVideoExternal NOTIFY Q_PROPERTY(bool openVideoExternal READ openVideoExternal WRITE setOpenVideoExternal NOTIFY
openVideoExternalChanged) openVideoExternalChanged)
Q_PROPERTY(bool hideAllPins READ hideAllPins WRITE setHideAllPins NOTIFY hideAllPinsChanged)
Q_PROPERTY(QStringList hiddenPins READ hiddenPins WRITE setHiddenPins NOTIFY hiddenPinsChanged) Q_PROPERTY(QStringList hiddenPins READ hiddenPins WRITE setHiddenPins NOTIFY hiddenPinsChanged)
Q_PROPERTY(QStringList shownPins READ shownPins WRITE setShownPins NOTIFY shownPinsChanged)
Q_PROPERTY(QStringList recentReactions READ recentReactions WRITE setRecentReactions NOTIFY Q_PROPERTY(QStringList recentReactions READ recentReactions WRITE setRecentReactions NOTIFY
recentReactionsChanged) recentReactionsChanged)
Q_PROPERTY(QStringList hiddenWidgets READ hiddenWidgets WRITE setHiddenWidgets NOTIFY Q_PROPERTY(QStringList hiddenWidgets READ hiddenWidgets WRITE setHiddenWidgets NOTIFY
@ -228,7 +230,9 @@ public:
void setDisableCertificateValidation(bool disabled); void setDisableCertificateValidation(bool disabled);
void setHiddenTags(const QStringList &hiddenTags); void setHiddenTags(const QStringList &hiddenTags);
void setMutedTags(const QStringList &mutedTags); void setMutedTags(const QStringList &mutedTags);
void setHiddenPins(const QStringList &hiddenTags); void setHideAllPins(bool state);
void setHiddenPins(const QStringList &hiddenPins);
void setShownPins(const QStringList &shownPins);
void setHiddenWidgets(const QStringList &hiddenTags); void setHiddenWidgets(const QStringList &hiddenTags);
void setRecentReactions(QStringList recent); void setRecentReactions(QStringList recent);
void setUseIdenticon(bool state); void setUseIdenticon(bool state);
@ -306,7 +310,9 @@ public:
bool disableCertificateValidation() const { return disableCertificateValidation_; } bool disableCertificateValidation() const { return disableCertificateValidation_; }
QStringList hiddenTags() const { return hiddenTags_; } QStringList hiddenTags() const { return hiddenTags_; }
QStringList mutedTags() const { return mutedTags_; } QStringList mutedTags() const { return mutedTags_; }
bool hideAllPins() const { return hideAllPins_; }
QStringList hiddenPins() const { return hiddenPins_; } QStringList hiddenPins() const { return hiddenPins_; }
QStringList shownPins() const { return shownPins_; }
QStringList hiddenWidgets() const { return hiddenWidgets_; } QStringList hiddenWidgets() const { return hiddenWidgets_; }
QStringList recentReactions() const { return recentReactions_; } QStringList recentReactions() const { return recentReactions_; }
bool useIdenticon() const; bool useIdenticon() const;
@ -377,7 +383,9 @@ signals:
void useIdenticonChanged(bool state); void useIdenticonChanged(bool state);
void openImageExternalChanged(bool state); void openImageExternalChanged(bool state);
void openVideoExternalChanged(bool state); void openVideoExternalChanged(bool state);
void hideAllPinsChanged(bool state);
void hiddenPinsChanged(); void hiddenPinsChanged();
void shownPinsChanged();
void hiddenWidgetsChanged(); void hiddenWidgetsChanged();
void recentReactionsChanged(); void recentReactionsChanged();
void exposeDBusApiChanged(bool state); void exposeDBusApiChanged(bool state);
@ -450,7 +458,9 @@ private:
QString homeserver_; QString homeserver_;
QStringList hiddenTags_; QStringList hiddenTags_;
QStringList mutedTags_; QStringList mutedTags_;
bool hideAllPins_;
QStringList hiddenPins_; QStringList hiddenPins_;
QStringList shownPins_;
QStringList hiddenWidgets_; QStringList hiddenWidgets_;
QStringList recentReactions_; QStringList recentReactions_;
QList<QStringList> collapsedSpaces_; QList<QStringList> collapsedSpaces_;
@ -489,6 +499,7 @@ class UserSettingsModel : public QAbstractListModel
PrivacyScreen, PrivacyScreen,
PrivacyScreenTimeout, PrivacyScreenTimeout,
ScrollbarsInRoomlist, ScrollbarsInRoomlist,
HideAllPins,
#ifdef NHEKO_DBUS_SYS #ifdef NHEKO_DBUS_SYS
ExposeDBusApi, ExposeDBusApi,
#endif #endif