code size reduse
authordisplacer
Mon, 07 Jan 2008 13:09:10 +0000
changeset 692 07787e748831
parent 691 0a534a03437e
child 693 32a546d1eb3e
code size reduse
QTfrontend/pages.cpp
QTfrontend/pages.h
--- a/QTfrontend/pages.cpp	Sun Dec 30 16:51:06 2007 +0000
+++ b/QTfrontend/pages.cpp	Mon Jan 07 13:09:10 2008 +0000
@@ -105,9 +105,9 @@
 	topLayout->addStretch(100);
 }
 
-PageEditTeam::PageEditTeam(QWidget* parent) : QWidget(parent)
+PageEditTeam::PageEditTeam(QWidget* parent) : 
+  AbstractPage(parent)
 {
-	QFont * font14 = new QFont("MS Shell Dlg", 14);
 	QGridLayout * pageLayout = new QGridLayout(this);
 	pageLayout->setColumnStretch(0, 1);
 	pageLayout->setColumnMinimumWidth(0, 150);
@@ -141,10 +141,7 @@
 	}
 	pageLayout->addWidget(GBoxHedgehogs, 1, 0, 2, 1);
 
-	BtnTeamDiscard = new QPushButton(this);
-	BtnTeamDiscard->setFont(*font14);
-	BtnTeamDiscard->setText(QPushButton::tr("Discard"));
-	pageLayout->addWidget(BtnTeamDiscard, 4, 0);
+	BtnTeamDiscard = addButton("Discard", pageLayout, 4, 0);
 
 	GBoxBinds = new QGroupBox(this);
 	GBoxBinds->setTitle(QGroupBox::tr("Key binds"));
@@ -229,10 +226,7 @@
 	GBFLayout->addWidget(FortPreview, 1, 0);
 	pageLayout->addWidget(GBoxFort, 2, 2, 1, 2);
 
-	BtnTeamSave = new QPushButton(this);
-	BtnTeamSave->setFont(*font14);
-	BtnTeamSave->setText(QPushButton::tr("Save"));
-	pageLayout->addWidget(BtnTeamSave, 4, 2, 1, 2);
+	BtnTeamSave = addButton("Save", pageLayout, 4, 2, 1, 2);
 
 	QDir tmpdir;
 	tmpdir.cd(datadir->absolutePath());
@@ -270,30 +264,24 @@
 	LevelPict->setPixmap(pix);
 }
 
-PageMultiplayer::PageMultiplayer(QWidget* parent) : QWidget(parent)
+PageMultiplayer::PageMultiplayer(QWidget* parent) : 
+  AbstractPage(parent)
 {
-	QFont * font14 = new QFont("MS Shell Dlg", 14);
 	QGridLayout * pageLayout = new QGridLayout(this);
 
-	BtnBack = new QPushButton(this);
-	BtnBack->setFont(*font14);
-	BtnBack->setText(QPushButton::tr("Back"));
-	pageLayout->addWidget(BtnBack, 1, 0);
+	BtnBack = addButton("Back", pageLayout, 1, 0);
 
 	gameCFG = new GameCFGWidget(this);
 	pageLayout->addWidget(gameCFG, 0, 0, 1, 2);
 	teamsSelect = new TeamSelWidget(this);
 	pageLayout->addWidget(teamsSelect, 0, 2, 1, 2);
 
-	BtnStartMPGame = new QPushButton(this);
-	BtnStartMPGame->setFont(*font14);
-	BtnStartMPGame->setText(QPushButton::tr("Start"));
-	pageLayout->addWidget(BtnStartMPGame, 1, 3);
+	BtnStartMPGame = addButton("Start", pageLayout, 1, 3);
 }
 
