diff --git a/editor.cpp b/editor.cpp index 4311a316..c9e0ccb5 100755 --- a/editor.cpp +++ b/editor.cpp @@ -1,4 +1,5 @@ #include "editor.h" +#include #include #include @@ -251,10 +252,14 @@ void Editor::displayMapGrid() { for (int i = 0; i <= map->getWidth(); i++) { int x = i * 16; QGraphicsLineItem *line = scene->addLine(x, 0, x, pixelHeight); + line->setVisible(gridToggleCheckbox->isChecked()); + connect(gridToggleCheckbox, &QCheckBox::toggled, [=](bool checked){line->setVisible(checked);}); } for (int j = 0; j <= map->getHeight(); j++) { int y = j * 16; QGraphicsLineItem *line = scene->addLine(0, y, pixelWidth, y); + line->setVisible(gridToggleCheckbox->isChecked()); + connect(gridToggleCheckbox, &QCheckBox::toggled, [=](bool checked){line->setVisible(checked);}); } } diff --git a/editor.h b/editor.h index f81a00c3..b4792eee 100755 --- a/editor.h +++ b/editor.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "project.h" @@ -25,6 +26,7 @@ public: QObject *parent = NULL; Project *project = NULL; Map *map = NULL; + QCheckBox *gridToggleCheckbox = NULL; void saveProject(); void save(); void undo(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 79e1e13e..a630322b 100755 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -27,6 +27,7 @@ MainWindow::MainWindow(QWidget *parent) : new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z), this, SLOT(redo())); editor = new Editor; + editor->gridToggleCheckbox = ui->checkBox_ToggleGrid; connect(editor, SIGNAL(objectsChanged()), this, SLOT(updateSelectedObjects())); connect(editor, SIGNAL(selectedObjectsChanged()), this, SLOT(updateSelectedObjects())); diff --git a/mainwindow.h b/mainwindow.h index 67d18aa9..a392b515 100755 --- a/mainwindow.h +++ b/mainwindow.h @@ -72,6 +72,8 @@ private slots: void onOpenMapListContextMenu(const QPoint &point); void onAddNewMapToGroupClick(QAction* triggeredAction); + void on_checkBox_ToggleGrid_toggled(bool checked); + private: Ui::MainWindow *ui; QStandardItemModel *mapListModel; diff --git a/mainwindow.ui b/mainwindow.ui index a3f7a857..8a493db5 100755 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -126,7 +126,7 @@ - + 0 0 @@ -143,98 +143,114 @@ QFrame::Raised - - - true + + + 4 - - - 0 - 0 - 31 - 31 - + + 4 - - Paint + + 4 - - - :/icons/pencil.ico:/icons/pencil.ico + + 4 - - true + + 4 - - true - - - false - - - - - true - - - - 30 - 0 - 31 - 31 - - - - Select - - - - :/icons/cursor.ico:/icons/cursor.ico - - - true - - - - - - 60 - 0 - 31 - 31 - - - - Fill - - - - :/icons/fill_color.ico:/icons/fill_color.ico - - - true - - - - - - 90 - 0 - 31 - 31 - - - - Dropper - - - - :/icons/pipette.ico:/icons/pipette.ico - - - true - - + + + + true + + + Paint + + + + :/icons/pencil.ico:/icons/pencil.ico + + + true + + + true + + + false + + + + + + + true + + + Select + + + + :/icons/cursor.ico:/icons/cursor.ico + + + true + + + + + + + Fill + + + + :/icons/fill_color.ico:/icons/fill_color.ico + + + true + + + + + + + Dropper + + + + :/icons/pipette.ico:/icons/pipette.ico + + + true + + + + + + + margin-left: 10px + + + Show Grid + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + @@ -274,8 +290,8 @@ 0 0 - 617 - 602 + 614 + 621 @@ -462,8 +478,8 @@ 0 0 - 186 - 609 + 180 + 629 @@ -675,8 +691,8 @@ 0 0 - 385 - 638 + 381 + 657 @@ -841,8 +857,8 @@ 0 0 - 416 - 557 + 420 + 584 @@ -1194,7 +1210,7 @@ 0 0 1117 - 20 + 21