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

Remember whether the chat and messages are visible #1660

Merged
merged 1 commit into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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