diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-07 20:56:08 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-10 10:27:30 +0100 |
| commit | fc60ea5b7a023493375a6fced6572156f48e36c3 (patch) | |
| tree | e21d7d1d5941d271fadece63001dd3126460d441 /src | |
| parent | 80371ae2ccdb233f9aa92c8982bad6a136c54ae9 (diff) | |
Add option to have different separator collapsed/expanded states between profiles.
Diffstat (limited to 'src')
| -rw-r--r-- | src/mainwindow.cpp | 1 | ||||
| -rw-r--r-- | src/modlistview.cpp | 22 | ||||
| -rw-r--r-- | src/modlistview.h | 5 | ||||
| -rw-r--r-- | src/organizercore.cpp | 1 | ||||
| -rw-r--r-- | src/organizercore.h | 7 | ||||
| -rw-r--r-- | src/settings.cpp | 10 | ||||
| -rw-r--r-- | src/settings.h | 5 | ||||
| -rw-r--r-- | src/settingsdialog.ui | 13 | ||||
| -rw-r--r-- | src/settingsdialoguserinterface.cpp | 3 |
9 files changed, 59 insertions, 8 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f761a5f0..ce98772a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1495,7 +1495,6 @@ void MainWindow::startExeAction() void MainWindow::activateSelectedProfile() { m_OrganizerCore.setCurrentProfile(ui->profileBox->currentText()); - ui->modList->setProfile(m_OrganizerCore.currentProfile()); m_SavesTab->refreshSaveList(); m_OrganizerCore.refresh(); diff --git a/src/modlistview.cpp b/src/modlistview.cpp index 7b1b6f0c..ec31d4dc 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -167,10 +167,24 @@ void ModListView::refresh() updateGroupByProxy();
}
-void ModListView::setProfile(Profile* profile)
+void ModListView::onProfileChanged(Profile* oldProfile, Profile* newProfile)
{
- m_sortProxy->setProfile(profile);
- m_byPriorityProxy->setProfile(profile);
+ const auto perProfileSeparators =
+ m_core->settings().interface().collapsibleSeparatorsPerProfile();
+
+ // save expanded/collapsed state of separators
+ if (oldProfile && perProfileSeparators) {
+ auto& collapsed = m_collapsed[m_byPriorityProxy];
+ oldProfile->storeSetting("UserInterface", "collapsed_separators", QStringList(collapsed.begin(), collapsed.end()));
+ }
+
+ m_sortProxy->setProfile(newProfile);
+ m_byPriorityProxy->setProfile(newProfile);
+
+ if (newProfile && perProfileSeparators) {
+ auto collapsed = newProfile->setting("UserInterface", "collapsed_separators", QStringList()).toStringList();
+ m_collapsed[m_byPriorityProxy] = { collapsed.begin(), collapsed.end() };
+ }
}
bool ModListView::hasCollapsibleSeparators() const
@@ -694,7 +708,9 @@ void ModListView::setup(OrganizerCore& core, CategoryFactory& factory, MainWindo mwui->espList
};
+
connect(m_core, &OrganizerCore::modInstalled, [=](auto&& name) { onModInstalled(name); });
+ connect(m_core, &OrganizerCore::profileChanged, this, &ModListView::onProfileChanged);
connect(core.modList(), &ModList::modPrioritiesChanged, [=](auto&& indices) { onModPrioritiesChanged(indices); });
connect(core.modList(), &ModList::clearOverwrite, [=] { m_actions->clearOverwrite(); });
connect(core.modList(), &ModList::modStatesChanged, [=] { updateModCount(); });
diff --git a/src/modlistview.h b/src/modlistview.h index 1a174568..d8e08a99 100644 --- a/src/modlistview.h +++ b/src/modlistview.h @@ -57,10 +57,6 @@ public: void restoreState(const Settings& s);
void saveState(Settings& s) const;
- // set the current profile
- //
- void setProfile(Profile* profile);
-
// check if collapsible separators are currently used
//
bool hasCollapsibleSeparators() const;
@@ -170,6 +166,7 @@ protected slots: void onCustomContextMenuRequested(const QPoint& pos);
void onDoubleClicked(const QModelIndex& index);
void onFiltersCriteria(const std::vector<ModListSortProxy::Criteria>& filters);
+ void onProfileChanged(Profile* oldProfile, Profile* newProfile);
private:
diff --git a/src/organizercore.cpp b/src/organizercore.cpp index d952bc4c..90771c0a 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -602,6 +602,7 @@ void OrganizerCore::setCurrentProfile(const QString &profileName) m_CurrentProfile->debugDump(); + emit profileChanged(oldProfile.get(), m_CurrentProfile.get()); m_ProfileChanged(oldProfile.get(), m_CurrentProfile.get()); } diff --git a/src/organizercore.h b/src/organizercore.h index 24de26ee..905fb111 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -406,6 +406,13 @@ signals: void close();
+ // emitted when the profile is changed, before notifying plugins
+ //
+ // the new profile can be stored but the old one is temporary and
+ // should not be
+ //
+ void profileChanged(Profile* oldProfile, Profile* newProfile);
+
// Notify that the directory structure is ready to be used on the main thread
// Use queued connections
void directoryStructureReady();
diff --git a/src/settings.cpp b/src/settings.cpp index 7f943904..251e2b15 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -2195,6 +2195,16 @@ void InterfaceSettings::setCollapsibleSeparatorsConflicts(bool b) set(m_Settings, "Settings", "collapsible_separators_conflicts", b); } +bool InterfaceSettings::collapsibleSeparatorsPerProfile() const +{ + return get<bool>(m_Settings, "Settings", "collapsible_separators_per_profile", false); +} + +void InterfaceSettings::setCollapsibleSeparatorsPerProfile(bool b) +{ + set(m_Settings, "Settings", "collapsible_separators_per_profile", b); +} + bool InterfaceSettings::saveFilters() const { return get<bool>(m_Settings, "Settings", "save_filters", false); diff --git a/src/settings.h b/src/settings.h index d61f3c20..efcfee57 100644 --- a/src/settings.h +++ b/src/settings.h @@ -631,6 +631,11 @@ public: bool collapsibleSeparatorsConflicts() const; void setCollapsibleSeparatorsConflicts(bool b); + // whether each profile should have its own expansion state + // + bool collapsibleSeparatorsPerProfile() const; + void setCollapsibleSeparatorsPerProfile(bool b); + // whether to save/restore filter states between runs // bool saveFilters() const; diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui index 527f9a91..b09a26de 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -331,6 +331,19 @@ If you disable this feature, MO will only display official DLCs this way. Please </property> </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> </layout> </widget> </item> diff --git a/src/settingsdialoguserinterface.cpp b/src/settingsdialoguserinterface.cpp index 550b4ddd..5d856395 100644 --- a/src/settingsdialoguserinterface.cpp +++ b/src/settingsdialoguserinterface.cpp @@ -15,6 +15,7 @@ UserInterfaceSettingsTab::UserInterfaceSettingsTab(Settings& s, SettingsDialog& // connect before setting to trigger QObject::connect(ui->collapsibleSeparatorsBox, &QGroupBox::toggled, [=](auto&& on) { ui->collapsibleSeparatorsConflictsBox->setEnabled(on); + ui->collapsibleSeparatorsPerProfileBox->setEnabled(on); }); // mod list @@ -22,6 +23,7 @@ UserInterfaceSettingsTab::UserInterfaceSettingsTab(Settings& s, SettingsDialog& ui->colorSeparatorsBox->setChecked(settings().colors().colorSeparatorScrollbar()); ui->collapsibleSeparatorsConflictsBox->setChecked(settings().interface().collapsibleSeparatorsConflicts()); ui->collapsibleSeparatorsBox->setChecked(settings().interface().collapsibleSeparators()); + ui->collapsibleSeparatorsPerProfileBox->setChecked(settings().interface().collapsibleSeparatorsPerProfile()); ui->saveFiltersBox->setChecked(settings().interface().saveFilters()); // download list @@ -42,6 +44,7 @@ void UserInterfaceSettingsTab::update() settings().interface().setDisplayForeign(ui->displayForeignBox->isChecked()); settings().interface().setCollapsibleSeparators(ui->collapsibleSeparatorsBox->isChecked()); settings().interface().setCollapsibleSeparatorsConflicts(ui->collapsibleSeparatorsConflictsBox->isChecked()); + settings().interface().setCollapsibleSeparatorsPerProfile(ui->collapsibleSeparatorsPerProfileBox->isChecked()); settings().interface().setSaveFilters(ui->saveFiltersBox->isChecked()); // download list |
