Ref T78, setting and dialog "do not show again"

Applies to automatic update info check
This commit is contained in:
Klaus Basan
2017-05-08 19:40:39 +02:00
parent 0af6a372e3
commit 9b8afdf499
6 changed files with 105 additions and 16 deletions

View File

@@ -26,8 +26,10 @@ namespace BlackGui
{ {
ui->setupUi(this); ui->setupUi(this);
ui->bb_DownloadInstallDialog->button(QDialogButtonBox::Ok)->setText(" Download and install "); ui->bb_DownloadInstallDialog->button(QDialogButtonBox::Ok)->setText(" Download and install ");
ui->cb_DontShowAgain->setChecked(!m_setting.get());
this->selectionChanged(); this->selectionChanged();
connect(ui->comp_DistributionInfo, &CDistributionInfoComponent::selectionChanged, this, &CDownloadAndInstallDialog::selectionChanged); connect(ui->comp_DistributionInfo, &CDistributionInfoComponent::selectionChanged, this, &CDownloadAndInstallDialog::selectionChanged);
connect(ui->cb_DontShowAgain, &QCheckBox::toggled, this, &CDownloadAndInstallDialog::onDontShowAgain);
} }
CDownloadAndInstallDialog::~CDownloadAndInstallDialog() CDownloadAndInstallDialog::~CDownloadAndInstallDialog()
@@ -53,6 +55,11 @@ namespace BlackGui
return QDialog::Rejected; return QDialog::Rejected;
} }
void CDownloadAndInstallDialog::onDontShowAgain(bool dontShowAgain)
{
m_setting.setAndSave(!dontShowAgain);
}
void CDownloadAndInstallDialog::selectionChanged() void CDownloadAndInstallDialog::selectionChanged()
{ {
const bool nv = ui->comp_DistributionInfo->isNewVersionAvailable(); const bool nv = ui->comp_DistributionInfo->isNewVersionAvailable();

View File

@@ -12,6 +12,7 @@
#ifndef BLACKGUI_COMPONENTS_DOWNLOADANDINSTALLDIALOG_H #ifndef BLACKGUI_COMPONENTS_DOWNLOADANDINSTALLDIALOG_H
#define BLACKGUI_COMPONENTS_DOWNLOADANDINSTALLDIALOG_H #define BLACKGUI_COMPONENTS_DOWNLOADANDINSTALLDIALOG_H
#include "blackgui/settings/updatenotification.h"
#include "blackgui/blackguiexport.h" #include "blackgui/blackguiexport.h"
#include <QDialog> #include <QDialog>
@@ -42,6 +43,10 @@ namespace BlackGui
private: private:
QScopedPointer<Ui::CDownloadAndInstallDialog> ui; QScopedPointer<Ui::CDownloadAndInstallDialog> ui;
BlackMisc::CSetting<BlackGui::Settings::TUpdateNotificationSettings> m_setting { this }; //!< show again?
//! Toggled checkbox
void onDontShowAgain(bool dontShowAgain);
//! Selection in distribution component changed //! Selection in distribution component changed
void selectionChanged(); void selectionChanged();

View File

@@ -7,37 +7,77 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>400</width>
<height>125</height> <height>150</height>
</rect> </rect>
</property> </property>
<property name="minimumSize">
<size>
<width>400</width>
<height>130</height>
</size>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Update checker</string> <string>Update checker</string>
</property> </property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="modal"> <property name="modal">
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QVBoxLayout" name="vl_DownloadAndInstall"> <layout class="QVBoxLayout" name="vl_DownloadAndInstall">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item> <item>
<widget class="BlackGui::Components::CDistributionInfoComponent" name="comp_DistributionInfo"> <widget class="BlackGui::Components::CDistributionInfoComponent" name="comp_DistributionInfo">
<property name="frameShape"> <property name="minimumSize">
<enum>QFrame::StyledPanel</enum> <size>
</property> <width>0</width>
<property name="frameShadow"> <height>75</height>
<enum>QFrame::Raised</enum> </size>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QDialogButtonBox" name="bb_DownloadInstallDialog"> <widget class="QWidget" name="wi_Bottom" native="true">
<property name="orientation"> <layout class="QHBoxLayout" name="hl_Bottom">
<enum>Qt::Horizontal</enum> <property name="leftMargin">
</property> <number>9</number>
<property name="standardButtons"> </property>
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> <property name="topMargin">
</property> <number>0</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="cb_DontShowAgain">
<property name="text">
<string>Don't show again</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="bb_DownloadInstallDialog">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@@ -630,6 +630,7 @@ namespace BlackGui
void CGuiApplication::triggerNewVersionCheck(int delayedMs) void CGuiApplication::triggerNewVersionCheck(int delayedMs)
{ {
if (!m_updateSetting.get()) { return; }
QTimer::singleShot(delayedMs, this, [ = ] QTimer::singleShot(delayedMs, this, [ = ]
{ {
if (this->m_installDialog) { return; } if (this->m_installDialog) { return; }

View File

@@ -17,6 +17,7 @@
#include "blackgui/enableforframelesswindow.h" #include "blackgui/enableforframelesswindow.h"
#include "blackgui/mainwindowaccess.h" #include "blackgui/mainwindowaccess.h"
#include "blackgui/settings/guisettings.h" #include "blackgui/settings/guisettings.h"
#include "blackgui/settings/updatenotification.h"
#include "blackgui/stylesheetutility.h" #include "blackgui/stylesheetutility.h"
#include "blackmisc/icons.h" #include "blackmisc/icons.h"
#include "blackmisc/statusmessage.h" #include "blackmisc/statusmessage.h"
@@ -218,6 +219,7 @@ namespace BlackGui
QScopedPointer<QSplashScreen> m_splashScreen; //!< splash screen QScopedPointer<QSplashScreen> m_splashScreen; //!< splash screen
BlackGui::Components::CApplicationCloseDialog *m_closeDialog = nullptr; //!< close dialog (no QScopedPointer because I need to set parent) BlackGui::Components::CApplicationCloseDialog *m_closeDialog = nullptr; //!< close dialog (no QScopedPointer because I need to set parent)
BlackMisc::CSettingReadOnly<BlackGui::Settings::TGeneralGui> m_guiSettings{ this, &CGuiApplication::settingsChanged }; BlackMisc::CSettingReadOnly<BlackGui::Settings::TGeneralGui> m_guiSettings{ this, &CGuiApplication::settingsChanged };
BlackMisc::CSettingReadOnly<BlackGui::Settings::TUpdateNotificationSettings> m_updateSetting { this }; //!< update notification settings
//! Qt help message to formatted HTML //! Qt help message to formatted HTML
static QString beautifyHelpMessage(const QString &helpText); static QString beautifyHelpMessage(const QString &helpText);

View File

@@ -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<bool>
{
//! 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