--- a/QTfrontend/ui/widget/mapContainer.cpp Fri Feb 01 08:47:07 2013 -0500
+++ b/QTfrontend/ui/widget/mapContainer.cpp Fri Feb 01 18:07:43 2013 -0500
@@ -132,14 +132,15 @@
QLabel * lblMapPreviewText = new QLabel(this);
lblMapPreviewText->setText(tr("Map preview:"));
leftLayout->addWidget(lblMapPreviewText, 0);
- leftLayout->addSpacing(2);
/* Map Preview */
- mapPreview = new QLabel(this);
+ mapPreview = new QPushButton(this);
mapPreview->setObjectName("mapPreview");
mapPreview->setFixedSize(256, 128);
+ mapPreview->setContentsMargins(0, 0, 0, 0);
leftLayout->addWidget(mapPreview, 0);
+ connect(mapPreview, SIGNAL(clicked()), this, SLOT(previewClicked()));
/* Bottom-Left layout */
@@ -230,7 +231,7 @@
lblDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
lblDesc->setAlignment(Qt::AlignTop | Qt::AlignLeft);
lblDesc->setStyleSheet("font: 10px;");
- bottomLeftLayout->addWidget(lblDesc, 1);
+ bottomLeftLayout->addWidget(lblDesc, 100);
/* Add stretch above theme button */
@@ -270,7 +271,7 @@
px.setMask(bm);
p.fillRect(pxres.rect(), linearGrad);
- p.drawPixmap(QPoint(0, 0), px);
+ p.drawPixmap(0, 0, px);
addInfoToPreview(pxres);
pMap = 0;
@@ -300,7 +301,14 @@
p.drawText(image.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, text);
p.drawPixmap(image.rect().width() - hhSmall.rect().width() - 5, 5, hhSmall.rect().width(), hhSmall.rect().height(), hhSmall);
- mapPreview->setPixmap(finalImage);
+ // Shrink, crop, and center preview image
+ QPixmap centered(QSize(m_previewSize.width() - 6, m_previewSize.height() - 6));
+ QPainter pc(¢ered);
+ pc.fillRect(centered.rect(), linearGrad);
+ pc.drawPixmap(-3, -3, finalImage);
+
+ mapPreview->setIcon(QIcon(centered));
+ mapPreview->setIconSize(centered.size());
}
void HWMapContainer::askForGeneratedPreview()
@@ -333,6 +341,19 @@
cType->setEnabled(false);
}
+void HWMapContainer::previewClicked()
+{
+ switch (m_mapInfo.type)
+ {
+ case MapModel::HandDrawnMap:
+ emit drawMapRequested();
+ break;
+ default:
+ setRandomMap();
+ break;
+ }
+}
+
QString HWMapContainer::getCurrentSeed() const
{
return m_seed;
@@ -594,7 +615,8 @@
{
case MapModel::Invalid:
failIcon = QPixmap(":/res/btnDisabled.png");
- mapPreview->setPixmap(failIcon);
+ mapPreview->setIcon(QIcon(failIcon));
+ mapPreview->setIconSize(failIcon.size());
break;
case MapModel::GeneratedMap:
askForGeneratedPreview();
@@ -611,7 +633,7 @@
if(!success)
{
- mapPreview->setPixmap(QPixmap());
+ mapPreview->setIcon(QIcon());
return;
}
@@ -730,6 +752,8 @@
}
}
+ repaint();
+
emit mapgenChanged(mapgen);
}
@@ -887,6 +911,7 @@
void HWMapContainer::setMaster(bool master)
{
+ if (master == m_master) return;
m_master = master;
foreach (QWidget *widget, m_childWidgets)