mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-11-20 23:12:34 -05:00
Update checking feature (#2648)
* Check on startup (toggleable setting) and manually * Option to check for pre-releases (eg, 2.4.0-beta1) * Only included if WITH_XC_NETWORKING is enabled
This commit is contained in:
parent
5c9b062f13
commit
779b529da2
17 changed files with 677 additions and 5 deletions
|
|
@ -41,6 +41,12 @@
|
|||
#include "keys/FileKey.h"
|
||||
#include "keys/PasswordKey.h"
|
||||
|
||||
#ifdef WITH_XC_NETWORKING
|
||||
#include "updatecheck/UpdateChecker.h"
|
||||
#include "gui/MessageBox.h"
|
||||
#include "gui/UpdateCheckDialog.h"
|
||||
#endif
|
||||
|
||||
#ifdef WITH_XC_SSHAGENT
|
||||
#include "sshagent/AgentSettingsPage.h"
|
||||
#include "sshagent/SSHAgent.h"
|
||||
|
|
@ -282,6 +288,7 @@ MainWindow::MainWindow()
|
|||
m_ui->actionPasswordGenerator->setIcon(filePath()->icon("actions", "password-generator"));
|
||||
|
||||
m_ui->actionAbout->setIcon(filePath()->icon("actions", "help-about"));
|
||||
m_ui->actionCheckForUpdates->setIcon(filePath()->icon("actions", "system-software-update"));
|
||||
|
||||
m_actionMultiplexer.connect(
|
||||
SIGNAL(currentModeChanged(DatabaseWidget::Mode)), this, SLOT(setMenuActionState(DatabaseWidget::Mode)));
|
||||
|
|
@ -364,6 +371,15 @@ MainWindow::MainWindow()
|
|||
#ifdef Q_OS_MACOS
|
||||
setUnifiedTitleAndToolBarOnMac(true);
|
||||
#endif
|
||||
|
||||
#ifdef WITH_XC_NETWORKING
|
||||
connect(m_ui->actionCheckForUpdates, SIGNAL(triggered()), SLOT(showUpdateCheckDialog()));
|
||||
connect(UpdateChecker::instance(), SIGNAL(updateCheckFinished(bool, QString, bool)), SLOT(hasUpdateAvailable(bool, QString, bool)));
|
||||
QTimer::singleShot(3000, this, SLOT(showUpdateCheckStartup()));
|
||||
#else
|
||||
m_ui->actionCheckForUpdates->setVisible(false);
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
connect(m_ui->tabWidget,
|
||||
SIGNAL(messageGlobal(QString,MessageWidget::MessageType)),
|
||||
|
|
@ -661,6 +677,48 @@ void MainWindow::showAboutDialog()
|
|||
aboutDialog->open();
|
||||
}
|
||||
|
||||
void MainWindow::showUpdateCheckStartup()
|
||||
{
|
||||
#ifdef WITH_XC_NETWORKING
|
||||
if (!config()->get("UpdateCheckMessageShown", false).toBool()) {
|
||||
auto result = MessageBox::question(this,
|
||||
tr("Check for updates on startup?"),
|
||||
tr("Would you like KeePassXC to check for updates on startup?") + "\n\n" +
|
||||
tr("You can always check for updates manually from the application menu."),
|
||||
MessageBox::Yes | MessageBox::No,
|
||||
MessageBox::Yes);
|
||||
|
||||
config()->set("GUI/CheckForUpdates", (result == MessageBox::Yes));
|
||||
config()->set("UpdateCheckMessageShown", true);
|
||||
}
|
||||
|
||||
if (config()->get("GUI/CheckForUpdates", false).toBool()) {
|
||||
updateCheck()->checkForUpdates(false);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void MainWindow::hasUpdateAvailable(bool hasUpdate, const QString& version, bool isManuallyRequested)
|
||||
{
|
||||
#ifdef WITH_XC_NETWORKING
|
||||
if (hasUpdate && !isManuallyRequested) {
|
||||
auto* updateCheckDialog = new UpdateCheckDialog(this);
|
||||
updateCheckDialog->showUpdateCheckResponse(hasUpdate, version);
|
||||
updateCheckDialog->show();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void MainWindow::showUpdateCheckDialog()
|
||||
{
|
||||
#ifdef WITH_XC_NETWORKING
|
||||
updateCheck()->checkForUpdates(true);
|
||||
auto* updateCheckDialog = new UpdateCheckDialog(this);
|
||||
updateCheckDialog->show();
|
||||
#endif
|
||||
}
|
||||
|
||||
void MainWindow::openDonateUrl()
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl("https://keepassxc.org/donate"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue