Merge bitcoin#17105: gui: Make RPCConsole::TabTypes an enum class

This commit is contained in:
Vijay Das Manikpuri 2022-04-02 08:06:14 +05:30
parent 94c5db49ef
commit 0d34bb3be1
No known key found for this signature in database
GPG Key ID: DB1D81B01DB7C46E
3 changed files with 23 additions and 21 deletions

View File

@ -1052,31 +1052,31 @@ void BitcoinGUI::showDebugWindow()
void BitcoinGUI::showInfo()
{
rpcConsole->setTabFocus(RPCConsole::TAB_INFO);
rpcConsole->setTabFocus(RPCConsole::TabTypes::INFO);
showDebugWindow();
}
void BitcoinGUI::showConsole()
{
rpcConsole->setTabFocus(RPCConsole::TAB_CONSOLE);
rpcConsole->setTabFocus(RPCConsole::TabTypes::CONSOLE);
showDebugWindow();
}
void BitcoinGUI::showGraph()
{
rpcConsole->setTabFocus(RPCConsole::TAB_GRAPH);
rpcConsole->setTabFocus(RPCConsole::TabTypes::GRAPH);
showDebugWindow();
}
void BitcoinGUI::showPeers()
{
rpcConsole->setTabFocus(RPCConsole::TAB_PEERS);
rpcConsole->setTabFocus(RPCConsole::TabTypes::PEERS);
showDebugWindow();
}
void BitcoinGUI::showRepair()
{
rpcConsole->setTabFocus(RPCConsole::TAB_REPAIR);
rpcConsole->setTabFocus(RPCConsole::TabTypes::REPAIR);
showDebugWindow();
}

View File

@ -529,7 +529,7 @@ RPCConsole::RPCConsole(interfaces::Node& node, QWidget* parent, Qt::WindowFlags
pageButtons->addButton(ui->btnRepair, pageButtons->buttons().size());
connect(pageButtons, QOverload<int>::of(&QButtonGroup::buttonClicked), this, &RPCConsole::showPage);
showPage(TAB_INFO);
showPage(int(TabTypes::INFO));
reloadThemedWidgets();
}
@ -1429,21 +1429,23 @@ void RPCConsole::showOrHideBanTableIfRequired()
void RPCConsole::setTabFocus(enum TabTypes tabType)
{
showPage(tabType);
showPage(int(tabType));
}
QString RPCConsole::tabTitle(TabTypes tab_type) const
{
return pageButtons->button(tab_type)->text();
return pageButtons->button(int(tab_type))->text();
}
QKeySequence RPCConsole::tabShortcut(TabTypes tab_type) const
{
switch (tab_type) {
case TAB_INFO: return QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I);
case TAB_CONSOLE: return QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C);
case TAB_GRAPH: return QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
case TAB_PEERS: return QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_P);
case TAB_REPAIR: return QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_R);
}
case TabTypes::INFO: return QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I);
case TabTypes::CONSOLE: return QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C);
case TabTypes::GRAPH: return QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
case TabTypes::PEERS: return QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_P);
case TabTypes::REPAIR: return QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_R);
} // no default case, so the compiler can warn about missing cases
assert(false);
}

View File

@ -59,15 +59,15 @@ public:
CMD_ERROR
};
enum TabTypes {
TAB_INFO = 0,
TAB_CONSOLE = 1,
TAB_GRAPH = 2,
TAB_PEERS = 3,
TAB_REPAIR = 4
enum class TabTypes {
INFO,
CONSOLE,
GRAPH,
PEERS,
REPAIR
};
std::vector<TabTypes> tabs() const { return {TAB_INFO, TAB_CONSOLE, TAB_GRAPH, TAB_PEERS, TAB_REPAIR}; }
std::vector<TabTypes> tabs() const { return {TabTypes::INFO, TabTypes::CONSOLE, TabTypes::GRAPH, TabTypes::PEERS, TabTypes::REPAIR}; }
QString tabTitle(TabTypes tab_type) const;
QKeySequence tabShortcut(TabTypes tab_type) const;