diff options
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r-- | src/mainwindow.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index eac5f02..7d26984 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -68,14 +68,19 @@ public: ExporterList exporters; }; -MainWindow::MainWindow() +MainWindow::MainWindow(const QString &fileName) : QMainWindow(), d(new MainWindowPrivate), m_model(NULL) { setupUi(); setupActions(); setupToolBar(); setupMenuBar(); - newModel(); + if (fileName.isEmpty()) { + newModel(); + } + else { + loadFile(fileName); + } QIcon icon; icon.addFile(":/icons/16x16/item-table.png", QSize(32, 32)); @@ -448,9 +453,14 @@ void MainWindow::loadFile(const QString &fileName) { DiagramDocument *model = new DiagramDocument(this); - model->load(fileName); - newModel(model); - addRecentFile(fileName); + if (model->load(fileName)) { + newModel(model); + addRecentFile(fileName); + } + else { + QMessageBox::critical(this, tr("Error"), tr("Unknown format.")); + newModel(); + } } void |