Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial implementation of the top bar #951

Merged
merged 26 commits into from
Mar 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5b46499
Move the sidebar to the top of the window
lmoureaux Mar 19, 2022
102b3fc
Rename sidebar -> top_bar
lmoureaux Mar 19, 2022
8b84fe8
Switch the top bar layout to horizontal mode
lmoureaux Mar 19, 2022
3e578d7
Remove unused heightForWidth from the top_bar
lmoureaux Mar 19, 2022
ed2b5d2
Rudimentary top bar implementation with QToolButton
lmoureaux Mar 19, 2022
fcf68b7
Replace custom "enabled" flag with the QWidget property
lmoureaux Mar 19, 2022
8bbc0bf
Top bar: Use QToolButton's icon functionality
lmoureaux Mar 19, 2022
66d5030
Set the top_bar_widget size policy internally
lmoureaux Mar 19, 2022
16ae104
Remove the empty space in the top bar
lmoureaux Mar 19, 2022
da19d19
Remove custom text processing in top_bar_widget
lmoureaux Mar 20, 2022
167257f
Remove "hover" flag in top bar widgets
lmoureaux Mar 20, 2022
e8e8b53
Remove custom painting of the top bar background
lmoureaux Mar 20, 2022
aa5fe96
Make the blink effect work with QToolButton
lmoureaux Mar 20, 2022
38fdd34
Remove bool parameter to top bar "clicked" callbacks
lmoureaux Mar 20, 2022
bbcc7f8
Restore an indication of which tab is selected
lmoureaux Mar 20, 2022
71e3038
Don't set all top bar buttons to checkable
lmoureaux Mar 20, 2022
d583b59
Restore the display of the current tax rates
lmoureaux Mar 20, 2022
639ec66
Restore the display of the "indicators"
lmoureaux Mar 20, 2022
60a35e4
Drop now-unused top_bar_widget::standard
lmoureaux Mar 20, 2022
9d4533b
clang-format
lmoureaux Mar 20, 2022
84b6b7b
Fix top bar styling with the Web theme
lmoureaux Mar 26, 2022
488fffd
Draw the background of top_bar
lmoureaux Mar 26, 2022
edd52fc
Fix chat and messages background with the system theme
lmoureaux Mar 26, 2022
ab0d4b0
Fix the Classic theme
lmoureaux Mar 26, 2022
c71826a
Fix top bar styling for Nightstalker
lmoureaux Mar 26, 2022
b231a2e
Fix top bar styling in Necrophos and TheLastLaserMaster
lmoureaux Mar 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/gui-qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ add_library(
qtg_cxxside.cpp
ratesdlg.cpp
shortcuts.cpp
sidebar.cpp
sciencedlg.cpp
spaceshipdlg.cpp
sprite.cpp
themes.cpp
tileset_debugger.cpp
top_bar.cpp
tradecalculation.cpp
tooltips.cpp
unitreport.cpp
Expand Down
4 changes: 2 additions & 2 deletions client/gui-qt/citydlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
#include "mapview.h"
#include "page_game.h"
#include "qtg_cxxside.h"
#include "sidebar.h"
#include "tooltips.h"
#include "top_bar.h"

extern QString split_text(const QString &text, bool cut);
extern QString cut_helptext(const QString &text);
Expand Down Expand Up @@ -2848,7 +2848,7 @@ void qtg_real_city_dialog_popup(struct city *pcity)
{
auto *widget = queen()->city_overlay;
if (!queen()->city_overlay->isVisible()) {
sidebarShowMap(true);
top_bar_show_map();
queen()->mapview_wdg->hide_all_fcwidgets();
}
center_tile_mapcanvas(pcity->tile);
Expand Down
3 changes: 1 addition & 2 deletions client/gui-qt/cityrep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1243,9 +1243,8 @@ void city_report::update_city(struct city *pcity)
/**
Display the city report dialog. Optionally raise it.
*/
void city_report_dialog_popup(bool raise)
void city_report_dialog_popup()
{
Q_UNUSED(raise)
int i;
city_report *cr;
QWidget *w;
Expand Down
9 changes: 5 additions & 4 deletions client/gui-qt/diplodlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
#include "fc_client.h"
#include "icons.h"
#include "page_game.h"
#include "sidebar.h"
#include "sprite.h"
#include "top_bar.h"

typedef advance *p_advance;
typedef city *p_city;
Expand Down Expand Up @@ -675,8 +675,8 @@ void diplo_wdg::update_wdg()
*/
void diplo_wdg::restore_pixmap()
{
queen()->sw_diplo->setPixmap(
fcIcons::instance()->getPixmap(QStringLiteral("nations")));
queen()->sw_diplo->setIcon(
fcIcons::instance()->getIcon(QStringLiteral("nations")));
queen()->sw_diplo->setCustomLabels(QString());
queen()->sw_diplo->update();
}
Expand Down Expand Up @@ -884,11 +884,12 @@ void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
hmid = qMax(1, hmid);
p.drawPixmap(1, hmid, *pix2);
p.end();
queen()->sw_diplo->setPixmap(pix3);
queen()->sw_diplo->setIcon(QIcon(*pix3));
queen()->sw_diplo->setCustomLabels(
QString(nation_plural_for_player(player_by_number(counterpart))));
queen()->sw_diplo->update();
delete pix2;
delete pix3;
if (!queen()->isRepoDlgOpen(QStringLiteral("DDI"))) {
dd = new diplo_dlg(counterpart, initiated_from);

Expand Down
5 changes: 2 additions & 3 deletions client/gui-qt/economyreport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,9 @@ void real_economy_report_dialog_update(void *unused)
}

/**
Display the economy report. Optionally raise it.
Typically triggered by F5.
* Display the economy report. Typically triggered by F5.
*/
void economy_report_dialog_popup(bool raise)
void economy_report_dialog_popup()
{
int i;
eco_report *eco_rep;
Expand Down
2 changes: 1 addition & 1 deletion client/gui-qt/fc_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
#include "page_network.h"
#include "page_pregame.h"
#include "page_scenario.h"
#include "sidebar.h"
#include "sprite.h"
#include "tileset_debugger.h"
#include "top_bar.h"
#include "voteinfo_bar.h"

fcFont *fcFont::m_instance = 0;
Expand Down
10 changes: 0 additions & 10 deletions client/gui-qt/gui_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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.
*/
Expand Down
7 changes: 5 additions & 2 deletions client/gui-qt/mapctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "shortcuts.h"
#include "unitselect.h"

extern void sidebarDisableEndturn(bool do_restore);
extern void top_bar_disable_end_turn(bool do_restore);
extern void qload_lua_script();
extern void qreload_lua_script();

Expand Down Expand Up @@ -69,7 +69,10 @@ void popup_newcity_dialog(struct unit *punit, const char *suggestname)
A turn done button should be provided for the player. This function
is called to toggle it between active/inactive.
*/
void set_turn_done_button_state(bool state) { sidebarDisableEndturn(state); }
void set_turn_done_button_state(bool state)
{
top_bar_disable_end_turn(state);
}

/**
Draw a goto or patrol line at the current mouse position.
Expand Down
6 changes: 3 additions & 3 deletions client/gui-qt/mapview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#include "page_game.h"
#include "qtg_cxxside.h"
#include "sciencedlg.h"
#include "sidebar.h"
#include "top_bar.h"
#include "widgetdecorations.h"

static int mapview_frozen_level = 0;
Expand Down Expand Up @@ -261,7 +261,7 @@ void map_view::hide_debugger()
void map_view::timer_event()
{
if (queen()->minimapview_wdg->underMouse()
|| queen()->sidebar_wdg->underMouse()) {
|| queen()->top_bar_wdg->underMouse()) {
update_cursor(CURSOR_DEFAULT);
return;
}
Expand Down Expand Up @@ -484,7 +484,7 @@ void update_turn_done_button(bool do_restore)
if (!get_turn_done_button_state()) {
return;
}
sidebarBlinkEndturn(do_restore);
top_bar_blink_end_turn(do_restore);
}

/**
Expand Down
30 changes: 5 additions & 25 deletions client/gui-qt/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
#include "sprite.h"

extern void popup_endgame_report();
extern void toggle_units_report(bool);
extern void toggle_units_report();
static void enable_interface(bool enable);
static QKeySequence shortcut2key(enum shortcut_id s);

Expand Down Expand Up @@ -1103,20 +1103,20 @@ void mr_menu::setup_menus()

act = menu->addAction(_("Units"));
act->setShortcut(QKeySequence(tr("F2")));
connect(act, &QAction::triggered, this, &mr_menu::slot_show_units_report);
connect(act, &QAction::triggered, this, &toggle_units_report);

// TRANS: Also menu item, but 'headers' should be good enough.
act = menu->addAction(Q_("?header:Players"));
act->setShortcut(QKeySequence(tr("F3")));
connect(act, &QAction::triggered, this, &mr_menu::slot_show_nations);
connect(act, &QAction::triggered, this, &popup_players_dialog);

act = menu->addAction(_("Cities"));
act->setShortcut(QKeySequence(tr("F4")));
connect(act, &QAction::triggered, this, &mr_menu::slot_show_cities);
connect(act, &QAction::triggered, this, &city_report_dialog_popup);

act = menu->addAction(_("Economy"));
act->setShortcut(QKeySequence(tr("F5")));
connect(act, &QAction::triggered, this, &mr_menu::slot_show_eco_report);
connect(act, &QAction::triggered, this, &economy_report_dialog_popup);

act = menu->addAction(_("Research"));
act->setShortcut(QKeySequence(tr("F6")));
Expand Down Expand Up @@ -1968,11 +1968,6 @@ void mr_menu::slot_spaceship()
}
}

/**
Slot for showing economy tab
*/
void mr_menu::slot_show_eco_report() { economy_report_dialog_popup(false); }

/**
Changes tab to mapview
*/
Expand All @@ -1981,21 +1976,6 @@ void mr_menu::slot_show_map()
::queen()->game_tab_widget->setCurrentIndex(0);
}

/**
Slot for showing units tab
*/
void mr_menu::slot_show_units_report() { toggle_units_report(true); }

/**
Slot for showing nations report
*/
void mr_menu::slot_show_nations() { popup_players_dialog(false); }

/**
Slot for showing cities report
*/
void mr_menu::slot_show_cities() { city_report_dialog_popup(false); }

/**
Action "BUILD_CITY"
*/
Expand Down
4 changes: 0 additions & 4 deletions client/gui-qt/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,6 @@ private slots:
void calc_trade_routes();
void slot_popup_tax_rates();
void slot_popup_mult_rates();
void slot_show_eco_report();
void slot_show_units_report();
void slot_show_nations();
void slot_show_cities();
void slot_show_research_tab();
void slot_spaceship();
void slot_demographics();
Expand Down
Loading