aboutsummaryrefslogtreecommitdiff
path: root/src/qt/bitcoingui.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2012-04-11 23:02:18 -0700
committerWladimir J. van der Laan <laanwj@gmail.com>2012-04-11 23:02:18 -0700
commit4ac24cf59e40f88089b3ba172a662e19e51bc4a3 (patch)
tree017c99de1180250539051836dfd6a9747bd297ee /src/qt/bitcoingui.cpp
parentca2c1cb446188061619f52d6072b5ddf905fb90b (diff)
parent86d5634941734cbde54e47fc6288f21104acf26e (diff)
Merge pull request #855 from sje397/ToggleHide
Toggle UI hide
Diffstat (limited to 'src/qt/bitcoingui.cpp')
-rw-r--r--src/qt/bitcoingui.cpp33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 70a3313309..9c1e05d0c1 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -23,6 +23,7 @@
#include "guiconstants.h"
#include "askpassphrasedialog.h"
#include "notificator.h"
+#include "guiutil.h"
#ifdef Q_WS_MAC
#include "macdockiconhandler.h"
@@ -239,8 +240,8 @@ void BitcoinGUI::createActions()
optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
optionsAction->setToolTip(tr("Modify configuration options for bitcoin"));
optionsAction->setMenuRole(QAction::PreferencesRole);
- openBitcoinAction = new QAction(QIcon(":/icons/bitcoin"), tr("Open &Bitcoin"), this);
- openBitcoinAction->setToolTip(tr("Show the Bitcoin window"));
+ toggleHideAction = new QAction(QIcon(":/icons/bitcoin"), tr("Show/Hide &Bitcoin"), this);
+ toggleHideAction->setToolTip(tr("Show or Hide the Bitcoin window"));
exportAction = new QAction(QIcon(":/icons/export"), tr("&Export..."), this);
exportAction->setToolTip(tr("Export the data in the current tab to a file"));
encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet"), this);
@@ -255,7 +256,7 @@ void BitcoinGUI::createActions()
connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
- connect(openBitcoinAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
+ connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden()));
connect(encryptWalletAction, SIGNAL(triggered(bool)), this, SLOT(encryptWallet(bool)));
connect(backupWalletAction, SIGNAL(triggered()), this, SLOT(backupWallet()));
connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase()));
@@ -392,7 +393,7 @@ void BitcoinGUI::createTrayIcon()
#endif
// Configuration of the tray icon (or dock icon) icon menu
- trayIconMenu->addAction(openBitcoinAction);
+ trayIconMenu->addAction(toggleHideAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(messageAction);
#ifndef FIRST_CLASS_MESSAGING
@@ -416,11 +417,33 @@ void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
if(reason == QSystemTrayIcon::Trigger)
{
// Click on system tray icon triggers "open bitcoin"
- openBitcoinAction->trigger();
+ toggleHideAction->trigger();
}
}
#endif
+void BitcoinGUI::toggleHidden()
+{
+ // activateWindow() (sometimes) helps with keyboard focus on Windows
+ if(isHidden())
+ {
+ show();
+ activateWindow();
+ }
+ else if(isMinimized())
+ {
+ showNormal();
+ activateWindow();
+ }
+ else if(GUIUtil::isObscured(this))
+ {
+ raise();
+ activateWindow();
+ }
+ else
+ hide();
+}
+
void BitcoinGUI::optionsClicked()
{
if(!clientModel || !clientModel->getOptionsModel())