From 7d027a446d61c9aa46365486f03755bf8a6db9d2 Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Thu, 14 Jan 2021 21:16:56 +0100 Subject: Add settings to enable/disable icons on collapsed separators. --- src/modlistversiondelegate.cpp | 8 +- src/modlistversiondelegate.h | 5 +- src/modlistview.cpp | 5 +- src/settings.cpp | 10 ++ src/settings.h | 5 + src/settingsdialog.ui | 236 ++++++++++++++++++++---------------- src/settingsdialoguserinterface.cpp | 27 ++++- src/settingsdialoguserinterface.h | 6 + 8 files changed, 188 insertions(+), 114 deletions(-) (limited to 'src') diff --git a/src/modlistversiondelegate.cpp b/src/modlistversiondelegate.cpp index 657718f5..5ce574a5 100644 --- a/src/modlistversiondelegate.cpp +++ b/src/modlistversiondelegate.cpp @@ -1,10 +1,13 @@ #include "modlistversiondelegate.h" +#include "settings.h" #include "modlistview.h" #include "log.h" -ModListVersionDelegate::ModListVersionDelegate(ModListView* view) : - QItemDelegate(view), m_view(view) { } +ModListVersionDelegate::ModListVersionDelegate(ModListView* view, Settings& settings) : + QItemDelegate(view), m_view(view), m_settings(settings) +{ +} void ModListVersionDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const @@ -13,6 +16,7 @@ void ModListVersionDelegate::paint(QPainter* painter, const QStyleOptionViewItem if (m_view->hasCollapsibleSeparators() && m_view->model()->hasChildren(index) + && m_settings.interface().collapsibleSeparatorsIcons(ModList::COL_VERSION) && !m_view->isExpanded(index.sibling(index.row(), 0))) { auto* model = m_view->model(); diff --git a/src/modlistversiondelegate.h b/src/modlistversiondelegate.h index 8a51e9b4..d3d0ad3b 100644 --- a/src/modlistversiondelegate.h +++ b/src/modlistversiondelegate.h @@ -4,18 +4,19 @@ #include class ModListView; +class Settings; class ModListVersionDelegate : public QItemDelegate { public: - ModListVersionDelegate(ModListView* view); + ModListVersionDelegate(ModListView* view, Settings& settings); void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; private: - ModListView* m_view; + Settings& m_settings; }; #endif diff --git a/src/modlistview.cpp b/src/modlistview.cpp index 9cc6d8b8..9f3a1266 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -787,7 +787,7 @@ void ModListView::setup(OrganizerCore& core, CategoryFactory& factory, MainWindo setItemDelegateForColumn(ModList::COL_FLAGS, new ModFlagIconDelegate(this, ModList::COL_FLAGS, 120)); setItemDelegateForColumn(ModList::COL_CONFLICTFLAGS, new ModConflictIconDelegate(this, ModList::COL_CONFLICTFLAGS, 80)); setItemDelegateForColumn(ModList::COL_CONTENT, new ModContentIconDelegate(this, ModList::COL_CONTENT, 150)); - setItemDelegateForColumn(ModList::COL_VERSION, new ModListVersionDelegate(this)); + setItemDelegateForColumn(ModList::COL_VERSION, new ModListVersionDelegate(this, core.settings())); if (m_core->settings().geometry().restoreState(header())) { // hack: force the resize-signal to be triggered because restoreState doesn't seem to do that @@ -1140,6 +1140,7 @@ std::vector ModListView::modFlags(const QModelIndex& index, bool bool compact = false; if (info->isSeparator() && hasCollapsibleSeparators() + && m_core->settings().interface().collapsibleSeparatorsIcons(ModList::COL_FLAGS) && !isExpanded(index.sibling(index.row(), 0))) { // combine the child conflicts @@ -1170,6 +1171,7 @@ std::vector ModListView::conflictFlags(const QModelIndex bool compact = false; if (info->isSeparator() && hasCollapsibleSeparators() + && m_core->settings().interface().collapsibleSeparatorsIcons(ModList::COL_CONFLICTFLAGS) && !isExpanded(index.sibling(index.row(), 0))) { // combine the child conflicts @@ -1204,6 +1206,7 @@ std::set ModListView::contents(const QModelIndex& index, bool* includeChild if (info->isSeparator() && hasCollapsibleSeparators() + && m_core->settings().interface().collapsibleSeparatorsIcons(ModList::COL_CONTENT) && !isExpanded(index.sibling(index.row(), 0))) { // combine the child contents diff --git a/src/settings.cpp b/src/settings.cpp index 4528d070..27108162 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -2208,6 +2208,16 @@ void InterfaceSettings::setCollapsibleSeparatorsHighlightFrom(bool b) set(m_Settings, "Settings", "collapsible_separators_conflicts_from", b); } +bool InterfaceSettings::collapsibleSeparatorsIcons(int column) const +{ + return get(m_Settings, "Settings", QString("collapsible_separators_icons_%1").arg(column), true); +} + +void InterfaceSettings::setCollapsibleSeparatorsIcons(int column, bool show) +{ + set(m_Settings, "Settings", QString("collapsible_separators_icons_%1").arg(column), show); +} + bool InterfaceSettings::collapsibleSeparatorsPerProfile() const { return get(m_Settings, "Settings", "collapsible_separators_per_profile", false); diff --git a/src/settings.h b/src/settings.h index e7ad7317..384d50a2 100644 --- a/src/settings.h +++ b/src/settings.h @@ -638,6 +638,11 @@ public: bool collapsibleSeparatorsHighlightFrom() const; void setCollapsibleSeparatorsHighlightFrom(bool b); + // whether to show icons on collapsed separators + // + bool collapsibleSeparatorsIcons(int column) const; + void setCollapsibleSeparatorsIcons(int column, bool show); + // whether each profile should have its own expansion state // bool collapsibleSeparatorsPerProfile() const; diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui index 25978865..93934fc1 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -311,22 +311,16 @@ If you disable this feature, MO will only display official DLCs this way. Please false - - - 7 - - - 7 - - - + + + 0 - 0 + 50 - + 0 @@ -339,99 +333,135 @@ If you disable this feature, MO will only display official DLCs this way. Please 0 - - - - When sorting by - - - - - - - ascending priority - - - true - - - - - - - descending priority - - - - - - - - - - Do not share the collapse/expanded state of separators between profiles. - - - Do not share the collapse/expanded state of separators between profiles. - - - Profile-specific collapse states for separators - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Show conflicts and plugins - - - - - - - Highlight collapsed separators based on conflicts and plugins from mods inside them. - - - Highlight collapsed separators based on conflicts and plugins from mods inside them. - - - on separators - - - true - - - - - - - When selecting a collapsed separator, highlight conflicting mods and plugins from mods inside the separator. - - - When selecting a collapsed separator, highlight conflicting mods and plugins from mods inside the separator. - - - from separators - - - true + + + + 9 - + + + + When sorting by + + + + + + + Show icons on separators + + + + + + + Do not share the collapse/expanded state of separators between profiles. + + + Do not share the collapse/expanded state of separators between profiles. + + + Profile-specific collapse states for separators + + + + + + + flags + + + true + + + + + + + Show conflicts and plugins + + + + + + + conflicts + + + true + + + + + + + content + + + true + + + + + + + version + + + true + + + + + + + ascending priority + + + true + + + + + + + descending priority + + + + + + + Highlight collapsed separators based on conflicts and plugins from mods inside them. + + + Highlight collapsed separators based on conflicts and plugins from mods inside them. + + + on separators + + + true + + + + + + + When selecting a collapsed separator, highlight conflicting mods and plugins from mods inside the separator. + + + When selecting a collapsed separator, highlight conflicting mods and plugins from mods inside the separator. + + + from separators + + + true + + + + diff --git a/src/settingsdialoguserinterface.cpp b/src/settingsdialoguserinterface.cpp index 783c690f..ca040315 100644 --- a/src/settingsdialoguserinterface.cpp +++ b/src/settingsdialoguserinterface.cpp @@ -3,13 +3,20 @@ #include "shared/appconfig.h" #include "categoriesdialog.h" #include "colortable.h" +#include "modlist.h" #include #include using namespace MOBase; UserInterfaceSettingsTab::UserInterfaceSettingsTab(Settings& s, SettingsDialog& d) - : SettingsTab(s, d) + : SettingsTab(s, d), + m_columnToBox{ + { ModList::COL_CONFLICTFLAGS, ui->collapsibleSeparatorsIconsConflictsBox }, + { ModList::COL_FLAGS, ui->collapsibleSeparatorsIconsFlagsBox }, + { ModList::COL_CONTENT, ui->collapsibleSeparatorsIconsContentsBox}, + { ModList::COL_VERSION, ui->collapsibleSeparatorsIconsVersionBox } + } { // connect before setting to trigger @@ -19,13 +26,17 @@ UserInterfaceSettingsTab::UserInterfaceSettingsTab(Settings& s, SettingsDialog& // mod list ui->displayForeignBox->setChecked(settings().interface().displayForeign()); ui->colorSeparatorsBox->setChecked(settings().colors().colorSeparatorScrollbar()); - ui->collapsibleSeparatorsHighlightFromBox->setChecked(settings().interface().collapsibleSeparatorsHighlightFrom()); - ui->collapsibleSeparatorsHighlightToBox->setChecked(settings().interface().collapsibleSeparatorsHighlightTo()); ui->collapsibleSeparatorsAscBox->setChecked(settings().interface().collapsibleSeparators(Qt::AscendingOrder)); ui->collapsibleSeparatorsDscBox->setChecked(settings().interface().collapsibleSeparators(Qt::DescendingOrder)); + ui->collapsibleSeparatorsHighlightFromBox->setChecked(settings().interface().collapsibleSeparatorsHighlightFrom()); + ui->collapsibleSeparatorsHighlightToBox->setChecked(settings().interface().collapsibleSeparatorsHighlightTo()); ui->collapsibleSeparatorsPerProfileBox->setChecked(settings().interface().collapsibleSeparatorsPerProfile()); ui->saveFiltersBox->setChecked(settings().interface().saveFilters()); + for (auto& p : m_columnToBox) { + p.second->setChecked(settings().interface().collapsibleSeparatorsIcons(p.first)); + } + // download list ui->compactBox->setChecked(settings().interface().compactDownloads()); ui->showMetaBox->setChecked(settings().interface().metaDownloads()); @@ -49,6 +60,10 @@ void UserInterfaceSettingsTab::update() settings().interface().setCollapsibleSeparatorsPerProfile(ui->collapsibleSeparatorsPerProfileBox->isChecked()); settings().interface().setSaveFilters(ui->saveFiltersBox->isChecked()); + for (auto& p : m_columnToBox) { + settings().interface().setCollapsibleSeparatorsIcons(p.first, p.second->isChecked()); + } + // download list settings().interface().setCompactDownloads(ui->compactBox->isChecked()); settings().interface().setMetaDownloads(ui->showMetaBox->isChecked()); @@ -61,7 +76,7 @@ void UserInterfaceSettingsTab::updateCollapsibleSeparatorsGroup() { const auto checked = ui->collapsibleSeparatorsAscBox->isChecked() || ui->collapsibleSeparatorsDscBox->isChecked(); - ui->collapsibleSeparatorsHighlightToBox->setEnabled(checked); - ui->collapsibleSeparatorsHighlightFromBox->setEnabled(checked); - ui->collapsibleSeparatorsPerProfileBox->setEnabled(checked); + for (auto* checkbox : ui->collapsibleSeparatorsBox->findChildren()) { + checkbox->setEnabled(checked); + } } diff --git a/src/settingsdialoguserinterface.h b/src/settingsdialoguserinterface.h index 4609ae54..0c3c7fb7 100644 --- a/src/settingsdialoguserinterface.h +++ b/src/settingsdialoguserinterface.h @@ -1,6 +1,8 @@ #ifndef SETTINGSDIALOGUSERINTERFACE_H #define SETTINGSDIALOGUSERINTERFACE_H +#include + #include "settingsdialog.h" #include "settings.h" @@ -16,6 +18,10 @@ protected slots: // enable/disable the collapsible separators group depending on // the checkbox states void updateCollapsibleSeparatorsGroup(); + +private: + + const std::map m_columnToBox; }; #endif // SETTINGSDIALOGGENERAL_H -- cgit v1.3.1