QTfrontend/playrecordpage.cpp
author unc0rr
Mon, 20 Aug 2007 18:11:43 +0000
changeset 580 d3ebf84e9fad
parent 579 94db15de0392
child 581 909141b17f68
permissions -rw-r--r--
Working 'Load' page
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
579
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
     1
/*
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
     2
 * Hedgewars, a worms-like game
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
     3
 * Copyright (c) 2006, 2007 Andrey Korotaev <unC0Rr@gmail.com>
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
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    19
#include <QFont>
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    20
#include <QGridLayout>
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    21
#include <QPushButton>
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    22
#include <QListWidget>
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    23
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    24
#include "hwconsts.h"
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    25
#include "playrecordpage.h"
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    26
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    27
PagePlayDemo::PagePlayDemo(QWidget* parent) : QWidget(parent)
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    28
{
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    29
	QFont * font14 = new QFont("MS Shell Dlg", 14);
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    30
	QGridLayout * pageLayout = new QGridLayout(this);
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    31
	pageLayout->setColumnStretch(0, 1);
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    32
	pageLayout->setColumnStretch(1, 2);
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    33
	pageLayout->setColumnStretch(2, 1);
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    34
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    35
	BtnBack = new QPushButton(this);
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    36
	BtnBack->setFont(*font14);
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    37
	BtnBack->setText(QPushButton::tr("Back"));
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    38
	pageLayout->addWidget(BtnBack, 1, 0);
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    39
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    40
	BtnPlayDemo	= new QPushButton(this);
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    41
	BtnPlayDemo->setGeometry(QRect(240,	330, 161, 41));
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    42
	BtnPlayDemo->setFont(*font14);
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    43
	BtnPlayDemo->setText(QPushButton::tr("Play demo"));
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    44
	pageLayout->addWidget(BtnPlayDemo, 1, 2);
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    45
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    46
	DemosList =	new QListWidget(this);
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    47
	DemosList->setGeometry(QRect(170, 10, 311, 311));
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    48
	pageLayout->addWidget(DemosList, 0, 1);
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    49
}
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    50
580
d3ebf84e9fad Working 'Load' page
unc0rr
parents: 579
diff changeset
    51
void PagePlayDemo::FillFromDir(QDir dir, const QString & extension)
579
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    52
{
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    53
	dir.setFilter(QDir::Files);
580
d3ebf84e9fad Working 'Load' page
unc0rr
parents: 579
diff changeset
    54
d3ebf84e9fad Working 'Load' page
unc0rr
parents: 579
diff changeset
    55
	QStringList sl = dir.entryList(QStringList(QString("*.%1").arg(extension)));
d3ebf84e9fad Working 'Load' page
unc0rr
parents: 579
diff changeset
    56
	sl.replaceInStrings(QRegExp(QString("^(.*).%1$").arg(extension)), "\\1");
d3ebf84e9fad Working 'Load' page
unc0rr
parents: 579
diff changeset
    57
579
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    58
	DemosList->clear();
580
d3ebf84e9fad Working 'Load' page
unc0rr
parents: 579
diff changeset
    59
	DemosList->addItems(sl);
579
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    60
580
d3ebf84e9fad Working 'Load' page
unc0rr
parents: 579
diff changeset
    61
	for (int i = 0; i < DemosList->count(); ++i)
d3ebf84e9fad Working 'Load' page
unc0rr
parents: 579
diff changeset
    62
	{
d3ebf84e9fad Working 'Load' page
unc0rr
parents: 579
diff changeset
    63
		DemosList->item(i)->setData(Qt::UserRole, dir.absoluteFilePath(QString("%1.%2").arg(sl[i], extension)));
d3ebf84e9fad Working 'Load' page
unc0rr
parents: 579
diff changeset
    64
	}
579
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    65
}
94db15de0392 - Some changes to make build process clear
unc0rr
parents:
diff changeset
    66