7171#include < QVBoxLayout>
7272#include < QWindow>
7373
74+ #include < algorithm>
7475#include < functional>
7576
7677namespace {
@@ -85,6 +86,10 @@ constexpr int GOV_CYCLE_FRAME_MS{STATUSBAR_ICON_CYCLE_MS / (GOV_CYCLE_FRAME_COUN
8586
8687// Per-frame interval for the spinner animation
8788constexpr int SPINNER_FRAME_MS{STATUSBAR_ICON_CYCLE_MS / SPINNER_FRAMES};
89+
90+ constexpr int FONT_SCALE_MIN{-100 };
91+ constexpr int FONT_SCALE_MAX{100 };
92+ constexpr int FONT_SCALE_SHORTCUT_STEP{3 };
8893} // anonymous namespace
8994
9095const std::string BitcoinGUI::DEFAULT_UIPLATFORM =
@@ -517,12 +522,27 @@ void BitcoinGUI::createActions()
517522 m_mask_values_action->setStatusTip (tr (" Mask the values in the Overview tab" ));
518523 m_mask_values_action->setCheckable (true );
519524
525+ m_zoom_in_action = new QAction (tr (" Zoom &In" ), this );
526+ m_zoom_in_action->setShortcuts ({QKeySequence (QKeySequence::ZoomIn), QKeySequence (tr (" Ctrl+=" ))});
527+ m_zoom_in_action->setStatusTip (tr (" Increase the font size" ));
528+
529+ m_zoom_out_action = new QAction (tr (" Zoom &Out" ), this );
530+ m_zoom_out_action->setShortcuts ({QKeySequence (QKeySequence::ZoomOut), QKeySequence (tr (" Ctrl+_" ))});
531+ m_zoom_out_action->setStatusTip (tr (" Decrease the font size" ));
532+
533+ m_zoom_reset_action = new QAction (tr (" Reset &Zoom" ), this );
534+ m_zoom_reset_action->setShortcut (QKeySequence (tr (" Ctrl+0" )));
535+ m_zoom_reset_action->setStatusTip (tr (" Reset the font size to default" ));
536+
520537 connect (quitAction, &QAction::triggered, this , &BitcoinGUI::quitRequested);
521538 connect (aboutAction, &QAction::triggered, this , &BitcoinGUI::aboutClicked);
522539 connect (aboutQtAction, &QAction::triggered, qApp, QApplication::aboutQt);
523540 connect (optionsAction, &QAction::triggered, this , &BitcoinGUI::optionsClicked);
524541 connect (showHelpMessageAction, &QAction::triggered, this , &BitcoinGUI::showHelpMessageClicked);
525542 connect (showCoinJoinHelpAction, &QAction::triggered, this , &BitcoinGUI::showCoinJoinHelpClicked);
543+ connect (m_zoom_in_action, &QAction::triggered, this , [this ] { adjustFontScale (FONT_SCALE_SHORTCUT_STEP); });
544+ connect (m_zoom_out_action, &QAction::triggered, this , [this ] { adjustFontScale (-FONT_SCALE_SHORTCUT_STEP); });
545+ connect (m_zoom_reset_action, &QAction::triggered, this , [this ] { adjustFontScale (0 ); });
526546
527547 // Jump directly to tabs in RPC-console
528548 connect (openInfoAction, &QAction::triggered, this , &BitcoinGUI::showInfo);
@@ -677,6 +697,11 @@ void BitcoinGUI::createMenuBar()
677697 }
678698 settings->addAction (optionsAction);
679699
700+ QMenu* view = appMenuBar->addMenu (tr (" &View" ));
701+ view->addAction (m_zoom_in_action);
702+ view->addAction (m_zoom_out_action);
703+ view->addAction (m_zoom_reset_action);
704+
680705 QMenu* window_menu = appMenuBar->addMenu (tr (" &Window" ));
681706
682707 QAction* minimize_action = window_menu->addAction (tr (" &Minimize" ));
@@ -735,6 +760,30 @@ void BitcoinGUI::createMenuBar()
735760 help->addAction (aboutQtAction);
736761}
737762
763+ void BitcoinGUI::adjustFontScale (int delta)
764+ {
765+ if (clientModel && clientModel->getOptionsModel () &&
766+ clientModel->getOptionsModel ()->isOptionOverridden (" -font-scale" )) {
767+ return ;
768+ }
769+
770+ const int current_scale{GUIUtil::g_font_registry.GetFontScale ()};
771+ const int new_scale{delta == 0
772+ ? GUIUtil::FontRegistry::DEFAULT_FONT_SCALE
773+ : std::clamp (current_scale + delta, FONT_SCALE_MIN, FONT_SCALE_MAX)};
774+
775+ if (new_scale == current_scale) {
776+ return ;
777+ }
778+
779+ GUIUtil::g_font_registry.SetFontScale (new_scale);
780+ GUIUtil::updateFonts ();
781+
782+ if (clientModel && clientModel->getOptionsModel ()) {
783+ clientModel->getOptionsModel ()->setOption (OptionsModel::FontScale, new_scale);
784+ }
785+ }
786+
738787void BitcoinGUI::createToolBars ()
739788{
740789#ifdef ENABLE_WALLET
0 commit comments