Skip to content

Commit

Permalink
Allow configuring of automatic update check
Browse files Browse the repository at this point in the history
Add a menu item for update check
Closes #32
  • Loading branch information
mominul committed May 13, 2018
1 parent 38a1fb2 commit 7b50810
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@
}
}
],
"version": 3
"version": 4
}
7 changes: 7 additions & 0 deletions src/frontend/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ void SettingsDialog::updateSettings() {
ui->btnClosePrevWin->setChecked(gSettings->getEnterKeyClosesPrevWin());
ui->btnShowPrevWin->setChecked(gSettings->getShowCWPhonetic());
ui->cmbOrientation->setCurrentIndex(gSettings->getCandidateWinHorizontal() ? 0 : 1);
ui->btnCheckUpdate->setChecked(gSettings->getUpdateCheck());
}

void SettingsDialog::on_buttonBox_accepted()
{
gSettings->setEnterKeyClosesPrevWin(ui->btnClosePrevWin->isChecked());
gSettings->setShowCWPhonetic(ui->btnShowPrevWin->isChecked());
gSettings->setCandidateWinHorizontal((ui->cmbOrientation->currentIndex() == 0));
gSettings->setUpdateCheck(ui->btnCheckUpdate->isChecked());
}

void SettingsDialog::on_buttonBox_rejected()
Expand All @@ -63,3 +65,8 @@ void SettingsDialog::on_btnShowPrevWin_toggled(bool checked)
{
ui->btnShowPrevWin->setText(checked ? "On" : "Off");
}

void SettingsDialog::on_btnCheckUpdate_toggled(bool checked)
{
ui->btnCheckUpdate->setText(checked ? "On" : "Off");
}
2 changes: 2 additions & 0 deletions src/frontend/SettingsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ private slots:

void on_btnShowPrevWin_toggled(bool checked);

void on_btnCheckUpdate_toggled(bool checked);

private:
Ui::SettingsDialog *ui;
};
Expand Down
33 changes: 31 additions & 2 deletions src/frontend/SettingsDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>453</width>
<height>182</height>
<height>224</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -17,7 +17,7 @@
<property name="geometry">
<rect>
<x>20</x>
<y>140</y>
<y>180</y>
<width>421</width>
<height>32</height>
</rect>
Expand Down Expand Up @@ -110,6 +110,35 @@
<string>Suggestion List Orientation:</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>110</x>
<y>140</y>
<width>231</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Automatically check for updates:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
<widget class="QPushButton" name="btnCheckUpdate">
<property name="geometry">
<rect>
<x>340</x>
<y>130</y>
<width>101</width>
<height>33</height>
</rect>
</property>
<property name="text">
<string>Off</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</widget>
<resources/>
<connections>
Expand Down
15 changes: 12 additions & 3 deletions src/frontend/TopBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ TopBar::TopBar(QWidget *parent) :
SetupTopBar();
SetupPopupMenus();
SetupTrayIcon();
checkForUpdate();

if(gSettings->getUpdateCheck()) {
checkForUpdate();
}
}

TopBar::~TopBar()
Expand Down Expand Up @@ -166,15 +169,21 @@ void TopBar::SetupPopupMenus() {
settingsMenu->addAction(settingsMenuShowDialog);

// About Popup Menu
aboutMenuLayout = new QAction("About current keyboard layout...", this);
aboutMenuLayout = new QAction("About current keyboard layout", this);
connect(aboutMenuLayout, SIGNAL(triggered()), this, SLOT(aboutMenuLayout_clicked()));

aboutMenuAbout = new QAction("About OpenBangla Keyboard...", this);
aboutMenuAbout = new QAction("About OpenBangla Keyboard", this);
connect(aboutMenuAbout, SIGNAL(triggered()), this, SLOT(aboutMenuAbout_clicked()));

aboutMenuUpdate = new QAction("Check for Updates", this);
connect(aboutMenuUpdate, &QAction::triggered, [=]() {
checkForUpdate();
});

aboutMenu = new QMenu(this);
aboutMenu->addAction(aboutMenuLayout);
aboutMenu->addAction(aboutMenuAbout);
aboutMenu->addAction(aboutMenuUpdate);

// Quit Popup Menu
quitMenuQuit = new QAction("Quit", this);
Expand Down
1 change: 1 addition & 0 deletions src/frontend/TopBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ private slots:
QMenu *aboutMenu;
QAction *aboutMenuLayout;
QAction *aboutMenuAbout;
QAction *aboutMenuUpdate;
/* Quit Popup Menu */
QMenu *quitMenu;
QAction *quitMenuOnTray;
Expand Down
10 changes: 10 additions & 0 deletions src/shared/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,13 @@ bool Settings::getShowCWPhonetic() {
setting->sync();
return setting->value("settings/CandidateWin/Phonetic", true).toBool();
}

void Settings::setUpdateCheck(bool b) {
setting->setValue("settings/UpdateCheck", b);
setting->sync();
}

bool Settings::getUpdateCheck() {
setting->sync();
return setting->value("settings/UpdateCheck", true).toBool();
}
3 changes: 3 additions & 0 deletions src/shared/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class Settings {

void setShowCWPhonetic(bool b);
bool getShowCWPhonetic();

void setUpdateCheck(bool b);
bool getUpdateCheck();
};

/* Global */
Expand Down

0 comments on commit 7b50810

Please sign in to comment.