UI: Remove QML; Prepare OptionsWindow.

This commit is contained in:
Nodir Temirkhodjaev 2019-12-16 15:41:44 +05:00
parent b5a8570afd
commit 176a870ae3
26 changed files with 149 additions and 314 deletions

View File

@ -4,17 +4,11 @@
"common": [
"${QTPATH}/bin/Qt6Core.dll",
"${QTPATH}/bin/Qt6Gui.dll",
"${QTPATH}/bin/Qt6Qml.dll",
"${QTPATH}/bin/Qt6QmlModels.dll",
"${QTPATH}/bin/Qt6Quick.dll",
"${QTPATH}/bin/Qt6QuickControls2.dll",
"${QTPATH}/bin/Qt6QuickTemplates2.dll",
"${QTPATH}/bin/Qt6Widgets.dll"
],
"fort": [
"${BUILD}/FortFirewall.exe",
"${ROOT}/ChangeLog",
"${ROOT}/src/scripts | *.qs Readme.txt |",
"${ROOT}/src/ui/i18n | *.qm |"
]
},
@ -23,25 +17,6 @@
"${ROOT}/src/driver/scripts | *.bat *.lnk |"
]
},
"${TARGET}/imports": {
"common": [
"${QTPATH}/qml/QtQuick.2 | *.dll qmldir | *d.dll",
"${QTPATH}/qml/QtQml | *.dll qmldir | *d.dll"
]
},
"${TARGET}/imports/QtQml": {
"common": [
"${QTPATH}/qml/QtQml/Models.2 | *.dll qmldir | *d.dll"
]
},
"${TARGET}/imports/QtQuick": {
"common": [
"${QTPATH}/qml/QtQuick/Controls.2 | *.dll qmldir *.qml | *d.dll",
"${QTPATH}/qml/QtQuick/Layouts | *.dll qmldir | *d.dll",
"${QTPATH}/qml/QtQuick/Templates.2 | *.dll qmldir | *d.dll",
"${QTPATH}/qml/QtQuick/Window.2 | *.dll qmldir | *d.dll"
]
},
"${TARGET}/plugins": {
"common": [
"${QTPATH}/plugins/platforms | qwindows.dll | *d.dll"

View File

@ -6,7 +6,7 @@
md %TARGET_PATH%
cd %TARGET_PATH%
del /Q /F qt*.* FortFirewall.exe
rd /Q /S driver\scripts i18n imports plugins scripts
rd /Q /S driver\scripts i18n imports plugins
cd ..
powershell.exe -executionpolicy remotesigned -file setup-deployment.ps1 %TARGET_PATH% %*

View File

@ -1,5 +0,0 @@
This folder contains control scripts.
Run as: FortFirewall.exe --control <path-to-script> "arg1" "arg2" ...
Example: FortFirewall.exe --control scripts/torrent.qs "torrentEnabled=0"

View File

@ -1,2 +0,0 @@
const torrentGroup = conf.appGroupByName("Torrent");
torrentGroup.enabled = !!parseInt(arg["torrentEnabled"]);

View File

@ -1,4 +1,4 @@
QT += core gui qml quick widgets
QT += core gui widgets
CONFIG += c++11
@ -18,6 +18,7 @@ SOURCES += \
control/controlworker.cpp \
driver/drivermanager.cpp \
driver/driverworker.cpp \
form/optionswindow.cpp \
fortcommon.cpp \
fortmanager.cpp \
fortsettings.cpp \
@ -50,7 +51,6 @@ SOURCES += \
task/taskupdatechecker.cpp \
task/taskworker.cpp \
translationmanager.cpp \
util/app/appiconprovider.cpp \
util/app/appinfo.cpp \
util/app/appinfocache.cpp \
util/app/appinfojob.cpp \
@ -94,6 +94,7 @@ HEADERS += \
control/controlworker.h \
driver/drivermanager.h \
driver/driverworker.h \
form/optionswindow.h \
fortcommon.h \
fortmanager.h \
fortsettings.h \
@ -125,7 +126,6 @@ HEADERS += \
task/taskupdatechecker.h \
task/taskworker.h \
translationmanager.h \
util/app/appiconprovider.h \
util/app/appinfo.h \
util/app/appinfocache.h \
util/app/appinfojob.h \
@ -175,9 +175,6 @@ QML_FILES += \
OTHER_FILES += \
$${QML_FILES}
# QML files
RESOURCES += fort_qml.qrc
# Images
RESOURCES += fort_images.qrc

View File

@ -211,11 +211,6 @@ void FirewallConf::setAppGroupBits(quint32 groupBits)
}
}
QQmlListProperty<AddressGroup> FirewallConf::addressGroups()
{
return {this, m_addressGroups};
}
AppGroup *FirewallConf::appGroupByName(const QString &name) const
{
for (AppGroup *appGroup : appGroupsList()) {
@ -225,11 +220,6 @@ AppGroup *FirewallConf::appGroupByName(const QString &name) const
return nullptr;
}
QQmlListProperty<AppGroup> FirewallConf::appGroups()
{
return {this, m_appGroups};
}
void FirewallConf::addAppGroup(AppGroup *appGroup, int to)
{
appGroup->setParent(this);

View File

@ -2,7 +2,6 @@
#define FIREWALLCONF_H
#include <QObject>
#include <QQmlListProperty>
#include <QVariant>
QT_FORWARD_DECLARE_CLASS(AddressGroup)
@ -38,8 +37,6 @@ class FirewallConf : public QObject
Q_PROPERTY(quint32 quotaDayMb READ quotaDayMb WRITE setQuotaDayMb NOTIFY quotaDayMbChanged)
Q_PROPERTY(quint32 quotaMonthMb READ quotaMonthMb WRITE setQuotaMonthMb NOTIFY quotaMonthMbChanged)
Q_PROPERTY(AddressGroup *inetAddressGroup READ inetAddressGroup NOTIFY addressGroupsChanged)
Q_PROPERTY(QQmlListProperty<AddressGroup> addressGroups READ addressGroups NOTIFY addressGroupsChanged)
Q_PROPERTY(QQmlListProperty<AppGroup> appGroups READ appGroups NOTIFY appGroupsChanged)
Q_CLASSINFO("DefaultProperty", "appGroups")
public:
@ -121,12 +118,10 @@ public:
AddressGroup *inetAddressGroup() const { return m_addressGroups.at(0); }
const QList<AddressGroup *> &addressGroupsList() const { return m_addressGroups; }
QQmlListProperty<AddressGroup> addressGroups();
Q_INVOKABLE AppGroup *appGroupByName(const QString &name) const;
const QList<AppGroup *> &appGroupsList() const { return m_appGroups; }
QQmlListProperty<AppGroup> appGroups();
const QList<AppGroup *> &removedAppGroupsList() const { return m_removedAppGroups; }
void clearRemovedAppGroups() const;

View File

@ -1,13 +1,14 @@
#include "controlmanager.h"
#include <QJSEngine>
#include <QLoggingCategory>
#include <QThreadPool>
#include "../conf/appgroup.h"
#include "../conf/firewallconf.h"
#include "../util/fileutil.h"
#include "controlworker.h"
#include "fortmanager.h"
#include "fortsettings.h"
Q_DECLARE_LOGGING_CATEGORY(CLOG_CONTROL_MANAGER)
Q_LOGGING_CATEGORY(CLOG_CONTROL_MANAGER, "fort.controlManager")
@ -16,11 +17,11 @@ Q_LOGGING_CATEGORY(CLOG_CONTROL_MANAGER, "fort.controlManager")
#define logCritical() qCCritical(CLOG_CONTROL_MANAGER,)
ControlManager::ControlManager(const QString &globalName,
const QString &scriptPath,
const QString &command,
QObject *parent) :
QObject(parent),
m_isClient(!scriptPath.isEmpty()),
m_scriptPath(scriptPath),
m_isClient(!command.isEmpty()),
m_command(command),
m_fortManager(nullptr),
m_worker(nullptr),
m_semaphore(globalName + QLatin1String("_ControlSemaphore"), 0,
@ -64,57 +65,60 @@ bool ControlManager::post(const QStringList &args)
ControlWorker worker(&m_semaphore, &m_sharedMemory);
return worker.post(m_scriptPath, args);
return worker.post(m_command, args);
}
void ControlManager::processRequest(const QString &scriptPath,
void ControlManager::processRequest(const QString &command,
const QStringList &args)
{
const QString script = FileUtil::readFile(scriptPath);
if (script.isEmpty()) {
logWarning() << "Script is empty:"
<< scriptPath;
return;
QString errorMessage;
if (!processCommand(command, args, errorMessage)) {
logWarning() << "Bad control command" << errorMessage
<< ':' << command << args;
}
}
QJSEngine engine;
engine.installExtensions(QJSEngine::ConsoleExtension);
bool ControlManager::processCommand(const QString &command,
const QStringList &args,
QString &errorMessage)
{
const int argsSize = args.size();
QJSValue globalObject = engine.globalObject();
// Arguments
QJSValue argsJs = engine.newArray(args.size());
QJSValue argsMapJs = engine.newObject();
for (int i = 0, n = args.size(); i < n; ++i) {
const QString &arg = args.at(i);
argsJs.setProperty(i, arg);
const int sepPos = arg.indexOf('=');
if (sepPos > 0) {
const QString k = arg.left(sepPos);
const QString v = arg.mid(sepPos + 1);
argsMapJs.setProperty(k, v);
if (command == QLatin1String("ini")) {
if (argsSize < 3) {
errorMessage = "ini <property> <value>";
return false;
}
}
globalObject.setProperty("args", argsJs);
globalObject.setProperty("arg", argsMapJs);
// FirewallConf
QJSValue firewallConfJs = engine.newQObject(
m_fortManager->firewallConf());
globalObject.setProperty("conf", firewallConfJs);
auto settings = m_fortManager->fortSettings();
// Run the script
const QJSValue res = engine.evaluate(script, scriptPath);
if (res.isError()) {
logWarning() << "Script error:"
<< scriptPath << "line"
<< res.property("lineNumber").toInt()
<< ":" << res.toString();
return;
settings->setProperty(args.at(0).toLatin1(), QVariant(args.at(1)));
} else if (command == QLatin1String("conf")) {
if (argsSize < 3) {
errorMessage = "conf <property> <value>";
return false;
}
auto conf = m_fortManager->firewallConf();
const auto confPropName = args.at(0);
if (confPropName == QLatin1String("appGroup")) {
if (argsSize < 4) {
errorMessage = "conf appGroup <group-name> <property> <value>";
return false;
}
auto appGroup = conf->appGroupByName(args.at(1));
appGroup->setProperty(args.at(2).toLatin1(), QVariant(args.at(3)));
} else {
conf->setProperty(confPropName.toLatin1(), QVariant(args.at(1)));
}
m_fortManager->saveOriginConf(tr("Control command executed"));
}
m_fortManager->saveOriginConf(tr("Control script executed"));
return true;
}
void ControlManager::setupWorker()

View File

@ -16,7 +16,7 @@ class ControlManager : public QObject
public:
explicit ControlManager(const QString &globalName,
const QString &scriptPath,
const QString &command,
QObject *parent = nullptr);
~ControlManager() override;
CLASS_DELETE_COPY_MOVE(ControlManager)
@ -31,10 +31,14 @@ signals:
public slots:
private slots:
void processRequest(const QString &scriptPath,
void processRequest(const QString &command,
const QStringList &args);
private:
bool processCommand(const QString &command,
const QStringList &args,
QString &errorMessage);
void setupWorker();
void abort();
@ -42,7 +46,7 @@ private:
private:
bool m_isClient;
QString m_scriptPath;
QString m_command;
FortManager *m_fortManager;
ControlWorker *m_worker;

View File

@ -38,12 +38,12 @@ void ControlWorker::abort()
}
}
bool ControlWorker::post(const QString &scriptPath,
bool ControlWorker::post(const QString &command,
const QStringList &args)
{
m_sharedMemory->lock();
const bool res = writeDataStream(scriptPath, args);
const bool res = writeDataStream(command, args);
m_sharedMemory->unlock();

View File

@ -19,11 +19,11 @@ public:
void run() override;
bool post(const QString &scriptPath,
bool post(const QString &command,
const QStringList &args);
signals:
void requestReady(const QString &scriptPath,
void requestReady(const QString &command,
const QStringList &args);
public slots:
@ -35,9 +35,9 @@ private:
bool writeData(const QByteArray &data);
QByteArray readData() const;
bool writeDataStream(const QString &scriptPath,
bool writeDataStream(const QString &command,
const QStringList &args);
bool readDataStream(QString &scriptPath,
bool readDataStream(QString &command,
QStringList &args) const;
private:

View File

@ -0,0 +1,15 @@
#include "optionswindow.h"
OptionsWindow::OptionsWindow(QWindow *parent) :
QWindow(parent)
{
setupUi();
}
void OptionsWindow::setupUi()
{
}
void OptionsWindow::retranslateUi()
{
}

View File

@ -0,0 +1,23 @@
#ifndef OPTIONSWINDOW_H
#define OPTIONSWINDOW_H
#include <QObject>
#include <QWindow>
class OptionsWindow : public QWindow
{
Q_OBJECT
public:
explicit OptionsWindow(QWindow *parent = nullptr);
signals:
public slots:
void retranslateUi();
private:
void setupUi();
};
#endif // OPTIONSWINDOW_H

View File

@ -6,8 +6,6 @@
#include <QMenu>
#include <QMessageBox>
#include <QMouseEvent>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QSystemTrayIcon>
#include <QThreadPool>
#include <QTimer>
@ -18,6 +16,7 @@
#include "conf/confmanager.h"
#include "conf/firewallconf.h"
#include "driver/drivermanager.h"
#include "form/optionswindow.h"
#include "fortsettings.h"
#include "graph/graphwindow.h"
#include "log/logmanager.h"
@ -31,7 +30,6 @@
#include "task/taskinfoupdatechecker.h"
#include "task/taskmanager.h"
#include "translationmanager.h"
#include "util/app/appiconprovider.h"
#include "util/app/appinfocache.h"
#include "util/app/appinfomanager.h"
#include "util/dateutil.h"
@ -52,9 +50,8 @@ FortManager::FortManager(FortSettings *fortSettings,
QObject *parent) :
QObject(parent),
m_trayIcon(new QSystemTrayIcon(this)),
m_engine(nullptr),
m_appWindow(nullptr),
m_appWindowState(new WindowStateWatcher(this)),
m_optWindow(nullptr),
m_optWindowState(new WindowStateWatcher(this)),
m_graphWindow(nullptr),
m_graphWindowState(new WidgetWindowStateWatcher(this)),
m_fortSettings(fortSettings),
@ -91,8 +88,6 @@ FortManager::FortManager(FortSettings *fortSettings,
loadSettings();
registerQmlTypes();
setupTaskManager();
setupTranslationManager();
setupTrayIcon();
@ -108,48 +103,6 @@ FortManager::~FortManager()
closeLogManager();
}
void FortManager::registerQmlTypes()
{
qmlRegisterUncreatableType<DriverManager>("com.fortfirewall", 1, 0, "DriverManager",
"Singleton");
qmlRegisterUncreatableType<FortSettings>("com.fortfirewall", 1, 0, "FortSettings",
"Singleton");
qmlRegisterUncreatableType<LogManager>("com.fortfirewall", 1, 0, "LogManager",
"Singleton");
qmlRegisterUncreatableType<AppBlockedModel>("com.fortfirewall", 1, 0, "AppBlockedModel",
"Singleton");
qmlRegisterUncreatableType<AppStatModel>("com.fortfirewall", 1, 0, "AppStatModel",
"Singleton");
qmlRegisterUncreatableType<IpListModel>("com.fortfirewall", 1, 0, "IpListModel",
"Singleton");
qmlRegisterUncreatableType<TrafListModel>("com.fortfirewall", 1, 0, "TrafListModel",
"Singleton");
qmlRegisterUncreatableType<TranslationManager>("com.fortfirewall", 1, 0, "TranslationManager",
"Singleton");
qmlRegisterUncreatableType<TaskManager>("com.fortfirewall", 1, 0, "TaskManager",
"Singleton");
qmlRegisterUncreatableType<TaskInfo>("com.fortfirewall", 1, 0, "TaskInfo",
"Singleton");
qmlRegisterUncreatableType<TaskInfoUpdateChecker>("com.fortfirewall", 1, 0, "TaskInfoUpdateChecker",
"Singleton");
qmlRegisterType<AddressGroup>("com.fortfirewall", 1, 0, "AddressGroup");
qmlRegisterType<AppGroup>("com.fortfirewall", 1, 0, "AppGroup");
qmlRegisterType<FirewallConf>("com.fortfirewall", 1, 0, "FirewallConf");
qRegisterMetaType<AppInfo>();
qmlRegisterType<AppInfoCache>("com.fortfirewall", 1, 0, "AppInfoCache");
qmlRegisterType<DateUtil>("com.fortfirewall", 1, 0, "DateUtil");
qmlRegisterType<FileUtil>("com.fortfirewall", 1, 0, "FileUtil");
qmlRegisterType<GuiUtil>("com.fortfirewall", 1, 0, "GuiUtil");
qmlRegisterType<HostInfoCache>("com.fortfirewall", 1, 0, "HostInfoCache");
qmlRegisterType<NetUtil>("com.fortfirewall", 1, 0, "NetUtil");
qmlRegisterType<OsUtil>("com.fortfirewall", 1, 0, "OsUtil");
qmlRegisterType<StringUtil>("com.fortfirewall", 1, 0, "StringUtil");
}
void FortManager::setupThreadPool()
{
QThreadPool::globalInstance()->setMaxThreadCount(
@ -257,7 +210,7 @@ void FortManager::setupTrayIcon()
connect(m_trayIcon, &QSystemTrayIcon::activated, this,
[this](QSystemTrayIcon::ActivationReason reason) {
if (reason == QSystemTrayIcon::Trigger) {
showWindow();
showOptionsWindow();
}
});
@ -281,61 +234,26 @@ void FortManager::setupAppInfoCache()
m_appInfoCache->setManager(manager);
}
bool FortManager::setupEngine()
bool FortManager::setupOptionsWindow()
{
if (m_fortSettings->isPortable()) {
qputenv("QML_DISABLE_DISK_CACHE", "1");
qputenv("QT_DISABLE_SHADER_DISK_CACHE", "1");
}
m_engine = new QQmlApplicationEngine(this);
QQmlContext *context = m_engine->rootContext();
context->setContextProperty("fortManager", this);
context->setContextProperty("driverManager", m_driverManager);
context->setContextProperty("translationManager", TranslationManager::instance());
context->setContextProperty("taskManager", m_taskManager);
context->setContextProperty("appInfoCache", m_appInfoCache);
m_engine->addImageProvider(AppIconProvider::id(),
new AppIconProvider(m_appInfoCache->manager()));
m_engine->load(QUrl("qrc:/qml/main.qml"));
const QList<QObject *> rootObjects = m_engine->rootObjects();
if (rootObjects.isEmpty()) {
showErrorBox("Cannot setup QML Engine");
return false;
}
m_optWindow = new OptionsWindow();
connect(TranslationManager::instance(), &TranslationManager::languageChanged,
m_engine, &QQmlEngine::retranslate);
m_optWindow, &OptionsWindow::retranslateUi);
m_appWindow = qobject_cast<QWindow *>(rootObjects.first());
Q_ASSERT(m_appWindow);
m_appWindowState->install(m_appWindow);
m_optWindowState->install(m_optWindow);
return true;
}
void FortManager::closeEngine()
{
m_appWindow = nullptr;
if (m_engine) {
m_engine->deleteLater();
m_engine = nullptr;
}
}
void FortManager::closeUi()
{
closeGraphWindow(true);
closeWindow();
closeEngine();
closeOptionsWindow();
}
void FortManager::launch()
@ -365,13 +283,13 @@ void FortManager::showTrayMenu(QMouseEvent *event)
menu->popup(event->globalPos());
}
void FortManager::showWindow()
void FortManager::showOptionsWindow()
{
if (!m_engine) {
setupEngine();
if (!m_optWindow) {
setupOptionsWindow();
}
if (!m_appWindow || !(m_appWindow->isVisible()
if (!m_optWindow || !(m_optWindow->isVisible()
|| checkPassword()))
return;
@ -380,21 +298,24 @@ void FortManager::showWindow()
setFirewallConfToEdit(newConf);
}
m_appWindow->show();
m_appWindow->raise();
m_appWindow->requestActivate();
m_optWindow->show();
m_optWindow->raise();
m_optWindow->requestActivate();
restoreWindowState();
restoreOptWindowState();
}
void FortManager::closeWindow()
void FortManager::closeOptionsWindow()
{
if (!m_appWindow)
if (!m_optWindow)
return;
saveWindowState();
saveOptWindowState();
m_appWindow->hide();
m_optWindow->hide();
m_optWindow->deleteLater();
m_optWindow = nullptr;
setFirewallConfToEdit(nullptr);
}
@ -504,7 +425,7 @@ bool FortManager::saveOriginConf(const QString &message)
if (!saveSettings(m_firewallConf))
return false;
closeWindow();
closeOptionsWindow();
showTrayMessage(message);
return true;
}
@ -646,17 +567,17 @@ void FortManager::saveTrayFlags()
updateDriverConf(true);
}
void FortManager::saveWindowState()
void FortManager::saveOptWindowState()
{
m_fortSettings->setOptWindowGeometry(m_appWindowState->geometry());
m_fortSettings->setOptWindowMaximized(m_appWindowState->maximized());
m_fortSettings->setOptWindowGeometry(m_optWindowState->geometry());
m_fortSettings->setOptWindowMaximized(m_optWindowState->maximized());
emit afterSaveWindowState();
}
void FortManager::restoreWindowState()
void FortManager::restoreOptWindowState()
{
m_appWindowState->restore(m_appWindow, QSize(1024, 768),
m_optWindowState->restore(m_optWindow, QSize(1024, 768),
m_fortSettings->optWindowGeometry(),
m_fortSettings->optWindowMaximized());
@ -699,7 +620,7 @@ void FortManager::updateTrayMenu()
QAction *optionsAction = addAction(
menu, QIcon(":/images/cog.png"), tr("Options"),
this, SLOT(showWindow()));
this, SLOT(showOptionsWindow()));
addHotKey(optionsAction, fortSettings()->hotKeyOptions(), hotKeyEnabled);
m_graphWindowAction = addAction(

View File

@ -6,7 +6,6 @@
#include "mainwindow.h"
#include "util/classhelpers.h"
QT_FORWARD_DECLARE_CLASS(QQmlApplicationEngine)
QT_FORWARD_DECLARE_CLASS(QSystemTrayIcon)
QT_FORWARD_DECLARE_CLASS(AppInfoCache)
@ -19,6 +18,7 @@ QT_FORWARD_DECLARE_CLASS(GraphWindow)
QT_FORWARD_DECLARE_CLASS(HotKeyManager)
QT_FORWARD_DECLARE_CLASS(LogManager)
QT_FORWARD_DECLARE_CLASS(NativeEventFilter)
QT_FORWARD_DECLARE_CLASS(OptionsWindow)
QT_FORWARD_DECLARE_CLASS(QuotaManager)
QT_FORWARD_DECLARE_CLASS(StatManager)
QT_FORWARD_DECLARE_CLASS(TaskManager)
@ -65,8 +65,8 @@ public slots:
void showTrayMessage(const QString &message);
void showTrayMenu(QMouseEvent *event);
void showWindow();
void closeWindow();
void showOptionsWindow();
void closeOptionsWindow();
void showGraphWindow();
void closeGraphWindow(bool storeVisibility = false);
@ -98,8 +98,6 @@ private slots:
private:
void setFirewallConfToEdit(FirewallConf *conf);
static void registerQmlTypes();
void setupThreadPool();
bool setupDriver();
@ -121,8 +119,7 @@ private:
void setupAppInfoCache();
bool setupEngine();
void closeEngine();
bool setupOptionsWindow();
void closeUi();
@ -135,8 +132,8 @@ private:
void updateLogManager(bool active);
void updateStatManager(FirewallConf *conf);
void saveWindowState();
void restoreWindowState();
void saveOptWindowState();
void restoreOptWindowState();
void saveGraphWindowState(bool visible);
void restoreGraphWindowState();
@ -159,10 +156,9 @@ private:
MainWindow m_window; // dummy window for tray icon
QSystemTrayIcon *m_trayIcon;
QQmlApplicationEngine *m_engine;
QWindow *m_appWindow;
WindowStateWatcher *m_appWindowState;
OptionsWindow *m_optWindow;
WindowStateWatcher *m_optWindowState;
GraphWindow *m_graphWindow;
WidgetWindowStateWatcher *m_graphWindowState;

View File

@ -64,7 +64,7 @@ void FortSettings::processArguments(const QStringList &args)
const QCommandLineOption controlOption(
QStringList() << "c" << "control",
"Control running instance by executing the JS file.", "control");
"Control running instance by executing the command.", "control");
parser.addOption(controlOption);
parser.addVersionOption();
@ -98,8 +98,8 @@ void FortSettings::processArguments(const QStringList &args)
FileUtil::absolutePath(m_statPath));
}
// Control JS file path
m_controlPath = parser.value(controlOption);
// Control command
m_controlCommand = parser.value(controlOption);
// Other Arguments
m_args = parser.positionalArguments();

View File

@ -173,7 +173,7 @@ public:
QString confOldFilePath() const;
QString confBackupFilePath() const;
QString controlPath() const { return m_controlPath; }
QString controlCommand() const { return m_controlCommand; }
QStringList args() const { return m_args; }
@ -250,7 +250,7 @@ private:
QString m_profilePath;
QString m_statPath;
QString m_controlPath;
QString m_controlCommand;
QStringList m_args;
QString m_errorMessage;

View File

@ -35,7 +35,7 @@ int main(int argc, char *argv[])
}
ControlManager controlManager(QApplication::applicationName(),
fortSettings.controlPath());
fortSettings.controlCommand());
// Send control request to running instance
if (controlManager.isClient()) {

View File

@ -22,11 +22,6 @@ TaskManager::TaskManager(FortManager *fortManager,
this, &TaskManager::runExpiredTasks);
}
QQmlListProperty<TaskInfo> TaskManager::taskInfos()
{
return {this, m_taskInfos};
}
void TaskManager::setupTasks()
{
m_taskInfoUpdateChecker = new TaskInfoUpdateChecker(this);

View File

@ -2,7 +2,6 @@
#define TASKMANAGER_H
#include <QObject>
#include <QQmlListProperty>
#include <QTimer>
QT_FORWARD_DECLARE_CLASS(ConfManager)
@ -15,7 +14,6 @@ class TaskManager : public QObject
{
Q_OBJECT
Q_PROPERTY(TaskInfoUpdateChecker *taskInfoUpdateChecker READ taskInfoUpdateChecker CONSTANT)
Q_PROPERTY(QQmlListProperty<TaskInfo> taskInfos READ taskInfos NOTIFY taskInfosChanged)
Q_CLASSINFO("DefaultProperty", "taskInfos")
public:
@ -27,7 +25,6 @@ public:
TaskInfoUpdateChecker *taskInfoUpdateChecker() const { return m_taskInfoUpdateChecker; }
const QList<TaskInfo *> &taskInfosList() const { return m_taskInfos; }
QQmlListProperty<TaskInfo> taskInfos();
signals:
void taskInfosChanged();

View File

@ -89,7 +89,7 @@ bool TranslationManager::switchLanguage(int language)
installTranslator(language, m_locale);
m_language = language;
emit languageChanged(m_language);
emit languageChanged();
return true;
}

View File

@ -32,7 +32,7 @@ public:
int getLanguageByName(const QString &localeName) const;
signals:
void languageChanged(int language);
void languageChanged();
public slots:
bool switchLanguage(int language = 0);

View File

@ -1,38 +0,0 @@
#include "appiconprovider.h"
#include "appinfomanager.h"
AppIconProvider::AppIconProvider(AppInfoManager *manager) :
QQuickImageProvider(QQuickImageProvider::Image),
m_manager(manager)
{
}
QImage AppIconProvider::requestImage(const QString &id, QSize *size,
const QSize &requestedSize)
{
Q_UNUSED(size)
Q_UNUSED(requestedSize)
QImage icon;
bool ok;
const qint64 iconId = id.toLongLong(&ok, 16);
if (ok && iconId != 0) {
icon = m_manager->loadIconFromDb(iconId);
}
return icon.isNull() ? QImage(":/images/application.png")
: icon;
}
QString AppIconProvider::id()
{
return QLatin1String("app-icon");
}
QString AppIconProvider::iconPath(qint64 iconId)
{
return QLatin1String("image://") + id()
+ QString("/%1").arg(iconId, 0, 16);
}

View File

@ -1,23 +0,0 @@
#ifndef APPICONPROVIDER_H
#define APPICONPROVIDER_H
#include <QQuickImageProvider>
QT_FORWARD_DECLARE_CLASS(AppInfoManager)
class AppIconProvider: public QQuickImageProvider
{
public:
explicit AppIconProvider(AppInfoManager *manager);
QImage requestImage(const QString &id, QSize *size,
const QSize &requestedSize) override;
static QString id();
static QString iconPath(qint64 iconId);
private:
AppInfoManager *m_manager;
};
#endif // APPICONPROVIDER_H

View File

@ -1,13 +1,7 @@
#include "appinfo.h"
#include "appiconprovider.h"
#include "apputil.h"
QString AppInfo::iconPath() const
{
return AppIconProvider::iconPath(iconId);
}
bool AppInfo::isFileModified(const QString &appPath) const
{
return fileModTime != AppUtil::getModTime(appPath);

View File

@ -7,15 +7,12 @@
class AppInfo
{
Q_GADGET
Q_PROPERTY(QString iconPath READ iconPath CONSTANT)
Q_PROPERTY(QString fileDescription MEMBER fileDescription CONSTANT)
Q_PROPERTY(QString companyName MEMBER companyName CONSTANT)
Q_PROPERTY(QString productName MEMBER productName CONSTANT)
Q_PROPERTY(QString productVersion MEMBER productVersion CONSTANT)
public:
QString iconPath() const;
bool isFileModified(const QString &appPath) const;
public: