diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-08-03 02:52:55 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-08-04 06:09:48 -0400 |
| commit | 7eed0450e84cc465b0d163a64ebb4d410db688c4 (patch) | |
| tree | 297bd5c3783c1fcae1a5f5e6af965a874d064fa3 | |
| parent | e40245abf46f133292636909fbacf10fc0712932 (diff) | |
moved geometry handling to ProfilesDialog
| -rw-r--r-- | src/mainwindow.cpp | 8 | ||||
| -rw-r--r-- | src/profilesdialog.cpp | 15 | ||||
| -rw-r--r-- | src/profilesdialog.h | 4 | ||||
| -rw-r--r-- | src/settings.cpp | 10 | ||||
| -rw-r--r-- | src/settings.h | 4 |
5 files changed, 35 insertions, 6 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7ef0c9b9..ac86d9d8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2554,17 +2554,13 @@ void MainWindow::on_actionAdd_Profile_triggered() ProfilesDialog profilesDialog(m_OrganizerCore.currentProfile()->name(), m_OrganizerCore.managedGame(), this); - QSettings &settings = m_OrganizerCore.settings().directInterface(); - QString key = QString("geometry/%1").arg(profilesDialog.objectName()); - if (settings.contains(key)) { - profilesDialog.restoreGeometry(settings.value(key).toByteArray()); - } + // workaround: need to disable monitoring of the saves directory, otherwise the active // profile directory is locked stopMonitorSaves(); profilesDialog.exec(); - settings.setValue(key, profilesDialog.saveGeometry()); refreshSaveList(); // since the save list may now be outdated we have to refresh it completely + if (refreshProfiles() && !profilesDialog.failed()) { break; } diff --git a/src/profilesdialog.cpp b/src/profilesdialog.cpp index d7863fc8..25fff2b2 100644 --- a/src/profilesdialog.cpp +++ b/src/profilesdialog.cpp @@ -84,6 +84,21 @@ ProfilesDialog::~ProfilesDialog() delete ui;
}
+int ProfilesDialog::exec()
+{
+ auto& settings = Settings::instance();
+
+ if (auto v=settings.geometry().getProfilesDialog()) {
+ restoreGeometry(*v);
+ }
+
+ const int r = QDialog::exec();
+
+ settings.geometry().setProfilesDialog(saveGeometry());
+
+ return r;
+}
+
void ProfilesDialog::showEvent(QShowEvent *event)
{
TutorableDialog::showEvent(event);
diff --git a/src/profilesdialog.h b/src/profilesdialog.h index a328ce40..a47367be 100644 --- a/src/profilesdialog.h +++ b/src/profilesdialog.h @@ -51,6 +51,10 @@ public: explicit ProfilesDialog(const QString &profileName, MOBase::IPluginGame const *game, QWidget *parent = 0);
~ProfilesDialog();
+ // also saves and restores geometry
+ //
+ int exec() override;
+
/**
* @return true if creation of a new profile failed
* @todo the notion of a fail state makes little sense in the current dialog
diff --git a/src/settings.cpp b/src/settings.cpp index 834bd1d8..1f5abb2a 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -866,6 +866,16 @@ void GeometrySettings::setExecutablesDialog(const QByteArray& v) m_Settings.setValue("geometry/EditExecutablesDialog", v); } +std::optional<QByteArray> GeometrySettings::getProfilesDialog() const +{ + return getOptional<QByteArray>(m_Settings, "geometry/ProfilesDialog"); +} + +void GeometrySettings::setProfilesDialog(const QByteArray& v) +{ + m_Settings.setValue("geometry/ProfilesDialog", v); +} + std::optional<int> GeometrySettings::getMainWindowMonitor() const { return getOptional<int>(m_Settings, "window_monitor"); diff --git a/src/settings.h b/src/settings.h index 0cdccd87..6d51c610 100644 --- a/src/settings.h +++ b/src/settings.h @@ -45,9 +45,13 @@ public: std::optional<bool> getStatusbarVisible() const; std::optional<QByteArray> getMainSplitterState() const; std::optional<bool> getFiltersVisible() const; + std::optional<QByteArray> getExecutablesDialog() const; void setExecutablesDialog(const QByteArray& v); + std::optional<QByteArray> getProfilesDialog() const; + void setProfilesDialog(const QByteArray& v); + std::optional<int> getMainWindowMonitor() const; void setDockSize(const QString& name, int size); |
