Skip to content

Commit

Permalink
Remember whether the chat and messages are visible
Browse files Browse the repository at this point in the history
It's nicer not to reopen them by hand every time we connect.

Closes #1488.
  • Loading branch information
lmoureaux authored and jwrober committed Dec 30, 2022
1 parent 0e27970 commit 801e928
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
12 changes: 11 additions & 1 deletion client/fc_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,11 @@ void fc_client::switch_page(int new_pg)
queen()->game_tab_widget->showFullScreen();
}
menuBar()->setVisible(true);
queen()->chat->set_chat_visible(qt_settings.show_chat);
queen()->mapview_wdg->setFocus();
queen()->sw_message->setChecked(qt_settings.show_messages);
queen()->sw_message->setIcon(
fcIcons::instance()->getIcon(QStringLiteral("messages")));
queen()->message->hide();
queen()->message->clr();
center_on_something();
voteinfo_gui_update();
Expand Down Expand Up @@ -451,6 +452,12 @@ void fc_client::read_settings()
} else {
qt_settings.show_battle_log = false;
}

qt_settings.show_chat =
s.value(QStringLiteral("show_chat"), true).toBool();
qt_settings.show_messages =
s.value(QStringLiteral("show_messages"), false).toBool();

if (s.contains(QStringLiteral("battlelog_x"))) {
qt_settings.battlelog_x =
s.value(QStringLiteral("battlelog_x")).toFloat();
Expand Down Expand Up @@ -521,6 +528,9 @@ void fc_client::write_settings()
s.setValue(QStringLiteral("new_turn_text"),
qt_settings.show_new_turn_text);
s.setValue(QStringLiteral("show_battle_log"), qt_settings.show_battle_log);
s.setValue(QStringLiteral("show_chat"), queen()->chat->is_chat_visible());
s.setValue(QStringLiteral("show_messages"),
queen()->sw_message->isChecked());
fc_shortcuts::sc()->write();
}

Expand Down
2 changes: 2 additions & 0 deletions client/fc_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ struct fc_settings {
int player_repo_sort_col;
bool show_new_turn_text;
bool show_battle_log;
bool show_chat; // Only used when loading
bool show_messages; // Only used when loading
Qt::SortOrder player_report_sort;
int city_repo_sort_col;
Qt::SortOrder city_report_sort;
Expand Down
11 changes: 6 additions & 5 deletions client/page_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,12 @@ pageGame::pageGame(QWidget *parent)
message = new message_widget(mapview_wdg);
message->setAttribute(Qt::WA_NoMousePropagation);
message->hide();
sw_message = new top_bar_widget(
_("Messages"), QLatin1String(""), +[] {
const auto message = queen()->message;
if (message) {
message->setVisible(!message->isVisible());
sw_message = new top_bar_widget(_("Messages"), QLatin1String(""), nullptr);
sw_message->setCheckable(true);
connect(
sw_message, &QToolButton::toggled, +[](bool checked) {
if (const auto message = queen()->message; message) {
message->setVisible(checked);

// change icon to default if icon is notify
const auto sw_message = queen()->sw_message;
Expand Down

0 comments on commit 801e928

Please sign in to comment.