Merge pull request #1420 from Diapolo/extend_showNormalIfMinimized

GUI: merge toggleHidden() code into showNormalIfMinimized()
This commit is contained in:
Wladimir J. van der Laan 2012-06-13 22:49:38 -07:00
commit 7a98f19fb6
2 changed files with 25 additions and 31 deletions

View file

@ -439,28 +439,6 @@ void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
} }
#endif #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() void BitcoinGUI::optionsClicked()
{ {
if(!clientModel || !clientModel->getOptionsModel()) if(!clientModel || !clientModel->getOptionsModel())
@ -782,9 +760,6 @@ void BitcoinGUI::handleURI(QString strURI)
gotoSendCoinsPage(); gotoSendCoinsPage();
sendCoinsPage->handleURI(strURI); sendCoinsPage->handleURI(strURI);
if(!isActiveWindow())
activateWindow();
showNormalIfMinimized(); showNormalIfMinimized();
} }
@ -867,10 +842,29 @@ void BitcoinGUI::unlockWallet()
} }
} }
void BitcoinGUI::showNormalIfMinimized() void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
{
// activateWindow() (sometimes) helps with keyboard focus on Windows
if (isHidden())
{ {
if(!isVisible()) // Show, if hidden
show(); show();
if(isMinimized()) // Unminimize, if minimized activateWindow();
showNormal(); }
else if (isMinimized())
{
showNormal();
activateWindow();
}
else if (GUIUtil::isObscured(this))
{
raise();
activateWindow();
}
else if(fToggleHidden)
hide();
}
void BitcoinGUI::toggleHidden()
{
showNormalIfMinimized(true);
} }

View file

@ -169,9 +169,9 @@ private slots:
/** Ask for pass phrase to unlock wallet temporarily */ /** Ask for pass phrase to unlock wallet temporarily */
void unlockWallet(); void unlockWallet();
/** Show window if hidden, unminimize when minimized */ /** Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHidden is true */
void showNormalIfMinimized(); void showNormalIfMinimized(bool fToggleHidden = false);
/** Hide window if visible, show if hidden */ /** simply calls showNormalIfMinimized(true) for use in SLOT() macro */
void toggleHidden(); void toggleHidden();
}; };