Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow.cc')
-rw-r--r--src/mainwindow.cc47
1 files changed, 37 insertions, 10 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index a92fb8b..4c79fd7 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -45,14 +45,19 @@ void MainWindow::init_actions()
// File -> Open
action_open = new QAction( tr("&Open..."), this);
action_open->setShortcuts(QKeySequence::Open);
- action_open->setStatusTip(tr("Open an existing zone"));
+ action_open->setStatusTip(tr("Open an existing zone ini file"));
connect(action_open, SIGNAL(triggered()), this, SLOT(slot_open()));
- action_save = new QAction( tr("&Save..."), this);
+ action_save = new QAction( tr("&Save"), this);
action_save->setShortcuts(QKeySequence::Save);
- action_save->setStatusTip(tr("Save File"));
+ action_save->setStatusTip(tr("Save zone"));
connect(action_save, SIGNAL(triggered()), this, SLOT(slot_save()));
+ action_save_as = new QAction( tr("Save &As..."), this);
+ action_save_as->setShortcuts(QKeySequence::SaveAs);
+ action_save_as->setStatusTip(tr("Save zone as ini file"));
+ connect(action_save_as, SIGNAL(triggered()), this, SLOT(slot_save_as()));
+
// File -> Quit
action_quit = new QAction(tr("&Quit"), this);
action_quit->setShortcuts(QKeySequence::Quit);
@@ -66,6 +71,7 @@ void MainWindow::init_menu()
mainwindow_filemenu->addAction(action_new);
mainwindow_filemenu->addAction(action_open);
mainwindow_filemenu->addAction(action_save);
+ mainwindow_filemenu->addAction(action_save_as);
mainwindow_filemenu->addSeparator();
mainwindow_filemenu->addAction(action_quit);
@@ -88,7 +94,7 @@ QMdiSubWindow *MainWindow::find_child(const QString &filename)
foreach (QMdiSubWindow *subwindow, mainwindow_mdiarea->subWindowList()) {
EditorWindow *editorwindow = qobject_cast<EditorWindow *>(subwindow->widget());
- if (editorwindow->filename() == canonical)
+ if (canonical == QFileInfo(editorwindow->filename()).canonicalFilePath())
return subwindow;
}
return 0;
@@ -105,11 +111,10 @@ EditorWindow *MainWindow::add_child()
QMdiSubWindow *subwindow = mainwindow_mdiarea->addSubWindow(child_widget);
child_widget->show();
- mainwindow_mdiarea->setActiveSubWindow(subwindow);
-
// FIXME check if maximized
subwindow->resize(768, 512);
+ mainwindow_mdiarea->setActiveSubWindow(subwindow);
return child_widget;
}
@@ -120,7 +125,7 @@ void MainWindow::slot_new()
void MainWindow::slot_open()
{
- QString filename = QFileDialog::getOpenFileName(this, tr("Open file"));
+ QString filename = QFileDialog::getOpenFileName(this, tr("Open..."));
if (!filename.isEmpty()) {
QMdiSubWindow *subwindow = find_child(filename);
@@ -139,13 +144,35 @@ void MainWindow::slot_open()
}
}
+void MainWindow::slot_save_as()
+{
+ EditorWindow *editorwindow = active_child();
+ if (editorwindow) {
+ QString filename = QFileDialog::getSaveFileName(this, tr("Save as..."));
+
+ if (!filename.isEmpty()) {
+ editorwindow->saveFile(filename);
+
+ QMdiSubWindow *subwindow = find_child(filename);
+ if (subwindow) {
+ subwindow->setWindowTitle(editorwindow->filename());
+ }
+ }
+ }
+}
+
void MainWindow::slot_save()
{
- QString filename;
-
+ /*
if (active_child()) {
- active_child()->saveFile(filename);
+ if (!active_child()->filename().size()) {
+ slot_save_as();
+ return;
+ } else {
+ active_child()->saveFile(active_child()->filename());
+ }
}
+ */
}
}