Move preview icons into comboboxes
authorunc0rr
Sun, 28 Sep 2008 08:26:18 +0000
changeset 1287 4a0cbcbe3521
parent 1286 a02a5345b91e
child 1288 cea4a8f52f5a
Move preview icons into comboboxes
QTfrontend/about.cpp
QTfrontend/pages.cpp
QTfrontend/pages.h
QTfrontend/team.cpp
--- a/QTfrontend/about.cpp	Tue Sep 23 06:27:53 2008 +0000
+++ b/QTfrontend/about.cpp	Sun Sep 28 08:26:18 2008 +0000
@@ -85,7 +85,7 @@
 			"Slovak: Jose Riha<br>"
 			"Spanish: Carlos Vives &lt;<a href=\"mailto:mail@carlosvives.es\">mail@carlosvives.es</a>&gt;<br>"
 			"Swedish: Niklas Grahn &lt;<a href=\"mailto:raewolusjoon@yaoo.com\">raewolusjoon@yaoo.com</a>&gt;<br>"
-			"Ukrainian: Eugene Lyubimkin &lt;<a href=\"mailto:jackyf.devel@gmail.com\">jackyf.devel@gmail.com</a>&gt;"
+			"Ukrainian: Eugene V. Lyubimkin &lt;<a href=\"mailto:jackyf.devel@gmail.com\">jackyf.devel@gmail.com</a>&gt;"
 			"</p><h2>") +
 			
 			QLabel::tr("Special thanks:") + "</h2><p>"
--- a/QTfrontend/pages.cpp	Tue Sep 23 06:27:53 2008 +0000
+++ b/QTfrontend/pages.cpp	Sun Sep 28 08:26:18 2008 +0000
@@ -150,10 +150,8 @@
 	QGridLayout * GBGLayout = new QGridLayout(GBoxGrave);
 	CBGrave = new QComboBox(GBoxGrave);
 	CBGrave->setMaxCount(65535);
+	CBGrave->setIconSize(QSize(32, 32));
 	GBGLayout->addWidget(CBGrave, 0, 0, 1, 3);
-	GravePreview = new QLabel(GBoxGrave);
-	GravePreview->setScaledContents(false);
-	GBGLayout->addWidget(GravePreview, 1, 1);
 	vbox2->addWidget(GBoxGrave);
 	
 	//page1Layout->addWidget(new QWidget(), 3, 1, 1, 1);
@@ -163,18 +161,15 @@
 	GBoxTeamLvl->setTitle(QGroupBox::tr("Team level"));
 	QGridLayout * GBTLLayout = new QGridLayout(GBoxTeamLvl);
 	CBTeamLvl = new QComboBox(GBoxTeamLvl);
-	CBTeamLvl->addItem(QComboBox::tr("Human"));
-	CBTeamLvl->addItem(QComboBox::tr("Level 5"));
-	CBTeamLvl->addItem(QComboBox::tr("Level 4"));
-	CBTeamLvl->addItem(QComboBox::tr("Level 3"));
-	CBTeamLvl->addItem(QComboBox::tr("Level 2"));
-	CBTeamLvl->addItem(QComboBox::tr("Level 1"));
-	CBTeamLvl->setMaxCount(6);
+	CBTeamLvl->setIconSize(QSize(32, 32));
+	CBTeamLvl->addItem(QIcon(":/res/botlevels/0.png"), QComboBox::tr("Human"));
+	for(int i = 5; i > 0; i--)
+		CBTeamLvl->addItem(
+				QIcon(QString(":/res/botlevels/%1.png").arg(6 - i)),
+				QString("%1 %2").arg(QComboBox::tr("Level")).arg(i)
+				);
+	
 	GBTLLayout->addWidget(CBTeamLvl, 0, 0, 1, 3);
-	LevelPict = new QLabel(GBoxTeamLvl);
-	LevelPict->setScaledContents(false);
-	LevelPict->setFixedSize(32, 32);
-	GBTLLayout->addWidget(LevelPict, 1, 1);
 	vbox2->addWidget(GBoxTeamLvl);
 
 	GBoxFort = new QGroupBox(this);
@@ -194,18 +189,18 @@
 	tmpdir.cd("Forts");
 	tmpdir.setFilter(QDir::Files);
 
