QTfrontend/ui/dialog/ask_quit.cpp
author Stepan777 <stepik-777@mail.ru>
Thu, 09 Aug 2012 01:24:38 +0400
changeset 7528 f8cf277dca36
parent 7447 01111960a48d
child 7631 01b599d6f72d
permissions -rw-r--r--
FindFFMPEG.cmake (used only for frontend for now). +fix for linux (older version of Qt)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7353
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     1
/*
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     2
 * Hedgewars, a free turn based strategy game
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     3
 * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     4
 *
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     8
 *
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    12
 * GNU General Public License for more details.
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    13
 *
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    17
 */
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    18
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    19
#include <QVBoxLayout>
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    20
#include <QLabel>
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    21
#include <QDialogButtonBox>
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    22
#include <QPushButton>
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    23
#include <QTimer>
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    24
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    25
#include "hwform.h"
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    26
#include "ask_quit.h"
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    27
#include "pagevideos.h"
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    28
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    29
HWAskQuitDialog::HWAskQuitDialog(QWidget* parent, HWForm * form) : QDialog(parent)
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    30
{
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    31
    this->form = form;
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    32
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    33
    setWindowTitle(tr("Do yot really want to quit?"));
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    34
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    35
    QVBoxLayout * layout = new QVBoxLayout(this);
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    36
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    37
    QLabel * lbLabel = new QLabel(this);
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
    38
    lbLabel->setText(QLabel::tr("There are videos that are currently being processed.\n"
7353
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    39
                                "Exiting now will abort them.\n"
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    40
                                "Do yot really want to quit?"));
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    41
    layout->addWidget(lbLabel);
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    42
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    43
    lbList = new QLabel(this);
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    44
    layout->addWidget(lbList);
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    45
    updateList();
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    46
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    47
    QDialogButtonBox* dbbButtons = new QDialogButtonBox(this);
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    48
    QPushButton * pbYes = dbbButtons->addButton(QDialogButtonBox::Yes);
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    49
    QPushButton * pbNo  = dbbButtons->addButton(QDialogButtonBox::No);
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    50
    QPushButton * pbMore = dbbButtons->addButton(QPushButton::tr("More info"), QDialogButtonBox::HelpRole);
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    51
    layout->addWidget(dbbButtons);
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    52
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    53
    connect(pbYes,  SIGNAL(clicked()), this, SLOT(accept()));
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    54
    connect(pbNo,   SIGNAL(clicked()), this, SLOT(reject()));
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    55
    connect(pbMore, SIGNAL(clicked()), this, SLOT(goToPageVideos()));
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    56
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    57
    // update list periodically
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    58
    QTimer * timer = new QTimer(this);
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    59
    connect(timer, SIGNAL(timeout()), this, SLOT(updateList()));
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    60
    timer->start(200);
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    61
}
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    62
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    63
void HWAskQuitDialog::goToPageVideos()
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    64
{
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    65
    reject();
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    66
    form->GoToVideos();
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    67
}
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    68
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    69
void HWAskQuitDialog::updateList()
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    70
{
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    71
    QString text = form->ui.pageVideos->getVideosInProgress();
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    72
    if (text.isEmpty())
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    73
    {
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    74
        // automatically exit when everything is finished
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    75
        accept();
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    76
        return;
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    77
    }
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    78
    lbList->setText(text);
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    79
}