mirror of
https://github.com/tnodir/fort
synced 2024-11-15 08:25:20 +00:00
Move startup shortcut handling to FortSettings.
This commit is contained in:
parent
42435f2ad4
commit
e7a29cdb26
@ -11,7 +11,6 @@
|
|||||||
#include "conf/appgroup.h"
|
#include "conf/appgroup.h"
|
||||||
#include "conf/firewallconf.h"
|
#include "conf/firewallconf.h"
|
||||||
#include "fortsettings.h"
|
#include "fortsettings.h"
|
||||||
#include "util/fileutil.h"
|
|
||||||
|
|
||||||
FortManager::FortManager(QObject *parent) :
|
FortManager::FortManager(QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
@ -29,22 +28,6 @@ FortManager::FortManager(QObject *parent) :
|
|||||||
setupEngine();
|
setupEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FortManager::startWithWindows() const
|
|
||||||
{
|
|
||||||
return FileUtil::fileExists(startupShortcutPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
void FortManager::setStartWithWindows(bool start)
|
|
||||||
{
|
|
||||||
const QString linkPath = startupShortcutPath();
|
|
||||||
if (start) {
|
|
||||||
FileUtil::linkFile(qApp->applicationFilePath(), linkPath);
|
|
||||||
} else {
|
|
||||||
FileUtil::removeFile(linkPath);
|
|
||||||
}
|
|
||||||
emit startWithWindowsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FortManager::registerQmlTypes()
|
void FortManager::registerQmlTypes()
|
||||||
{
|
{
|
||||||
qmlRegisterUncreatableType<FortManager>("com.fortfirewall", 1, 0, "FortManager",
|
qmlRegisterUncreatableType<FortManager>("com.fortfirewall", 1, 0, "FortManager",
|
||||||
@ -198,10 +181,3 @@ void FortManager::setActionCheckable(QAction *action, bool checked,
|
|||||||
connect(action, SIGNAL(toggled(bool)), receiver, member);
|
connect(action, SIGNAL(toggled(bool)), receiver, member);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FortManager::startupShortcutPath()
|
|
||||||
{
|
|
||||||
return FileUtil::applicationsLocation() + QLatin1Char('\\')
|
|
||||||
+ "Startup" + QLatin1Char('\\')
|
|
||||||
+ qApp->applicationName() + ".lnk";
|
|
||||||
}
|
|
||||||
|
@ -15,7 +15,6 @@ class FortManager : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(FortSettings *fortSettings READ fortSettings CONSTANT)
|
Q_PROPERTY(FortSettings *fortSettings READ fortSettings CONSTANT)
|
||||||
Q_PROPERTY(FirewallConf *firewallConfToEdit READ firewallConfToEdit NOTIFY firewallConfToEditChanged)
|
Q_PROPERTY(FirewallConf *firewallConfToEdit READ firewallConfToEdit NOTIFY firewallConfToEditChanged)
|
||||||
Q_PROPERTY(bool startWithWindows READ startWithWindows WRITE setStartWithWindows NOTIFY startWithWindowsChanged)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FortManager(QObject *parent = nullptr);
|
explicit FortManager(QObject *parent = nullptr);
|
||||||
@ -26,12 +25,8 @@ public:
|
|||||||
return m_firewallConfToEdit ? m_firewallConfToEdit : m_firewallConf;
|
return m_firewallConfToEdit ? m_firewallConfToEdit : m_firewallConf;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool startWithWindows() const;
|
|
||||||
void setStartWithWindows(bool start);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void firewallConfToEditChanged();
|
void firewallConfToEditChanged();
|
||||||
void startWithWindowsChanged();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void showTrayIcon();
|
void showTrayIcon();
|
||||||
@ -65,8 +60,6 @@ private:
|
|||||||
static void setActionCheckable(QAction *action, bool checked = false,
|
static void setActionCheckable(QAction *action, bool checked = false,
|
||||||
const QObject *receiver = 0, const char *member = 0);
|
const QObject *receiver = 0, const char *member = 0);
|
||||||
|
|
||||||
static QString startupShortcutPath();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMainWindow m_window; // dummy window for tray icon
|
QMainWindow m_window; // dummy window for tray icon
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "fortsettings.h"
|
#include "fortsettings.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
@ -16,6 +17,22 @@ FortSettings::FortSettings(const QStringList &args,
|
|||||||
setupIni();
|
setupIni();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FortSettings::startWithWindows() const
|
||||||
|
{
|
||||||
|
return FileUtil::fileExists(startupShortcutPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
void FortSettings::setStartWithWindows(bool start)
|
||||||
|
{
|
||||||
|
const QString linkPath = startupShortcutPath();
|
||||||
|
if (start) {
|
||||||
|
FileUtil::linkFile(qApp->applicationFilePath(), linkPath);
|
||||||
|
} else {
|
||||||
|
FileUtil::removeFile(linkPath);
|
||||||
|
}
|
||||||
|
emit startWithWindowsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void FortSettings::processArguments(const QStringList &args)
|
void FortSettings::processArguments(const QStringList &args)
|
||||||
{
|
{
|
||||||
const QCommandLineOption profileOption("profile", "Directory to store settings.");
|
const QCommandLineOption profileOption("profile", "Directory to store settings.");
|
||||||
@ -191,3 +208,10 @@ void FortSettings::setIniValue(const QString &key, const QVariant &value,
|
|||||||
m_ini->setValue(key, value);
|
m_ini->setValue(key, value);
|
||||||
emit iniChanged();
|
emit iniChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString FortSettings::startupShortcutPath()
|
||||||
|
{
|
||||||
|
return FileUtil::applicationsLocation() + QLatin1Char('\\')
|
||||||
|
+ "Startup" + QLatin1Char('\\')
|
||||||
|
+ qApp->applicationName() + ".lnk";
|
||||||
|
}
|
||||||
|
@ -12,6 +12,7 @@ class FortSettings : public QObject
|
|||||||
Q_PROPERTY(bool debug READ debug WRITE setDebug NOTIFY iniChanged)
|
Q_PROPERTY(bool debug READ debug WRITE setDebug NOTIFY iniChanged)
|
||||||
Q_PROPERTY(QString language READ language WRITE setLanguage NOTIFY iniChanged)
|
Q_PROPERTY(QString language READ language WRITE setLanguage NOTIFY iniChanged)
|
||||||
Q_PROPERTY(QString updatesUrl READ updatesUrl WRITE setUpdatesUrl NOTIFY iniChanged)
|
Q_PROPERTY(QString updatesUrl READ updatesUrl WRITE setUpdatesUrl NOTIFY iniChanged)
|
||||||
|
Q_PROPERTY(bool startWithWindows READ startWithWindows WRITE setStartWithWindows NOTIFY startWithWindowsChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FortSettings(const QStringList &args,
|
explicit FortSettings(const QStringList &args,
|
||||||
@ -26,8 +27,12 @@ public:
|
|||||||
QString updatesUrl() const { return iniText("base/updatesUrl"); }
|
QString updatesUrl() const { return iniText("base/updatesUrl"); }
|
||||||
void setUpdatesUrl(const QString &v) { setIniValue("base/updatesUrl", v); }
|
void setUpdatesUrl(const QString &v) { setIniValue("base/updatesUrl", v); }
|
||||||
|
|
||||||
|
bool startWithWindows() const;
|
||||||
|
void setStartWithWindows(bool start);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void iniChanged();
|
void iniChanged();
|
||||||
|
void startWithWindowsChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QString confFilePath() const;
|
QString confFilePath() const;
|
||||||
@ -58,6 +63,8 @@ private:
|
|||||||
void setIniValue(const QString &key, const QVariant &value,
|
void setIniValue(const QString &key, const QVariant &value,
|
||||||
const QVariant &defaultValue = QVariant());
|
const QVariant &defaultValue = QVariant());
|
||||||
|
|
||||||
|
static QString startupShortcutPath();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_profilePath;
|
QString m_profilePath;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import com.fortfirewall 1.0
|
|||||||
BasePage {
|
BasePage {
|
||||||
|
|
||||||
function onSaved() { // overload
|
function onSaved() { // overload
|
||||||
fortManager.startWithWindows = cbStart.checked;
|
fortSettings.startWithWindows = cbStart.checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
@ -15,7 +15,7 @@ BasePage {
|
|||||||
CheckBox {
|
CheckBox {
|
||||||
id: cbStart
|
id: cbStart
|
||||||
text: QT_TRANSLATE_NOOP("qml", "Start with Windows")
|
text: QT_TRANSLATE_NOOP("qml", "Start with Windows")
|
||||||
checked: fortManager.startWithWindows
|
checked: fortSettings.startWithWindows
|
||||||
}
|
}
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: cbFilter
|
id: cbFilter
|
||||||
|
Loading…
Reference in New Issue
Block a user