QTfrontend/ui/page/pageplayrecord.cpp
author dag10
Mon, 21 Jan 2013 21:52:49 -0500
changeset 8424 225ede46e3dc
parent 7794 ab7b94c03bc9
child 9080 9b42757d7e71
permissions -rw-r--r--
On pagenetgame, when window is too small the map/game options becomes a tabbed interface to allow for a few lines of chat to always be visible. Restored HWForm's min height to 580. Fixed the 2px alignment issue with the map list and map previews' top edges that unC0Rr was whining about. <3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
579
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
     1
/*
1066
1f1b3686a2b0 Update copyright headers a bit
unc0rr
parents: 720
diff changeset
     2
 * Hedgewars, a free turn based strategy game
6952
7f70f37bbf08 license header year range adjustments
sheepluva
parents: 6700
diff changeset
     3
 * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
579
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
     4
 *
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
     8
 *
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    12
 * GNU General Public License for more details.
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    13
 *
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    17
 */
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    18
7000
d22633829ac8 allow F5 magic to refresh demos/saves list too
sheepluva
parents: 6952
diff changeset
    19
#include "pageplayrecord.h"
d22633829ac8 allow F5 magic to refresh demos/saves list too
sheepluva
parents: 6952
diff changeset
    20
579
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    21
#include <QFont>
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    22
#include <QGridLayout>
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    23
#include <QPushButton>
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    24
#include <QListWidget>
627
92e136c3eb46 Button for renaming demo and save files
unc0rr
parents: 603
diff changeset
    25
#include <QListWidgetItem>
92e136c3eb46 Button for renaming demo and save files
unc0rr
parents: 603
diff changeset
    26
#include <QFileInfo>
92e136c3eb46 Button for renaming demo and save files
unc0rr
parents: 603
diff changeset
    27
#include <QMessageBox>
92e136c3eb46 Button for renaming demo and save files
unc0rr
parents: 603
diff changeset
    28
#include <QInputDialog>
579
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    29
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    30
#include "hwconsts.h"
7000
d22633829ac8 allow F5 magic to refresh demos/saves list too
sheepluva
parents: 6952
diff changeset
    31
d22633829ac8 allow F5 magic to refresh demos/saves list too
sheepluva
parents: 6952
diff changeset
    32
#include "DataManager.h"
579
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    33
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
    34
QLayout * PagePlayDemo::bodyLayoutDefinition()
579
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    35
{
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
    36
    QGridLayout * pageLayout = new QGridLayout();
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    37
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    38
    pageLayout->setColumnStretch(0, 1);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    39
    pageLayout->setColumnStretch(1, 2);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    40
    pageLayout->setColumnStretch(2, 1);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    41
    pageLayout->setRowStretch(2, 100);
579
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    42
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    43
    BtnPlayDemo = new QPushButton(this);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    44
    BtnPlayDemo->setFont(*font14);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    45
    BtnPlayDemo->setText(QPushButton::tr("Play demo"));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    46
    pageLayout->addWidget(BtnPlayDemo, 3, 2);
579
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    47
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    48
    BtnRenameRecord = new QPushButton(this);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    49
    BtnRenameRecord->setText(QPushButton::tr("Rename"));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    50
    pageLayout->addWidget(BtnRenameRecord, 0, 2);
627
92e136c3eb46 Button for renaming demo and save files
unc0rr
parents: 603
diff changeset
    51
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    52
    BtnRemoveRecord = new QPushButton(this);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    53
    BtnRemoveRecord->setText(QPushButton::tr("Delete"));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    54
    pageLayout->addWidget(BtnRemoveRecord, 1, 2);
720
97a9d67d5c3e - Add 'Delete' button to demos and saves pages
unc0rr
parents: 628
diff changeset
    55
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    56
    DemosList = new QListWidget(this);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    57
    DemosList->setGeometry(QRect(170, 10, 311, 311));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    58
    pageLayout->addWidget(DemosList, 0, 1, 3, 1);
627
92e136c3eb46 Button for renaming demo and save files
unc0rr
parents: 603
diff changeset
    59
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
    60
    return pageLayout;
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
    61
}
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
    62
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
    63
void PagePlayDemo::connectSignals()
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
    64
{
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    65
    connect(BtnRenameRecord, SIGNAL(clicked()), this, SLOT(renameRecord()));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    66
    connect(BtnRemoveRecord, SIGNAL(clicked()), this, SLOT(removeRecord()));
7000
d22633829ac8 allow F5 magic to refresh demos/saves list too
sheepluva
parents: 6952
diff changeset
    67
    connect(&DataManager::instance(), SIGNAL(updated()), this, SLOT(refresh()));
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
    68
}
6009
14f6fc9869f2 code cleanup/etc
sheepluva
parents: 5865
diff changeset
    69
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
    70
