1 /* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2021 Ricardo Villalba <ricardo@smplayer.info>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 #include "shutdowndialog.h"
20 #include "images.h"
21 #include <QTimer>
22 #include <QPushButton>
23
ShutdownDialog(QWidget * parent,Qt::WindowFlags f)24 ShutdownDialog::ShutdownDialog( QWidget* parent, Qt::WindowFlags f )
25 : QDialog(parent, f)
26 , countdown(30)
27 , timer(0)
28 {
29 setupUi(this);
30
31 QPushButton * ok_button = buttonBox->button(QDialogButtonBox::Ok);
32 QPushButton * cancel_button = buttonBox->button(QDialogButtonBox::Cancel);
33
34 if (ok_button) { ok_button->setDefault(false); ok_button->setAutoDefault(false); }
35 if (cancel_button) { cancel_button->setDefault(true); cancel_button->setAutoDefault(true); }
36
37 setMinimumSize(QSize(500, 100));
38
39 icon_label->setPixmap(Images::icon("shutdown"));
40
41 text = tr("Playback has finished. SMPlayer is about to exit.") +"<br>"+
42 tr("The computer will shut down in %1 seconds.") +"<br>"+ tr("Press <b>Cancel</b> to abort shutdown.");
43 text_label->setText(text.arg(countdown));
44
45 adjustSize();
46
47 timer = new QTimer(this);
48 timer->setInterval(1000);
49 connect(timer, SIGNAL(timeout()), this, SLOT(updateCountdown()));
50 timer->start();
51 }
52
~ShutdownDialog()53 ShutdownDialog::~ShutdownDialog() {
54 }
55
updateCountdown()56 void ShutdownDialog::updateCountdown() {
57 countdown--;
58 text_label->setText(text.arg(countdown));
59 if (countdown < 1) accept();
60 }
61
62 #include "moc_shutdowndialog.cpp"
63