From 65a1e639b54e976d0eba46c8ef326fcd9bf81635 Mon Sep 17 00:00:00 2001 From: Louis Moureaux Date: Sat, 19 Mar 2022 23:15:07 +0100 Subject: [PATCH] Move the sidebar to the top of the window We decided that the contents of the sidebar would be shown above the map. Start this change by moving the widget to the top. See #940. --- client/gui-qt/gui_main.cpp | 10 ---------- client/gui-qt/page_game.cpp | 29 +++++------------------------ client/gui-qt/page_game.h | 1 - client/gui-qt/sidebar.cpp | 17 ----------------- client/gui-qt/sidebar.h | 2 -- client/options.cpp | 19 +------------------ client/options.h | 2 -- 7 files changed, 6 insertions(+), 74 deletions(-) diff --git a/client/gui-qt/gui_main.cpp b/client/gui-qt/gui_main.cpp index e175ec7531..3dcebd4e74 100644 --- a/client/gui-qt/gui_main.cpp +++ b/client/gui-qt/gui_main.cpp @@ -51,7 +51,6 @@ static fc_client *freeciv_qt; void reset_unit_table(); static void apply_help_font(struct option *poption); static void apply_notify_font(struct option *poption); -static void apply_sidebar(struct option *poption); static void apply_titlebar(struct option *poption); /** @@ -134,7 +133,6 @@ void qtg_options_extra_init() option_var_set_callback(gui_qt_font_chatline, gui_qt_apply_font); option_var_set_callback(gui_qt_font_notify_label, apply_notify_font); option_var_set_callback(gui_qt_show_titlebar, apply_titlebar); - option_var_set_callback(gui_qt_sidebar_left, apply_sidebar); #undef option_var_set_callback } @@ -264,14 +262,6 @@ void apply_titlebar(struct option *poption) king()->show(); } -/** - Change sidebar position - */ -void apply_sidebar(struct option *poption) -{ - queen()->updateSidebarPosition(); -} - /** Change the given font. */ diff --git a/client/gui-qt/page_game.cpp b/client/gui-qt/page_game.cpp index ad8531fdf6..ead8c54865 100644 --- a/client/gui-qt/page_game.cpp +++ b/client/gui-qt/page_game.cpp @@ -58,10 +58,8 @@ extern void toggle_units_report(bool); pageGame::pageGame(QWidget *parent) : QWidget(parent), unit_selector(nullptr), update_info_timer(nullptr) { - QGridLayout *page_game_layout; QGridLayout *game_layout; - page_game_layout = new QGridLayout; game_main_widget = new QWidget; game_layout = new QGridLayout; game_layout->setContentsMargins(0, 0, 0, 0); @@ -160,15 +158,14 @@ pageGame::pageGame(QWidget *parent) game_tab_widget->setContentsMargins(0, 0, 0, 0); game_tab_widget->addWidget(game_main_widget); - if (gui_options.gui_qt_sidebar_left) { - page_game_layout->addWidget(sidebar_wdg, 1, 0); - } else { - page_game_layout->addWidget(sidebar_wdg, 1, 2); - } - page_game_layout->addWidget(game_tab_widget, 1, 1); + + auto page_game_layout = new QVBoxLayout; + page_game_layout->addWidget(sidebar_wdg); + page_game_layout->addWidget(game_tab_widget); page_game_layout->setContentsMargins(0, 0, 0, 0); page_game_layout->setSpacing(0); setLayout(page_game_layout); + game_tab_widget->init(); } @@ -192,21 +189,6 @@ void pageGame::reloadSidebarIcons() fcIcons::instance()->getPixmap(QStringLiteral("economy"))); sw_endturn->setPixmap( fcIcons::instance()->getPixmap(QStringLiteral("endturn"))); - sidebar_wdg->resizeMe(); -} - -/** - Update position - */ -void pageGame::updateSidebarPosition() -{ - QGridLayout *l = qobject_cast(layout()); - l->removeWidget(queen()->sidebar_wdg); - if (gui_options.gui_qt_sidebar_left) { - l->addWidget(queen()->sidebar_wdg, 1, 0); - } else { - l->addWidget(sidebar_wdg, 1, 2); - } } /** @@ -515,7 +497,6 @@ void fc_game_tab_widget::resizeEvent(QResizeEvent *event) QSize size; size = event->size(); if (C_S_RUNNING <= client_state()) { - queen()->sidebar_wdg->resizeMe(); map_canvas_resized(size.width(), size.height()); queen()->message->resize( qRound((size.width() * king()->qt_settings.chat_fwidth)), diff --git a/client/gui-qt/page_game.h b/client/gui-qt/page_game.h index 376b9b03c5..394875360b 100644 --- a/client/gui-qt/page_game.h +++ b/client/gui-qt/page_game.h @@ -54,7 +54,6 @@ class pageGame : public QWidget { public: pageGame(QWidget *); ~pageGame() override; - void updateSidebarPosition(); void reloadSidebarIcons(); void updateSidebarTooltips(); int addGameTab(QWidget *widget); diff --git a/client/gui-qt/sidebar.cpp b/client/gui-qt/sidebar.cpp index 43e964f368..59ac8fbead 100644 --- a/client/gui-qt/sidebar.cpp +++ b/client/gui-qt/sidebar.cpp @@ -471,23 +471,6 @@ void sidebar::paint(QPainter *painter, QPaintEvent *event) painter->drawRect(event->rect()); } -void sidebar::resizeEvent(QResizeEvent *event) -{ - if (C_S_RUNNING <= client_state()) { - resizeMe(); - } -} - -/** - * Resize the sidebar according to the user preference. The default is 90px - * and can be changed in increments of 15px using - * `gui_options.gui_qt_sidebar_width`. - */ -void sidebar::resizeMe() -{ - setFixedWidth(15 + gui_options.gui_qt_sidebar_width * 15); -} - /** Callback to show map */ diff --git a/client/gui-qt/sidebar.h b/client/gui-qt/sidebar.h index 161dc5e8f2..407e36f620 100644 --- a/client/gui-qt/sidebar.h +++ b/client/gui-qt/sidebar.h @@ -98,12 +98,10 @@ class sidebar : public QWidget { void addWidget(sidebarWidget *fsw); void addSpacer(); void paint(QPainter *painter, QPaintEvent *event); - void resizeMe(); QList objects; protected: void paintEvent(QPaintEvent *event) override; - void resizeEvent(QResizeEvent *event) override; private: QVBoxLayout *layout; diff --git a/client/options.cpp b/client/options.cpp index 508b51479e..dcae24bb12 100644 --- a/client/options.cpp +++ b/client/options.cpp @@ -193,7 +193,6 @@ struct client_options gui_options = { false, //.gui_qt_fullscreen = true, //.gui_qt_show_preview = true, //.gui_qt_allied_chat_only = - true, //.gui_qt_sidebar_left = 0, // font_increase FC_QT_DEFAULT_THEME_NAME, "Monospace,8,-1,5,75,0,0,0,0,0", //.gui_qt_font_notify_label = @@ -205,7 +204,6 @@ struct client_options gui_options = { "Sans Serif,10,-1,5,50,1,0,0,0,0", //.gui_qt_font_reqtree_text = {true}, //=? true, //.gui_qt_show_titlebar - 5, {}}; /* Set to TRUE after the first call to options_init(), to avoid the usage @@ -1467,7 +1465,6 @@ static void manual_turn_done_callback(struct option *poption); static void voteinfo_bar_callback(struct option *poption); static void font_changed_callback(struct option *poption); static void allfont_changed_callback(struct option *poption); -static void sidebar_changed_callback(struct option *poption); static void mapimg_changed_callback(struct option *poption); static void game_music_enable_callback(struct option *poption); static void menu_music_enable_callback(struct option *poption); @@ -2023,9 +2020,6 @@ static struct client_option client_options[] = { "That options is not unsaveable. Hit Apply button" "after changing this."), COC_FONT, 0, -100, 100, allfont_changed_callback), - GEN_INT_OPTION(gui_qt_sidebar_width, N_("Sidebar width"), - N_("Change width of sidebar. 1 - narrow, 9 - fat"), - COC_INTERFACE, 5, 1, 31, sidebar_changed_callback), GEN_FONT_OPTION(gui_qt_font_default, "default_font", N_("Default font"), N_("This is default font"), COC_FONT, "Sans Serif,10,-1,5,75,0,0,0,0,0", @@ -2069,12 +2063,7 @@ static struct client_option client_options[] = { GEN_BOOL_OPTION(gui_qt_show_preview, N_("Show savegame information"), N_("If this option is set the client will show " "information and map preview of current savegame."), - COC_GRAPHICS, true, NULL), - GEN_BOOL_OPTION( - gui_qt_sidebar_left, N_("Sidebar position"), - N_("If this option is set, the sidebar will be to the left " - "of the map, otherwise to the right."), - COC_INTERFACE, true, NULL)}; + COC_GRAPHICS, true, NULL)}; static const int client_options_num = ARRAY_SIZE(client_options); // Iteration loop, including invalid options for the current gui type. @@ -4860,12 +4849,6 @@ static void allfont_changed_callback(struct option *poption) gui_update_allfonts(); } -static void sidebar_changed_callback(struct option *poption) -{ - Q_UNUSED(poption) - gui_update_sidebar(); -} - /** Callback for font options. */ diff --git a/client/options.h b/client/options.h index 760b46b944..3c2a111564 100644 --- a/client/options.h +++ b/client/options.h @@ -157,7 +157,6 @@ struct client_options { bool gui_qt_fullscreen; bool gui_qt_show_preview; bool gui_qt_allied_chat_only; - bool gui_qt_sidebar_left; int gui_qt_increase_fonts; char gui_qt_default_theme_name[512]; char gui_qt_font_default[512]; @@ -169,7 +168,6 @@ struct client_options { char gui_qt_font_city_productions[512]; char gui_qt_font_reqtree_text[512]; bool gui_qt_show_titlebar; - int gui_qt_sidebar_width; struct overview overview; };