PagePlayDemo::PagePlayDemo(QWidget* parent) : AbstractPage(parent)
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
    71
{
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
    72
    initPage();
579
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    73
}
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    74
581
909141b17f68 Better 'Load' page
unc0rr
parents: 580
diff changeset
    75
void PagePlayDemo::FillFromDir(RecordType rectype)
579
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    76
{
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    77
    QDir dir;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    78
    QString extension;
581
909141b17f68 Better 'Load' page
unc0rr
parents: 580
diff changeset
    79
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    80
    recType = rectype;
627
92e136c3eb46 Button for renaming demo and save files
unc0rr
parents: 603
diff changeset
    81
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    82
    dir.cd(cfgdir->absolutePath());
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    83
    if (rectype == RT_Demo)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    84
    {
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    85
        dir.cd("Demos");
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    86
        extension = "hwd";
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    87
        BtnPlayDemo->setText(QPushButton::tr("Play demo"));
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    88
    }
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    89
    else
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    90
    {
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    91
        dir.cd("Saves");
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    92
        extension = "hws";
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    93
        BtnPlayDemo->setText(QPushButton::tr("Load"));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    94
    }
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    95
    dir.setFilter(QDir::Files);
580
d3ebf84e9fad Working 'Load' page
unc0rr
parents: 579
diff changeset
    96
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    97
    QStringList sl = dir.entryList(QStringList(QString("*.%2.%1").arg(extension, *cProtoVer)));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
    98
    sl.replaceInStrings(QRegExp(QString("^(.*)\\.%2\\.%1$").arg(extension, *cProtoVer)), "\\1");
580
d3ebf84e9fad Working 'Load' page
unc0rr
parents: 579
diff changeset
    99
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   100
    DemosList->clear();
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   101
    DemosList->addItems(sl);
579
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
   102
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   103
    for (int i = 0; i < DemosList->count(); ++i)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   104
    {
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   105
        DemosList->item(i)->setData(Qt::UserRole, dir.absoluteFilePath(QString("%1.%3.%2").arg(sl[i], extension, *cProtoVer)));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   106
        DemosList->item(i)->setIcon(recType == RT_Demo ? QIcon(":/res/file_demo.png") : QIcon(":/res/file_save.png"));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   107
    }
579
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
   108
}
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
   109
7000
d22633829ac8 allow F5 magic to refresh demos/saves list too
sheepluva
parents: 6952
diff changeset
   110
d22633829ac8 allow F5 magic to refresh demos/saves list too
sheepluva
parents: 6952
diff changeset
   111
void PagePlayDemo::refresh()
d22633829ac8 allow F5 magic to refresh demos/saves list too
sheepluva
parents: 6952
diff changeset
   112
{
7130
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents: 7000
diff changeset
   113
    if (this->isVisible())
7000
d22633829ac8 allow F5 magic to refresh demos/saves list too
sheepluva
parents: 6952
diff changeset
   114
        FillFromDir(recType);
d22633829ac8 allow F5 magic to refresh demos/saves list too
sheepluva
parents: 6952
diff changeset
   115
}
d22633829ac8 allow F5 magic to refresh demos/saves list too
sheepluva
parents: 6952
diff changeset
   116
d22633829ac8 allow F5 magic to refresh demos/saves list too
sheepluva
parents: 6952
diff changeset
   117
627
92e136c3eb46 Button for renaming demo and save files
unc0rr
parents: 603
diff changeset
   118
