diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.cc | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc index 9dabde1..04c5f2a 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -470,7 +470,18 @@ void MainWindow::newProject() void MainWindow::loadProject() { - QFile file("test.dgedit"); + QString filename = + QFileDialog::getOpenFileName(this, + tr("Load DGEdit Project"), + "", + tr("DGEdit Project Files (*.dgedit)")); + if(filename == "") + { + // User clicked cancel + return; + } + + QFile file(filename); if(!file.open(QIODevice::ReadOnly)) { return; @@ -482,15 +493,34 @@ void MainWindow::loadProject() ProjectSerialiser ser; ser.deserialise(xml, project); - std::cout << project.getProjectName().toStdString() << std::endl; - std::cout << project.getRawFileRoot().toStdString() << std::endl; + statusBar()->showMessage(tr("Loaded")); } void MainWindow::saveProject() { + QString filename + = QFileDialog::getSaveFileName(this, tr("Save DGEdit Project"), + "", + tr("DGEdit Project Files (*.dgedit)")); + + if(filename == "") + { + // User clicked cancel + return; + } + + QFile file(filename); + if(!file.open(QIODevice::WriteOnly)) + { + return; + } + ProjectSerialiser ser; auto xml = ser.serialise(project); - std::cout << xml.toStdString() << std::endl; + + file.write(xml.toUtf8()); + + statusBar()->showMessage(tr("Saved")); } void MainWindow::projectChanged() |