|
1 /* |
|
2 * Hedgewars, a free turn based strategy game |
|
3 * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
|
4 * |
|
5 * This program is free software; you can redistribute it and/or modify |
|
6 * it under the terms of the GNU General Public License as published by |
|
7 * the Free Software Foundation; version 2 of the License |
|
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 <QVBoxLayout> |
|
20 #include <QLabel> |
|
21 #include <QDialogButtonBox> |
|
22 #include <QPushButton> |
|
23 #include <QTimer> |
|
24 |
|
25 #include "hwform.h" |
|
26 #include "ask_quit.h" |
|
27 #include "pagevideos.h" |
|
28 |
|
29 HWAskQuitDialog::HWAskQuitDialog(QWidget* parent, HWForm * form) : QDialog(parent) |
|
30 { |
|
31 this->form = form; |
|
32 |
|
33 setWindowTitle(tr("Do yot really want to quit?")); |
|
34 |
|
35 QVBoxLayout * layout = new QVBoxLayout(this); |
|
36 |
|
37 QLabel * lbLabel = new QLabel(this); |
|
38 lbLabel->setText(QLabel::tr("There are videos that are currently being encoded.\n" |
|
39 "Exiting now will abort them.\n" |
|
40 "Do yot really want to quit?")); |
|
41 layout->addWidget(lbLabel); |
|
42 |
|
43 lbList = new QLabel(this); |
|
44 layout->addWidget(lbList); |
|
45 updateList(); |
|
46 |
|
47 QDialogButtonBox* dbbButtons = new QDialogButtonBox(this); |
|
48 QPushButton * pbYes = dbbButtons->addButton(QDialogButtonBox::Yes); |
|
49 QPushButton * pbNo = dbbButtons->addButton(QDialogButtonBox::No); |
|
50 QPushButton * pbMore = dbbButtons->addButton(QPushButton::tr("More info"), QDialogButtonBox::HelpRole); |
|
51 layout->addWidget(dbbButtons); |
|
52 |
|
53 connect(pbYes, SIGNAL(clicked()), this, SLOT(accept())); |
|
54 connect(pbNo, SIGNAL(clicked()), this, SLOT(reject())); |
|
55 connect(pbMore, SIGNAL(clicked()), this, SLOT(goToPageVideos())); |
|
56 |
|
57 // update list periodically |
|
58 QTimer * timer = new QTimer(this); |
|
59 connect(timer, SIGNAL(timeout()), this, SLOT(updateList())); |
|
60 timer->start(200); |
|
61 } |
|
62 |
|
63 void HWAskQuitDialog::goToPageVideos() |
|
64 { |
|
65 reject(); |
|
66 form->GoToVideos(); |
|
67 } |
|
68 |
|
69 void HWAskQuitDialog::updateList() |
|
70 { |
|
71 QString text = form->ui.pageVideos->getVideosInProgress(); |
|
72 if (text.isEmpty()) |
|
73 { |
|
74 // automatically exit when everything is finished |
|
75 accept(); |
|
76 return; |
|
77 } |
|
78 lbList->setText(text); |
|
79 } |