diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/instancemanagerdialog.cpp | 28 | ||||
| -rw-r--r-- | src/instancemanagerdialog.h | 10 | ||||
| -rw-r--r-- | src/instancemanagerdialog.ui | 4 | ||||
| -rw-r--r-- | src/settings.cpp | 8 | ||||
| -rw-r--r-- | src/settings.h | 10 |
5 files changed, 55 insertions, 5 deletions
diff --git a/src/instancemanagerdialog.cpp b/src/instancemanagerdialog.cpp index 71fed78d..d579ea9c 100644 --- a/src/instancemanagerdialog.cpp +++ b/src/instancemanagerdialog.cpp @@ -111,7 +111,7 @@ InstanceManagerDialog::InstanceManagerDialog( { ui->setupUi(this); - ui->splitter->setSizes({200, 1}); + ui->splitter->setSizes({250, 1}); ui->splitter->setStretchFactor(0, 0); ui->splitter->setStretchFactor(1, 1); @@ -146,6 +146,32 @@ InstanceManagerDialog::InstanceManagerDialog( connect(ui->close, &QPushButton::clicked, [&]{ close(); }); } +void InstanceManagerDialog::showEvent(QShowEvent* e) +{ + // there might not be a global Settings object if this is called on startup + // when there's no current instance + const auto* s = Settings::maybeInstance(); + + if (s) { + s->geometry().restoreGeometry(this); + } + + QDialog::showEvent(e); +} + +void InstanceManagerDialog::done(int r) +{ + // there might not be a global Settings object if this is called on startup + // when there's no current instance + auto* s = Settings::maybeInstance(); + + if (s) { + s->geometry().saveGeometry(this); + } + + QDialog::done(r); +} + void InstanceManagerDialog::updateInstances() { auto& m = InstanceManager::singleton(); diff --git a/src/instancemanagerdialog.h b/src/instancemanagerdialog.h index 94f379ca..2641f716 100644 --- a/src/instancemanagerdialog.h +++ b/src/instancemanagerdialog.h @@ -78,6 +78,16 @@ public: // void setRestartOnSelect(bool b); + + // saves geometry + // + void done(int r) override; + +protected: + // restores geometry + // + void showEvent(QShowEvent* e) override; + private: static const std::size_t NoSelection = -1; diff --git a/src/instancemanagerdialog.ui b/src/instancemanagerdialog.ui index 45b99e21..4137d1b6 100644 --- a/src/instancemanagerdialog.ui +++ b/src/instancemanagerdialog.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>689</width> - <height>413</height> + <width>884</width> + <height>539</height> </rect> </property> <property name="windowTitle"> diff --git a/src/settings.cpp b/src/settings.cpp index a8ada6ba..54d32786 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -86,14 +86,20 @@ Settings::~Settings() } } -Settings &Settings::instance() +Settings& Settings::instance() { if (s_Instance == nullptr) { throw std::runtime_error("no instance of \"Settings\""); } + return *s_Instance; } +Settings* Settings::maybeInstance() +{ + return s_Instance; +} + void Settings::processUpdates( const QVersionNumber& currentVersion, const QVersionNumber& lastVersion) { diff --git a/src/settings.h b/src/settings.h index df081c5c..689067d7 100644 --- a/src/settings.h +++ b/src/settings.h @@ -693,7 +693,15 @@ public: Settings(const QString& path, bool globalInstance=false); ~Settings(); - static Settings &instance(); + + // throws if there is no global Settings instance + // + static Settings& instance(); + + // returns null if there is no global Settings instance + // + static Settings* maybeInstance(); + // name of the ini file // |
