- Add 'Delete' button to demos and saves pages
authorunc0rr
Sun, 20 Jan 2008 13:17:24 +0000
changeset 720 97a9d67d5c3e
parent 719 bea32693bd7a
child 721 92672040c50a
- Add 'Delete' button to demos and saves pages - Set version to 0.9.2
CMakeLists.txt
QTfrontend/about.cpp
QTfrontend/playrecordpage.cpp
QTfrontend/playrecordpage.h
hedgewars/hwengine.dpr
--- a/CMakeLists.txt	Sun Jan 20 12:50:26 2008 +0000
+++ b/CMakeLists.txt	Sun Jan 20 13:17:24 2008 +0000
@@ -22,7 +22,7 @@
 set(CPACK_PACKAGE_VENDOR "Hedgewars")
 set(CPACK_PACKAGE_VERSION_MAJOR "0")
 set(CPACK_PACKAGE_VERSION_MINOR "9")
-set(CPACK_PACKAGE_VERSION_PATCH "0")
+set(CPACK_PACKAGE_VERSION_PATCH "2")
 set(CPACK_PACKAGE_FILE_NAME "hedgewars-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
 set(CPACK_SOURCE_PACKAGE_FILE_NAME "hedgewars-src-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
 set(CPACK_PACKAGE_EXECUTABLES "hedgewars" "hedgewars")
--- a/QTfrontend/about.cpp	Sun Jan 20 12:50:26 2008 +0000
+++ b/QTfrontend/about.cpp	Sun Jan 20 13:17:24 2008 +0000
@@ -35,7 +35,7 @@
 	lbl1->setOpenExternalLinks(true);
 	lbl1->setText(
 			"<div align=\"center\"><h1>Hedgewars</h1>" +
-			QLabel::tr("<h3>Version 0.9</h3>") +
+			QLabel::tr("<h3>Version 0.9.2</h3>") +
 			"<p><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p><br>" +
 			QLabel::tr("This program is distributed under the GNU General Public License") +
 			"</div>"
--- a/QTfrontend/playrecordpage.cpp	Sun Jan 20 12:50:26 2008 +0000
+++ b/QTfrontend/playrecordpage.cpp	Sun Jan 20 13:17:24 2008 +0000
@@ -35,27 +35,32 @@
 	pageLayout->setColumnStretch(0, 1);
 	pageLayout->setColumnStretch(1, 2);
 	pageLayout->setColumnStretch(2, 1);
+	pageLayout->setRowStretch(2, 100);
 
 	BtnBack = new QPushButton(this);
 	BtnBack->setFont(*font14);
 	BtnBack->setText(QPushButton::tr("Back"));
-	pageLayout->addWidget(BtnBack, 2, 0);
+	pageLayout->addWidget(BtnBack, 3, 0);
 
 	BtnPlayDemo = new QPushButton(this);
 	BtnPlayDemo->setFont(*font14);
 	BtnPlayDemo->setText(QPushButton::tr("Play demo"));
-	pageLayout->addWidget(BtnPlayDemo, 2, 2);
+	pageLayout->addWidget(BtnPlayDemo, 3, 2);
 
 	BtnRenameRecord = new QPushButton(this);
-//	BtnRenameRecord->setFont(*font14);
 	BtnRenameRecord->setText(QPushButton::tr("Rename"));
 	pageLayout->addWidget(BtnRenameRecord, 0, 2);
 
+	BtnRemoveRecord = new QPushButton(this);
+	BtnRemoveRecord->setText(QPushButton::tr("Delete"));
+	pageLayout->addWidget(BtnRemoveRecord, 1, 2);
+
 	DemosList = new QListWidget(this);
 	DemosList->setGeometry(QRect(170, 10, 311, 311));
-	pageLayout->addWidget(DemosList, 0, 1, 2, 1);
+	pageLayout->addWidget(DemosList, 0, 1, 3, 1);
 
 	connect(BtnRenameRecord, SIGNAL(clicked()), this, SLOT(renameRecord()));
+	connect(BtnRemoveRecord, SIGNAL(clicked()), this, SLOT(removeRecord()));
 }
 
 void PagePlayDemo::FillFromDir(RecordType rectype)
@@ -124,3 +129,27 @@
 			FillFromDir(recType);
 	}
 }
+
+void PagePlayDemo::removeRecord()
+{
+	QListWidgetItem * curritem = DemosList->currentItem();
+	if (!curritem)
+	{
+		QMessageBox::critical(this,
+				tr("Error"),
+				tr("Please, select record from the list"),
+				tr("OK"));
+		return ;
+	}
+	QFile rfile(curritem->data(Qt::UserRole).toString());
+
+	QFileInfo finfo(rfile);
+
+	bool ok;
+
+	ok = rfile.remove();
+	if(!ok)
+		QMessageBox::critical(this, tr("Error"), tr("Cannot delete file"));
+	else
+		FillFromDir(recType);
+}
--- a/QTfrontend/playrecordpage.h	Sun Jan 20 12:50:26 2008 +0000
+++ b/QTfrontend/playrecordpage.h	Sun Jan 20 13:17:24 2008 +0000
@@ -42,6 +42,7 @@
 	QPushButton *BtnBack;
 	QPushButton *BtnPlayDemo;
 	QPushButton *BtnRenameRecord;
+	QPushButton *BtnRemoveRecord;
 	QListWidget *DemosList;
 
 private:
@@ -49,6 +50,7 @@
 
 private slots:
 	void renameRecord();
+	void removeRecord();
 };
 
 
--- a/hedgewars/hwengine.dpr	Sun Jan 20 12:50:26 2008 +0000
+++ b/hedgewars/hwengine.dpr	Sun Jan 20 13:17:24 2008 +0000
@@ -288,8 +288,8 @@
 ////////////////////////////////////////////////////////////////////////////////
 
 begin
-WriteLnToConsole('-= HedgeWars 0.9 =-');
-WriteLnToConsole('  -= by unC0Rr =-  ');
+WriteLnToConsole('-= HedgeWars 0.9.2 =-');
+WriteLnToConsole('   -= by unC0Rr =-   ');
 GetParams;
 Randomize;