Skip to content

Commit

Permalink
Merge #14573: qt: Add Window menu
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jonasschnelli committed Dec 16, 2018
2 parents 9133227 + 95a5a9f commit dba0f4c
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 9 deletions.
64 changes: 55 additions & 9 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include <QToolBar>
#include <QUrlQuery>
#include <QVBoxLayout>
#include <QWindow>

#include <boost/bind.hpp>

Expand Down Expand Up @@ -324,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);
Expand Down Expand Up @@ -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);

Expand All @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
5 changes: 5 additions & 0 deletions src/qt/rpcconsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class RPCConsole: public QWidget
TAB_PEERS = 3
};

std::vector<TabTypes> 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 *);
Expand Down

0 comments on commit dba0f4c

Please sign in to comment.