-PageOptions::PageOptions(QWidget* parent) : QWidget(parent)
+PageOptions::PageOptions(QWidget* parent) : 
+  AbstractPage(parent)
 {
-	QFont * font14 = new QFont("MS Shell Dlg", 14);
 	QGridLayout * pageLayout = new QGridLayout(this);
 	pageLayout->setColumnStretch(0, 100);
 	pageLayout->setColumnStretch(1, 100);
@@ -309,18 +297,13 @@
 	pageLayout->addWidget(groupBox, 0, 0, 1, 3);
 
 	QGridLayout * GBTlayout = new QGridLayout(groupBox);
-	BtnNewTeam = new QPushButton(groupBox);
-	BtnNewTeam->setFont(*font14);
-	BtnNewTeam->setText(QPushButton::tr("New team"));
-	GBTlayout->addWidget(BtnNewTeam, 0, 0);
+
+	BtnNewTeam = addButton("New team", GBTlayout, 0, 0);
 
 	CBTeamName = new QComboBox(groupBox);
 	GBTlayout->addWidget(CBTeamName, 0, 1);
 
-	BtnEditTeam	= new QPushButton(groupBox);
-	BtnEditTeam->setFont(*font14);
-	BtnEditTeam->setText(QPushButton::tr("Edit team"));
-	GBTlayout->addWidget(BtnEditTeam, 0, 2);
+	BtnEditTeam	= addButton("Edit team", GBTlayout, 0, 2);
 
 	AGGroupBox = new QGroupBox(this);
 	AGGroupBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
@@ -364,20 +347,11 @@
 	fpsedit = new FPSEdit(AGGroupBox);
 	GBAfpslayout->addWidget(fpsedit);
 
-	BtnSaveOptions = new QPushButton(this);
-	BtnSaveOptions->setFont(*font14);
-	BtnSaveOptions->setText(QPushButton::tr("Save"));
-	pageLayout->addWidget(BtnSaveOptions, 4, 2);
+	BtnSaveOptions = addButton("Save", pageLayout, 4, 2);
 
-	BtnBack = new QPushButton(this);
-	BtnBack->setFont(*font14);
-	BtnBack->setText(QPushButton::tr("Back"));
-	pageLayout->addWidget(BtnBack, 4, 0);
+	BtnBack = addButton("Back", pageLayout, 4, 0);
 
-	WeaponsButt = new QPushButton(this);
-	WeaponsButt->setFont(*font14);
-	WeaponsButt->setText(QPushButton::tr("Weapons scheme"));
-	pageLayout->addWidget(WeaponsButt, 1, 0);
+	WeaponsButt = addButton("Weapons scheme", pageLayout, 1, 0);
 
 	NNGroupBox = new QGroupBox(this);
 	NNGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
@@ -675,9 +649,6 @@
 {
 	QGridLayout * pageLayout = new QGridLayout(this);
 	pageLayout->setMargin(25);
-	//pageLayout->setColumnStretch(0, 1);
-	//pageLayout->setColumnStretch(1, 2);
-	//pageLayout->setColumnStretch(2, 1);
         
         pWeapons=new SelWeaponWidget(20, this);
 	pageLayout->addWidget(pWeapons, 0, 0, 1, 3);
--- a/QTfrontend/pages.h	Sun Dec 30 16:51:06 2007 +0000
+++ b/QTfrontend/pages.h	Mon Jan 07 13:09:10 2008 +0000
@@ -67,6 +67,14 @@
     return butt;
   };
 
+  QPushButton* addButton(const char* btname, QGridLayout* grid, int wy, int wx, int rowSpan, int columnSpan) {
+    QPushButton* butt = new QPushButton(this);
+    butt->setFont(*font14);
+    butt->setText(QPushButton::tr(btname));
+    grid->addWidget(butt, wy, wx, rowSpan, columnSpan);
+    return butt;
+  };
+
   QPushButton* addButton(const char* btname, QBoxLayout* box, int where) {
     QPushButton* butt = new QPushButton(this);
     butt->setFont(*font14);
@@ -107,7 +115,7 @@
 	GameCFGWidget *gameCFG;
 };
 
-class PageEditTeam : public QWidget
+class PageEditTeam : public AbstractPage
 {
 	Q_OBJECT
 
@@ -145,7 +153,7 @@
 	QLabel * LBind[BINDS_NUMBER];
 };
 
-class PageMultiplayer : public QWidget
+class PageMultiplayer : public AbstractPage
 {
 	Q_OBJECT
 
@@ -158,7 +166,7 @@
 	QPushButton *BtnStartMPGame;
 };
 
-class PageOptions : public QWidget
+class PageOptions : public AbstractPage
 {
 	Q_OBJECT