1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-03 14:52:11 +02:00

Implement map export to image

This commit is contained in:
nordsoft 2023-04-22 20:41:23 +04:00 committed by Nordsoft91
parent 9aaa8c0d89
commit dee235ea19
3 changed files with 23 additions and 4 deletions

View File

@ -1234,3 +1234,14 @@ void MainWindow::on_actionPaste_triggered()
}
}
void MainWindow::on_actionExport_triggered()
{
QString fileName = QFileDialog::getSaveFileName(this, "Save to image", QCoreApplication::applicationDirPath(), "BMP (*.bmp);;JPEG (*.jpeg);;PNG (*.png)");
if(!fileName.isNull())
{
auto pixmap = ui->mapView->grab();
pixmap.save(fileName);
}
}

View File

@ -41,7 +41,7 @@ public:
void saveMap();
bool openMap(const QString &);
MapView * mapView();
//MapView * mapView();
void loadObjectsTree();
@ -115,6 +115,8 @@ private slots:
void on_actionPaste_triggered();
void on_actionExport_triggered();
public slots:
void treeViewSelected(const QModelIndex &selected, const QModelIndex &deselected);

View File

@ -62,6 +62,7 @@
<addaction name="actionOpen"/>
<addaction name="actionSave"/>
<addaction name="actionSave_as"/>
<addaction name="actionExport"/>
</widget>
<widget class="QMenu" name="menuMap">
<property name="title">
@ -750,7 +751,7 @@
<x>0</x>
<y>0</y>
<width>128</width>
<height>257</height>
<height>251</height>
</rect>
</property>
<property name="sizePolicy">
@ -793,7 +794,7 @@
<x>0</x>
<y>0</y>
<width>128</width>
<height>257</height>
<height>251</height>
</rect>
</property>
<property name="sizePolicy">
@ -829,7 +830,7 @@
<x>0</x>
<y>0</y>
<width>128</width>
<height>257</height>
<height>251</height>
</rect>
</property>
<property name="sizePolicy">
@ -1228,6 +1229,11 @@
<string notr="true">Ctrl+8</string>
</property>
</action>
<action name="actionExport">
<property name="text">
<string>Export as</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>