Fixed self destruct countdown formatting

This commit is contained in:
Jordan Sherer 2019-02-07 14:31:11 -05:00
parent 9e655f7f12
commit 910339fc74
3 changed files with 12 additions and 2 deletions

View File

@ -7,11 +7,13 @@ SelfDestructMessageBox::SelfDestructMessageBox(
QMessageBox::Icon icon,
QMessageBox::StandardButtons buttons,
QMessageBox::StandardButton defaultButton,
bool show_countdown,
QWidget* parent,
Qt::WindowFlags flags)
: QMessageBox(icon, title, text, buttons, parent, flags),
m_timeout(timeout),
m_text(text)
m_text(text),
m_show_countdown(show_countdown)
{
connect(&m_timer, &QTimer::timeout, this, &SelfDestructMessageBox::tick);
m_timer.setInterval(1000);
@ -31,7 +33,9 @@ void SelfDestructMessageBox::tick(){
m_timeout--;
if(m_timeout){
if(m_show_countdown){
setText(m_text.arg(m_timeout));
}
return;
}

View File

@ -18,15 +18,19 @@ public:
QMessageBox::Icon icon,
QMessageBox::StandardButtons buttons = QMessageBox::Ok | QMessageBox::Cancel,
QMessageBox::StandardButton defaultButton = QMessageBox::Ok,
bool show_countdown = false,
QWidget* parent = nullptr,
Qt::WindowFlags flags = 0);
void showEvent(QShowEvent* event) override;
void setShowCountdown(bool countdown){ m_show_countdown = countdown; }
private slots:
void tick();
private:
bool m_show_countdown;
int m_timeout;
QString m_text;
QTimer m_timer;

View File

@ -1815,6 +1815,7 @@ void MainWindow::tryBandHop(){
QMessageBox::Information,
QMessageBox::Ok | QMessageBox::Cancel,
QMessageBox::Ok,
true,
this);
connect(m, &SelfDestructMessageBox::accepted, this, [this, frequency](){
@ -10099,6 +10100,7 @@ void MainWindow::processCommandActivity() {
QMessageBox::Information,
QMessageBox::Ok,
QMessageBox::Ok,
false,
this);
m->show();