From 6f21f3a19fbd82bc43c97dcab877959220ce2f22 Mon Sep 17 00:00:00 2001
From: isanae <14251494+isanae@users.noreply.github.com>
Date: Thu, 30 Jul 2020 01:17:30 -0400
Subject: disable portable instance button if one exists
---
src/createinstancedialog.ui | 18 ++++++++++++++----
src/createinstancedialogpages.cpp | 12 ++++++++++--
src/instancemanager.cpp | 5 ++---
src/instancemanager.h | 2 +-
4 files changed, 27 insertions(+), 10 deletions(-)
(limited to 'src')
diff --git a/src/createinstancedialog.ui b/src/createinstancedialog.ui
index ebaef84d..a3c3db92 100644
--- a/src/createinstancedialog.ui
+++ b/src/createinstancedialog.ui
@@ -181,6 +181,16 @@
+ -
+
+
+ A portable instance already exists.
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
-
@@ -266,8 +276,8 @@
0
0
- 63
- 16
+ 455
+ 286
@@ -402,8 +412,8 @@
0
0
- 63
- 16
+ 455
+ 278
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:
--
cgit v1.3.1