From 9b8afdf499880e99b57d43e216221140dbd05e6e Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 8 May 2017 19:40:39 +0200 Subject: [PATCH] Ref T78, setting and dialog "do not show again" Applies to automatic update info check --- .../components/downloadandinstalldialog.cpp | 7 ++ .../components/downloadandinstalldialog.h | 5 ++ .../components/downloadandinstalldialog.ui | 72 ++++++++++++++----- src/blackgui/guiapplication.cpp | 1 + src/blackgui/guiapplication.h | 2 + src/blackgui/settings/updatenotification.h | 34 +++++++++ 6 files changed, 105 insertions(+), 16 deletions(-) create mode 100644 src/blackgui/settings/updatenotification.h diff --git a/src/blackgui/components/downloadandinstalldialog.cpp b/src/blackgui/components/downloadandinstalldialog.cpp index 5278bd065..67faf38c6 100644 --- a/src/blackgui/components/downloadandinstalldialog.cpp +++ b/src/blackgui/components/downloadandinstalldialog.cpp @@ -26,8 +26,10 @@ namespace BlackGui { ui->setupUi(this); ui->bb_DownloadInstallDialog->button(QDialogButtonBox::Ok)->setText(" Download and install "); + ui->cb_DontShowAgain->setChecked(!m_setting.get()); this->selectionChanged(); connect(ui->comp_DistributionInfo, &CDistributionInfoComponent::selectionChanged, this, &CDownloadAndInstallDialog::selectionChanged); + connect(ui->cb_DontShowAgain, &QCheckBox::toggled, this, &CDownloadAndInstallDialog::onDontShowAgain); } CDownloadAndInstallDialog::~CDownloadAndInstallDialog() @@ -53,6 +55,11 @@ namespace BlackGui return QDialog::Rejected; } + void CDownloadAndInstallDialog::onDontShowAgain(bool dontShowAgain) + { + m_setting.setAndSave(!dontShowAgain); + } + void CDownloadAndInstallDialog::selectionChanged() { const bool nv = ui->comp_DistributionInfo->isNewVersionAvailable(); diff --git a/src/blackgui/components/downloadandinstalldialog.h b/src/blackgui/components/downloadandinstalldialog.h index 9c6116760..923473551 100644 --- a/src/blackgui/components/downloadandinstalldialog.h +++ b/src/blackgui/components/downloadandinstalldialog.h @@ -12,6 +12,7 @@ #ifndef BLACKGUI_COMPONENTS_DOWNLOADANDINSTALLDIALOG_H #define BLACKGUI_COMPONENTS_DOWNLOADANDINSTALLDIALOG_H +#include "blackgui/settings/updatenotification.h" #include "blackgui/blackguiexport.h" #include @@ -42,6 +43,10 @@ namespace BlackGui private: QScopedPointer ui; + BlackMisc::CSetting m_setting { this }; //!< show again? + + //! Toggled checkbox + void onDontShowAgain(bool dontShowAgain); //! Selection in distribution component changed void selectionChanged(); diff --git a/src/blackgui/components/downloadandinstalldialog.ui b/src/blackgui/components/downloadandinstalldialog.ui index cae577f91..f3d80c15e 100644 --- a/src/blackgui/components/downloadandinstalldialog.ui +++ b/src/blackgui/components/downloadandinstalldialog.ui @@ -7,37 +7,77 @@ 0 0 400 - 125 + 150 + + + 400 + 130 + + Update checker - - - true + + 4 + + + 4 + + + 4 + + + 4 + - - QFrame::StyledPanel - - - QFrame::Raised + + + 0 + 75 + - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - + + + + 9 + + + 0 + + + 9 + + + 0 + + + + + Don't show again + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + diff --git a/src/blackgui/guiapplication.cpp b/src/blackgui/guiapplication.cpp index d50d505d2..dd8f490bc 100644 --- a/src/blackgui/guiapplication.cpp +++ b/src/blackgui/guiapplication.cpp @@ -630,6 +630,7 @@ namespace BlackGui void CGuiApplication::triggerNewVersionCheck(int delayedMs) { + if (!m_updateSetting.get()) { return; } QTimer::singleShot(delayedMs, this, [ = ] { if (this->m_installDialog) { return; } diff --git a/src/blackgui/guiapplication.h b/src/blackgui/guiapplication.h index ff4b30fbd..a9daf48e1 100644 --- a/src/blackgui/guiapplication.h +++ b/src/blackgui/guiapplication.h @@ -17,6 +17,7 @@ #include "blackgui/enableforframelesswindow.h" #include "blackgui/mainwindowaccess.h" #include "blackgui/settings/guisettings.h" +#include "blackgui/settings/updatenotification.h" #include "blackgui/stylesheetutility.h" #include "blackmisc/icons.h" #include "blackmisc/statusmessage.h" @@ -218,6 +219,7 @@ namespace BlackGui QScopedPointer m_splashScreen; //!< splash screen BlackGui::Components::CApplicationCloseDialog *m_closeDialog = nullptr; //!< close dialog (no QScopedPointer because I need to set parent) BlackMisc::CSettingReadOnly m_guiSettings{ this, &CGuiApplication::settingsChanged }; + BlackMisc::CSettingReadOnly m_updateSetting { this }; //!< update notification settings //! Qt help message to formatted HTML static QString beautifyHelpMessage(const QString &helpText); diff --git a/src/blackgui/settings/updatenotification.h b/src/blackgui/settings/updatenotification.h new file mode 100644 index 000000000..100615bf5 --- /dev/null +++ b/src/blackgui/settings/updatenotification.h @@ -0,0 +1,34 @@ +/* Copyright (C) 2017 + * swift project community / contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKGUI_SETTINGS_UPDATENOTIFICATIONSETTINGS_H +#define BLACKGUI_SETTINGS_UPDATENOTIFICATIONSETTINGS_H + +#include "blackgui/blackguiexport.h" +#include "blackmisc/settingscache.h" + +namespace BlackGui +{ + namespace Settings + { + //! Trait for directory settings + struct TUpdateNotificationSettings : public BlackMisc::TSettingTrait + { + //! Key in data cache + static const char *key() { return "guiupdatenotification/%Application%"; } + + //! Default, not consolidating + static const bool &defaultValue() { static const bool d = true; return d; } + }; + } // ns +} // ns + +#endif // guard