aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikko Syrjä <mikko@3d-system.fi>2019-03-08 23:46:37 +0200
committerMikko Syrjä <mikko@3d-system.fi>2019-03-08 23:46:37 +0200
commitf8c3caee56c821322e79f6540ffe98a8e920597f (patch)
tree549a599bf4b028ed7a9b44b25d5a96528c6d3725
parentcaa8a50b5c30d9c82e4e5db2d5e24ad5e55aab6a (diff)
downloadsymedit-f8c3caee56c821322e79f6540ffe98a8e920597f.tar.gz
symedit-f8c3caee56c821322e79f6540ffe98a8e920597f.zip
Initial file open handling.
-rw-r--r--main.cpp4
-rw-r--r--main.qml27
-rw-r--r--symedit.cpp14
-rw-r--r--symedit.h6
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 <QGuiApplication>
#include <QClipboard>
#include <QSettings>
-
+//#include <QFileDialog>
#include <QDesktopServices>
#include <QUrl>
@@ -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.