+	connect(CBFort, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(CBFort_activated(const QString &)));
 	CBFort->addItems(tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L\\.png"), "\\1"));
+	
 	tmpdir.cd("../Graphics/Graves");
 	QStringList list = tmpdir.entryList(QStringList("*.png"));
 	for (QStringList::Iterator it = list.begin(); it != list.end(); ++it )
 	{
-		CBGrave->addItem((*it).replace(QRegExp("^(.*)\\.png"), "\\1"));
+		QPixmap pix(datadir->absolutePath() + "/Graphics/Graves/" + *it);
+		QIcon icon(pix.copy(0, 0, 32, 32));
+		CBGrave->addItem(icon, (*it).replace(QRegExp("^(.*)\\.png"), "\\1"));
 	}
 
-	connect(CBGrave, SIGNAL(activated(const QString &)), this, SLOT(CBGrave_activated(const QString &)));
-	connect(CBTeamLvl, SIGNAL(activated(int)), this, SLOT(CBTeamLvl_activated(int)));
-	connect(CBFort, SIGNAL(activated(const QString &)), this, SLOT(CBFort_activated(const QString &)));
-
 	vbox1->addStretch();
 	vbox2->addStretch();
 //	vbox3->addStretch();
@@ -252,25 +247,13 @@
 	}
 }
 
-void PageEditTeam::CBGrave_activated(const QString & gravename)
-{
-	QPixmap pix(datadir->absolutePath() + "/Graphics/Graves/" + gravename + ".png");
-	GravePreview->setPixmap(pix.copy(0, 0, 32, 32));
-}
-
 void PageEditTeam::CBFort_activated(const QString & fortname)
 {
 	QPixmap pix(datadir->absolutePath() + "/Forts/" + fortname + "L.png");
 	FortPreview->setPixmap(pix);
 }
 
-void PageEditTeam::CBTeamLvl_activated(int id)
-{
-	QPixmap pix(QString(":/res/botlevels/%1.png").arg(id));
-	LevelPict->setPixmap(pix);
-}
-
-PageMultiplayer::PageMultiplayer(QWidget* parent) : 
+PageMultiplayer::PageMultiplayer(QWidget* parent) :
   AbstractPage(parent)
 {
 	QGridLayout * pageLayout = new QGridLayout(this);
--- a/QTfrontend/pages.h	Tue Sep 23 06:27:53 2008 +0000
+++ b/QTfrontend/pages.h	Sun Sep 28 08:26:18 2008 +0000
@@ -139,10 +139,8 @@
 	SquareLabel *FortPreview;
 	QGroupBox *GBoxGrave;
 	QComboBox *CBGrave;
-	QLabel *GravePreview;
 	QGroupBox *GBoxTeamLvl;
 	QComboBox *CBTeamLvl;
-	QLabel *LevelPict;
 	QGroupBox *GBoxBinds;
 	QToolBox *BindsBox;
 	QWidget *page_A;
@@ -157,9 +155,7 @@
 	QComboBox * CBBind[BINDS_NUMBER];
 
 public slots:
-	void CBGrave_activated(const QString & gravename);
 	void CBFort_activated(const QString & gravename);
-	void CBTeamLvl_activated(int id);
 
 private:
 	QLabel * LBind[BINDS_NUMBER];
--- a/QTfrontend/team.cpp	Tue Sep 23 06:27:53 2008 +0000
+++ b/QTfrontend/team.cpp	Sun Sep 28 08:26:18 2008 +0000
@@ -194,17 +194,15 @@
 {
 	hwform->ui.pageEditTeam->TeamNameEdit->setText(TeamName);
 	hwform->ui.pageEditTeam->CBTeamLvl->setCurrentIndex(difficulty);
-	hwform->ui.pageEditTeam->CBTeamLvl_activated(difficulty);
 	for(int i = 0; i < 8; i++)
 	{
 		hwform->ui.pageEditTeam->HHNameEdit[i]->setText(HHName[i]);
 		hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData(HHHat[i], Qt::DisplayRole));
 	}
 	hwform->ui.pageEditTeam->CBGrave->setCurrentIndex(hwform->ui.pageEditTeam->CBGrave->findText(Grave));
-	hwform->ui.pageEditTeam->CBGrave_activated(Grave);
 
 	hwform->ui.pageEditTeam->CBFort->setCurrentIndex(hwform->ui.pageEditTeam->CBFort->findText(Fort));
-	hwform->ui.pageEditTeam->CBFort_activated(Fort);
+	//hwform->ui.pageEditTeam->CBFort_activated(Fort);
 
 	for(int i = 0; i < BINDS_NUMBER; i++)
 	{