mirror of
https://github.com/tnodir/fort
synced 2024-11-15 18:56:55 +00:00
UI: Restart when needed.
This commit is contained in:
parent
033e253e01
commit
c94fe31da8
@ -57,7 +57,7 @@ void OptionsPage::onSaved()
|
|||||||
const bool isServiceMode = StartupUtil::isServiceMode(m_currentStartMode);
|
const bool isServiceMode = StartupUtil::isServiceMode(m_currentStartMode);
|
||||||
if (isServiceMode != wasServiceMode) {
|
if (isServiceMode != wasServiceMode) {
|
||||||
QMetaObject::invokeMethod(
|
QMetaObject::invokeMethod(
|
||||||
this, &OptionsPage::processRestartRequired, Qt::QueuedConnection);
|
fortManager(), &FortManager::processRestartRequired, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,11 +480,3 @@ void OptionsPage::setupNewVersionUpdate()
|
|||||||
connect(taskManager()->taskInfoUpdateChecker(), &TaskInfoUpdateChecker::versionChanged, this,
|
connect(taskManager()->taskInfoUpdateChecker(), &TaskInfoUpdateChecker::versionChanged, this,
|
||||||
refreshNewVersion);
|
refreshNewVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsPage::processRestartRequired()
|
|
||||||
{
|
|
||||||
if (!fortManager()->showYesNoBox(tr("Restart Required"), tr("Restart Now"), tr("Later")))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// TODO: Restart the app with args
|
|
||||||
}
|
|
||||||
|
@ -40,8 +40,6 @@ private:
|
|||||||
void setupNewVersionBox();
|
void setupNewVersionBox();
|
||||||
void setupNewVersionUpdate();
|
void setupNewVersionUpdate();
|
||||||
|
|
||||||
void processRestartRequired();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint m_iniEdited : 1;
|
uint m_iniEdited : 1;
|
||||||
uint m_currentStartMode : 4;
|
uint m_currentStartMode : 4;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
#include <QProcess>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
@ -557,6 +558,19 @@ void FortManager::closeConnectionsWindow()
|
|||||||
m_connWindow = nullptr;
|
m_connWindow = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FortManager::processRestartRequired()
|
||||||
|
{
|
||||||
|
if (!showYesNoBox(tr("Restart Required"), tr("Restart Now"), tr("Later")))
|
||||||
|
return;
|
||||||
|
|
||||||
|
const QString appFilePath = QCoreApplication::applicationFilePath();
|
||||||
|
const QStringList args = settings()->appArguments();
|
||||||
|
|
||||||
|
connect(this, &QObject::destroyed, [=] { QProcess::startDetached(appFilePath, args); });
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
void FortManager::exit(int retcode)
|
void FortManager::exit(int retcode)
|
||||||
{
|
{
|
||||||
if (!checkPassword())
|
if (!checkPassword())
|
||||||
@ -620,7 +634,7 @@ bool FortManager::showYesNoBox(
|
|||||||
box.addButton(yesText, QMessageBox::YesRole);
|
box.addButton(yesText, QMessageBox::YesRole);
|
||||||
box.addButton(noText, QMessageBox::NoRole);
|
box.addButton(noText, QMessageBox::NoRole);
|
||||||
|
|
||||||
return box.exec() == QMessageBox::Yes;
|
return box.exec() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FortManager::saveOriginConf(const QString &message, bool onlyFlags)
|
bool FortManager::saveOriginConf(const QString &message, bool onlyFlags)
|
||||||
|
@ -109,6 +109,8 @@ public slots:
|
|||||||
void showConnectionsWindow();
|
void showConnectionsWindow();
|
||||||
void closeConnectionsWindow();
|
void closeConnectionsWindow();
|
||||||
|
|
||||||
|
void processRestartRequired();
|
||||||
|
|
||||||
void exit(int retcode = 0);
|
void exit(int retcode = 0);
|
||||||
|
|
||||||
bool checkPassword();
|
bool checkPassword();
|
||||||
|
@ -28,7 +28,7 @@ QString expandPath(const QString &path, EnvManager *envManager = nullptr)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FortSettings::FortSettings(int argc, char *argv[], QObject *parent) :
|
FortSettings::FortSettings(QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_iniExists(false),
|
m_iniExists(false),
|
||||||
m_noCache(false),
|
m_noCache(false),
|
||||||
@ -36,9 +36,7 @@ FortSettings::FortSettings(int argc, char *argv[], QObject *parent) :
|
|||||||
m_hasService(false),
|
m_hasService(false),
|
||||||
m_isWindowControl(false),
|
m_isWindowControl(false),
|
||||||
m_bulkUpdating(false),
|
m_bulkUpdating(false),
|
||||||
m_bulkIniChanged(false),
|
m_bulkIniChanged(false)
|
||||||
m_argc(argc),
|
|
||||||
m_argv(argv)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,6 +184,8 @@ void FortSettings::processArguments(const QStringList &args, EnvManager *envMana
|
|||||||
|
|
||||||
// Other Arguments
|
// Other Arguments
|
||||||
m_args = parser.positionalArguments();
|
m_args = parser.positionalArguments();
|
||||||
|
|
||||||
|
m_appArguments = args.mid(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FortSettings::setupIni()
|
void FortSettings::setupIni()
|
||||||
|
@ -15,7 +15,7 @@ class FortSettings : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FortSettings(int argc = 0, char *argv[] = nullptr, QObject *parent = nullptr);
|
explicit FortSettings(QObject *parent = nullptr);
|
||||||
|
|
||||||
bool debug() const { return iniBool("base/debug"); }
|
bool debug() const { return iniBool("base/debug"); }
|
||||||
void setDebug(bool on) { setIniValue("base/debug", on); }
|
void setDebug(bool on) { setIniValue("base/debug", on); }
|
||||||
@ -219,7 +219,9 @@ public:
|
|||||||
bool isWindowControl() const { return m_isWindowControl; }
|
bool isWindowControl() const { return m_isWindowControl; }
|
||||||
QString controlCommand() const { return m_controlCommand; }
|
QString controlCommand() const { return m_controlCommand; }
|
||||||
|
|
||||||
QStringList args() const { return m_args; }
|
const QStringList &args() const { return m_args; }
|
||||||
|
|
||||||
|
const QStringList &appArguments() const { return m_appArguments; }
|
||||||
|
|
||||||
QString errorMessage() const { return m_errorMessage; }
|
QString errorMessage() const { return m_errorMessage; }
|
||||||
|
|
||||||
@ -287,9 +289,6 @@ private:
|
|||||||
bool m_bulkUpdating : 1;
|
bool m_bulkUpdating : 1;
|
||||||
bool m_bulkIniChanged : 1;
|
bool m_bulkIniChanged : 1;
|
||||||
|
|
||||||
int m_argc = 0;
|
|
||||||
char **m_argv = nullptr;
|
|
||||||
|
|
||||||
QString m_defaultLanguage;
|
QString m_defaultLanguage;
|
||||||
QString m_profilePath;
|
QString m_profilePath;
|
||||||
QString m_statPath;
|
QString m_statPath;
|
||||||
@ -298,6 +297,8 @@ private:
|
|||||||
QString m_controlCommand;
|
QString m_controlCommand;
|
||||||
QStringList m_args;
|
QStringList m_args;
|
||||||
|
|
||||||
|
QStringList m_appArguments;
|
||||||
|
|
||||||
QString m_errorMessage;
|
QString m_errorMessage;
|
||||||
|
|
||||||
QSettings *m_ini = nullptr;
|
QSettings *m_ini = nullptr;
|
||||||
|
@ -28,7 +28,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process global settings required before QApplication costruction
|
// Process global settings required before QApplication costruction
|
||||||
FortSettings fortSettings(argc, argv);
|
FortSettings fortSettings;
|
||||||
fortSettings.setHasService(StartupUtil::isServiceInstalled());
|
fortSettings.setHasService(StartupUtil::isServiceInstalled());
|
||||||
fortSettings.setupGlobal();
|
fortSettings.setupGlobal();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user