-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmapviewer.cpp
44 lines (36 loc) · 896 Bytes
/
mapviewer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <QLabel>
#include <QImage>
#include <QImageReader>
#include <QImageWriter>
#include <QGuiApplication>
#include <QScreen>
#include <QString>
#include "mapviewer.h"
MapViewer::MapViewer() : mapLabel(new QLabel)
{
mapLabel->setBackgroundRole(QPalette::Base);
mapLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
mapLabel->setScaledContents(true);
this->setBackgroundRole(QPalette::Dark);
this->setWidget(mapLabel.get());
this->setVisible(false);
}
QSize MapViewer::minimumSizeHint() const
{
return QSize(100, 100);
}
QSize MapViewer::sizeHint() const
{
return QSize(400, 400);
}
void MapViewer::setImage(const QImage& map_image)
{
mapLabel->setPixmap(QPixmap::fromImage(map_image));
map = map_image;
this->setVisible(true);
this->setWidgetResizable(true);
}
bool MapViewer::saveMap(const QString& file_name)
{
return map.save(file_name);
}