diff options
| author | Mikko Syrjä <mikko@3d-system.fi> | 2019-02-27 01:07:20 +0200 |
|---|---|---|
| committer | Mikko Syrjä <mikko@3d-system.fi> | 2019-02-27 01:07:20 +0200 |
| commit | ab3e047e2a1eb10946f6c3217db426ac27e98fbb (patch) | |
| tree | 13a344511bacefc823b8afb77e9a3287975e4dca | |
| parent | 70ae750525aa8810015ca8b4658703c5970932a0 (diff) | |
| download | symedit-ab3e047e2a1eb10946f6c3217db426ac27e98fbb.tar.gz symedit-ab3e047e2a1eb10946f6c3217db426ac27e98fbb.zip | |
Added text value save and load.
| -rw-r--r-- | main.qml | 47 | ||||
| -rw-r--r-- | symedit.cpp | 65 | ||||
| -rw-r--r-- | symedit.h | 5 |
3 files changed, 82 insertions, 35 deletions
@@ -1,6 +1,7 @@ import QtQuick 2.9 import QtQuick.Controls 1.4 import QtQuick.Layouts 1.0 +import QtQuick.Dialogs 1.2 ApplicationWindow { @@ -17,6 +18,7 @@ ApplicationWindow property int alignment: 1 property int textsize: 1 property int snapgrid: 1 + property string textvalue: textfield.text property int tool: 0 property string symbol @@ -99,7 +101,7 @@ ApplicationWindow title: qsTr("Help") //%% MenuItem { text: qsTr("Help"); shortcut: "F1"; onTriggered: help() } //%% MenuSeparator { } - MenuItem { text: qsTr("About"); onTriggered: about() } //%% + MenuItem { text: qsTr("About"); onTriggered: aboutDialog.open() } //%% } } @@ -171,9 +173,8 @@ ApplicationWindow ComboBox { id: filllist - implicitWidth: 100 - model: [ "No fill", "Area fill", "Backgroud" ] //%% -// model: [ "Ei täyttöä", "Aluetäyttö", "Taustaväri" ] //%% + implicitWidth: 50 + model: [ "0 No fill", "1 Area fill", "2 Backgroud" ] //%% onCurrentIndexChanged: { fillitem = currentIndex; editor.update() } function setFill() { currentIndex = fillitem } } @@ -203,7 +204,18 @@ ApplicationWindow { id: alignlist implicitWidth: 50 - model: [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] + model: + [ + "1 Top Right", //%% + "2 Top Center", //%% + "3 Top Left", //%% + "4 Base Right", //%% + "5 Base Center", //%% + "6 Base Left", //%% + "7 Bottom Right", //%% + "8 Bottom Center", //%% + "9 Bottom Left" //%% + ] onCurrentIndexChanged: { alignment = currentIndex + 1 } function setAlign() { currentIndex = alignment - 1 } } @@ -213,8 +225,6 @@ ApplicationWindow { id: textfield implicitWidth: 120 - - } } } @@ -234,6 +244,20 @@ ApplicationWindow } } + Dialog + { + id: aboutDialog + title: qsTr("About") + Label + { + anchors.fill: parent + text: qsTr("Symbol Editor for 3D-Win\n\nhttp://www.3d-system.fi\n") //%% + horizontalAlignment: Text.AlignHCenter + } + + standardButtons: StandardButton.Ok + } + onXChanged: { manager.setGeometry(Qt.point(x, y), Qt.size(width, height)) } onYChanged: { manager.setGeometry(Qt.point(x, y), Qt.size(width, height)) } onWidthChanged: { manager.setGeometry(Qt.point(x, y), Qt.size(width, height)) } @@ -244,6 +268,8 @@ ApplicationWindow onLinewidthChanged: { manager.setIntSetting("LineWidth", linewidth); } onTextsizeChanged: { manager.setIntSetting("TextSize", textsize); } onSnapgridChanged: { manager.setIntSetting("SnapGrid", snapgrid); } + + onTextvalueChanged: { manager.setTextSetting("TextValue", textvalue); } onToolChanged: { manager.setIntSetting("Tool", tool); } Component.onCompleted: @@ -258,6 +284,8 @@ ApplicationWindow linewidth = manager.getIntSetting("LineWidth") textsize = manager.getIntSetting("TextSize") snapgrid = manager.getIntSetting("SnapGrid") + + textfield.text = manager.getTextSetting("TextValue") tool = manager.getIntSetting("Tool") filllist.setFill() @@ -364,9 +392,4 @@ ApplicationWindow { } - - function about() - { - - } } diff --git a/symedit.cpp b/symedit.cpp index 56bcb39..6e3b256 100644 --- a/symedit.cpp +++ b/symedit.cpp @@ -10,12 +10,14 @@ //! Constructor. SymEditSettings::SymEditSettings() { - Values.emplace("FillItem", 0); - Values.emplace("Alignment", 9); - Values.emplace("LineWidth", 1); - Values.emplace("TextSize", 1); - Values.emplace("SnapGrid", 5); - Values.emplace("Tool", 1); + IntValues.emplace("FillItem", 0); + IntValues.emplace("Alignment", 9); + IntValues.emplace("LineWidth", 1); + IntValues.emplace("TextSize", 1); + IntValues.emplace("SnapGrid", 5); + IntValues.emplace("Tool", 1); + + TextValues.emplace("TextValue", ""); } //! Load settings. @@ -28,12 +30,14 @@ void SymEditSettings::Load() Size.setWidth(settings.value("window/width", 500).toInt()); Size.setHeight(settings.value("window/height", 500).toInt()); - Values.at("FillItem") = settings.value("editor/fill", 0).toInt(); - Values.at("Alignment") = settings.value("editor/align", 9).toInt(); - Values.at("LineWidth") = settings.value("editor/width", 1).toInt(); - Values.at("TextSize") = settings.value("editor/size", 1).toInt(); - Values.at("SnapGrid") = settings.value("editor/snap", 5).toInt(); - Values.at("Tool") = settings.value("editor/tool", 1).toInt(); + IntValues.at("FillItem") = settings.value("editor/fill", 0).toInt(); + IntValues.at("Alignment") = settings.value("editor/align", 9).toInt(); + IntValues.at("LineWidth") = settings.value("editor/width", 1).toInt(); + IntValues.at("TextSize") = settings.value("editor/size", 1).toInt(); + IntValues.at("SnapGrid") = settings.value("editor/snap", 5).toInt(); + IntValues.at("Tool") = settings.value("editor/tool", 1).toInt(); + + TextValues.at("TextValue") = settings.value("editor/text").toString(); } //! Save settings. @@ -46,12 +50,14 @@ void SymEditSettings::Save() const settings.setValue("window/width", Size.width()); settings.setValue("window/height", Size.height()); - settings.setValue("editor/fill", Values.at("FillItem")); - settings.setValue("editor/align", Values.at("Alignment")); - settings.setValue("editor/width", Values.at("LineWidth")); - settings.setValue("editor/size", Values.at("TextSize")); - settings.setValue("editor/snap", Values.at("SnapGrid")); - settings.setValue("editor/tool", Values.at("Tool")); + settings.setValue("editor/fill", IntValues.at("FillItem")); + settings.setValue("editor/align", IntValues.at("Alignment")); + settings.setValue("editor/width", IntValues.at("LineWidth")); + settings.setValue("editor/size", IntValues.at("TextSize")); + settings.setValue("editor/snap", IntValues.at("SnapGrid")); + settings.setValue("editor/tool", IntValues.at("Tool")); + + settings.setValue("editor/text", TextValues.at("TextValue")); } // @@ -106,6 +112,7 @@ QSize SymEditManager::getWindowSize() const return Settings.Size; } +//@{ //! Set setting value. /*! \param name Setting name. @@ -113,10 +120,17 @@ QSize SymEditManager::getWindowSize() const */ void SymEditManager::setIntSetting(QString name, int value) { - if ( Settings.Values.find(name) != Settings.Values.end() ) - Settings.Values.at(name) = value; + if ( Settings.IntValues.find(name) != Settings.IntValues.end() ) + Settings.IntValues.at(name) = value; } +void SymEditManager::setTextSetting(QString name, QString value) +{ + if ( Settings.TextValues.find(name) != Settings.TextValues.end() ) + Settings.TextValues.at(name) = value; +} +//@} +//@{ //! Get setting value. /*! \param name Setting name. @@ -124,10 +138,17 @@ void SymEditManager::setIntSetting(QString name, int value) */ int SymEditManager::getIntSetting(QString name) const { - if ( Settings.Values.find(name) != Settings.Values.end() ) - return Settings.Values.at(name); + if ( Settings.IntValues.find(name) != Settings.IntValues.end() ) + return Settings.IntValues.at(name); return 0; } +QString SymEditManager::getTextSetting(QString name) const +{ + if ( Settings.TextValues.find(name) != Settings.TextValues.end() ) + return Settings.TextValues.at(name); + return QString(); +} +//@} //! Get symbol as string. /*! @@ -25,7 +25,8 @@ private: QPoint Position; //!< Window position. QSize Size; //!< Window size. - std::map<QString, int> Values; //!< Setting values. + std::map<QString, int> IntValues; //!< Integer setting values. + std::map<QString, QString> TextValues; //!< String setting values. }; //! Manager class. @@ -47,6 +48,8 @@ public: Q_INVOKABLE void setIntSetting(QString name, int value); Q_INVOKABLE int getIntSetting(QString name) const; + Q_INVOKABLE void setTextSetting(QString name, QString value); + Q_INVOKABLE QString getTextSetting(QString name) const; Q_INVOKABLE QString getSymbol() const; |
