diff options
| -rw-r--r-- | src/createinstancedialog.ui | 18 | ||||
| -rw-r--r-- | src/createinstancedialogpages.cpp | 12 | ||||
| -rw-r--r-- | src/instancemanager.cpp | 5 | ||||
| -rw-r--r-- | src/instancemanager.h | 2 |
4 files changed, 27 insertions, 10 deletions
diff --git a/src/createinstancedialog.ui b/src/createinstancedialog.ui index ebaef84d..a3c3db92 100644 --- a/src/createinstancedialog.ui +++ b/src/createinstancedialog.ui @@ -182,6 +182,16 @@ </widget> </item> <item> + <widget class="QLabel" name="portableExistsLabel"> + <property name="text"> + <string>A portable instance already exists.</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item> <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -266,8 +276,8 @@ <rect> <x>0</x> <y>0</y> - <width>63</width> - <height>16</height> + <width>455</width> + <height>286</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_26"> @@ -402,8 +412,8 @@ <rect> <x>0</x> <y>0</y> - <width>63</width> - <height>16</height> + <width>455</width> + <height>278</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_17"> diff --git a/src/createinstancedialogpages.cpp b/src/createinstancedialogpages.cpp index b2e3612f..127243c6 100644 --- a/src/createinstancedialogpages.cpp +++ b/src/createinstancedialogpages.cpp @@ -171,11 +171,19 @@ TypePage::TypePage(CreateInstanceDialog& dlg) { ui->createGlobal->setDescription( ui->createGlobal->description() - .arg(InstanceManager::instance().instancesPath())); + .arg(InstanceManager::instance().instancesPath())); ui->createPortable->setDescription( ui->createPortable->description() - .arg(InstanceManager::portablePath())); + .arg(InstanceManager::portablePath())); + + if (InstanceManager::instance().portableInstanceExists()) { + ui->createPortable->setEnabled(false); + ui->portableExistsLabel->setVisible(true); + } else { + ui->createPortable->setEnabled(true); + ui->portableExistsLabel->setVisible(false); + } QObject::connect( ui->createGlobal, &QAbstractButton::clicked, [&]{ global(); }); diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp index 2c8d8fb3..b6798fa9 100644 --- a/src/instancemanager.cpp +++ b/src/instancemanager.cpp @@ -344,7 +344,7 @@ QString InstanceManager::portablePath() return qApp->applicationDirPath(); } -bool InstanceManager::portableInstall() const +bool InstanceManager::portableInstanceExists() const { return QFile::exists(qApp->applicationDirPath() + "/" + QString::fromStdWString(AppConfig::iniFileName())); @@ -357,7 +357,6 @@ bool InstanceManager::portableInstallIsLocked() const QString::fromStdWString(AppConfig::portableLockFileName())); } - bool InstanceManager::allowedToChangeInstance() const { return !portableInstallIsLocked(); @@ -388,7 +387,7 @@ QString InstanceManager::determineDataPath() { instanceId.clear(); } - if (instanceId.isEmpty() && !m_Reset && (m_overrideInstance || portableInstall())) + if (instanceId.isEmpty() && !m_Reset && (m_overrideInstance || portableInstanceExists())) { // startup, apparently using portable mode before return qApp->applicationDirPath(); diff --git a/src/instancemanager.h b/src/instancemanager.h index f038678a..9250ffe9 100644 --- a/src/instancemanager.h +++ b/src/instancemanager.h @@ -54,6 +54,7 @@ public: bool allowedToChangeInstance() const; static bool isPortablePath(const QString& dataPath); static QString portablePath(); + bool portableInstanceExists() const; QString instancesPath() const; QStringList instanceNames() const; @@ -76,7 +77,6 @@ private: QString chooseInstance(const QStringList &instanceList) const; void createDataPath(const QString &dataPath) const; - bool portableInstall() const; bool portableInstallIsLocked() const; private: |
