mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-10-30 09:30:47 +03:00
Allow users to hide all pins by default
This commit is contained in:
parent
24c687d5cd
commit
9045caa025
3 changed files with 71 additions and 13 deletions
|
@ -133,7 +133,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
|
||||||
|
@ -147,16 +147,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 {
|
||||||
|
@ -273,7 +280,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 {
|
||||||
|
|
|
@ -122,8 +122,10 @@ UserSettings::load(std::optional<QString> profile)
|
||||||
deviceId_ = settings.value(prefix + "auth/device_id", "").toString();
|
deviceId_ = settings.value(prefix + "auth/device_id", "").toString();
|
||||||
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();
|
||||||
hiddenPins_ = settings.value(prefix + "user/hidden_pins", QStringList{}).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();
|
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();
|
||||||
|
@ -254,13 +256,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)
|
||||||
{
|
{
|
||||||
|
@ -949,7 +967,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(
|
||||||
|
@ -1014,6 +1034,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:
|
||||||
|
@ -1172,6 +1194,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:
|
||||||
|
@ -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.");
|
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 "
|
||||||
|
@ -1516,6 +1543,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:
|
||||||
|
@ -1758,6 +1786,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());
|
||||||
|
@ -2253,6 +2288,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});
|
||||||
});
|
});
|
||||||
|
|
|
@ -111,7 +111,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
|
||||||
|
@ -218,7 +220,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);
|
||||||
|
@ -295,7 +299,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;
|
||||||
|
@ -365,7 +371,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);
|
||||||
|
@ -437,7 +445,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_;
|
||||||
|
@ -476,6 +486,7 @@ class UserSettingsModel : public QAbstractListModel
|
||||||
PrivacyScreen,
|
PrivacyScreen,
|
||||||
PrivacyScreenTimeout,
|
PrivacyScreenTimeout,
|
||||||
ScrollbarsInRoomlist,
|
ScrollbarsInRoomlist,
|
||||||
|
HideAllPins,
|
||||||
#ifdef NHEKO_DBUS_SYS
|
#ifdef NHEKO_DBUS_SYS
|
||||||
ExposeDBusApi,
|
ExposeDBusApi,
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue