mirror of
git://projects.qi-hardware.com/nanomap.git
synced 2024-11-22 07:20:37 +02:00
press Alt+s to take a screenshot of the map
This commit is contained in:
parent
baed4e06d9
commit
772ed4475a
@ -43,6 +43,8 @@ MapWidget::MapWidget(QWidget *parent)
|
|||||||
m_usage(false),
|
m_usage(false),
|
||||||
m_ui(true),
|
m_ui(true),
|
||||||
m_zoomable(false),
|
m_zoomable(false),
|
||||||
|
m_takeScreenshot(false),
|
||||||
|
m_screenshotNumber(0),
|
||||||
m_baseName(),
|
m_baseName(),
|
||||||
m_xPadding(0),
|
m_xPadding(0),
|
||||||
m_yPadding(0),
|
m_yPadding(0),
|
||||||
@ -276,6 +278,13 @@ void MapWidget::keyPressEvent(QKeyEvent *event)
|
|||||||
m_usage = !m_usage;
|
m_usage = !m_usage;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case Qt::Key_S:
|
||||||
|
{
|
||||||
|
if (event->modifiers() == Qt::AltModifier) {
|
||||||
|
m_takeScreenshot = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case Qt::Key_Q:
|
case Qt::Key_Q:
|
||||||
case Qt::Key_Escape:
|
case Qt::Key_Escape:
|
||||||
{
|
{
|
||||||
@ -299,7 +308,14 @@ void MapWidget::paintEvent(QPaintEvent *event)
|
|||||||
{
|
{
|
||||||
event->accept();
|
event->accept();
|
||||||
|
|
||||||
QPainter painter(this);
|
QImage screenshot(width(), height(), QImage::Format_ARGB32);
|
||||||
|
|
||||||
|
QPainter painter;
|
||||||
|
if (m_takeScreenshot) {
|
||||||
|
painter.begin(&screenshot);
|
||||||
|
} else {
|
||||||
|
painter.begin(this);
|
||||||
|
}
|
||||||
|
|
||||||
for (int x = 0; x < m_cols; ++x) {
|
for (int x = 0; x < m_cols; ++x) {
|
||||||
for (int y = 0; y < m_rows; ++y) {
|
for (int y = 0; y < m_rows; ++y) {
|
||||||
@ -374,6 +390,12 @@ void MapWidget::paintEvent(QPaintEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
painter.end();
|
painter.end();
|
||||||
|
if (m_takeScreenshot) {
|
||||||
|
screenshot.save(QString("NanoMap-%1.png").arg(m_screenshotNumber));
|
||||||
|
m_takeScreenshot = false;
|
||||||
|
++m_screenshotNumber;
|
||||||
|
update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapWidget::replyFinished(QNetworkReply *reply)
|
void MapWidget::replyFinished(QNetworkReply *reply)
|
||||||
|
@ -72,6 +72,8 @@ private:
|
|||||||
void changeZoomLevel(int diff);
|
void changeZoomLevel(int diff);
|
||||||
|
|
||||||
bool m_usage, m_ui, m_zoomable;
|
bool m_usage, m_ui, m_zoomable;
|
||||||
|
bool m_takeScreenshot;
|
||||||
|
int m_screenshotNumber;
|
||||||
QString m_baseName;
|
QString m_baseName;
|
||||||
int m_xPadding, m_yPadding;
|
int m_xPadding, m_yPadding;
|
||||||
QPoint m_pos, m_startPos;
|
QPoint m_pos, m_startPos;
|
||||||
|
Loading…
Reference in New Issue
Block a user