From 3630e54f4e1c584f3d31f01782347320216d4508 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Tue, 24 Jan 2012 01:19:09 +0100 Subject: [PATCH] Slightly improved "announce" message box. --- src/Config.h | 2 +- src/Dialog_MainWindow.cpp | 54 ++++++++++++++++++++++++++++----------- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/Config.h b/src/Config.h index 13427e54..c0fb917d 100644 --- a/src/Config.h +++ b/src/Config.h @@ -30,7 +30,7 @@ #define VER_LAMEXP_MINOR_LO 4 #define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 16 -#define VER_LAMEXP_BUILD 880 +#define VER_LAMEXP_BUILD 881 /////////////////////////////////////////////////////////////////////////////// // Tool versions (minimum expected versions!) diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index 9a042bf3..dbcb086d 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -1156,32 +1156,56 @@ void MainWindow::windowShown(void) */ void MainWindow::showAnnounceBox(void) { + const unsigned int timeout = 8U; + const QString announceText = QString("%1

%2
%3
").arg ( NOBR("We are still looking for LameXP translators!"), NOBR("If you are willing to translate LameXP to your language or to complete an existing translation, please refer to:"), LINK("http://mulder.brhack.net/public/doc/lamexp_translate.html") ); - + QMessageBox *announceBox = new QMessageBox(QMessageBox::Warning, "We want you!", announceText, QMessageBox::NoButton, this); announceBox->setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint); announceBox->setIconPixmap(QIcon(":/images/Announcement.png").pixmap(64,79)); - QPushButton *button1 = announceBox->addButton(tr("Discard"), QMessageBox::AcceptRole); - QPushButton *button2 = announceBox->addButton(tr("Discard"), QMessageBox::NoRole); - button1->setVisible(false); - button2->setEnabled(false); - - QTimer *announceTimer = new QTimer(this); - announceTimer->setSingleShot(true); - announceTimer->setInterval(8000); - connect(announceTimer, SIGNAL(timeout()), button1, SLOT(show())); - connect(announceTimer, SIGNAL(timeout()), button2, SLOT(hide())); - announceTimer->start(); - while(announceTimer->isActive()) announceBox->exec(); - announceTimer->stop(); + QTimer *timers[timeout+1]; + QPushButton *buttons[timeout+1]; + + for(unsigned int i = 0; i <= timeout; i++) + { + QString text = (i > 0) ? QString("%1 (%2)").arg(tr("Discard"), QString::number(i)) : tr("Discard"); + buttons[i] = announceBox->addButton(text, (i > 0) ? QMessageBox::NoRole : QMessageBox::AcceptRole); + } + + for(unsigned int i = 0; i <= timeout; i++) + { + buttons[i]->setEnabled(i == 0); + buttons[i]->setVisible(i == timeout); + } + + for(unsigned int i = 0; i < timeout; i++) + { + timers[i] = new QTimer(this); + timers[i]->setSingleShot(true); + timers[i]->setInterval(1000); + connect(timers[i], SIGNAL(timeout()), buttons[i+1], SLOT(hide())); + connect(timers[i], SIGNAL(timeout()), buttons[i], SLOT(show())); + if(i > 0) + { + connect(timers[i], SIGNAL(timeout()), timers[i-1], SLOT(start())); + } + } + + timers[timeout-1]->start(); + announceBox->exec(); + + for(unsigned int i = 0; i < timeout; i++) + { + timers[i]->stop(); + LAMEXP_DELETE(timers[i]); + } - LAMEXP_DELETE(announceTimer); LAMEXP_DELETE(announceBox); }