diff --git a/src/blackgui/components/logincomponent.cpp b/src/blackgui/components/logincomponent.cpp index 8dc1fb36a..6a09f147b 100644 --- a/src/blackgui/components/logincomponent.cpp +++ b/src/blackgui/components/logincomponent.cpp @@ -204,6 +204,7 @@ namespace BlackGui this->setOwnModelAndIcaoValues(); const bool isConnected = sGui->getIContextNetwork()->isConnected(); this->setUiLoginState(isConnected); + if (isConnected) { this->blinkDisconnectButton(); } } // we decided to make it difficult for users to disable it @@ -817,6 +818,32 @@ namespace BlackGui ui->pb_Ok->setText(s); } + void CLoginComponent::blinkDisconnectButton() + { + ui->pb_Ok->setProperty("blinkOn", true); + static constexpr int blinkLength = 100; + static constexpr int blinkTimes = 10; + + auto timer = new QTimer(this); + connect(timer, &QTimer::timeout, this, [this, timer, count = std::make_shared(0)] + { + if (++*count <= blinkTimes) + { + ui->pb_Ok->setProperty("blinkOn", !ui->pb_Ok->property("blinkOn").toBool()); + } + else + { + ui->pb_Ok->setProperty("blinkOn", false); + timer->stop(); + timer->deleteLater(); + } + ui->pb_Ok->style()->unpolish(ui->pb_Ok); + ui->pb_Ok->style()->polish(ui->pb_Ok); + }); + timer->setObjectName("blinker"); + timer->start(blinkLength); + } + void CLoginComponent::highlightModelField(const CAircraftModel &model) { if (!model.hasModelString()) { ui->le_SimulatorModel->setProperty("validation", "error"); } diff --git a/src/blackgui/components/logincomponent.h b/src/blackgui/components/logincomponent.h index d8072fb90..d3d3dd6c1 100644 --- a/src/blackgui/components/logincomponent.h +++ b/src/blackgui/components/logincomponent.h @@ -200,6 +200,9 @@ namespace BlackGui //! Show / hide elements for UI depending on login state void setUiLoginState(bool connected); + //! Make disconnect button flash briefly to catch the user's attention + void blinkDisconnectButton(); + //! Own model and ICAO data for GUI and own aircraft void setOwnModelAndIcaoValues(const BlackMisc::Simulation::CAircraftModel &ownModel = {}); diff --git a/src/blackgui/share/qss/stdwidget.qss b/src/blackgui/share/qss/stdwidget.qss index 43cc61c4c..7acabcbe1 100644 --- a/src/blackgui/share/qss/stdwidget.qss +++ b/src/blackgui/share/qss/stdwidget.qss @@ -237,6 +237,12 @@ QPushButton::disabled { QPushButton:pressed{ background-color: lightblue; } +// Button blinks on to catch the user's attention +QPushButton[blinkOn="true"] { + background-color: yellow; + color: black; +} + /** KEYPAD area buttons are in swift GUI stylesheet diff --git a/src/swiftguistandard/swiftguistd.cpp b/src/swiftguistandard/swiftguistd.cpp index 15f31a3c8..ef81f1764 100644 --- a/src/swiftguistandard/swiftguistd.cpp +++ b/src/swiftguistandard/swiftguistd.cpp @@ -258,7 +258,13 @@ void SwiftGuiStd::loginRequested() } else { + const bool changed = MainPageLogin != ui->sw_MainMiddle->currentIndex(); this->setMainPage(MainPageLogin); + if (!changed) + { + // fake changed signal to trigger blinking disconnect button (issue #115) + emit this->currentMainInfoAreaChanged(ui->sw_MainMiddle->currentWidget()); + } } }