Skip to content

Commit

Permalink
[BUGFIX] Suppress "toggled routes" message during startup (#248)
Browse files Browse the repository at this point in the history
We started remembering the "Show routes" setting between startups.
On startup, the setting was restored but that lead to an annoying
"toggled routes [on]" message in the startup screen.

This also cleans up unneeded function parameters around GuiMessage.
  • Loading branch information
jonaseberle committed May 29, 2023
1 parent f8329c8 commit 8bd7eaa
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
10 changes: 4 additions & 6 deletions src/GuiMessage.cpp
Expand Up @@ -122,7 +122,7 @@ void GuiMessages::progressBarDestroyed(QObject *obj) {

///////////////////////////////////////////////////////////////////////////
// INTERNALLY USED CLASS AND METHODS (called by static methods)
void GuiMessages::updateMessage(GuiMessage *gm, bool callUpdate) {
void GuiMessages::updateMessage(GuiMessage *gm) {
//qDebug() << "GuiMessages::updateMessage()" << guiMessage;
GuiMessage *existing = messageById(gm->id, gm->type);
if (existing != 0) {
Expand All @@ -141,10 +141,9 @@ void GuiMessages::updateMessage(GuiMessage *gm, bool callUpdate) {
// qDebug() << "GuiMessage()::updateMessage() new" << gm;
_messages.insert(gm->type, gm);
}
if (callUpdate)
update();
update();
}
void GuiMessages::removeMessageById(const QString &id, bool callUpdate) {
void GuiMessages::removeMessageById(const QString &id) {
// qDebug() << "GuiMessages::removeMessage() id=" << id;
foreach(int key, _messages.keys()) {
foreach(GuiMessage *gm, _messages.values(key)) {
Expand All @@ -159,8 +158,7 @@ void GuiMessages::removeMessageById(const QString &id, bool callUpdate) {
}
}
}
if (callUpdate)
update();
update();
}

///////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions src/GuiMessage.h
Expand Up @@ -86,8 +86,8 @@ class GuiMessages : public QObject {
};
///////////////////////////////////////////////////////////////////////////
// INTERNALLY USED METHODS (public to be callable out of static methods)
void updateMessage(GuiMessage *gm, bool callUpdate = true);
void removeMessageById(const QString &id, bool callUpdate = true);
void updateMessage(GuiMessage *gm);
void removeMessageById(const QString &id);
public slots:
void labelDestroyed(QObject *obj);
void progressBarDestroyed(QObject *obj);
Expand Down
17 changes: 13 additions & 4 deletions src/Window.cpp
Expand Up @@ -84,9 +84,16 @@ Window::Window(QWidget *parent) :
setEnableBookedAtc(Settings::downloadBookings());
actionShowWaypoints->setChecked(Settings::showUsedWaypoints());

connect(actionShowRoutes, &QAction::toggled, this, &Window::actionShowRoutes_triggered);
actionShowRoutes->setChecked(Settings::showRoutes());
actionShowRoutes_triggered(Settings::showRoutes());
connect(
actionShowRoutes,
&QAction::toggled,
this,
[=]( const bool &newValue ) {
actionShowRoutes_triggered(newValue);
}
);
actionShowRoutes_triggered(Settings::showRoutes(), false);

Whazzup *whazzup = Whazzup::instance();
connect(actionDownload, &QAction::triggered, whazzup, &Whazzup::downloadJson3);
Expand Down Expand Up @@ -841,10 +848,12 @@ void Window::shootScreenshot() {
qDebug() << "Window::shootScreenshot()" << QString("%1.png").arg(filename); //fixme
}

void Window::actionShowRoutes_triggered(bool checked) {
void Window::actionShowRoutes_triggered(bool checked, bool showStatus) {
qDebug() << "Window::on_actionShowRoutes_triggered()" << checked;
Settings::setShowRoutes(checked);
GuiMessages::message(QString("toggled routes [%1]").arg(checked? "on": "off"), "routeToggle");
if (showStatus) {
GuiMessages::message(QString("toggled routes [%1]").arg(checked? "on": "off"), "routeToggle");
}
foreach(Airport *a, NavData::instance()->airports.values()) // synonym to "toggle routes" on all airports
a->showRoutes = checked;
if (!checked) { // when disabled, this shall clear all routes
Expand Down
2 changes: 1 addition & 1 deletion src/Window.h
Expand Up @@ -28,7 +28,7 @@ class Window : public QMainWindow, public Ui::Window {
void restored();
void cloudDownloaded();
private slots:
void actionShowRoutes_triggered(bool checked);
void actionShowRoutes_triggered(bool checked, bool showStatus = true);
void on_actionShowWaypoints_triggered(bool checked);
void on_actionHighlight_Friends_triggered(bool checked);
void on_pb_highlightFriends_toggled(bool checked);
Expand Down

0 comments on commit 8bd7eaa

Please sign in to comment.