--- a/QTfrontend/net/hwmap.cpp Wed Feb 26 00:28:27 2014 +0400
+++ b/QTfrontend/net/hwmap.cpp Wed Feb 26 23:07:55 2014 +0400
@@ -17,6 +17,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <QPainter>
+#include <QBitmap>
+#include <QLinearGradient>
+
#include "hwconsts.h"
#include "hwmap.h"
@@ -58,14 +62,30 @@
}
void HWMap::onClientDisconnect()
-{
+{
+ QLinearGradient linearGrad(QPoint(128, 0), QPoint(128, 128));
+ linearGrad.setColorAt(1, QColor(0, 0, 192));
+ linearGrad.setColorAt(0, QColor(66, 115, 225));
+
if (readbuffer.size() == 128 * 32 + 1)
{
quint8 *buf = (quint8*) readbuffer.constData();
QImage im(buf, 256, 128, QImage::Format_Mono);
im.setNumColors(2);
+
+ QPixmap px(QSize(256, 128));
+ QPixmap pxres(px.size());
+ QPainter p(&pxres);
+
+ px.fill(Qt::yellow);
+ QBitmap bm = QBitmap::fromImage(im);
+ px.setMask(bm);
+
+ p.fillRect(pxres.rect(), linearGrad);
+ p.drawPixmap(0, 0, px);
+
emit HHLimitReceived(buf[128 * 32]);
- emit ImageReceived(im);
+ emit ImageReceived(px);
}
}
--- a/QTfrontend/net/hwmap.h Wed Feb 26 00:28:27 2014 +0400
+++ b/QTfrontend/net/hwmap.h Wed Feb 26 23:07:55 2014 +0400
@@ -22,7 +22,7 @@
#include <QByteArray>
#include <QString>
-#include <QImage>
+#include <QPixmap>
#include "tcpBase.h"
@@ -50,7 +50,7 @@
virtual void SendToClientFirst();
signals:
- void ImageReceived(const QImage newImage);
+ void ImageReceived(const QPixmap & newImage);
void HHLimitReceived(int hhLimit);
private:
--- a/QTfrontend/ui/widget/mapContainer.cpp Wed Feb 26 00:28:27 2014 +0400
+++ b/QTfrontend/ui/widget/mapContainer.cpp Wed Feb 26 23:07:55 2014 +0400
@@ -146,7 +146,7 @@
mapPreview = new QPushButton(this);
mapPreview->setObjectName("mapPreview");
mapPreview->setFlat(true);
- mapPreview->setFixedSize(256, 128);
+ mapPreview->setFixedSize(256 + 6, 128 + 6);
mapPreview->setContentsMargins(0, 0, 0, 0);
leftLayout->addWidget(mapPreview, 0);
connect(mapPreview, SIGNAL(clicked()), this, SLOT(previewClicked()));
@@ -255,20 +255,9 @@
changeMapType(MapModel::GeneratedMap);
}
-void HWMapContainer::setImage(const QImage newImage)
+void HWMapContainer::setImage(const QPixmap &newImage)
{
- QPixmap px(m_previewSize);
- QPixmap pxres(px.size());
- QPainter p(&pxres);
-
- px.fill(Qt::yellow);
- QBitmap bm = QBitmap::fromImage(newImage);
- px.setMask(bm);
-
- p.fillRect(pxres.rect(), linearGrad);
- p.drawPixmap(0, 0, px);
-
- addInfoToPreview(pxres);
+ addInfoToPreview(newImage);
pMap = 0;
cType->setEnabled(isMaster());
@@ -280,36 +269,37 @@
}
// Should this add text to identify map size?
-void HWMapContainer::addInfoToPreview(QPixmap image)
+void HWMapContainer::addInfoToPreview(const QPixmap &image)
{
QPixmap finalImage = QPixmap(image.size());
- finalImage.fill(QColor(0, 0, 0, 0));
+//finalImage.fill(QColor(0, 0, 0, 0));
QPainter p(&finalImage);
- p.drawPixmap(image.rect(), image);
+ p.fillRect(finalImage.rect(), linearGrad);
+ p.drawPixmap(finalImage.rect(), image);
//p.setPen(QColor(0xf4,0x9e,0xe9));
p.setPen(QColor(0xff,0xcc,0x00));
p.setBrush(QColor(0, 0, 0));
- p.drawRect(image.rect().width() - hhSmall.rect().width() - 28, 3, 40, 20);
+ p.drawRect(finalImage.rect().width() - hhSmall.rect().width() - 28, 3, 40, 20);
p.setFont(QFont("MS Shell Dlg", 10));
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);
+ p.drawText(finalImage.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, text);
+ p.drawPixmap(finalImage.rect().width() - hhSmall.rect().width() - 5, 5, hhSmall.rect().width(), hhSmall.rect().height(), hhSmall);
// Shrink, crop, and center preview image
- QPixmap centered(QSize(m_previewSize.width() - 6, m_previewSize.height() - 6));
+ /*QPixmap centered(QSize(m_previewSize.width() - 6, m_previewSize.height() - 6));
QPainter pc(¢ered);
pc.fillRect(centered.rect(), linearGrad);
- pc.drawPixmap(-3, -3, finalImage);
+ pc.drawPixmap(-3, -3, finalImage);*/
- mapPreview->setIcon(QIcon(centered));
- mapPreview->setIconSize(centered.size());
+ mapPreview->setIcon(QIcon(finalImage));
+ mapPreview->setIconSize(finalImage.size());
}
void HWMapContainer::askForGeneratedPreview()
{
pMap = new HWMap(this);
- connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage)));
+ connect(pMap, SIGNAL(ImageReceived(QPixmap)), this, SLOT(setImage(QPixmap)));
connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int)));
connect(pMap, SIGNAL(destroyed(QObject *)), this, SLOT(onPreviewMapDestroyed(QObject *)));
pMap->getImage(m_seed,
--- a/QTfrontend/ui/widget/mapContainer.h Wed Feb 26 00:28:27 2014 +0400
+++ b/QTfrontend/ui/widget/mapContainer.h Wed Feb 26 23:07:55 2014 +0400
@@ -94,12 +94,12 @@
void drawnMapChanged(const QByteArray & data);
private slots:
- void setImage(const QImage newImage);
+ void setImage(const QPixmap & newImage);
void setHHLimit(int hhLimit);
void setRandomSeed();
void setRandomTheme();
void setRandomMap();
- void addInfoToPreview(QPixmap image);
+ void addInfoToPreview(const QPixmap & image);
void setNewSeed(const QString & newSeed);
void mapTypeChanged(int);
void showThemePrompt();