From 9ea38d022281713e7f79a219b37651ac5648d695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Barbosa?= Date: Tue, 11 Dec 2018 13:13:48 +0000 Subject: [PATCH 1/3] qt: Allow to inspect RPCConsole tabs --- src/qt/rpcconsole.cpp | 10 ++++++++++ src/qt/rpcconsole.h | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 606f1d291..774a0d78e 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -1275,7 +1275,17 @@ void RPCConsole::showOrHideBanTableIfRequired() ui->banHeading->setVisible(visible); } +RPCConsole::TabTypes RPCConsole::tabFocus() const +{ + return (TabTypes) ui->tabWidget->currentIndex(); +} + void RPCConsole::setTabFocus(enum TabTypes tabType) { ui->tabWidget->setCurrentIndex(tabType); } + +QString RPCConsole::tabTitle(TabTypes tab_type) const +{ + return ui->tabWidget->tabText(tab_type); +} diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index db7704395..20dbf5ec9 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -65,6 +65,11 @@ public: TAB_PEERS = 3 }; + std::vector tabs() const { return {TAB_INFO, TAB_CONSOLE, TAB_GRAPH, TAB_PEERS}; } + + TabTypes tabFocus() const; + QString tabTitle(TabTypes tab_type) const; + protected: virtual bool eventFilter(QObject* obj, QEvent *event); void keyPressEvent(QKeyEvent *); From a96c0df35eb25357d10803226d870dcc2ec542d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Barbosa?= Date: Thu, 25 Oct 2018 15:27:50 +0100 Subject: [PATCH 2/3] qt: Add Window menu --- src/qt/bitcoingui.cpp | 60 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index a16b2ddeb..282155915 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -56,6 +56,7 @@ #include #include #include +#include #include @@ -385,9 +386,6 @@ void BitcoinGUI::createMenuBar() file->addAction(signMessageAction); file->addAction(verifyMessageAction); file->addSeparator(); - file->addAction(usedSendingAddressesAction); - file->addAction(usedReceivingAddressesAction); - file->addSeparator(); } file->addAction(quitAction); @@ -400,11 +398,59 @@ void BitcoinGUI::createMenuBar() } settings->addAction(optionsAction); - QMenu *help = appMenuBar->addMenu(tr("&Help")); - if(walletFrame) - { - help->addAction(openRPCConsoleAction); + QMenu* window_menu = appMenuBar->addMenu(tr("&Window")); + + QAction* minimize_action = window_menu->addAction(tr("Minimize"), [] { + qApp->focusWindow()->showMinimized(); + }, QKeySequence(Qt::CTRL + Qt::Key_M)); + + connect(qApp, &QApplication::focusWindowChanged, [minimize_action] (QWindow* window) { + minimize_action->setEnabled(window != nullptr && (window->flags() & Qt::Dialog) != Qt::Dialog && window->windowState() != Qt::WindowMinimized); + }); + +#ifdef Q_OS_MAC + QAction* zoom_action = window_menu->addAction(tr("Zoom"), [] { + QWindow* window = qApp->focusWindow(); + if (window->windowState() != Qt::WindowMaximized) { + window->showMaximized(); + } else { + window->showNormal(); + } + }); + + connect(qApp, &QApplication::focusWindowChanged, [zoom_action] (QWindow* window) { + zoom_action->setEnabled(window != nullptr); + }); +#else + QAction* restore_action = window_menu->addAction(tr("Restore"), [] { + qApp->focusWindow()->showNormal(); + }); + + connect(qApp, &QApplication::focusWindowChanged, [restore_action] (QWindow* window) { + restore_action->setEnabled(window != nullptr); + }); +#endif + + if (walletFrame) { + window_menu->addSeparator(); + window_menu->addAction(tr("Main Window"), [this] { + GUIUtil::bringToFront(this); + }); + + window_menu->addSeparator(); + window_menu->addAction(usedSendingAddressesAction); + window_menu->addAction(usedReceivingAddressesAction); } + + window_menu->addSeparator(); + for (RPCConsole::TabTypes tab_type : rpcConsole->tabs()) { + window_menu->addAction(rpcConsole->tabTitle(tab_type), [this, tab_type] { + rpcConsole->setTabFocus(tab_type); + showDebugWindow(); + }); + } + + QMenu *help = appMenuBar->addMenu(tr("&Help")); help->addAction(showHelpMessageAction); help->addSeparator(); help->addAction(aboutAction); From 95a5a9fccb8b4296d2db1270a9798c359c9c1cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Barbosa?= Date: Tue, 11 Dec 2018 00:27:38 +0000 Subject: [PATCH 3/3] qt: Remove ellipsis from sending/receiving addresses Considering https://stackoverflow.com/a/637708 the ellipsis in these menu actions should be removed. --- src/qt/bitcoingui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 282155915..c281e2bb0 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -325,9 +325,9 @@ void BitcoinGUI::createActions() // initially disable the debug window menu item openRPCConsoleAction->setEnabled(false); - usedSendingAddressesAction = new QAction(platformStyle->TextColorIcon(":/icons/address-book"), tr("&Sending addresses..."), this); + usedSendingAddressesAction = new QAction(platformStyle->TextColorIcon(":/icons/address-book"), tr("&Sending addresses"), this); usedSendingAddressesAction->setStatusTip(tr("Show the list of used sending addresses and labels")); - usedReceivingAddressesAction = new QAction(platformStyle->TextColorIcon(":/icons/address-book"), tr("&Receiving addresses..."), this); + usedReceivingAddressesAction = new QAction(platformStyle->TextColorIcon(":/icons/address-book"), tr("&Receiving addresses"), this); usedReceivingAddressesAction->setStatusTip(tr("Show the list of used receiving addresses and labels")); openAction = new QAction(platformStyle->TextColorIcon(":/icons/open"), tr("Open &URI..."), this);