Skip to content

Commit

Permalink
auto update subscribes
Browse files Browse the repository at this point in the history
  • Loading branch information
josephpei committed Jan 6, 2021
1 parent 4f511b4 commit d5a2e06
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/core/configurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,24 @@ const bool Configurator::isStartAtLogin()
return loadValue("startAtLogin", false).toBool();
}

void Configurator::setSystemProxy(bool flag) {
void Configurator::setAutoUpdate(bool autoUpdate)
{
saveValue("autoUpdate", autoUpdate);
}

const bool Configurator::isAutoUpdate()
{
return loadValue("autoUpdate", true).toBool();
}

void Configurator::setSystemProxy(bool flag)
{
saveValue("systemProxy", flag);
if (flag) {
NetworkProxy httpProxy("http", "127.0.0.1",
getHttpPort(), NetworkProxyMode::GLOBAL_MODE);
NetworkProxyHelper::setSystemProxy(httpProxy);
#ifndef Q_OS_WIN
#ifndef Q_OS_WIN
NetworkProxy socksProxy("socks", "127.0.0.1",
getSocksPort(), NetworkProxyMode::GLOBAL_MODE);
NetworkProxyHelper::setSystemProxy(socksProxy);
Expand Down
3 changes: 3 additions & 0 deletions src/core/configurator.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class Configurator : public QObject {
void setStartAtLogin(bool autoStart);
const bool isStartAtLogin();

void setAutoUpdate(bool autoUpdate);
const bool isAutoUpdate();

void setSystemProxy(bool flag);
const bool isSystemProxy();

Expand Down
5 changes: 4 additions & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ void MainWindow::createActions()

autoUpdateSubConfig = new QAction(tr("Auto Update"), this);
autoUpdateSubConfig->setCheckable(true);
autoUpdateSubConfig->setChecked(configurator.isAutoUpdate());
connect(autoUpdateSubConfig, &QAction::triggered, this, &MainWindow::autoUpdateSubConfigChange);

about = new QAction(tr("About"), this);
Expand Down Expand Up @@ -348,8 +349,10 @@ void MainWindow::startAtLoginChange(bool autoStart)

void MainWindow::autoUpdateSubConfigChange(bool autoUpdate)
{
configurator.setAutoUpdate(autoUpdate);
if (autoUpdate) {

if (!timer->isActive())
timer->start();
} else {
if (timer->isActive())
timer->stop();
Expand Down

0 comments on commit d5a2e06

Please sign in to comment.