mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Issue #115 Blink the disconnect button to catch the user's attention
This commit is contained in:
@@ -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<int>(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"); }
|
||||
|
||||
@@ -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 = {});
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user