author | unC0Rr |
Wed, 20 Nov 2024 21:37:47 +0100 | |
branch | transitional_engine |
changeset 16067 | d903f8d2395a |
parent 14857 | b9437746bffb |
permissions | -rw-r--r-- |
579 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
579 | 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 |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9998
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
579 | 17 |
*/ |
18 |
||
7000 | 19 |
#include "pageplayrecord.h" |
20 |
||
579 | 21 |
#include <QFont> |
22 |
#include <QGridLayout> |
|
23 |
#include <QPushButton> |
|
24 |
#include <QListWidget> |
|
627 | 25 |
#include <QListWidgetItem> |
26 |
#include <QFileInfo> |
|
27 |
#include <QMessageBox> |
|
28 |
#include <QInputDialog> |
|
579 | 29 |
|
30 |
#include "hwconsts.h" |
|
7000 | 31 |
|
32 |
#include "DataManager.h" |
|
579 | 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 | 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 | 42 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
43 |
BtnRenameRecord = new QPushButton(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
44 |
BtnRenameRecord->setText(QPushButton::tr("Rename")); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
45 |
pageLayout->addWidget(BtnRenameRecord, 0, 2); |
627 | 46 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
47 |
BtnRemoveRecord = new QPushButton(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
48 |
BtnRemoveRecord->setText(QPushButton::tr("Delete")); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
49 |
pageLayout->addWidget(BtnRemoveRecord, 1, 2); |
720 | 50 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
51 |
DemosList = new QListWidget(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
52 |
DemosList->setGeometry(QRect(170, 10, 311, 311)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
53 |
pageLayout->addWidget(DemosList, 0, 1, 3, 1); |
627 | 54 |
|
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
|
55 |
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
|
56 |
} |
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
|
57 |
|
11819
7642955690bc
Tweak sizes and icons of most footer buttons of frontend
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
58 |
QLayout * PagePlayDemo::footerLayoutDefinition() |
7642955690bc
Tweak sizes and icons of most footer buttons of frontend
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
59 |
{ |
7642955690bc
Tweak sizes and icons of most footer buttons of frontend
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
60 |
QHBoxLayout * bottomLayout = new QHBoxLayout(); |
7642955690bc
Tweak sizes and icons of most footer buttons of frontend
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
61 |
|
7642955690bc
Tweak sizes and icons of most footer buttons of frontend
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
62 |
BtnPlayDemo = addButton(tr("Play demo"), bottomLayout, 0, false, Qt::AlignBottom); |
7642955690bc
Tweak sizes and icons of most footer buttons of frontend
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
63 |
const QIcon& lp = QIcon(":/res/Start.png"); |
7642955690bc
Tweak sizes and icons of most footer buttons of frontend
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
64 |
QSize sz = lp.actualSize(QSize(65535, 65535)); |
12236
a0ed4caa6d35
Apply minimal padding to all text buttons in frontend
Wuzzy <almikes@aol.com>
parents:
11819
diff
changeset
|
65 |
BtnPlayDemo->setStyleSheet("padding: 5px 10px"); |
11819
7642955690bc
Tweak sizes and icons of most footer buttons of frontend
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
66 |
BtnPlayDemo->setIcon(lp); |
7642955690bc
Tweak sizes and icons of most footer buttons of frontend
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
67 |
BtnPlayDemo->setFixedHeight(50); |
7642955690bc
Tweak sizes and icons of most footer buttons of frontend
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
68 |
BtnPlayDemo->setIconSize(sz); |
7642955690bc
Tweak sizes and icons of most footer buttons of frontend
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
69 |
BtnPlayDemo->setFlat(true); |
7642955690bc
Tweak sizes and icons of most footer buttons of frontend
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
70 |
BtnPlayDemo->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); |
7642955690bc
Tweak sizes and icons of most footer buttons of frontend
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
71 |
|
7642955690bc
Tweak sizes and icons of most footer buttons of frontend
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
72 |
return bottomLayout; |
7642955690bc
Tweak sizes and icons of most footer buttons of frontend
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
73 |
} |
7642955690bc
Tweak sizes and icons of most footer buttons of frontend
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
74 |
|
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
|
75 |
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
|
76 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
77 |
connect(BtnRenameRecord, SIGNAL(clicked()), this, SLOT(renameRecord())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
78 |
connect(BtnRemoveRecord, SIGNAL(clicked()), this, SLOT(removeRecord())); |
7000 | 79 |
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
|
80 |
} |
6009 | 81 |
|
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
|
82 |
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
|
83 |
{ |
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
|
84 |
initPage(); |
579 | 85 |
} |
86 |
||
581 | 87 |
void PagePlayDemo::FillFromDir(RecordType rectype) |
579 | 88 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
89 |
QDir dir; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
90 |
QString extension; |
581 | 91 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
92 |
recType = rectype; |
627 | 93 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
94 |
dir.cd(cfgdir->absolutePath()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
95 |
if (rectype == RT_Demo) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
96 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
97 |
dir.cd("Demos"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
98 |
extension = "hwd"; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
99 |
BtnPlayDemo->setText(QPushButton::tr("Play demo")); |
11819
7642955690bc
Tweak sizes and icons of most footer buttons of frontend
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
100 |
BtnPlayDemo->setWhatsThis(tr("Play the selected demo")); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
101 |
} |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
102 |
else |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
103 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
104 |
dir.cd("Saves"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
105 |
extension = "hws"; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
106 |
BtnPlayDemo->setText(QPushButton::tr("Load")); |
11819
7642955690bc
Tweak sizes and icons of most footer buttons of frontend
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
107 |
BtnPlayDemo->setWhatsThis(tr("Load the selected game")); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
108 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
109 |
dir.setFilter(QDir::Files); |
580 | 110 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
111 |
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
|
112 |
sl.replaceInStrings(QRegExp(QString("^(.*)\\.%2\\.%1$").arg(extension, *cProtoVer)), "\\1"); |
580 | 113 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
114 |
DemosList->clear(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
115 |
DemosList->addItems(sl); |
579 | 116 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
117 |
for (int i = 0; i < DemosList->count(); ++i) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
118 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
119 |
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
|
120 |
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
|
121 |
} |
579 | 122 |
} |
123 |
||
7000 | 124 |
|
125 |
void PagePlayDemo::refresh() |
|
126 |
{ |
|
7130 | 127 |
if (this->isVisible()) |
7000 | 128 |
FillFromDir(recType); |
129 |
} |
|
130 |
||
131 |
||
627 | 132 |
void PagePlayDemo::renameRecord() |
133 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
134 |
QListWidgetItem * curritem = DemosList->currentItem(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
135 |
if (!curritem) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
136 |
{ |
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
|
137 |
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
|
138 |
recordMsg.setIcon(QMessageBox::Warning); |
12473
faed28f815c7
Simplify error messages in record play page and fix poor grammar.
Wuzzy <almikes@aol.com>
parents:
12471
diff
changeset
|
139 |
recordMsg.setWindowTitle(QMessageBox::tr("Error")); |
faed28f815c7
Simplify error messages in record play page and fix poor grammar.
Wuzzy <almikes@aol.com>
parents:
12471
diff
changeset
|
140 |
recordMsg.setText(QMessageBox::tr("Please select a file from the list.")); |
14857
b9437746bffb
Frontend: Force plain text mode for many message windows
Wuzzy <Wuzzy2@mail.ru>
parents:
12473
diff
changeset
|
141 |
recordMsg.setTextFormat(Qt::PlainText); |
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
|
142 |
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
|
143 |
recordMsg.exec(); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
144 |
return ; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
145 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
146 |
QFile rfile(curritem->data(Qt::UserRole).toString()); |
627 | 147 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
148 |
QFileInfo finfo(rfile); |
627 | 149 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
150 |
bool ok; |
627 | 151 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
152 |
QString newname = QInputDialog::getText(this, tr("Rename dialog"), tr("Enter new file name:"), QLineEdit::Normal, finfo.completeBaseName().replace("." + *cProtoVer, ""), &ok); |
627 | 153 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
154 |
if(ok && newname.size()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
155 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
156 |
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
|
157 |
.arg(finfo.absolutePath()) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
158 |
.arg(newname) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
159 |
.arg(*cProtoVer) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
160 |
.arg(finfo.suffix()); |
627 | 161 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
162 |
ok = rfile.rename(newfullname); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
163 |
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
|
164 |
{ |
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
|
165 |
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
|
166 |
renameMsg.setIcon(QMessageBox::Warning); |
12473
faed28f815c7
Simplify error messages in record play page and fix poor grammar.
Wuzzy <almikes@aol.com>
parents:
12471
diff
changeset
|
167 |
renameMsg.setWindowTitle(QMessageBox::tr("Error")); |
faed28f815c7
Simplify error messages in record play page and fix poor grammar.
Wuzzy <almikes@aol.com>
parents:
12471
diff
changeset
|
168 |
renameMsg.setText(QMessageBox::tr("Cannot rename file to %1.").arg(newfullname)); |
14857
b9437746bffb
Frontend: Force plain text mode for many message windows
Wuzzy <Wuzzy2@mail.ru>
parents:
12473
diff
changeset
|
169 |
renameMsg.setTextFormat(Qt::PlainText); |
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
|
170 |
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
|
171 |
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
|
172 |
} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
173 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
174 |
FillFromDir(recType); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
175 |
} |
627 | 176 |
} |
720 | 177 |
|
178 |
void PagePlayDemo::removeRecord() |
|
179 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
180 |
QListWidgetItem * curritem = DemosList->currentItem(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
181 |
if (!curritem) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
182 |
{ |
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
|
183 |
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
|
184 |
recordMsg.setIcon(QMessageBox::Warning); |
12473
faed28f815c7
Simplify error messages in record play page and fix poor grammar.
Wuzzy <almikes@aol.com>
parents:
12471
diff
changeset
|
185 |
recordMsg.setWindowTitle(QMessageBox::tr("Error")); |
faed28f815c7
Simplify error messages in record play page and fix poor grammar.
Wuzzy <almikes@aol.com>
parents:
12471
diff
changeset
|
186 |
recordMsg.setText(QMessageBox::tr("Please select a file from the list.")); |
14857
b9437746bffb
Frontend: Force plain text mode for many message windows
Wuzzy <Wuzzy2@mail.ru>
parents:
12473
diff
changeset
|
187 |
recordMsg.setTextFormat(Qt::PlainText); |
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
|
188 |
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
|
189 |
recordMsg.exec(); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
190 |
return ; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
191 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
192 |
QFile rfile(curritem->data(Qt::UserRole).toString()); |
720 | 193 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
194 |
bool ok; |
720 | 195 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
196 |
ok = rfile.remove(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
197 |
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
|
198 |
{ |
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
|
199 |
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
|
200 |
removeMsg.setIcon(QMessageBox::Warning); |
12473
faed28f815c7
Simplify error messages in record play page and fix poor grammar.
Wuzzy <almikes@aol.com>
parents:
12471
diff
changeset
|
201 |
removeMsg.setWindowTitle(QMessageBox::tr("Error")); |
faed28f815c7
Simplify error messages in record play page and fix poor grammar.
Wuzzy <almikes@aol.com>
parents:
12471
diff
changeset
|
202 |
removeMsg.setText(QMessageBox::tr("Cannot delete file %1.").arg(rfile.fileName())); |
14857
b9437746bffb
Frontend: Force plain text mode for many message windows
Wuzzy <Wuzzy2@mail.ru>
parents:
12473
diff
changeset
|
203 |
removeMsg.setTextFormat(Qt::PlainText); |
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
|
204 |
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
|
205 |
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
|
206 |
} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
207 |
else |
7382
b158940f83e2
When removing a record, set selection on the next item in the list
unc0rr
parents:
7130
diff
changeset
|
208 |
{ |
b158940f83e2
When removing a record, set selection on the next item in the list
unc0rr
parents:
7130
diff
changeset
|
209 |
int i = DemosList->row(curritem); |
b158940f83e2
When removing a record, set selection on the next item in the list
unc0rr
parents:
7130
diff
changeset
|
210 |
delete curritem; |
b158940f83e2
When removing a record, set selection on the next item in the list
unc0rr
parents:
7130
diff
changeset
|
211 |
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
|
212 |
} |
720 | 213 |
} |
5865 | 214 |
|
215 |
bool PagePlayDemo::isSave() |
|
216 |
{ |
|
217 |
return recType == RT_Save; |
|
218 |
} |