UI: Options: Add "Auto-update" flag

This commit is contained in:
Nodir Temirkhodjaev 2024-04-21 14:01:16 +03:00
parent 968b3390eb
commit bed9ea3b02
5 changed files with 37 additions and 1 deletions

View File

@ -34,6 +34,9 @@ public:
QVariant taskInfoList() const { return value("task/infoList_"); } QVariant taskInfoList() const { return value("task/infoList_"); }
void setTaskInfoList(const QVariant &v) { setValue("task/infoList_", v); } void setTaskInfoList(const QVariant &v) { setValue("task/infoList_", v); }
bool updaterAutoUpdate() const { return valueBool("updater/autoUpdate"); }
void setUpdaterAutoUpdate(bool v) { setValue("updater/autoUpdate", v); }
bool noServiceControl() const { return valueBool("protect/noServiceControl"); } bool noServiceControl() const { return valueBool("protect/noServiceControl"); }
void setNoServiceControl(bool v) { setValue("protect/noServiceControl", v); } void setNoServiceControl(bool v) { setValue("protect/noServiceControl", v); }

View File

@ -24,6 +24,7 @@
#include <fortsettings.h> #include <fortsettings.h>
#include <manager/translationmanager.h> #include <manager/translationmanager.h>
#include <manager/windowmanager.h> #include <manager/windowmanager.h>
#include <task/taskinfo.h>
#include <user/iniuser.h> #include <user/iniuser.h>
#include <util/guiutil.h> #include <util/guiutil.h>
#include <util/iconcache.h> #include <util/iconcache.h>
@ -61,6 +62,7 @@ void OptionsPage::onResetToDefault()
m_cbAppAlertAutoShow->setChecked(true); m_cbAppAlertAutoShow->setChecked(true);
m_cbAppAlertAlwaysOnTop->setChecked(false); m_cbAppAlertAlwaysOnTop->setChecked(false);
m_cbPurgeOnMounted->setChecked(false); m_cbPurgeOnMounted->setChecked(false);
m_cbAutoUpdate->setChecked(false);
m_cbUseSystemLocale->setChecked(true); m_cbUseSystemLocale->setChecked(true);
m_cbHotKeysEnabled->setChecked(false); m_cbHotKeysEnabled->setChecked(false);
@ -179,6 +181,7 @@ void OptionsPage::onRetranslateUi()
m_gbTraffic->setTitle(tr("Traffic")); m_gbTraffic->setTitle(tr("Traffic"));
m_gbProtection->setTitle(tr("Self Protection")); m_gbProtection->setTitle(tr("Self Protection"));
m_gbProg->setTitle(tr("Programs")); m_gbProg->setTitle(tr("Programs"));
m_gbUpdate->setTitle(TaskInfo::title(TaskInfo::UpdateChecker));
m_gbGlobal->setTitle(tr("Global")); m_gbGlobal->setTitle(tr("Global"));
m_gbHotKeys->setTitle(tr("Hot Keys")); m_gbHotKeys->setTitle(tr("Hot Keys"));
m_gbHome->setTitle(tr("My Fort")); m_gbHome->setTitle(tr("My Fort"));
@ -217,6 +220,7 @@ void OptionsPage::onRetranslateUi()
m_cbAppAlertAutoShow->setText(tr("Auto-Show Alert Window for New Programs")); m_cbAppAlertAutoShow->setText(tr("Auto-Show Alert Window for New Programs"));
m_cbAppAlertAlwaysOnTop->setText(tr("Alert Window is Always on top")); m_cbAppAlertAlwaysOnTop->setText(tr("Alert Window is Always on top"));
m_cbPurgeOnMounted->setText(tr("Purge Obsolete only on mounted drives")); m_cbPurgeOnMounted->setText(tr("Purge Obsolete only on mounted drives"));
m_cbAutoUpdate->setText(tr("Auto-update"));
m_cbExplorerMenu->setText(tr("Windows Explorer integration")); m_cbExplorerMenu->setText(tr("Windows Explorer integration"));
m_cbUseSystemLocale->setText(tr("Use System Regional Settings")); m_cbUseSystemLocale->setText(tr("Use System Regional Settings"));
@ -401,6 +405,10 @@ QLayout *OptionsPage::setupColumn1()
setupProgBox(); setupProgBox();
layout->addWidget(m_gbProg); layout->addWidget(m_gbProg);
// Update Checker Group Box
setupUpdateBox();
layout->addWidget(m_gbUpdate);
layout->addStretch(); layout->addStretch();
return layout; return layout;
@ -622,6 +630,22 @@ void OptionsPage::setupProgBox()
m_gbProg->setLayout(layout); m_gbProg->setLayout(layout);
} }
void OptionsPage::setupUpdateBox()
{
m_cbAutoUpdate = ControlUtil::createCheckBox(ini()->updaterAutoUpdate(), [&](bool checked) {
if (ini()->updaterAutoUpdate() != checked) {
ini()->setUpdaterAutoUpdate(checked);
ctrl()->setIniEdited();
}
});
// Layout
auto layout = ControlUtil::createVLayoutByWidgets({ m_cbAutoUpdate });
m_gbUpdate = new QGroupBox();
m_gbUpdate->setLayout(layout);
}
void OptionsPage::setupLogBlocked() void OptionsPage::setupLogBlocked()
{ {
m_cbLogBlocked = ControlUtil::createCheckBox(conf()->logBlocked(), [&](bool checked) { m_cbLogBlocked = ControlUtil::createCheckBox(conf()->logBlocked(), [&](bool checked) {

View File

@ -54,6 +54,7 @@ private:
void setupEditPassword(); void setupEditPassword();
void setupPasswordLock(); void setupPasswordLock();
void setupProgBox(); void setupProgBox();
void setupUpdateBox();
void setupLogBlocked(); void setupLogBlocked();
QLayout *setupColumn2(); QLayout *setupColumn2();
@ -84,6 +85,7 @@ private:
QGroupBox *m_gbTraffic = nullptr; QGroupBox *m_gbTraffic = nullptr;
QGroupBox *m_gbProtection = nullptr; QGroupBox *m_gbProtection = nullptr;
QGroupBox *m_gbProg = nullptr; QGroupBox *m_gbProg = nullptr;
QGroupBox *m_gbUpdate = nullptr;
QGroupBox *m_gbGlobal = nullptr; QGroupBox *m_gbGlobal = nullptr;
QGroupBox *m_gbHotKeys = nullptr; QGroupBox *m_gbHotKeys = nullptr;
QGroupBox *m_gbHome = nullptr; QGroupBox *m_gbHome = nullptr;
@ -111,6 +113,7 @@ private:
QCheckBox *m_cbAppAlertAutoShow = nullptr; QCheckBox *m_cbAppAlertAutoShow = nullptr;
QCheckBox *m_cbAppAlertAlwaysOnTop = nullptr; QCheckBox *m_cbAppAlertAlwaysOnTop = nullptr;
QCheckBox *m_cbPurgeOnMounted = nullptr; QCheckBox *m_cbPurgeOnMounted = nullptr;
QCheckBox *m_cbAutoUpdate = nullptr;
QCheckBox *m_cbExplorerMenu = nullptr; QCheckBox *m_cbExplorerMenu = nullptr;
QCheckBox *m_cbUseSystemLocale = nullptr; QCheckBox *m_cbUseSystemLocale = nullptr;

View File

@ -56,7 +56,12 @@ void TaskInfo::setIntervalHours(int intervalHours)
QString TaskInfo::title() const QString TaskInfo::title() const
{ {
switch (m_type) { return title(m_type);
}
QString TaskInfo::title(TaskType type)
{
switch (type) {
case UpdateChecker: case UpdateChecker:
return tr("Fort Firewall Update Checker"); return tr("Fort Firewall Update Checker");
case ZoneDownloader: case ZoneDownloader:

View File

@ -45,6 +45,7 @@ public:
void setIntervalHours(int intervalHours); void setIntervalHours(int intervalHours);
QString title() const; QString title() const;
static QString title(TaskType type);
TaskInfo::TaskType type() const { return m_type; } TaskInfo::TaskType type() const { return m_type; }
void setType(TaskInfo::TaskType type); void setType(TaskInfo::TaskType type);