Ref T146, avoid double clicks for "connect button" using disableButtonBriefly

This commit is contained in:
Klaus Basan
2017-09-02 18:57:14 +02:00
committed by Mathew Sutcliffe
parent b6ca59eda8
commit adfd341cbc
2 changed files with 8 additions and 0 deletions

View File

@@ -55,6 +55,7 @@ namespace BlackGui
// non info areas
connect(ui->pb_Connect, &QPushButton::pressed, this, &CMainKeypadAreaComponent::buttonSelected);
connect(ui->pb_Connect, &QPushButton::pressed, this, &CMainKeypadAreaComponent::disableButtonBriefly);
connect(ui->pb_CockpitIdent, &QPushButton::released, this, &CMainKeypadAreaComponent::buttonSelected);
connect(ui->pb_Opacity050, &QPushButton::pressed, this, &CMainKeypadAreaComponent::buttonSelected);
connect(ui->pb_Opacity100, &QPushButton::pressed, this, &CMainKeypadAreaComponent::buttonSelected);
@@ -251,6 +252,10 @@ namespace BlackGui
void CMainKeypadAreaComponent::disableButtonBriefly()
{
QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
if (!pb) { return; }
pb->setEnabled(false);
QTimer::singleShot(750, [pb] { pb->setEnabled(true); });
}
} // namespace
} // namespace

View File

@@ -98,6 +98,9 @@ namespace BlackGui
//! Info area buttons
void unsetInfoAreaButtons();
//! Disable button for some (short) time to avoid double click
void disableButtonBriefly();
QScopedPointer<Ui::CMainKeypadAreaComponent> ui;
BlackMisc::CIdentifier m_identifier { QStringLiteral("KEYPADAREACOMPONENT") };
};