Compare commits

...

2 commits

Author SHA1 Message Date
Loren Burkholder
a3ddbb8f51
Merge 9045caa025 into 2f967978f2 2024-10-14 14:32:34 +02:00
Loren Burkholder
9045caa025
Allow users to hide all pins by default 2024-06-29 18:44:35 -04:00
3 changed files with 71 additions and 13 deletions

View file

@ -132,7 +132,7 @@ Pane {
ImageButton {
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.column: 3
@ -146,16 +146,23 @@ Pane {
visible: !!room && room.pinnedMessages.length > 0
onClicked: {
var ps = Settings.hiddenPins;
var hidden = Settings.hiddenPins;
var shown = Settings.shownPins;
if (pinsShown) {
ps.push(roomId);
} else {
const index = ps.indexOf(roomId);
hidden.push(roomId);
const index = shown.indexOf(roomId);
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 {
@ -272,7 +279,9 @@ Pane {
Layout.row: 3
ScrollBar.horizontal.visible: false
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
ListView {

View file

@ -122,8 +122,10 @@ UserSettings::load(std::optional<QString> profile)
deviceId_ = settings.value(prefix + "auth/device_id", "").toString();
currentTagId_ = settings.value(prefix + "user/current_tag_id", "").toString();
hiddenTags_ = settings.value(prefix + "user/hidden_tags", QStringList{}).toStringList();
mutedTags_ = settings.value(prefix + "user/muted_tags", QStringList{"global"}).toStringList();
hiddenPins_ = settings.value(prefix + "user/hidden_pins", QStringList{}).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();
shownPins_ = settings.value(prefix + "user/shown_pins", QStringList{}).toStringList();
hiddenWidgets_ = settings.value(prefix + "user/hidden_widgets", QStringList{}).toStringList();
recentReactions_ =
settings.value(prefix + "user/recent_reactions", QStringList{}).toStringList();
@ -260,13 +262,29 @@ UserSettings::setMutedTags(const QStringList &mutedTags)
}
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();
emit hiddenPinsChanged();
}
void
UserSettings::setShownPins(const QStringList &shownPins)
{
shownPins_ = shownPins;
save();
emit shownPinsChanged();
}
void
UserSettings::setHiddenWidgets(const QStringList &hiddenTags)
{
@ -965,7 +983,9 @@ UserSettings::save()
settings.setValue(prefix + "user/online_key_backup", useOnlineKeyBackup_);
settings.setValue(prefix + "user/hidden_tags", hiddenTags_);
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/shown_pins", shownPins_);
settings.setValue(prefix + "user/hidden_widgets", hiddenWidgets_);
settings.setValue(prefix + "user/recent_reactions", recentReactions_);
settings.setValue(
@ -1033,6 +1053,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
return tr("Communities sidebar");
case ScrollbarsInRoomlist:
return tr("Scrollbars in room list");
case HideAllPins:
return tr("Hide pinned messages by default");
case Markdown:
return tr("Send messages as Markdown");
case InvertEnterKey:
@ -1193,6 +1215,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
return i->groupView();
case ScrollbarsInRoomlist:
return i->scrollbarsInRoomlist();
case HideAllPins:
return i->hideAllPins();
case Markdown:
return i->markdown();
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.");
case ScrollbarsInRoomlist:
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:
return tr(
"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 GroupView:
case ScrollbarsInRoomlist:
case HideAllPins:
case Markdown:
case InvertEnterKey:
case Bubbles:
@ -1803,6 +1831,13 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int
} else
return false;
}
case HideAllPins: {
if (value.userType() == QMetaType::Bool) {
i->setHideAllPins(value.toBool());
return true;
} else
return false;
}
case Markdown: {
if (value.userType() == QMetaType::Bool) {
i->setMarkdown(value.toBool());
@ -2315,6 +2350,9 @@ UserSettingsModel::UserSettingsModel(QObject *p)
connect(s.get(), &UserSettings::scrollbarsInRoomlistChanged, this, [this]() {
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]() {
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
openVideoExternalChanged)
Q_PROPERTY(bool hideAllPins READ hideAllPins WRITE setHideAllPins NOTIFY hideAllPinsChanged)
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
recentReactionsChanged)
Q_PROPERTY(QStringList hiddenWidgets READ hiddenWidgets WRITE setHiddenWidgets NOTIFY
@ -228,7 +230,9 @@ public:
void setDisableCertificateValidation(bool disabled);
void setHiddenTags(const QStringList &hiddenTags);
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 setRecentReactions(QStringList recent);
void setUseIdenticon(bool state);
@ -306,7 +310,9 @@ public:
bool disableCertificateValidation() const { return disableCertificateValidation_; }
QStringList hiddenTags() const { return hiddenTags_; }
QStringList mutedTags() const { return mutedTags_; }
bool hideAllPins() const { return hideAllPins_; }
QStringList hiddenPins() const { return hiddenPins_; }
QStringList shownPins() const { return shownPins_; }
QStringList hiddenWidgets() const { return hiddenWidgets_; }
QStringList recentReactions() const { return recentReactions_; }
bool useIdenticon() const;
@ -377,7 +383,9 @@ signals:
void useIdenticonChanged(bool state);
void openImageExternalChanged(bool state);
void openVideoExternalChanged(bool state);
void hideAllPinsChanged(bool state);
void hiddenPinsChanged();
void shownPinsChanged();
void hiddenWidgetsChanged();
void recentReactionsChanged();
void exposeDBusApiChanged(bool state);
@ -450,7 +458,9 @@ private:
QString homeserver_;
QStringList hiddenTags_;
QStringList mutedTags_;
bool hideAllPins_;
QStringList hiddenPins_;
QStringList shownPins_;
QStringList hiddenWidgets_;
QStringList recentReactions_;
QList<QStringList> collapsedSpaces_;
@ -489,6 +499,7 @@ class UserSettingsModel : public QAbstractListModel
PrivacyScreen,
PrivacyScreenTimeout,
ScrollbarsInRoomlist,
HideAllPins,
#ifdef NHEKO_DBUS_SYS
ExposeDBusApi,
#endif