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

View File

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

View File

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