From f8c3caee56c821322e79f6540ffe98a8e920597f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikko=20Syrj=C3=A4?= Date: Fri, 8 Mar 2019 23:46:37 +0200 Subject: Initial file open handling. --- main.cpp | 4 +--- main.qml | 27 +++++++++++++++++++++++---- symedit.cpp | 14 ++++++++------ symedit.h | 6 +++--- 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/main.cpp b/main.cpp index b202026..328a646 100644 --- a/main.cpp +++ b/main.cpp @@ -68,9 +68,7 @@ int main(int argc, char *argv[]) int result = app.exec(); if ( transfer ) - { - //## save file - } + manager.save(filename); manager.SaveSettings(); return result; diff --git a/main.qml b/main.qml index d702a70..43d06bf 100644 --- a/main.qml +++ b/main.qml @@ -103,7 +103,7 @@ ApplicationWindow title: qsTrId("id_menu_help") MenuItem { text: qsTrId("id_menu_help_contents"); shortcut: "F1"; onTriggered: help() } MenuSeparator { } - MenuItem { text: qsTrId("id_menu_help_about"); onTriggered: aboutDialog.open() } + MenuItem { text: qsTrId("id_menu_help_about"); onTriggered: aboutdialog.open() } } } @@ -269,9 +269,27 @@ ApplicationWindow } } + FileDialog + { + id: filedialog + title: "Please choose a file" + folder: shortcuts.home + onAccepted: + { +// console.log("You chose: " + fileDialog.fileUrls) +// Qt.quit() + } + onRejected: + { +// console.log("Canceled") +// Qt.quit() + } +// Component.onCompleted: visible = true + } + Dialog { - id: aboutDialog + id: aboutdialog title: qsTrId("id_dialog_about") Label { @@ -327,13 +345,14 @@ ApplicationWindow function open() { - manager.open(); + filedialog.open() +// manager.open(true); editor.update() } function save() { - manager.save(); + //## } function zoom(dir) diff --git a/symedit.cpp b/symedit.cpp index da2d9ec..8bb523c 100644 --- a/symedit.cpp +++ b/symedit.cpp @@ -1,7 +1,7 @@ #include #include #include - +//#include #include #include @@ -81,9 +81,11 @@ SymEditManager::SymEditManager(QObject* parent) : QObject(parent) \param symbol Symbol string from command line. */ SymEditManager::SymEditManager(const QString& filename, const QString& symbol) - : SymEditManager(nullptr) + : QObject(nullptr), FileName(filename) { - if ( !filename.isEmpty() ) + Settings.Load(); + + if ( !FileName.isEmpty() ) { //## load file } @@ -433,14 +435,14 @@ bool SymEditManager::raiseItem(int dir) } //! Open symbol file. -bool SymEditManager::open() +bool SymEditManager::open(QString filename) { //## return false; } //! Save symbol file. -bool SymEditManager::save() +bool SymEditManager::save(QString filename) { //## return false; @@ -493,8 +495,8 @@ void SymEditManager::undosave() */ void SymEditManager::help(QString topic) const { + Q_UNUSED(topic); QString path = QCoreApplication::applicationDirPath(); path.append("/help/fin/index.html"); QDesktopServices::openUrl(QUrl(path)); -// QDesktopServices::openUrl(QUrl("https://qt.io/")); } diff --git a/symedit.h b/symedit.h index 92cd16a..8dda3e8 100644 --- a/symedit.h +++ b/symedit.h @@ -80,8 +80,8 @@ public: Q_INVOKABLE void rotateSymbol(int dir); Q_INVOKABLE bool raiseItem(int dir); - Q_INVOKABLE bool open(); - Q_INVOKABLE bool save(); + Q_INVOKABLE bool open(QString filename); + Q_INVOKABLE bool save(QString filename); Q_INVOKABLE bool undo(bool undo); Q_INVOKABLE void help(QString topic) const; @@ -90,7 +90,7 @@ private: void undosave(); bool Initialized = false; //!< Initialization mutex. - QString SymbolFile; //!< Symbol file name. + QString FileName; //!< Symbol file name. SymEditSymbol Symbol; //!< Current symbol. SymEditSettings Settings; //!< Editor settings. -- cgit v1.2.3