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