mirror of
https://github.com/tnodir/fort
synced 2024-11-15 11:25:08 +00:00
UI: Simplify main().
This commit is contained in:
parent
f53672603e
commit
02397a9736
@ -9,6 +9,7 @@
|
||||
#include "util/dateutil.h"
|
||||
#include "util/envmanager.h"
|
||||
#include "util/fileutil.h"
|
||||
#include "util/osutil.h"
|
||||
#include "util/startuputil.h"
|
||||
#include "util/stringutil.h"
|
||||
|
||||
@ -103,6 +104,9 @@ void FortSettings::setupGlobal()
|
||||
qputenv("QT_SCALE_FACTOR_ROUNDING_POLICY", dpiPolicy.toLatin1());
|
||||
}
|
||||
|
||||
m_hasService = StartupUtil::isServiceInstalled();
|
||||
m_isUserAdmin = OsUtil::isUserAdmin();
|
||||
|
||||
m_noCache = settings.value("global/noCache").toBool();
|
||||
m_defaultLanguage = settings.value("global/defaultLanguage").toString();
|
||||
|
||||
|
@ -20,14 +20,11 @@ public:
|
||||
bool noCache() const { return m_noCache; }
|
||||
|
||||
bool isService() const { return m_isService; }
|
||||
|
||||
bool hasService() const { return m_hasService; }
|
||||
void setHasService(bool v) { m_hasService = v; }
|
||||
|
||||
bool isServiceClient() const { return hasService() && !isService(); }
|
||||
|
||||
bool isUserAdmin() const { return m_isUserAdmin; }
|
||||
void setIsUserAdmin(bool v) { m_isUserAdmin = v; }
|
||||
|
||||
QString defaultLanguage() const { return m_defaultLanguage; }
|
||||
|
||||
|
@ -40,25 +40,32 @@ void install(const char *arg)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
bool processArgs(int argc, char *argv[])
|
||||
{
|
||||
// Uninstall
|
||||
if (argc > 1 && !strcmp(argv[1], "-u")) {
|
||||
uninstall();
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Install
|
||||
if (argc > 2 && !strcmp(argv[1], "-i")) {
|
||||
install(argv[2]);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (processArgs(argc, argv))
|
||||
return 0;
|
||||
|
||||
// Process global settings required before QApplication costruction
|
||||
FortSettings settings;
|
||||
settings.setHasService(StartupUtil::isServiceInstalled());
|
||||
settings.setupGlobal();
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
@ -80,9 +87,8 @@ int main(int argc, char *argv[])
|
||||
ControlManager controlManager(&settings);
|
||||
|
||||
// Send control command to running instance
|
||||
if (controlManager.isCommandClient()) {
|
||||
if (controlManager.isCommandClient())
|
||||
return controlManager.postCommand() ? 0 : FORT_ERROR_CONTROL;
|
||||
}
|
||||
|
||||
FortManager::setupResources();
|
||||
|
||||
@ -92,8 +98,6 @@ int main(int argc, char *argv[])
|
||||
if (!fortManager.checkRunningInstance())
|
||||
return FORT_ERROR_INSTANCE;
|
||||
|
||||
settings.setIsUserAdmin(OsUtil::isUserAdmin());
|
||||
|
||||
fortManager.initialize();
|
||||
|
||||
if (settings.isService()) {
|
||||
|
Loading…
Reference in New Issue
Block a user