# HG changeset patch # User sheepluva # Date 1336047713 -7200 # Node ID 19a434fc91fca82a301d0cf477907c1390b4a1f5 # Parent 8b34f46e10c1677c5c774ea69062f09a6b1afa77 visually indicate when map preview generation is in progress. diff -r 8b34f46e10c1 -r 19a434fc91fc QTfrontend/ui/widget/mapContainer.cpp --- a/QTfrontend/ui/widget/mapContainer.cpp Thu May 03 16:04:38 2012 +0100 +++ b/QTfrontend/ui/widget/mapContainer.cpp Thu May 03 14:21:53 2012 +0200 @@ -41,12 +41,17 @@ QWidget(parent), mainLayout(this), pMap(0), - mapgen(MAPGEN_REGULAR) + mapgen(MAPGEN_REGULAR), + m_previewSize(256, 128) { hhSmall.load(":/res/hh_small.png"); hhLimit = 18; templateFilter = 0; + linearGrad = QLinearGradient(QPoint(128, 0), QPoint(128, 128)); + linearGrad.setColorAt(1, QColor(0, 0, 192)); + linearGrad.setColorAt(0, QColor(66, 115, 225)); + mainLayout.setContentsMargins(HWApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin), 1, HWApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin), @@ -185,18 +190,15 @@ void HWMapContainer::setImage(const QImage newImage) { - QPixmap px(256, 128); - QPixmap pxres(256, 128); + QPixmap px(m_previewSize); + QPixmap pxres(px.size()); QPainter p(&pxres); px.fill(Qt::yellow); QBitmap bm = QBitmap::fromImage(newImage); px.setMask(bm); - QLinearGradient linearGrad(QPoint(128, 0), QPoint(128, 128)); - linearGrad.setColorAt(1, QColor(0, 0, 192)); - linearGrad.setColorAt(0, QColor(66, 115, 225)); - p.fillRect(QRect(0, 0, 256, 128), linearGrad); + p.fillRect(pxres.rect(), linearGrad); p.drawPixmap(QPoint(0, 0), px); addInfoToPreview(pxres); @@ -281,7 +283,8 @@ p.setBrush(QColor(0, 0, 0)); p.drawRect(image.rect().width() - hhSmall.rect().width() - 28, 3, 40, 20); p.setFont(QFont("MS Shell Dlg", 10)); - p.drawText(image.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, QString::number(hhLimit)); + QString text = (hhLimit > 0) ? QString::number(hhLimit) : "?"; + 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); imageButt->setIcon(finalImage); @@ -307,6 +310,20 @@ getMazeSize(), getDrawnMapData() ); + + setHHLimit(0); + + const QPixmap waitIcon(":/res/iconTime.png"); + + QPixmap waitImage(m_previewSize); + QPainter p(&waitImage); + + p.fillRect(waitImage.rect(), linearGrad); + int x = (waitImage.width() - waitIcon.width()) / 2; + int y = (waitImage.height() - waitIcon.height()) / 2; + p.drawPixmap(QPoint(x, y), waitIcon); + + addInfoToPreview(waitImage); } void HWMapContainer::themeSelected(const QModelIndex & current, const QModelIndex &) diff -r 8b34f46e10c1 -r 19a434fc91fc QTfrontend/ui/widget/mapContainer.h --- a/QTfrontend/ui/widget/mapContainer.h Thu May 03 16:04:38 2012 +0100 +++ b/QTfrontend/ui/widget/mapContainer.h Thu May 03 14:21:53 2012 +0200 @@ -131,6 +131,9 @@ MapModel::MapInfo m_mapInfo; QString m_theme; QString m_curMap; + + QLinearGradient linearGrad; ///< for preview background + QSize m_previewSize; }; #endif // _HWMAP_CONTAINER_INCLUDED