Clean up mainwindow initialization
This commit is contained in:
parent
083e8e6101
commit
afc25805d3
4 changed files with 45 additions and 24 deletions
|
@ -33,22 +33,46 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
QApplication::setWindowIcon(QIcon(":/icons/porymap-icon-1.ico"));
|
QApplication::setWindowIcon(QIcon(":/icons/porymap-icon-1.ico"));
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
this->initExtraSignals();
|
||||||
ui->newEventToolButton->initButton();
|
this->initExtraShortcuts();
|
||||||
connect(ui->newEventToolButton, SIGNAL(newEventAdded(QString)), this, SLOT(addNewEvent(QString)));
|
this->loadUserSettings();
|
||||||
|
this->initEditor();
|
||||||
new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z), this, SLOT(redo()));
|
this->openRecentProject();
|
||||||
|
|
||||||
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()));
|
|
||||||
|
|
||||||
on_toolButton_Paint_clicked();
|
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;
|
QSettings settings;
|
||||||
QString key = "recent_projects";
|
QString key = "recent_projects";
|
||||||
if (settings.contains(key)) {
|
if (settings.contains(key)) {
|
||||||
|
@ -58,15 +82,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
openProject(default_dir);
|
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*/) {
|
void MainWindow::setStatusBarMessage(QString message, int timeout/* = 0*/) {
|
||||||
|
|
|
@ -145,6 +145,11 @@ private:
|
||||||
void checkToolButtons();
|
void checkToolButtons();
|
||||||
|
|
||||||
void scaleMapView(int);
|
void scaleMapView(int);
|
||||||
|
void initExtraShortcuts();
|
||||||
|
void initExtraSignals();
|
||||||
|
void initEditor();
|
||||||
|
void loadUserSettings();
|
||||||
|
void openRecentProject();
|
||||||
};
|
};
|
||||||
|
|
||||||
enum MapListUserRoles {
|
enum MapListUserRoles {
|
||||||
|
|
|
@ -10,9 +10,10 @@ NewEventToolButton::NewEventToolButton(QWidget *parent) :
|
||||||
setPopupMode(QToolButton::MenuButtonPopup);
|
setPopupMode(QToolButton::MenuButtonPopup);
|
||||||
QObject::connect(this, SIGNAL(triggered(QAction*)),
|
QObject::connect(this, SIGNAL(triggered(QAction*)),
|
||||||
this, SLOT(setDefaultAction(QAction*)));
|
this, SLOT(setDefaultAction(QAction*)));
|
||||||
|
this->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewEventToolButton::initButton()
|
void NewEventToolButton::init()
|
||||||
{
|
{
|
||||||
// Add a context menu to select different types of map events.
|
// Add a context menu to select different types of map events.
|
||||||
this->newObjectAction = new QAction("New Object", this);
|
this->newObjectAction = new QAction("New Object", this);
|
||||||
|
|
|
@ -9,7 +9,6 @@ class NewEventToolButton : public QToolButton
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit NewEventToolButton(QWidget *parent = nullptr);
|
explicit NewEventToolButton(QWidget *parent = nullptr);
|
||||||
void initButton();
|
|
||||||
QString getSelectedEventType();
|
QString getSelectedEventType();
|
||||||
public slots:
|
public slots:
|
||||||
void newObject();
|
void newObject();
|
||||||
|
@ -32,6 +31,7 @@ private:
|
||||||
QAction *newSignAction;
|
QAction *newSignAction;
|
||||||
QAction *newHiddenItemAction;
|
QAction *newHiddenItemAction;
|
||||||
QAction *newSecretBaseAction;
|
QAction *newSecretBaseAction;
|
||||||
|
void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NEWEVENTTOOLBUTTON_H
|
#endif // NEWEVENTTOOLBUTTON_H
|
||||||
|
|
Loading…
Reference in a new issue