Skip to content

Commit dba0f4c

Browse files
committed
Merge #14573: qt: Add Window menu
95a5a9f qt: Remove ellipsis from sending/receiving addresses (João Barbosa) a96c0df qt: Add Window menu (João Barbosa) 9ea38d0 qt: Allow to inspect RPCConsole tabs (João Barbosa) Pull request description: Overall this PR does the following: - add top level menu Window - add Minimize and Zoom actions to Window menu - move Sending/Receiving address to Window - remove Help->Debug window - add one menu entry for each debug window tab This removes the access to address book from the File menu. With wallet support: <img width="522" alt="screenshot 2018-12-11 at 00 33 05" src="https://user-images.githubusercontent.com/3534524/49770451-5bec0800-fcdc-11e8-91d6-f8f850ead92d.png"> Without wallet support: <img width="593" alt="screenshot 2018-12-11 at 12 55 21" src="https://user-images.githubusercontent.com/3534524/49802183-19f6ac80-fd44-11e8-9973-36fcfb4f129e.png"> Tree-SHA512: 4fb03702efe18df7bae33950e462940162abe634c55d0214b8920812127b763234cc9b73f27b3702502a37b6d49bdd6c50b7c8d9a3daea75cecb0136556dd1ea
2 parents 9133227 + 95a5a9f commit dba0f4c

File tree

3 files changed

+70
-9
lines changed

3 files changed

+70
-9
lines changed

src/qt/bitcoingui.cpp

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#include <QToolBar>
5757
#include <QUrlQuery>
5858
#include <QVBoxLayout>
59+
#include <QWindow>
5960

6061
#include <boost/bind.hpp>
6162

@@ -324,9 +325,9 @@ void BitcoinGUI::createActions()
324325
// initially disable the debug window menu item
325326
openRPCConsoleAction->setEnabled(false);
326327

327-
usedSendingAddressesAction = new QAction(platformStyle->TextColorIcon(":/icons/address-book"), tr("&Sending addresses..."), this);
328+
usedSendingAddressesAction = new QAction(platformStyle->TextColorIcon(":/icons/address-book"), tr("&Sending addresses"), this);
328329
usedSendingAddressesAction->setStatusTip(tr("Show the list of used sending addresses and labels"));
329-
usedReceivingAddressesAction = new QAction(platformStyle->TextColorIcon(":/icons/address-book"), tr("&Receiving addresses..."), this);
330+
usedReceivingAddressesAction = new QAction(platformStyle->TextColorIcon(":/icons/address-book"), tr("&Receiving addresses"), this);
330331
usedReceivingAddressesAction->setStatusTip(tr("Show the list of used receiving addresses and labels"));
331332

332333
openAction = new QAction(platformStyle->TextColorIcon(":/icons/open"), tr("Open &URI..."), this);
@@ -385,9 +386,6 @@ void BitcoinGUI::createMenuBar()
385386
file->addAction(signMessageAction);
386387
file->addAction(verifyMessageAction);
387388
file->addSeparator();
388-
file->addAction(usedSendingAddressesAction);
389-
file->addAction(usedReceivingAddressesAction);
390-
file->addSeparator();
391389
}
392390
file->addAction(quitAction);
393391

@@ -400,11 +398,59 @@ void BitcoinGUI::createMenuBar()
400398
}
401399
settings->addAction(optionsAction);
402400

403-
QMenu *help = appMenuBar->addMenu(tr("&Help"));
404-
if(walletFrame)
405-
{
406-
help->addAction(openRPCConsoleAction);
401+
QMenu* window_menu = appMenuBar->addMenu(tr("&Window"));
402+
403+
QAction* minimize_action = window_menu->addAction(tr("Minimize"), [] {
404+
qApp->focusWindow()->showMinimized();
405+
}, QKeySequence(Qt::CTRL + Qt::Key_M));
406+
407+
connect(qApp, &QApplication::focusWindowChanged, [minimize_action] (QWindow* window) {
408+
minimize_action->setEnabled(window != nullptr && (window->flags() & Qt::Dialog) != Qt::Dialog && window->windowState() != Qt::WindowMinimized);
409+
});
410+
411+
#ifdef Q_OS_MAC
412+
QAction* zoom_action = window_menu->addAction(tr("Zoom"), [] {
413+
QWindow* window = qApp->focusWindow();
414+
if (window->windowState() != Qt::WindowMaximized) {
415+
window->showMaximized();
416+
} else {
417+
window->showNormal();
418+
}
419+
});
420+
421+
connect(qApp, &QApplication::focusWindowChanged, [zoom_action] (QWindow* window) {
422+
zoom_action->setEnabled(window != nullptr);
423+
});
424+
#else
425+
QAction* restore_action = window_menu->addAction(tr("Restore"), [] {
426+
qApp->focusWindow()->showNormal();
427+
});
428+
429+
connect(qApp, &QApplication::focusWindowChanged, [restore_action] (QWindow* window) {
430+
restore_action->setEnabled(window != nullptr);
431+
});
432+
#endif
433+
434+
if (walletFrame) {
435+
window_menu->addSeparator();
436+
window_menu->addAction(tr("Main Window"), [this] {
437+
GUIUtil::bringToFront(this);
438+
});
439+
440+
window_menu->addSeparator();
441+
window_menu->addAction(usedSendingAddressesAction);
442+
window_menu->addAction(usedReceivingAddressesAction);
443+
}
444+
445+
window_menu->addSeparator();
446+
for (RPCConsole::TabTypes tab_type : rpcConsole->tabs()) {
447+
window_menu->addAction(rpcConsole->tabTitle(tab_type), [this, tab_type] {
448+
rpcConsole->setTabFocus(tab_type);
449+
showDebugWindow();
450+
});
407451
}
452+
453+
QMenu *help = appMenuBar->addMenu(tr("&Help"));
408454
help->addAction(showHelpMessageAction);
409455
help->addSeparator();
410456
help->addAction(aboutAction);

src/qt/rpcconsole.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,17 @@ void RPCConsole::showOrHideBanTableIfRequired()
12751275
ui->banHeading->setVisible(visible);
12761276
}
12771277

1278+
RPCConsole::TabTypes RPCConsole::tabFocus() const
1279+
{
1280+
return (TabTypes) ui->tabWidget->currentIndex();
1281+
}
1282+
12781283
void RPCConsole::setTabFocus(enum TabTypes tabType)
12791284
{
12801285
ui->tabWidget->setCurrentIndex(tabType);
12811286
}
1287+
1288+
QString RPCConsole::tabTitle(TabTypes tab_type) const
1289+
{
1290+
return ui->tabWidget->tabText(tab_type);
1291+
}

src/qt/rpcconsole.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ class RPCConsole: public QWidget
6565
TAB_PEERS = 3
6666
};
6767

68+
std::vector<TabTypes> tabs() const { return {TAB_INFO, TAB_CONSOLE, TAB_GRAPH, TAB_PEERS}; }
69+
70+
TabTypes tabFocus() const;
71+
QString tabTitle(TabTypes tab_type) const;
72+
6873
protected:
6974
virtual bool eventFilter(QObject* obj, QEvent *event);
7075
void keyPressEvent(QKeyEvent *);

0 commit comments

Comments
 (0)