void PagePlayDemo::renameRecord()
92e136c3eb46 Button for renaming demo and save files
unc0rr
parents: 603
diff changeset
   119
{
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   120
    QListWidgetItem * curritem = DemosList->currentItem();
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   121
    if (!curritem)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   122
    {
7794
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   123
        QMessageBox recordMsg(this);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   124
        recordMsg.setIcon(QMessageBox::Warning);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   125
        recordMsg.setWindowTitle(QMessageBox::tr("Record Play - Error"));
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   126
        recordMsg.setText(QMessageBox::tr("Please select record from the list"));
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   127
        recordMsg.setWindowModality(Qt::WindowModal);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   128
        recordMsg.exec();
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   129
        return ;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   130
    }
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   131
    QFile rfile(curritem->data(Qt::UserRole).toString());
627
92e136c3eb46 Button for renaming demo and save files
unc0rr
parents: 603
diff changeset
   132
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   133
    QFileInfo finfo(rfile);
627
92e136c3eb46 Button for renaming demo and save files
unc0rr
parents: 603
diff changeset
   134
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   135
    bool ok;
627
92e136c3eb46 Button for renaming demo and save files
unc0rr
parents: 603
diff changeset
   136
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   137
    QString newname = QInputDialog::getText(this, tr("Rename dialog"), tr("Enter new file name:"), QLineEdit::Normal, finfo.completeBaseName().replace("." + *cProtoVer, ""), &ok);
627
92e136c3eb46 Button for renaming demo and save files
unc0rr
parents: 603
diff changeset
   138
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   139
    if(ok && newname.size())
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   140
    {
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   141
        QString newfullname = QString("%1/%2.%3.%4")
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   142
                              .arg(finfo.absolutePath())
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   143
                              .arg(newname)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   144
                              .arg(*cProtoVer)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   145
                              .arg(finfo.suffix());
627
92e136c3eb46 Button for renaming demo and save files
unc0rr
parents: 603
diff changeset
   146
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   147
        ok = rfile.rename(newfullname);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   148
        if(!ok)
7794
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   149
        {
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   150
            QMessageBox renameMsg(this);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   151
            renameMsg.setIcon(QMessageBox::Warning);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   152
            renameMsg.setWindowTitle(QMessageBox::tr("Record Play - Error"));
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   153
            renameMsg.setText(QMessageBox::tr("Cannot rename to ") + newfullname);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   154
            renameMsg.setWindowModality(Qt::WindowModal);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   155
            renameMsg.exec();
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   156
        }
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   157
        else
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   158
            FillFromDir(recType);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   159
    }
627
92e136c3eb46 Button for renaming demo and save files
unc0rr
parents: 603
diff changeset
   160
}
720
97a9d67d5c3e - Add 'Delete' button to demos and saves pages
unc0rr
parents: 628
diff changeset
   161
97a9d67d5c3e - Add 'Delete' button to demos and saves pages
unc0rr
parents: 628
diff changeset
   162
void PagePlayDemo::removeRecord()
97a9d67d5c3e - Add 'Delete' button to demos and saves pages
unc0rr
parents: 628
diff changeset
   163
{
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   164
    QListWidgetItem * curritem = DemosList->currentItem();
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   165
    if (!curritem)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   166
    {
7794
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   167
        QMessageBox recordMsg(this);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   168
        recordMsg.setIcon(QMessageBox::Warning);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   169
        recordMsg.setWindowTitle(QMessageBox::tr("Record Play - Error"));
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   170
        recordMsg.setText(QMessageBox::tr("Please select record from the list"));
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   171
        recordMsg.setWindowModality(Qt::WindowModal);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   172
        recordMsg.exec();
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   173
        return ;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   174
    }
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   175
    QFile rfile(curritem->data(Qt::UserRole).toString());
720
97a9d67d5c3e - Add 'Delete' button to demos and saves pages
unc0rr
parents: 628
diff changeset
   176
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   177
    bool ok;
720
97a9d67d5c3e - Add 'Delete' button to demos and saves pages
unc0rr
parents: 628
diff changeset
   178
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   179
    ok = rfile.remove();
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   180
    if(!ok)
7794
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   181
    {
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   182
        QMessageBox removeMsg(this);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   183
        removeMsg.setIcon(QMessageBox::Warning);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   184
        removeMsg.setWindowTitle(QMessageBox::tr("Record Play - Error"));
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   185
        removeMsg.setText(QMessageBox::tr("Cannot delete file ") + rfile.fileName());
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   186
        removeMsg.setWindowModality(Qt::WindowModal);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   187
        removeMsg.exec();
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7382
diff changeset
   188
    }
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2742
diff changeset
   189
    else
7382
b158940f83e2 When removing a record, set selection on the next item in the list
unc0rr
parents: 7130
diff changeset
   190
    {
b158940f83e2 When removing a record, set selection on the next item in the list
unc0rr
parents: 7130
diff changeset
   191
        int i = DemosList->row(curritem);
b158940f83e2 When removing a record, set selection on the next item in the list
unc0rr
parents: 7130
diff changeset
   192
        delete curritem;
b158940f83e2 When removing a record, set selection on the next item in the list
unc0rr
parents: 7130
diff changeset
   193
        DemosList->setCurrentRow(i < DemosList->count() ? i : DemosList->count() - 1);
b158940f83e2 When removing a record, set selection on the next item in the list
unc0rr
parents: 7130
diff changeset
   194
    }
720
97a9d67d5c3e - Add 'Delete' button to demos and saves pages
unc0rr
parents: 628
diff changeset
   195
}
5865
35387d27f73a Save demo when loaded from save game finishes
unc0rr
parents: 5205
diff changeset
   196
35387d27f73a Save demo when loaded from save game finishes
unc0rr
parents: 5205
diff changeset
   197
bool PagePlayDemo::isSave()
35387d27f73a Save demo when loaded from save game finishes
unc0rr
parents: 5205
diff changeset
   198
{
35387d27f73a Save demo when loaded from save game finishes
unc0rr
parents: 5205
diff changeset
   199
    return recType == RT_Save;
35387d27f73a Save demo when loaded from save game finishes
unc0rr
parents: 5205
diff changeset
   200
}