Procházet zdrojové kódy

Merge pull request #26 from huderlem/exportpic

Add ability to export map image
yenatch před 6 roky
rodič
revize
6cb394ebde
No account linked to committer's email address
3 změnil soubory, kde provedl 17 přidání a 1 odebrání
  1. 9
    0
      mainwindow.cpp
  2. 1
    1
      mainwindow.h
  3. 7
    0
      mainwindow.ui

+ 9
- 0
mainwindow.cpp Zobrazit soubor

@@ -759,3 +759,12 @@ void MainWindow::checkToolButtons() {
759 759
 void MainWindow::onMapChanged(Map *map) {
760 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 Zobrazit soubor

@@ -72,7 +72,7 @@ private slots:
72 72
     void onOpenMapListContextMenu(const QPoint &point);
73 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 77
 private:
78 78
     Ui::MainWindow *ui;

+ 7
- 0
mainwindow.ui Zobrazit soubor

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