130 /* Map preview label */ |
130 /* Map preview label */ |
131 |
131 |
132 QLabel * lblMapPreviewText = new QLabel(this); |
132 QLabel * lblMapPreviewText = new QLabel(this); |
133 lblMapPreviewText->setText(tr("Map preview:")); |
133 lblMapPreviewText->setText(tr("Map preview:")); |
134 leftLayout->addWidget(lblMapPreviewText, 0); |
134 leftLayout->addWidget(lblMapPreviewText, 0); |
135 leftLayout->addSpacing(2); |
|
136 |
135 |
137 /* Map Preview */ |
136 /* Map Preview */ |
138 |
137 |
139 mapPreview = new QLabel(this); |
138 mapPreview = new QPushButton(this); |
140 mapPreview->setObjectName("mapPreview"); |
139 mapPreview->setObjectName("mapPreview"); |
141 mapPreview->setFixedSize(256, 128); |
140 mapPreview->setFixedSize(256, 128); |
|
141 mapPreview->setContentsMargins(0, 0, 0, 0); |
142 leftLayout->addWidget(mapPreview, 0); |
142 leftLayout->addWidget(mapPreview, 0); |
|
143 connect(mapPreview, SIGNAL(clicked()), this, SLOT(previewClicked())); |
143 |
144 |
144 /* Bottom-Left layout */ |
145 /* Bottom-Left layout */ |
145 |
146 |
146 QVBoxLayout * bottomLeftLayout = new QVBoxLayout(); |
147 QVBoxLayout * bottomLeftLayout = new QVBoxLayout(); |
147 leftLayout->addLayout(bottomLeftLayout, 1); |
148 leftLayout->addLayout(bottomLeftLayout, 1); |
228 lblDesc = new QLabel(); |
229 lblDesc = new QLabel(); |
229 lblDesc->setWordWrap(true); |
230 lblDesc->setWordWrap(true); |
230 lblDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
231 lblDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
231 lblDesc->setAlignment(Qt::AlignTop | Qt::AlignLeft); |
232 lblDesc->setAlignment(Qt::AlignTop | Qt::AlignLeft); |
232 lblDesc->setStyleSheet("font: 10px;"); |
233 lblDesc->setStyleSheet("font: 10px;"); |
233 bottomLeftLayout->addWidget(lblDesc, 1); |
234 bottomLeftLayout->addWidget(lblDesc, 100); |
234 |
235 |
235 /* Add stretch above theme button */ |
236 /* Add stretch above theme button */ |
236 |
237 |
237 bottomLeftLayout->addStretch(1); |
238 bottomLeftLayout->addStretch(1); |
238 |
239 |
268 px.fill(Qt::yellow); |
269 px.fill(Qt::yellow); |
269 QBitmap bm = QBitmap::fromImage(newImage); |
270 QBitmap bm = QBitmap::fromImage(newImage); |
270 px.setMask(bm); |
271 px.setMask(bm); |
271 |
272 |
272 p.fillRect(pxres.rect(), linearGrad); |
273 p.fillRect(pxres.rect(), linearGrad); |
273 p.drawPixmap(QPoint(0, 0), px); |
274 p.drawPixmap(0, 0, px); |
274 |
275 |
275 addInfoToPreview(pxres); |
276 addInfoToPreview(pxres); |
276 pMap = 0; |
277 pMap = 0; |
277 |
278 |
278 cType->setEnabled(isMaster()); |
279 cType->setEnabled(isMaster()); |
298 p.setFont(QFont("MS Shell Dlg", 10)); |
299 p.setFont(QFont("MS Shell Dlg", 10)); |
299 QString text = (hhLimit > 0) ? QString::number(hhLimit) : "?"; |
300 QString text = (hhLimit > 0) ? QString::number(hhLimit) : "?"; |
300 p.drawText(image.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, text); |
301 p.drawText(image.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, text); |
301 p.drawPixmap(image.rect().width() - hhSmall.rect().width() - 5, 5, hhSmall.rect().width(), hhSmall.rect().height(), hhSmall); |
302 p.drawPixmap(image.rect().width() - hhSmall.rect().width() - 5, 5, hhSmall.rect().width(), hhSmall.rect().height(), hhSmall); |
302 |
303 |
303 mapPreview->setPixmap(finalImage); |
304 // Shrink, crop, and center preview image |
|
305 QPixmap centered(QSize(m_previewSize.width() - 6, m_previewSize.height() - 6)); |
|
306 QPainter pc(¢ered); |
|
307 pc.fillRect(centered.rect(), linearGrad); |
|
308 pc.drawPixmap(-3, -3, finalImage); |
|
309 |
|
310 mapPreview->setIcon(QIcon(centered)); |
|
311 mapPreview->setIconSize(centered.size()); |
304 } |
312 } |
305 |
313 |
306 void HWMapContainer::askForGeneratedPreview() |
314 void HWMapContainer::askForGeneratedPreview() |
307 { |
315 { |
308 pMap = new HWMap(this); |
316 pMap = new HWMap(this); |
329 p.drawPixmap(QPoint(x, y), waitIcon); |
337 p.drawPixmap(QPoint(x, y), waitIcon); |
330 |
338 |
331 addInfoToPreview(waitImage); |
339 addInfoToPreview(waitImage); |
332 |
340 |
333 cType->setEnabled(false); |
341 cType->setEnabled(false); |
|
342 } |
|
343 |
|
344 void HWMapContainer::previewClicked() |
|
345 { |
|
346 switch (m_mapInfo.type) |
|
347 { |
|
348 case MapModel::HandDrawnMap: |
|
349 emit drawMapRequested(); |
|
350 break; |
|
351 default: |
|
352 setRandomMap(); |
|
353 break; |
|
354 } |
334 } |
355 } |
335 |
356 |
336 QString HWMapContainer::getCurrentSeed() const |
357 QString HWMapContainer::getCurrentSeed() const |
337 { |
358 { |
338 return m_seed; |
359 return m_seed; |
592 |
613 |
593 switch(m_mapInfo.type) |
614 switch(m_mapInfo.type) |
594 { |
615 { |
595 case MapModel::Invalid: |
616 case MapModel::Invalid: |
596 failIcon = QPixmap(":/res/btnDisabled.png"); |
617 failIcon = QPixmap(":/res/btnDisabled.png"); |
597 mapPreview->setPixmap(failIcon); |
618 mapPreview->setIcon(QIcon(failIcon)); |
|
619 mapPreview->setIconSize(failIcon.size()); |
598 break; |
620 break; |
599 case MapModel::GeneratedMap: |
621 case MapModel::GeneratedMap: |
600 askForGeneratedPreview(); |
622 askForGeneratedPreview(); |
601 break; |
623 break; |
602 case MapModel::GeneratedMaze: |
624 case MapModel::GeneratedMaze: |