Merge pull request #26 from huderlem/exportpic

Add ability to export map image
This commit is contained in:
yenatch 2018-03-04 22:07:18 -05:00 committed by GitHub
commit 6cb394ebde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View file

@ -759,3 +759,12 @@ void MainWindow::checkToolButtons() {
void MainWindow::onMapChanged(Map *map) {
updateMapList();
}
void MainWindow::on_action_Export_Map_Image_triggered()
{
QString defaultFilepath = QString("%1/%2.png").arg(editor->project->root).arg(editor->map->name);
QString filepath = QFileDialog::getSaveFileName(this, "Export Map Image", defaultFilepath, "Image Files (*.png *.jpg *.bmp)");
if (!filepath.isEmpty()) {
editor->map_item->pixmap().save(filepath);
}
}

View file

@ -72,7 +72,7 @@ private slots:
void onOpenMapListContextMenu(const QPoint &point);
void onAddNewMapToGroupClick(QAction* triggeredAction);
void on_checkBox_ToggleGrid_toggled(bool checked);
void on_action_Export_Map_Image_triggered();
private:
Ui::MainWindow *ui;

View file

@ -1221,6 +1221,8 @@
<addaction name="action_Save"/>
<addaction name="action_Save_Project"/>
<addaction name="separator"/>
<addaction name="action_Export_Map_Image"/>
<addaction name="separator"/>
<addaction name="action_Exit"/>
</widget>
<widget class="QMenu" name="menuEdit">
@ -1285,6 +1287,11 @@
<string>Ctrl+Y</string>
</property>
</action>
<action name="action_Export_Map_Image">
<property name="text">
<string>Export Map Image...</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>