diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-14 21:16:56 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-14 21:16:56 +0100 |
| commit | 7d027a446d61c9aa46365486f03755bf8a6db9d2 (patch) | |
| tree | 73b35cb174e98fec076c3031a820933983f10c83 /src | |
| parent | 38129e6e7760ffcb660de88e7b87e691e16a49df (diff) | |
Add settings to enable/disable icons on collapsed separators.
Diffstat (limited to 'src')
| -rw-r--r-- | src/modlistversiondelegate.cpp | 8 | ||||
| -rw-r--r-- | src/modlistversiondelegate.h | 5 | ||||
| -rw-r--r-- | src/modlistview.cpp | 5 | ||||
| -rw-r--r-- | src/settings.cpp | 10 | ||||
| -rw-r--r-- | src/settings.h | 5 | ||||
| -rw-r--r-- | src/settingsdialog.ui | 236 | ||||
| -rw-r--r-- | src/settingsdialoguserinterface.cpp | 27 | ||||
| -rw-r--r-- | src/settingsdialoguserinterface.h | 6 |
8 files changed, 188 insertions, 114 deletions
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 <QStyledItemDelegate> 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<ModInfo::EFlag> 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<ModInfo::EConflictFlag> 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<int> 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<bool>(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<bool>(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 <property name="checked"> <bool>false</bool> </property> - <layout class="QVBoxLayout" name="verticalLayout_20"> - <property name="leftMargin"> - <number>7</number> - </property> - <property name="rightMargin"> - <number>7</number> - </property> - <item> - <widget class="QWidget" name="widget_8" native="true"> + <layout class="QGridLayout" name="gridLayout_7"> + <item row="0" column="0"> + <widget class="QWidget" name="widget_11" native="true"> <property name="minimumSize"> <size> <width>0</width> - <height>0</height> + <height>50</height> </size> </property> - <layout class="QHBoxLayout" name="horizontalLayout_13"> + <layout class="QGridLayout" name="gridLayout_10"> <property name="leftMargin"> <number>0</number> </property> @@ -339,99 +333,135 @@ If you disable this feature, MO will only display official DLCs this way. Please <property name="bottomMargin"> <number>0</number> </property> - <item> - <widget class="QLabel" name="label_18"> - <property name="text"> - <string>When sorting by</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="collapsibleSeparatorsAscBox"> - <property name="text"> - <string>ascending priority</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="collapsibleSeparatorsDscBox"> - <property name="text"> - <string>descending priority</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QCheckBox" name="collapsibleSeparatorsPerProfileBox"> - <property name="toolTip"> - <string>Do not share the collapse/expanded state of separators between profiles.</string> - </property> - <property name="whatsThis"> - <string>Do not share the collapse/expanded state of separators between profiles.</string> - </property> - <property name="text"> - <string>Profile-specific collapse states for separators</string> - </property> - </widget> - </item> - <item> - <widget class="QWidget" name="widget_9" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_12"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label_34"> - <property name="text"> - <string>Show conflicts and plugins </string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="collapsibleSeparatorsHighlightToBox"> - <property name="toolTip"> - <string>Highlight collapsed separators based on conflicts and plugins from mods inside them.</string> - </property> - <property name="whatsThis"> - <string>Highlight collapsed separators based on conflicts and plugins from mods inside them.</string> - </property> - <property name="text"> - <string>on separators</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="collapsibleSeparatorsHighlightFromBox"> - <property name="toolTip"> - <string>When selecting a collapsed separator, highlight conflicting mods and plugins from mods inside the separator.</string> - </property> - <property name="whatsThis"> - <string>When selecting a collapsed separator, highlight conflicting mods and plugins from mods inside the separator.</string> - </property> - <property name="text"> - <string>from separators</string> - </property> - <property name="checked"> - <bool>true</bool> + <item row="0" column="0"> + <layout class="QGridLayout" name="gridLayout_9"> + <property name="verticalSpacing"> + <number>9</number> </property> - </widget> + <item row="0" column="0"> + <widget class="QLabel" name="label_18"> + <property name="text"> + <string>When sorting by</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_35"> + <property name="text"> + <string>Show icons on separators</string> + </property> + </widget> + </item> + <item row="1" column="0" colspan="3"> + <widget class="QCheckBox" name="collapsibleSeparatorsPerProfileBox"> + <property name="toolTip"> + <string>Do not share the collapse/expanded state of separators between profiles.</string> + </property> + <property name="whatsThis"> + <string>Do not share the collapse/expanded state of separators between profiles.</string> + </property> + <property name="text"> + <string>Profile-specific collapse states for separators</string> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QCheckBox" name="collapsibleSeparatorsIconsFlagsBox"> + <property name="text"> + <string>flags</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_34"> + <property name="text"> + <string>Show conflicts and plugins </string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QCheckBox" name="collapsibleSeparatorsIconsConflictsBox"> + <property name="text"> + <string>conflicts</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="3" column="3"> + <widget class="QCheckBox" name="collapsibleSeparatorsIconsContentsBox"> + <property name="text"> + <string>content</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="3" column="4"> + <widget class="QCheckBox" name="collapsibleSeparatorsIconsVersionBox"> + <property name="text"> + <string>version</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="1" colspan="2"> + <widget class="QCheckBox" name="collapsibleSeparatorsAscBox"> + <property name="text"> + <string>ascending priority</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="3" colspan="2"> + <widget class="QCheckBox" name="collapsibleSeparatorsDscBox"> + <property name="text"> + <string>descending priority</string> + </property> + </widget> + </item> + <item row="2" column="1" colspan="2"> + <widget class="QCheckBox" name="collapsibleSeparatorsHighlightToBox"> + <property name="toolTip"> + <string>Highlight collapsed separators based on conflicts and plugins from mods inside them.</string> + </property> + <property name="whatsThis"> + <string>Highlight collapsed separators based on conflicts and plugins from mods inside them.</string> + </property> + <property name="text"> + <string>on separators</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="3" colspan="2"> + <widget class="QCheckBox" name="collapsibleSeparatorsHighlightFromBox"> + <property name="toolTip"> + <string>When selecting a collapsed separator, highlight conflicting mods and plugins from mods inside the separator.</string> + </property> + <property name="whatsThis"> + <string>When selecting a collapsed separator, highlight conflicting mods and plugins from mods inside the separator.</string> + </property> + <property name="text"> + <string>from separators</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> </item> </layout> </widget> 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 <utility.h> #include <questionboxmemory.h> 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<QCheckBox*>()) { + 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 <QCheckBox> + #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<int, QCheckBox*> m_columnToBox; }; #endif // SETTINGSDIALOGGENERAL_H |
