diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/editorwindow.cc | 5 | ||||
-rw-r--r-- | src/editorwindow.h | 2 | ||||
-rw-r--r-- | src/mainwindow.cc | 66 | ||||
-rw-r--r-- | src/mainwindow.h | 14 | ||||
-rw-r--r-- | src/sidebar.cc | 2 | ||||
-rw-r--r-- | src/sidebar.h | 2 |
6 files changed, 73 insertions, 18 deletions
diff --git a/src/editorwindow.cc b/src/editorwindow.cc index 6757745..2423cff 100644 --- a/src/editorwindow.cc +++ b/src/editorwindow.cc @@ -34,6 +34,11 @@ EditorWindow::EditorWindow(QWidget *parent) : QWidget(parent) connect(editorwindow_sidebar, SIGNAL(entityChanged()), editorwindow_mapwidget, SLOT(resizeChildren())); } +QSize EditorWindow::sizeHint () const +{ + return QSize(768, 512); +} + void EditorWindow::resizeEvent (QResizeEvent *event) { /* diff --git a/src/editorwindow.h b/src/editorwindow.h index 2a1f3f6..89dcae4 100644 --- a/src/editorwindow.h +++ b/src/editorwindow.h @@ -37,6 +37,8 @@ public: return editorwindow_filename; } + virtual QSize sizeHint() const; + public slots: bool loadFile(const QString &filename); diff --git a/src/mainwindow.cc b/src/mainwindow.cc index 260a630..6985506 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -25,16 +25,18 @@ MainWindow::MainWindow() mainwindow_mdiarea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); mainwindow_mdiarea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); setCentralWidget(mainwindow_mdiarea); + + connect(mainwindow_mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(updateMenus())); // initialize actions - init_actions(); + initActions(); // initialize menu bar - init_menu(); + initMenus(); } -void MainWindow::init_actions() +void MainWindow::initActions() { // File -> New action_new = new QAction( tr("&New..."), this); @@ -63,9 +65,18 @@ void MainWindow::init_actions() action_quit->setShortcuts(QKeySequence::Quit); action_quit->setStatusTip(tr("Exit the application")); connect(action_quit, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); + + // Edit -> Add + action_add = new QAction(tr("&Add"), this); + connect(action_add, SIGNAL(triggered()), this, SLOT(slot_add())); + action_delete = new QAction(tr("&Delete"), this); + connect(action_delete, SIGNAL(triggered()), this, SLOT(slot_delete())); + action_duplicate = new QAction(tr("D&uplicate"), this); + connect(action_duplicate, SIGNAL(triggered()), this, SLOT(slot_duplicate())); + } -void MainWindow::init_menu() +void MainWindow::initMenus() { mainwindow_filemenu = menuBar()->addMenu(tr("&File")); mainwindow_filemenu->addAction(action_new); @@ -76,8 +87,22 @@ void MainWindow::init_menu() mainwindow_filemenu->addAction(action_quit); mainwindow_editmenu = menuBar()->addMenu(tr("&Edit")); + mainwindow_editmenu->addAction(action_add); + mainwindow_editmenu->addAction(action_delete); + mainwindow_editmenu->addAction(action_duplicate); } +void MainWindow::updateMenus() +{ + bool active =(mainwindow_mdiarea->activeSubWindow() != 0); + + action_save_as->setEnabled(active); + action_save->setEnabled(active); + + action_add->setEnabled(active); + action_delete->setEnabled(active); + action_duplicate->setEnabled(active); +} EditorWindow *MainWindow::active_child() { @@ -109,7 +134,7 @@ EditorWindow *MainWindow::add_child() // add the widget to the MDI area, // this will wrap an QMdiSubWindow around it QMdiSubWindow *subwindow = mainwindow_mdiarea->addSubWindow(child_widget); - subwindow->resize(768, 512); + //subwindow->resize(768, 512); child_widget->show(); // FIXME check if maximized @@ -131,6 +156,8 @@ void MainWindow::slot_open() QMdiSubWindow *subwindow = find_child(filename); if (subwindow) { + subwindow->raise(); + subwindow->activateWindow(); mainwindow_mdiarea->setActiveSubWindow(subwindow); } else { EditorWindow *editorwindow = add_child(); @@ -138,13 +165,11 @@ void MainWindow::slot_open() if (!editorwindow->loadFile(filename)) { subwindow = find_child(filename); subwindow->close(); - return; - } - - subwindow = find_child(filename); - if (subwindow) { - subwindow->setWindowTitle(filename); - mainwindow_mdiarea->setActiveSubWindow(subwindow); + } else { + subwindow = find_child(filename); + if (subwindow) { + subwindow->setWindowTitle(filename); + } } } } @@ -170,7 +195,6 @@ void MainWindow::slot_save_as() void MainWindow::slot_save() { - /* if (active_child()) { if (active_child()->filename().isEmpty()) { slot_save_as(); @@ -179,7 +203,21 @@ void MainWindow::slot_save() active_child()->saveFile(active_child()->filename()); } } - */ +} + +void MainWindow::slot_add() +{ + qDebug() << "slot_add"; +} + +void MainWindow::slot_delete() +{ + qDebug() << "slot_delete"; +} + +void MainWindow::slot_duplicate() +{ + qDebug() << "slot_duplicate"; } } diff --git a/src/mainwindow.h b/src/mainwindow.h index b76eaa8..0563aa9 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -33,10 +33,16 @@ private slots: void slot_open(); void slot_save(); void slot_save_as(); + + void slot_add(); + void slot_delete(); + void slot_duplicate(); + + void updateMenus(); private: - void init_actions(); - void init_menu(); + void initActions(); + void initMenus(); /// add a new child window EditorWindow *add_child(); @@ -56,6 +62,10 @@ private: QAction *action_save; QAction *action_save_as; QAction *action_quit; + + QAction *action_add; + QAction *action_delete; + QAction *action_duplicate; }; } diff --git a/src/sidebar.cc b/src/sidebar.cc index ed757d4..9412dc9 100644 --- a/src/sidebar.cc +++ b/src/sidebar.cc @@ -250,7 +250,7 @@ void SideBar::updateEntityTemplateType(int template_type) } } -void SideBar::UpdateEntityTemplateLabel(const QString &template_label) +void SideBar::updateEntityTemplateLabel(const QString &template_label) { if (last_selected) { last_selected->set_template_label(template_label); diff --git a/src/sidebar.h b/src/sidebar.h index 644a733..f919b33 100644 --- a/src/sidebar.h +++ b/src/sidebar.h @@ -68,7 +68,7 @@ private slots: void updateEntityTemplateType(int template_type); - void UpdateEntityTemplateLabel(const QString &template_label); + void updateEntityTemplateLabel(const QString &template_label); void updateEntityValues(); |