diff -r 1dbf3f4340e0 -r 0e55228e1303 QTfrontend/ui/dialog/ask_quit.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/dialog/ask_quit.cpp Fri Jul 06 19:15:44 2012 +0400 @@ -0,0 +1,79 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include +#include + +#include "hwform.h" +#include "ask_quit.h" +#include "pagevideos.h" + +HWAskQuitDialog::HWAskQuitDialog(QWidget* parent, HWForm * form) : QDialog(parent) +{ + this->form = form; + + setWindowTitle(tr("Do yot really want to quit?")); + + QVBoxLayout * layout = new QVBoxLayout(this); + + QLabel * lbLabel = new QLabel(this); + lbLabel->setText(QLabel::tr("There are videos that are currently being encoded.\n" + "Exiting now will abort them.\n" + "Do yot really want to quit?")); + layout->addWidget(lbLabel); + + lbList = new QLabel(this); + layout->addWidget(lbList); + updateList(); + + QDialogButtonBox* dbbButtons = new QDialogButtonBox(this); + QPushButton * pbYes = dbbButtons->addButton(QDialogButtonBox::Yes); + QPushButton * pbNo = dbbButtons->addButton(QDialogButtonBox::No); + QPushButton * pbMore = dbbButtons->addButton(QPushButton::tr("More info"), QDialogButtonBox::HelpRole); + layout->addWidget(dbbButtons); + + connect(pbYes, SIGNAL(clicked()), this, SLOT(accept())); + connect(pbNo, SIGNAL(clicked()), this, SLOT(reject())); + connect(pbMore, SIGNAL(clicked()), this, SLOT(goToPageVideos())); + + // update list periodically + QTimer * timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(updateList())); + timer->start(200); +} + +void HWAskQuitDialog::goToPageVideos() +{ + reject(); + form->GoToVideos(); +} + +void HWAskQuitDialog::updateList() +{ + QString text = form->ui.pageVideos->getVideosInProgress(); + if (text.isEmpty()) + { + // automatically exit when everything is finished + accept(); + return; + } + lbList->setText(text); +}