diff --git a/src/blackgui/components/mainkeypadareacomponent.cpp b/src/blackgui/components/mainkeypadareacomponent.cpp index cfa90e7c5..7a5e5e7e0 100644 --- a/src/blackgui/components/mainkeypadareacomponent.cpp +++ b/src/blackgui/components/mainkeypadareacomponent.cpp @@ -57,8 +57,7 @@ namespace BlackGui connect(ui->pb_MainWeather, &QPushButton::released, this, &CMainKeypadAreaComponent::buttonSelected); // non info areas - connect(ui->pb_Connect, &QPushButton::pressed, this, &CMainKeypadAreaComponent::buttonSelected); - connect(ui->pb_Connect, &QPushButton::pressed, this, &CMainKeypadAreaComponent::disableButtonBriefly); + connect(ui->pb_Connect, &QPushButton::released, this, &CMainKeypadAreaComponent::buttonSelected); connect(ui->pb_Opacity050, &QPushButton::pressed, this, &CMainKeypadAreaComponent::buttonSelected); connect(ui->pb_Opacity100, &QPushButton::pressed, this, &CMainKeypadAreaComponent::buttonSelected); connect(ui->pb_SoundMaxVolume, &QPushButton::pressed, this, &CMainKeypadAreaComponent::buttonSelected); @@ -107,6 +106,8 @@ namespace BlackGui if (pb) { pb->setChecked(true); } } + this->updateConnectionStatus(); + Q_UNUSED(dockedIndexes) } @@ -153,6 +154,7 @@ namespace BlackGui else if (senderButton == ui->pb_Connect) { emit this->connectPressed(); + this->updateConnectionStatus(); } else if (senderButton == ui->pb_Audio) { @@ -167,7 +169,7 @@ namespace BlackGui // Connected button if (to.isConnected()) { - ui->pb_Connect->setText("Discon."); // full terms some too wide + ui->pb_Connect->setText("Connected"); ui->pb_Connect->setChecked(true); // moved to stylesheet: ui->pb_Connect->setStyleSheet("background-color: green"); } @@ -255,19 +257,8 @@ namespace BlackGui ui->pb_MainTextMessages->setChecked(false); ui->pb_MainUsers->setChecked(false); ui->pb_MainWeather->setChecked(false); - } - void CMainKeypadAreaComponent::disableButtonBriefly() - { - QPushButton *pb = qobject_cast(QObject::sender()); - if (!pb) { return; } - pb->setEnabled(false); - QPointer myself(this); - QTimer::singleShot(750, [ = ] - { - if (!sGui || sGui->isShuttingDown() || !myself) { return; } - pb->setEnabled(true); - }); + this->updateConnectionStatus(); } void CMainKeypadAreaComponent::update() @@ -277,11 +268,19 @@ namespace BlackGui { this->muteChanged(sGui->getCContextAudioBase()->isMuted()); } + this->updateConnectionStatus(); + } + void CMainKeypadAreaComponent::updateConnectionStatus() + { if (sGui->getIContextNetwork() && sGui->getIContextNetwork()->isConnected()) { this->connectionStatusChanged(CConnectionStatus::Connected, CConnectionStatus::Connected); } + else + { + this->connectionStatusChanged(CConnectionStatus::Disconnected, CConnectionStatus::Disconnected); + } } } // namespace } // namespace diff --git a/src/blackgui/components/mainkeypadareacomponent.h b/src/blackgui/components/mainkeypadareacomponent.h index 0906585ac..c2f4fc57c 100644 --- a/src/blackgui/components/mainkeypadareacomponent.h +++ b/src/blackgui/components/mainkeypadareacomponent.h @@ -94,12 +94,12 @@ namespace BlackGui //! Info area buttons void unsetInfoAreaButtons(); - //! Disable button for some (short) time to avoid double click - void disableButtonBriefly(); - //! Update values void update(); + //! Update connection status + void updateConnectionStatus(); + QScopedPointer ui; BlackMisc::CIdentifier m_identifier { "MainKeypadAreaComponent", this }; };