Allow users to hide all pins by default

pull/1769/head
Loren Burkholder 5 months ago
parent 24c687d5cd
commit 9045caa025
No known key found for this signature in database
GPG Key ID: AB62CB312CEC2BBC
  1. 23
      resources/qml/TopBar.qml
  2. 42
      src/UserSettingsPage.cpp
  3. 13
      src/UserSettingsPage.h

@ -133,7 +133,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
@ -147,16 +147,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);
hidden.push(roomId);
const index = shown.indexOf(roomId);
if (index > -1) {
shown.splice(index, 1);
}
} else {
const index = ps.indexOf(roomId);
shown.push(roomId);
const index = hidden.indexOf(roomId);
if (index > -1) {
ps.splice(index, 1);
hidden.splice(index, 1);
}
}
Settings.hiddenPins = ps;
Settings.hiddenPins = hidden;
Settings.shownPins = shown;
}
}
AbstractButton {
@ -273,7 +280,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 {

@ -123,7 +123,9 @@ UserSettings::load(std::optional<QString> profile)
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();
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();
@ -254,13 +256,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)
{
@ -949,7 +967,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(
@ -1014,6 +1034,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:
@ -1172,6 +1194,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:
@ -1334,6 +1358,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 "
@ -1516,6 +1543,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
case StartInTray:
case GroupView:
case ScrollbarsInRoomlist:
case HideAllPins:
case Markdown:
case InvertEnterKey:
case Bubbles:
@ -1758,6 +1786,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());
@ -2253,6 +2288,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});
});

@ -111,7 +111,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
@ -218,7 +220,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);
@ -295,7 +299,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;
@ -365,7 +371,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);
@ -437,7 +445,9 @@ private:
QString homeserver_;
QStringList hiddenTags_;
QStringList mutedTags_;
bool hideAllPins_;
QStringList hiddenPins_;
QStringList shownPins_;
QStringList hiddenWidgets_;
QStringList recentReactions_;
QList<QStringList> collapsedSpaces_;
@ -476,6 +486,7 @@ class UserSettingsModel : public QAbstractListModel
PrivacyScreen,
PrivacyScreenTimeout,
ScrollbarsInRoomlist,
HideAllPins,
#ifdef NHEKO_DBUS_SYS
ExposeDBusApi,
#endif

Loading…
Cancel
Save