From 910339fc7486ab4ee3ea8ea0fb0f11f7ab3f1ded Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Thu, 7 Feb 2019 14:31:11 -0500 Subject: [PATCH] Fixed self destruct countdown formatting --- SelfDestructMessageBox.cpp | 8 ++++++-- SelfDestructMessageBox.h | 4 ++++ mainwindow.cpp | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/SelfDestructMessageBox.cpp b/SelfDestructMessageBox.cpp index 5ec787b..05d519e 100644 --- a/SelfDestructMessageBox.cpp +++ b/SelfDestructMessageBox.cpp @@ -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){ - setText(m_text.arg(m_timeout)); + if(m_show_countdown){ + setText(m_text.arg(m_timeout)); + } return; } diff --git a/SelfDestructMessageBox.h b/SelfDestructMessageBox.h index 7b3e5cd..cea3dd8 100644 --- a/SelfDestructMessageBox.h +++ b/SelfDestructMessageBox.h @@ -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; diff --git a/mainwindow.cpp b/mainwindow.cpp index 51a2e6f..2a82917 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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();