Browse Source

Merge pull request #26 from huderlem/exportpic

Add ability to export map image
yenatch 6 years ago
parent
commit
6cb394ebde
No account linked to committer's email address
3 changed files with 17 additions and 1 deletions
  1. 9
    0
      mainwindow.cpp
  2. 1
    1
      mainwindow.h
  3. 7
    0
      mainwindow.ui

+ 9
- 0
mainwindow.cpp View File

759
 void MainWindow::onMapChanged(Map *map) {
759
 void MainWindow::onMapChanged(Map *map) {
760
     updateMapList();
760
     updateMapList();
761
 }
761
 }
762
+
763
+void MainWindow::on_action_Export_Map_Image_triggered()
764
+{
765
+    QString defaultFilepath = QString("%1/%2.png").arg(editor->project->root).arg(editor->map->name);
766
+    QString filepath = QFileDialog::getSaveFileName(this, "Export Map Image", defaultFilepath, "Image Files (*.png *.jpg *.bmp)");
767
+    if (!filepath.isEmpty()) {
768
+        editor->map_item->pixmap().save(filepath);
769
+    }
770
+}

+ 1
- 1
mainwindow.h View File

72
     void onOpenMapListContextMenu(const QPoint &point);
72
     void onOpenMapListContextMenu(const QPoint &point);
73
     void onAddNewMapToGroupClick(QAction* triggeredAction);
73
     void onAddNewMapToGroupClick(QAction* triggeredAction);
74
 
74
 
75
-    void on_checkBox_ToggleGrid_toggled(bool checked);
75
+    void on_action_Export_Map_Image_triggered();
76
 
76
 
77
 private:
77
 private:
78
     Ui::MainWindow *ui;
78
     Ui::MainWindow *ui;

+ 7
- 0
mainwindow.ui View File

1221
     <addaction name="action_Save"/>
1221
     <addaction name="action_Save"/>
1222
     <addaction name="action_Save_Project"/>
1222
     <addaction name="action_Save_Project"/>
1223
     <addaction name="separator"/>
1223
     <addaction name="separator"/>
1224
+    <addaction name="action_Export_Map_Image"/>
1225
+    <addaction name="separator"/>
1224
     <addaction name="action_Exit"/>
1226
     <addaction name="action_Exit"/>
1225
    </widget>
1227
    </widget>
1226
    <widget class="QMenu" name="menuEdit">
1228
    <widget class="QMenu" name="menuEdit">
1285
     <string>Ctrl+Y</string>
1287
     <string>Ctrl+Y</string>
1286
    </property>
1288
    </property>
1287
   </action>
1289
   </action>
1290
+  <action name="action_Export_Map_Image">
1291
+   <property name="text">
1292
+    <string>Export Map Image...</string>
1293
+   </property>
1294
+  </action>
1288
  </widget>
1295
  </widget>
1289
  <layoutdefault spacing="6" margin="11"/>
1296
  <layoutdefault spacing="6" margin="11"/>
1290
  <customwidgets>
1297
  <customwidgets>