浏览代码

Add map dimensions dialog window

Marcus Huderle 6 年前
父节点
当前提交
eb0d238a01
共有 3 个文件被更改,包括 41 次插入1 次删除
  1. 31
    0
      mainwindow.cpp
  2. 2
    0
      mainwindow.h
  3. 8
    1
      mainwindow.ui

+ 31
- 0
mainwindow.cpp 查看文件

@@ -15,6 +15,8 @@
15 15
 #include <QSpacerItem>
16 16
 #include <QFont>
17 17
 #include <QScrollBar>
18
+#include <QMessageBox>
19
+#include <QDialogButtonBox>
18 20
 
19 21
 MainWindow::MainWindow(QWidget *parent) :
20 22
     QMainWindow(parent),
@@ -838,3 +840,32 @@ void MainWindow::on_comboBox_SecondaryTileset_activated(const QString &tilesetLa
838 840
 {
839 841
     editor->updateSecondaryTileset(tilesetLabel);
840 842
 }
843
+
844
+void MainWindow::on_pushButton_clicked()
845
+{
846
+    QDialog dialog(this, Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
847
+    dialog.setWindowTitle("Change Map Dimensions");
848
+    dialog.setWindowModality(Qt::NonModal);
849
+
850
+    QFormLayout form(&dialog);
851
+
852
+    QSpinBox *widthSpinBox = new QSpinBox();
853
+    QSpinBox *heightSpinBox = new QSpinBox();
854
+    widthSpinBox->setValue(editor->map->getWidth());
855
+    heightSpinBox->setValue(editor->map->getHeight());
856
+    widthSpinBox->setMinimum(1);
857
+    heightSpinBox->setMinimum(1);
858
+    widthSpinBox->setMaximum(255);
859
+    heightSpinBox->setMaximum(255);
860
+    form.addRow(new QLabel("Width"), widthSpinBox);
861
+    form.addRow(new QLabel("Height"), heightSpinBox);
862
+
863
+    QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog);
864
+    form.addRow(&buttonBox);
865
+    connect(&buttonBox, SIGNAL(accepted()), &dialog, SLOT(accept()));
866
+    connect(&buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject()));
867
+
868
+    if (dialog.exec() == QDialog::Accepted) {
869
+        qDebug() << "Change width";
870
+    }
871
+}

+ 2
- 0
mainwindow.h 查看文件

@@ -93,6 +93,8 @@ private slots:
93 93
 
94 94
     void on_comboBox_SecondaryTileset_activated(const QString &arg1);
95 95
 
96
+    void on_pushButton_clicked();
97
+
96 98
 private:
97 99
     Ui::MainWindow *ui;
98 100
     QStandardItemModel *mapListModel;

+ 8
- 1
mainwindow.ui 查看文件

@@ -250,6 +250,13 @@
250 250
                   </property>
251 251
                  </spacer>
252 252
                 </item>
253
+                <item>
254
+                 <widget class="QPushButton" name="pushButton">
255
+                  <property name="text">
256
+                   <string>Change Dimensions</string>
257
+                  </property>
258
+                 </widget>
259
+                </item>
253 260
                </layout>
254 261
               </widget>
255 262
              </item>
@@ -291,7 +298,7 @@
291 298
                      <x>0</x>
292 299
                      <y>0</y>
293 300
                      <width>436</width>
294
-                     <height>621</height>
301
+                     <height>620</height>
295 302
                     </rect>
296 303
                    </property>
297 304
                    <layout class="QGridLayout" name="gridLayout_8">