diff options
| author | Stijn Buys <ingar@osirion.org> | 2012-02-21 20:06:17 +0000 | 
|---|---|---|
| committer | Stijn Buys <ingar@osirion.org> | 2012-02-21 20:06:17 +0000 | 
| commit | 4460f43972bd52c498161c64d4ddcc4da4c45d20 (patch) | |
| tree | bf9f56c6d0e04bc249986e4bfc2fd1fa30e1c60f /src/mainwindow.cc | |
| parent | 43c292e1dda7c789a31cdb679065c75d8f8cebba (diff) | |
Add support for zone properties, added framework to save files.
Diffstat (limited to 'src/mainwindow.cc')
| -rw-r--r-- | src/mainwindow.cc | 28 | 
1 files changed, 25 insertions, 3 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc index f80f0ab..d1069d7 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -48,6 +48,11 @@ void MainWindow::init_actions()  	action_open->setStatusTip(tr("Open an existing zone"));  	connect(action_open, SIGNAL(triggered()), this, SLOT(slot_open())); +	action_save  = new QAction( tr("&Save..."), this); +	action_save->setShortcuts(QKeySequence::Save); +	action_save->setStatusTip(tr("Save File")); +	connect(action_save, SIGNAL(triggered()), this, SLOT(slot_save())); +	  	// File -> Quit  	action_quit = new QAction(tr("&Quit"), this);  	action_quit->setShortcuts(QKeySequence::Quit); @@ -60,13 +65,22 @@ void MainWindow::init_menu()  	mainwindow_filemenu = menuBar()->addMenu(tr("&File"));  	mainwindow_filemenu->addAction(action_new);  	mainwindow_filemenu->addAction(action_open); +	mainwindow_filemenu->addAction(action_save);  	mainwindow_filemenu->addSeparator();  	mainwindow_filemenu->addAction(action_quit);  	mainwindow_editmenu = menuBar()->addMenu(tr("&Edit"));  } -EditorWindow *MainWindow::addEditorWindow() + +EditorWindow *MainWindow::active_child() +{ +	if (QMdiSubWindow *active_subwindow = mainwindow_mdiarea->activeSubWindow()) +		return qobject_cast<EditorWindow *>(active_subwindow->widget()); +	return 0; +} + +EditorWindow *MainWindow::add_child()  {  	// create a child widget  	EditorWindow *child_widget = new EditorWindow(); @@ -85,7 +99,7 @@ EditorWindow *MainWindow::addEditorWindow()  void MainWindow::slot_new()  { -	addEditorWindow(); +	add_child();  }  void MainWindow::slot_open() @@ -93,10 +107,18 @@ void MainWindow::slot_open()  	QString filename = QFileDialog::getOpenFileName(this, tr("Open file"));  	if (!filename.isEmpty()) { -		EditorWindow *editorwindow = addEditorWindow(); +		EditorWindow *editorwindow = add_child();  		editorwindow->loadFile(filename);  	}  } +void MainWindow::slot_save() +{ +	QString filename; +	 +	if (active_child()) { +		active_child()->saveFile(filename); +	} +}  }  | 
