mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge bitcoin-core/gui#115: Replace "Hide tray icon" option with positive "Show tray icon" one
03edb52eee5a87af16161c23bdc6cde91a2e5b8b qt: Remove redundant BitcoinGUI::setTrayIconVisible (Hennadii Stepanov) 17174f8328c44ae84479e8365c122ad8502bd7da gui: Replace "Hide tray icon" option with positive "Show tray icon" one (Hennadii Stepanov) Pull request description: This change makes easier both (1) using this option, and (2) reasoning about the code. ACKs for top commit: jonasschnelli: utACK 03edb52eee5a87af16161c23bdc6cde91a2e5b8b Tree-SHA512: 38e317492210d4fb13302dea383bd1f4f0ae1219d7ff2fdcb78607f15ac61a51969acaadb59b72c3f075b6356ef54368eb46fb49e6e1bd42db6d5804b97e232b
This commit is contained in:
parent
65b80e76b7
commit
a2f190deff
@ -842,10 +842,10 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
|
|||||||
OptionsModel* optionsModel = _clientModel->getOptionsModel();
|
OptionsModel* optionsModel = _clientModel->getOptionsModel();
|
||||||
if (optionsModel && trayIcon) {
|
if (optionsModel && trayIcon) {
|
||||||
// be aware of the tray icon disable state change reported by the OptionsModel object.
|
// be aware of the tray icon disable state change reported by the OptionsModel object.
|
||||||
connect(optionsModel, &OptionsModel::hideTrayIconChanged, this, &BitcoinGUI::setTrayIconVisible);
|
connect(optionsModel, &OptionsModel::showTrayIconChanged, trayIcon, &QSystemTrayIcon::setVisible);
|
||||||
|
|
||||||
// initialize the disable state of the tray icon with the current value in the model.
|
// initialize the disable state of the tray icon with the current value in the model.
|
||||||
setTrayIconVisible(optionsModel->getHideTrayIcon());
|
trayIcon->setVisible(optionsModel->getShowTrayIcon());
|
||||||
|
|
||||||
connect(optionsModel, &OptionsModel::coinJoinEnabledChanged, this, &BitcoinGUI::updateCoinJoinVisibility);
|
connect(optionsModel, &OptionsModel::coinJoinEnabledChanged, this, &BitcoinGUI::updateCoinJoinVisibility);
|
||||||
}
|
}
|
||||||
@ -1965,14 +1965,6 @@ void BitcoinGUI::showProgress(const QString &title, int nProgress)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinGUI::setTrayIconVisible(bool fHideTrayIcon)
|
|
||||||
{
|
|
||||||
if (trayIcon)
|
|
||||||
{
|
|
||||||
trayIcon->setVisible(!fHideTrayIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BitcoinGUI::showModalOverlay()
|
void BitcoinGUI::showModalOverlay()
|
||||||
{
|
{
|
||||||
if (modalOverlay && (progressBar->isVisible() || modalOverlay->isLayerVisible()))
|
if (modalOverlay && (progressBar->isVisible() || modalOverlay->isLayerVisible()))
|
||||||
|
@ -388,9 +388,6 @@ public Q_SLOTS:
|
|||||||
/** Show progress dialog e.g. for verifychain */
|
/** Show progress dialog e.g. for verifychain */
|
||||||
void showProgress(const QString &title, int nProgress);
|
void showProgress(const QString &title, int nProgress);
|
||||||
|
|
||||||
/** When hideTrayIcon setting is changed in OptionsModel hide or show the icon accordingly. */
|
|
||||||
void setTrayIconVisible(bool);
|
|
||||||
|
|
||||||
void showModalOverlay();
|
void showModalOverlay();
|
||||||
|
|
||||||
void updateCoinJoinVisibility();
|
void updateCoinJoinVisibility();
|
||||||
|
@ -130,13 +130,16 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="hideTrayIcon">
|
<widget class="QCheckBox" name="showTrayIcon">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Hide the icon from the system tray.</string>
|
<string>Show the icon in the system tray.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Hide tray icon</string>
|
<string>&Show tray icon</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -52,7 +52,7 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
|
|||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
/* Hide some options on Mac */
|
/* Hide some options on Mac */
|
||||||
ui->hideTrayIcon->hide();
|
ui->showTrayIcon->hide();
|
||||||
ui->minimizeToTray->hide();
|
ui->minimizeToTray->hide();
|
||||||
ui->minimizeOnClose->hide();
|
ui->minimizeOnClose->hide();
|
||||||
#endif
|
#endif
|
||||||
@ -198,8 +198,8 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
|
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
|
||||||
ui->hideTrayIcon->setChecked(true);
|
ui->showTrayIcon->setChecked(false);
|
||||||
ui->hideTrayIcon->setEnabled(false);
|
ui->showTrayIcon->setEnabled(false);
|
||||||
ui->minimizeToTray->setChecked(false);
|
ui->minimizeToTray->setChecked(false);
|
||||||
ui->minimizeToTray->setEnabled(false);
|
ui->minimizeToTray->setEnabled(false);
|
||||||
}
|
}
|
||||||
@ -312,7 +312,7 @@ void OptionsDialog::setMapper()
|
|||||||
mapper->addMapping(ui->bitcoinAtStartup, OptionsModel::StartAtStartup);
|
mapper->addMapping(ui->bitcoinAtStartup, OptionsModel::StartAtStartup);
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
if (QSystemTrayIcon::isSystemTrayAvailable()) {
|
if (QSystemTrayIcon::isSystemTrayAvailable()) {
|
||||||
mapper->addMapping(ui->hideTrayIcon, OptionsModel::HideTrayIcon);
|
mapper->addMapping(ui->showTrayIcon, OptionsModel::ShowTrayIcon);
|
||||||
mapper->addMapping(ui->minimizeToTray, OptionsModel::MinimizeToTray);
|
mapper->addMapping(ui->minimizeToTray, OptionsModel::MinimizeToTray);
|
||||||
}
|
}
|
||||||
mapper->addMapping(ui->minimizeOnClose, OptionsModel::MinimizeOnClose);
|
mapper->addMapping(ui->minimizeOnClose, OptionsModel::MinimizeOnClose);
|
||||||
@ -426,17 +426,14 @@ void OptionsDialog::on_cancelButton_clicked()
|
|||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsDialog::on_hideTrayIcon_stateChanged(int fState)
|
void OptionsDialog::on_showTrayIcon_stateChanged(int state)
|
||||||
{
|
{
|
||||||
if(fState)
|
if (state == Qt::Checked) {
|
||||||
{
|
ui->minimizeToTray->setEnabled(true);
|
||||||
|
} else {
|
||||||
ui->minimizeToTray->setChecked(false);
|
ui->minimizeToTray->setChecked(false);
|
||||||
ui->minimizeToTray->setEnabled(false);
|
ui->minimizeToTray->setEnabled(false);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->minimizeToTray->setEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsDialog::togglePruneWarning(bool enabled)
|
void OptionsDialog::togglePruneWarning(bool enabled)
|
||||||
|
@ -64,7 +64,7 @@ private Q_SLOTS:
|
|||||||
void on_okButton_clicked();
|
void on_okButton_clicked();
|
||||||
void on_cancelButton_clicked();
|
void on_cancelButton_clicked();
|
||||||
|
|
||||||
void on_hideTrayIcon_stateChanged(int fState);
|
void on_showTrayIcon_stateChanged(int state);
|
||||||
|
|
||||||
void togglePruneWarning(bool enabled);
|
void togglePruneWarning(bool enabled);
|
||||||
void showRestartWarning(bool fPersistent = false);
|
void showRestartWarning(bool fPersistent = false);
|
||||||
|
@ -60,14 +60,15 @@ void OptionsModel::Init(bool resetSettings)
|
|||||||
// These are Qt-only settings:
|
// These are Qt-only settings:
|
||||||
|
|
||||||
// Window
|
// Window
|
||||||
if (!settings.contains("fHideTrayIcon"))
|
if (!settings.contains("fHideTrayIcon")) {
|
||||||
settings.setValue("fHideTrayIcon", false);
|
settings.setValue("fHideTrayIcon", false);
|
||||||
fHideTrayIcon = settings.value("fHideTrayIcon").toBool();
|
}
|
||||||
Q_EMIT hideTrayIconChanged(fHideTrayIcon);
|
m_show_tray_icon = !settings.value("fHideTrayIcon").toBool();
|
||||||
|
Q_EMIT showTrayIconChanged(m_show_tray_icon);
|
||||||
|
|
||||||
if (!settings.contains("fMinimizeToTray"))
|
if (!settings.contains("fMinimizeToTray"))
|
||||||
settings.setValue("fMinimizeToTray", false);
|
settings.setValue("fMinimizeToTray", false);
|
||||||
fMinimizeToTray = settings.value("fMinimizeToTray").toBool() && !fHideTrayIcon;
|
fMinimizeToTray = settings.value("fMinimizeToTray").toBool() && m_show_tray_icon;
|
||||||
|
|
||||||
if (!settings.contains("fMinimizeOnClose"))
|
if (!settings.contains("fMinimizeOnClose"))
|
||||||
settings.setValue("fMinimizeOnClose", false);
|
settings.setValue("fMinimizeOnClose", false);
|
||||||
@ -417,8 +418,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
|||||||
{
|
{
|
||||||
case StartAtStartup:
|
case StartAtStartup:
|
||||||
return GUIUtil::GetStartOnSystemStartup();
|
return GUIUtil::GetStartOnSystemStartup();
|
||||||
case HideTrayIcon:
|
case ShowTrayIcon:
|
||||||
return fHideTrayIcon;
|
return m_show_tray_icon;
|
||||||
case MinimizeToTray:
|
case MinimizeToTray:
|
||||||
return fMinimizeToTray;
|
return fMinimizeToTray;
|
||||||
case MapPortUPnP:
|
case MapPortUPnP:
|
||||||
@ -545,10 +546,10 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
|||||||
case StartAtStartup:
|
case StartAtStartup:
|
||||||
successful = GUIUtil::SetStartOnSystemStartup(value.toBool());
|
successful = GUIUtil::SetStartOnSystemStartup(value.toBool());
|
||||||
break;
|
break;
|
||||||
case HideTrayIcon:
|
case ShowTrayIcon:
|
||||||
fHideTrayIcon = value.toBool();
|
m_show_tray_icon = value.toBool();
|
||||||
settings.setValue("fHideTrayIcon", fHideTrayIcon);
|
settings.setValue("fHideTrayIcon", !m_show_tray_icon);
|
||||||
Q_EMIT hideTrayIconChanged(fHideTrayIcon);
|
Q_EMIT showTrayIconChanged(m_show_tray_icon);
|
||||||
break;
|
break;
|
||||||
case MinimizeToTray:
|
case MinimizeToTray:
|
||||||
fMinimizeToTray = value.toBool();
|
fMinimizeToTray = value.toBool();
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
|
|
||||||
enum OptionID {
|
enum OptionID {
|
||||||
StartAtStartup, // bool
|
StartAtStartup, // bool
|
||||||
HideTrayIcon, // bool
|
ShowTrayIcon, // bool
|
||||||
MinimizeToTray, // bool
|
MinimizeToTray, // bool
|
||||||
MapPortUPnP, // bool
|
MapPortUPnP, // bool
|
||||||
MapPortNatpmp, // bool
|
MapPortNatpmp, // bool
|
||||||
@ -99,7 +99,7 @@ public:
|
|||||||
void setDisplayUnit(const QVariant &value);
|
void setDisplayUnit(const QVariant &value);
|
||||||
|
|
||||||
/* Explicit getters */
|
/* Explicit getters */
|
||||||
bool getHideTrayIcon() const { return fHideTrayIcon; }
|
bool getShowTrayIcon() const { return m_show_tray_icon; }
|
||||||
bool getMinimizeToTray() const { return fMinimizeToTray; }
|
bool getMinimizeToTray() const { return fMinimizeToTray; }
|
||||||
bool getMinimizeOnClose() const { return fMinimizeOnClose; }
|
bool getMinimizeOnClose() const { return fMinimizeOnClose; }
|
||||||
int getDisplayUnit() const { return nDisplayUnit; }
|
int getDisplayUnit() const { return nDisplayUnit; }
|
||||||
@ -125,7 +125,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
interfaces::Node* m_node = nullptr;
|
interfaces::Node* m_node = nullptr;
|
||||||
/* Qt-only settings */
|
/* Qt-only settings */
|
||||||
bool fHideTrayIcon;
|
bool m_show_tray_icon;
|
||||||
bool fMinimizeToTray;
|
bool fMinimizeToTray;
|
||||||
bool fMinimizeOnClose;
|
bool fMinimizeOnClose;
|
||||||
QString language;
|
QString language;
|
||||||
@ -150,7 +150,7 @@ Q_SIGNALS:
|
|||||||
void AdvancedCJUIChanged(bool);
|
void AdvancedCJUIChanged(bool);
|
||||||
void coinControlFeaturesChanged(bool);
|
void coinControlFeaturesChanged(bool);
|
||||||
void keepChangeAddressChanged(bool);
|
void keepChangeAddressChanged(bool);
|
||||||
void hideTrayIconChanged(bool);
|
void showTrayIconChanged(bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BITCOIN_QT_OPTIONSMODEL_H
|
#endif // BITCOIN_QT_OPTIONSMODEL_H
|
||||||
|
Loading…
Reference in New Issue
Block a user