Browse Source

Add map dimensions dialog window

Marcus Huderle 6 years ago
parent
commit
eb0d238a01
3 changed files with 41 additions and 1 deletions
  1. 31
    0
      mainwindow.cpp
  2. 2
    0
      mainwindow.h
  3. 8
    1
      mainwindow.ui

+ 31
- 0
mainwindow.cpp View File

15
 #include <QSpacerItem>
15
 #include <QSpacerItem>
16
 #include <QFont>
16
 #include <QFont>
17
 #include <QScrollBar>
17
 #include <QScrollBar>
18
+#include <QMessageBox>
19
+#include <QDialogButtonBox>
18
 
20
 
19
 MainWindow::MainWindow(QWidget *parent) :
21
 MainWindow::MainWindow(QWidget *parent) :
20
     QMainWindow(parent),
22
     QMainWindow(parent),
838
 {
840
 {
839
     editor->updateSecondaryTileset(tilesetLabel);
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 View File

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

+ 8
- 1
mainwindow.ui View File

250
                   </property>
250
                   </property>
251
                  </spacer>
251
                  </spacer>
252
                 </item>
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
                </layout>
260
                </layout>
254
               </widget>
261
               </widget>
255
              </item>
262
              </item>
291
                      <x>0</x>
298
                      <x>0</x>
292
                      <y>0</y>
299
                      <y>0</y>
293
                      <width>436</width>
300
                      <width>436</width>
294
-                     <height>621</height>
301
+                     <height>620</height>
295
                     </rect>
302
                     </rect>
296
                    </property>
303
                    </property>
297
                    <layout class="QGridLayout" name="gridLayout_8">
304
                    <layout class="QGridLayout" name="gridLayout_8">