Remember all the collapsed trees
This commit is contained in:
parent
aa5d2098d0
commit
b774a671da
@ -69,7 +69,6 @@ UserSettings::load(std::optional<QString> profile)
|
|||||||
hasDesktopNotifications_ = settings.value("user/desktop_notifications", true).toBool();
|
hasDesktopNotifications_ = settings.value("user/desktop_notifications", true).toBool();
|
||||||
hasAlertOnNotification_ = settings.value("user/alert_on_notification", false).toBool();
|
hasAlertOnNotification_ = settings.value("user/alert_on_notification", false).toBool();
|
||||||
groupView_ = settings.value("user/group_view", true).toBool();
|
groupView_ = settings.value("user/group_view", true).toBool();
|
||||||
hiddenTags_ = settings.value("user/hidden_tags", QStringList{}).toStringList();
|
|
||||||
buttonsInTimeline_ = settings.value("user/timeline/buttons", true).toBool();
|
buttonsInTimeline_ = settings.value("user/timeline/buttons", true).toBool();
|
||||||
timelineMaxWidth_ = settings.value("user/timeline/max_width", 0).toInt();
|
timelineMaxWidth_ = settings.value("user/timeline/max_width", 0).toInt();
|
||||||
messageHoverHighlight_ =
|
messageHoverHighlight_ =
|
||||||
@ -117,6 +116,12 @@ UserSettings::load(std::optional<QString> profile)
|
|||||||
homeserver_ = settings.value(prefix + "auth/home_server", "").toString();
|
homeserver_ = settings.value(prefix + "auth/home_server", "").toString();
|
||||||
userId_ = settings.value(prefix + "auth/user_id", "").toString();
|
userId_ = settings.value(prefix + "auth/user_id", "").toString();
|
||||||
deviceId_ = settings.value(prefix + "auth/device_id", "").toString();
|
deviceId_ = settings.value(prefix + "auth/device_id", "").toString();
|
||||||
|
hiddenTags_ = settings.value(prefix + "user/hidden_tags", QStringList{}).toStringList();
|
||||||
|
|
||||||
|
collapsedSpaces_.clear();
|
||||||
|
for (const auto &e :
|
||||||
|
settings.value(prefix + "user/collapsed_spaces", QList<QVariant>{}).toList())
|
||||||
|
collapsedSpaces_.push_back(e.toStringList());
|
||||||
|
|
||||||
shareKeysWithTrustedUsers_ =
|
shareKeysWithTrustedUsers_ =
|
||||||
settings.value(prefix + "user/automatically_share_keys_with_trusted_users", false).toBool();
|
settings.value(prefix + "user/automatically_share_keys_with_trusted_users", false).toBool();
|
||||||
@ -195,6 +200,13 @@ UserSettings::setHiddenTags(QStringList hiddenTags)
|
|||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
UserSettings::setCollapsedSpaces(QList<QStringList> spaces)
|
||||||
|
{
|
||||||
|
collapsedSpaces_ = spaces;
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
UserSettings::setMarkdown(bool state)
|
UserSettings::setMarkdown(bool state)
|
||||||
{
|
{
|
||||||
@ -658,7 +670,6 @@ UserSettings::save()
|
|||||||
settings.setValue("minor_events", sortByImportance_);
|
settings.setValue("minor_events", sortByImportance_);
|
||||||
settings.setValue("read_receipts", readReceipts_);
|
settings.setValue("read_receipts", readReceipts_);
|
||||||
settings.setValue("group_view", groupView_);
|
settings.setValue("group_view", groupView_);
|
||||||
settings.setValue("hidden_tags", hiddenTags_);
|
|
||||||
settings.setValue("markdown_enabled", markdown_);
|
settings.setValue("markdown_enabled", markdown_);
|
||||||
settings.setValue("animate_images_on_hover", animateImagesOnHover_);
|
settings.setValue("animate_images_on_hover", animateImagesOnHover_);
|
||||||
settings.setValue("desktop_notifications", hasDesktopNotifications_);
|
settings.setValue("desktop_notifications", hasDesktopNotifications_);
|
||||||
@ -695,6 +706,12 @@ UserSettings::save()
|
|||||||
settings.setValue(prefix + "user/only_share_keys_with_verified_users",
|
settings.setValue(prefix + "user/only_share_keys_with_verified_users",
|
||||||
onlyShareKeysWithVerifiedUsers_);
|
onlyShareKeysWithVerifiedUsers_);
|
||||||
settings.setValue(prefix + "user/online_key_backup", useOnlineKeyBackup_);
|
settings.setValue(prefix + "user/online_key_backup", useOnlineKeyBackup_);
|
||||||
|
settings.setValue(prefix + "user/hidden_tags", hiddenTags_);
|
||||||
|
|
||||||
|
QVariantList v;
|
||||||
|
for (const auto &e : collapsedSpaces_)
|
||||||
|
v.push_back(e);
|
||||||
|
settings.setValue(prefix + "user/collapsed_spaces", v);
|
||||||
|
|
||||||
settings.setValue("disable_certificate_validation", disableCertificateValidation_);
|
settings.setValue("disable_certificate_validation", disableCertificateValidation_);
|
||||||
|
|
||||||
|
@ -172,6 +172,7 @@ public:
|
|||||||
void setDisableCertificateValidation(bool disabled);
|
void setDisableCertificateValidation(bool disabled);
|
||||||
void setHiddenTags(QStringList hiddenTags);
|
void setHiddenTags(QStringList hiddenTags);
|
||||||
void setUseIdenticon(bool state);
|
void setUseIdenticon(bool state);
|
||||||
|
void setCollapsedSpaces(QList<QStringList> spaces);
|
||||||
|
|
||||||
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_; }
|
||||||
@ -228,6 +229,7 @@ public:
|
|||||||
bool disableCertificateValidation() const { return disableCertificateValidation_; }
|
bool disableCertificateValidation() const { return disableCertificateValidation_; }
|
||||||
QStringList hiddenTags() const { return hiddenTags_; }
|
QStringList hiddenTags() const { return hiddenTags_; }
|
||||||
bool useIdenticon() const { return useIdenticon_ && JdenticonProvider::isAvailable(); }
|
bool useIdenticon() const { return useIdenticon_ && JdenticonProvider::isAvailable(); }
|
||||||
|
QList<QStringList> collapsedSpaces() const { return collapsedSpaces_; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void groupViewStateChanged(bool state);
|
void groupViewStateChanged(bool state);
|
||||||
@ -329,6 +331,7 @@ private:
|
|||||||
QString deviceId_;
|
QString deviceId_;
|
||||||
QString homeserver_;
|
QString homeserver_;
|
||||||
QStringList hiddenTags_;
|
QStringList hiddenTags_;
|
||||||
|
QList<QStringList> collapsedSpaces_;
|
||||||
bool useIdenticon_;
|
bool useIdenticon_;
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
@ -40,6 +40,7 @@ CommunitiesModel::setData(const QModelIndex &index, const QVariant &value, int r
|
|||||||
|
|
||||||
const auto cindex = spaceOrder_.lastChild(index.row() - 2);
|
const auto cindex = spaceOrder_.lastChild(index.row() - 2);
|
||||||
emit dataChanged(index, this->index(cindex + 2), {Collapsed, Qt::DisplayRole});
|
emit dataChanged(index, this->index(cindex + 2), {Collapsed, Qt::DisplayRole});
|
||||||
|
spaceOrder_.storeCollapsed();
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
@ -276,6 +277,7 @@ CommunitiesModel::initializeSidebar()
|
|||||||
tags_.push_back(QString::fromStdString(t));
|
tags_.push_back(QString::fromStdString(t));
|
||||||
|
|
||||||
hiddentTagIds_ = UserSettings::instance()->hiddenTags();
|
hiddentTagIds_ = UserSettings::instance()->hiddenTags();
|
||||||
|
spaceOrder_.restoreCollapsed();
|
||||||
endResetModel();
|
endResetModel();
|
||||||
|
|
||||||
emit tagsChanged();
|
emit tagsChanged();
|
||||||
@ -283,6 +285,55 @@ CommunitiesModel::initializeSidebar()
|
|||||||
emit containsSubspacesChanged();
|
emit containsSubspacesChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CommunitiesModel::FlatTree::storeCollapsed()
|
||||||
|
{
|
||||||
|
QList<QStringList> elements;
|
||||||
|
|
||||||
|
int depth = -1;
|
||||||
|
|
||||||
|
QStringList current;
|
||||||
|
|
||||||
|
for (const auto &e : tree) {
|
||||||
|
if (e.depth > depth) {
|
||||||
|
current.push_back(e.name);
|
||||||
|
} else if (e.depth == depth) {
|
||||||
|
current.back() = e.name;
|
||||||
|
} else {
|
||||||
|
current.pop_back();
|
||||||
|
current.back() = e.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.collapsed)
|
||||||
|
elements.push_back(current);
|
||||||
|
}
|
||||||
|
|
||||||
|
UserSettings::instance()->setCollapsedSpaces(elements);
|
||||||
|
}
|
||||||
|
void
|
||||||
|
CommunitiesModel::FlatTree::restoreCollapsed()
|
||||||
|
{
|
||||||
|
QList<QStringList> elements = UserSettings::instance()->collapsedSpaces();
|
||||||
|
|
||||||
|
int depth = -1;
|
||||||
|
|
||||||
|
QStringList current;
|
||||||
|
|
||||||
|
for (auto &e : tree) {
|
||||||
|
if (e.depth > depth) {
|
||||||
|
current.push_back(e.name);
|
||||||
|
} else if (e.depth == depth) {
|
||||||
|
current.back() = e.name;
|
||||||
|
} else {
|
||||||
|
current.pop_back();
|
||||||
|
current.back() = e.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elements.contains(current))
|
||||||
|
e.collapsed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CommunitiesModel::clear()
|
CommunitiesModel::clear()
|
||||||
{
|
{
|
||||||
|
@ -92,6 +92,9 @@ public:
|
|||||||
break;
|
break;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void storeCollapsed();
|
||||||
|
void restoreCollapsed();
|
||||||
};
|
};
|
||||||
|
|
||||||
CommunitiesModel(QObject *parent = nullptr);
|
CommunitiesModel(QObject *parent = nullptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user