Skip to content

Commit

Permalink
Update based on feedback, make code simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
jwrober committed Dec 21, 2022
1 parent b52bd4b commit ec0ecac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 35 deletions.
18 changes: 3 additions & 15 deletions client/diplodlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,11 +843,7 @@ void handle_diplomacy_accept_treaty(int counterpart, bool I_accepted,
dw->treaty.accept0 = I_accepted;
dw->treaty.accept1 = other_accepted;
dw->update_wdg();
if (dd->count() > 0) {
update_top_bar_diplomacy_status(true);
} else {
update_top_bar_diplomacy_status(false);
}
update_top_bar_diplomacy_status(dd->count() > 0);
}

/**
Expand Down Expand Up @@ -894,11 +890,7 @@ void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
if (player_by_number(initiated_from) == client.conn.playing) {
queen()->game_tab_widget->setCurrentIndex(i);
}
if (dd->count() > 0) {
update_top_bar_diplomacy_status(true);
} else {
update_top_bar_diplomacy_status(false);
}
update_top_bar_diplomacy_status(dd->count() > 0);
}

/**
Expand Down Expand Up @@ -944,11 +936,7 @@ void handle_diplomacy_cancel_meeting(int counterpart, int initiated_from)
w = queen()->game_tab_widget->widget(i);
dd = qobject_cast<diplo_dlg *>(w);
dd->close_widget(counterpart);
if (dd->count() > 0) {
update_top_bar_diplomacy_status(true);
} else {
update_top_bar_diplomacy_status(false);
}
update_top_bar_diplomacy_status(dd->count() > 0);
}

/**
Expand Down
31 changes: 11 additions & 20 deletions client/plrdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,13 +726,10 @@ plr_report::plr_report() : QWidget()
ui.plr_wdg->sortByColumn(king()->qt_settings.player_repo_sort_col,
king()->qt_settings.player_report_sort);
}
if (queen()->gimmeIndexOf(QStringLiteral("DDI")) > 0) {
ui.diplo_but->setEnabled(true);
update_top_bar_diplomacy_status(true);
} else {
ui.diplo_but->setEnabled(false);
update_top_bar_diplomacy_status(false);
}
const bool has_meeting =
(queen()->gimmeIndexOf(QStringLiteral("DDI")) > 0);
ui.diplo_but->setEnabled(has_meeting);
update_top_bar_diplomacy_status(has_meeting);
queen()->updateSidebarTooltips();
ui.plr_wdg->set_pr_rep(this);
}
Expand Down Expand Up @@ -918,13 +915,10 @@ void plr_report::update_report(bool update_selection)
if (can_meet_with_player(other_player)) {
ui.meet_but->setEnabled(true);
}
if (queen()->gimmeIndexOf(QStringLiteral("DDI")) > 0) {
ui.diplo_but->setEnabled(true);
update_top_bar_diplomacy_status(true);
} else {
ui.diplo_but->setEnabled(false);
update_top_bar_diplomacy_status(false);
}
const bool has_meeting =
(queen()->gimmeIndexOf(QStringLiteral("DDI")) > 0);
ui.diplo_but->setEnabled(has_meeting);
update_top_bar_diplomacy_status(has_meeting);
ui.plr_wdg->restore_selection();
}

Expand Down Expand Up @@ -1011,15 +1005,12 @@ void close_intel_dialog(struct player *p) { real_players_dialog_update(p); }
*/
void update_top_bar_diplomacy_status(bool blinker)
{
queen()->sw_diplo->keep_blinking = blinker;
if (blinker) {
queen()->sw_diplo->keep_blinking = true;
queen()->sw_diplo->sblink();
queen()->updateSidebarTooltips();
queen()->reloadSidebarIcons();
} else {
queen()->sw_diplo->keep_blinking = false;
queen()->sw_diplo->update();
queen()->updateSidebarTooltips();
queen()->reloadSidebarIcons();
}
queen()->updateSidebarTooltips();
queen()->reloadSidebarIcons();
}

0 comments on commit ec0ecac

Please sign in to comment.