diff --git a/mainwindow.cpp b/mainwindow.cpp index af9d9992..9d12041d 100755 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -33,22 +33,46 @@ MainWindow::MainWindow(QWidget *parent) : QApplication::setWindowIcon(QIcon(":/icons/porymap-icon-1.ico")); ui->setupUi(this); - - ui->newEventToolButton->initButton(); - connect(ui->newEventToolButton, SIGNAL(newEventAdded(QString)), this, SLOT(addNewEvent(QString))); - - new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z), this, SLOT(redo())); - - editor = new Editor(ui); - connect(editor, SIGNAL(objectsChanged()), this, SLOT(updateSelectedObjects())); - connect(editor, SIGNAL(selectedObjectsChanged()), this, SLOT(updateSelectedObjects())); - connect(editor, SIGNAL(loadMapRequested(QString, QString)), this, SLOT(onLoadMapRequested(QString, QString))); - connect(editor, SIGNAL(tilesetChanged(QString)), this, SLOT(onTilesetChanged(QString))); - connect(editor, SIGNAL(warpEventDoubleClicked(QString,QString)), this, SLOT(openWarpMap(QString,QString))); - connect(editor, SIGNAL(currentMetatilesSelectionChanged()), this, SLOT(currentMetatilesSelectionChanged())); + this->initExtraSignals(); + this->initExtraShortcuts(); + this->loadUserSettings(); + this->initEditor(); + this->openRecentProject(); on_toolButton_Paint_clicked(); +} +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::initExtraShortcuts() { + new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z), this, SLOT(redo())); +} + +void MainWindow::initExtraSignals() { + connect(ui->newEventToolButton, SIGNAL(newEventAdded(QString)), this, SLOT(addNewEvent(QString))); +} + +void MainWindow::initEditor() { + this->editor = new Editor(ui); + connect(this->editor, SIGNAL(objectsChanged()), this, SLOT(updateSelectedObjects())); + connect(this->editor, SIGNAL(selectedObjectsChanged()), this, SLOT(updateSelectedObjects())); + connect(this->editor, SIGNAL(loadMapRequested(QString, QString)), this, SLOT(onLoadMapRequested(QString, QString))); + connect(this->editor, SIGNAL(tilesetChanged(QString)), this, SLOT(onTilesetChanged(QString))); + connect(this->editor, SIGNAL(warpEventDoubleClicked(QString,QString)), this, SLOT(openWarpMap(QString,QString))); + connect(this->editor, SIGNAL(currentMetatilesSelectionChanged()), this, SLOT(currentMetatilesSelectionChanged())); +} + +void MainWindow::loadUserSettings() { + QSettings settings; + if (settings.contains("cursor_mode") && settings.value("cursor_mode") == "0") { + ui->actionBetter_Cursors->setChecked(false); + } +} + +void MainWindow::openRecentProject() { QSettings settings; QString key = "recent_projects"; if (settings.contains(key)) { @@ -58,15 +82,6 @@ MainWindow::MainWindow(QWidget *parent) : openProject(default_dir); } } - - if (settings.contains("cursor_mode") && settings.value("cursor_mode") == "0") { - ui->actionBetter_Cursors->setChecked(false); - } -} - -MainWindow::~MainWindow() -{ - delete ui; } void MainWindow::setStatusBarMessage(QString message, int timeout/* = 0*/) { diff --git a/mainwindow.h b/mainwindow.h index e1191c3a..a4a277a8 100755 --- a/mainwindow.h +++ b/mainwindow.h @@ -145,6 +145,11 @@ private: void checkToolButtons(); void scaleMapView(int); + void initExtraShortcuts(); + void initExtraSignals(); + void initEditor(); + void loadUserSettings(); + void openRecentProject(); }; enum MapListUserRoles { diff --git a/ui/neweventtoolbutton.cpp b/ui/neweventtoolbutton.cpp index cfd0adab..7abd7b53 100644 --- a/ui/neweventtoolbutton.cpp +++ b/ui/neweventtoolbutton.cpp @@ -10,9 +10,10 @@ NewEventToolButton::NewEventToolButton(QWidget *parent) : setPopupMode(QToolButton::MenuButtonPopup); QObject::connect(this, SIGNAL(triggered(QAction*)), this, SLOT(setDefaultAction(QAction*))); + this->init(); } -void NewEventToolButton::initButton() +void NewEventToolButton::init() { // Add a context menu to select different types of map events. this->newObjectAction = new QAction("New Object", this); diff --git a/ui/neweventtoolbutton.h b/ui/neweventtoolbutton.h index 4d5d0a9c..7ff446fd 100644 --- a/ui/neweventtoolbutton.h +++ b/ui/neweventtoolbutton.h @@ -9,7 +9,6 @@ class NewEventToolButton : public QToolButton Q_OBJECT public: explicit NewEventToolButton(QWidget *parent = nullptr); - void initButton(); QString getSelectedEventType(); public slots: void newObject(); @@ -32,6 +31,7 @@ private: QAction *newSignAction; QAction *newHiddenItemAction; QAction *newSecretBaseAction; + void init(); }; #endif // NEWEVENTTOOLBUTTON_H