From b9e74b0ccea06504a630382ab5eb86341b831db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikko=20Syrj=C3=A4?= Date: Thu, 14 Mar 2019 23:58:56 +0200 Subject: Open, save and tool fixes. --- Editor.qml | 10 ++-- image/circle_diameter.kra | Bin 0 -> 462027 bytes image/circle_diameter.png | Bin 0 -> 1044 bytes image/circle_radius.kra | Bin 462027 -> 0 bytes image/circle_radius.png | Bin 1044 -> 0 bytes image/quarter_radius.kra | Bin 0 -> 453637 bytes image/semi_diameter.kra | Bin 0 -> 457481 bytes image/semi_diameter.png | Bin 0 -> 822 bytes image/semi_radius.png | Bin 822 -> 0 bytes locale/symedit.en_GB.ts | 30 +++++------ locale/symedit.fi_FI.ts | 24 ++++----- main.cpp | 6 ++- main.qml | 6 +-- qml.qrc | 4 +- symedit.cpp | 127 +++++++++++++++++++++++++--------------------- symedit.h | 7 ++- symedit.pro | 6 ++- 17 files changed, 121 insertions(+), 99 deletions(-) create mode 100644 image/circle_diameter.kra create mode 100644 image/circle_diameter.png delete mode 100644 image/circle_radius.kra delete mode 100644 image/circle_radius.png create mode 100644 image/quarter_radius.kra create mode 100644 image/semi_diameter.kra create mode 100644 image/semi_diameter.png delete mode 100644 image/semi_radius.png diff --git a/Editor.qml b/Editor.qml index 396ee06..21e42a8 100644 --- a/Editor.qml +++ b/Editor.qml @@ -10,7 +10,7 @@ Rectangle RectCenter = 21, RectCorner = 22, CircleCorner = 31, - CircleRadius = 32, + CircleDiameter = 32, CircleCenter = 33, ArcSemi = 41, ArcQuarter = 42, @@ -35,7 +35,7 @@ Rectangle property int endy: 0 property string paintcolor: "black" - property string editcolor: "red" + property string editcolor: "brown" property string gridcolor: "gray" property string backcolor: "white" property string graycolor: "lightgray" @@ -122,7 +122,7 @@ Rectangle centerx = (startx + endx) / 2 centery = (starty + endy) / 2 } - else if ( tool === Editor.Tool.CircleRadius ) + else if ( tool === Editor.Tool.CircleDiameter ) { radius = Math.sqrt(deltax * deltax + deltay * deltay) / 2 centerx = (startx + endx) / 2 @@ -252,7 +252,7 @@ Rectangle function paintgrid(context) { - context.lineWidth = 0.2 + context.lineWidth = 0.4 context.strokeStyle = gridcolor if ( viewgrid && !preview ) { @@ -372,7 +372,7 @@ Rectangle centerx = (startx + mousex) / 2 centery = (starty + mousey) / 2 } - else if ( tool === Editor.Tool.CircleRadius ) + else if ( tool === Editor.Tool.CircleDiameter ) { radius = Math.sqrt(deltax * deltax + deltay * deltay) / 2 centerx = (startx + mousex) / 2 diff --git a/image/circle_diameter.kra b/image/circle_diameter.kra new file mode 100644 index 0000000..259594e Binary files /dev/null and b/image/circle_diameter.kra differ diff --git a/image/circle_diameter.png b/image/circle_diameter.png new file mode 100644 index 0000000..73169c7 Binary files /dev/null and b/image/circle_diameter.png differ diff --git a/image/circle_radius.kra b/image/circle_radius.kra deleted file mode 100644 index 259594e..0000000 Binary files a/image/circle_radius.kra and /dev/null differ diff --git a/image/circle_radius.png b/image/circle_radius.png deleted file mode 100644 index 73169c7..0000000 Binary files a/image/circle_radius.png and /dev/null differ diff --git a/image/quarter_radius.kra b/image/quarter_radius.kra new file mode 100644 index 0000000..3c750fd Binary files /dev/null and b/image/quarter_radius.kra differ diff --git a/image/semi_diameter.kra b/image/semi_diameter.kra new file mode 100644 index 0000000..d40c7b7 Binary files /dev/null and b/image/semi_diameter.kra differ diff --git a/image/semi_diameter.png b/image/semi_diameter.png new file mode 100644 index 0000000..277791b Binary files /dev/null and b/image/semi_diameter.png differ diff --git a/image/semi_radius.png b/image/semi_radius.png deleted file mode 100644 index 277791b..0000000 Binary files a/image/semi_radius.png and /dev/null differ diff --git a/locale/symedit.en_GB.ts b/locale/symedit.en_GB.ts index 197b567..6d1c74e 100644 --- a/locale/symedit.en_GB.ts +++ b/locale/symedit.en_GB.ts @@ -119,9 +119,9 @@ Circle Corner - + - Circle Radius + Circle Diameter @@ -219,15 +219,23 @@ Circle corner - + - Circle radius + Circle diameter Circle center - + + + Semicircle diameter + + + + Quarter circle radius + + Draw text @@ -339,14 +347,6 @@ Symbol editor for 3D-Win - - - - - - - - symbol @@ -357,11 +357,11 @@ - language + lang - Application language abbreviation <language>. + Application language abbreviation <lang>. diff --git a/locale/symedit.fi_FI.ts b/locale/symedit.fi_FI.ts index 2ba3bf0..6fe0c60 100644 --- a/locale/symedit.fi_FI.ts +++ b/locale/symedit.fi_FI.ts @@ -119,7 +119,7 @@ Ympyrä kulmista - + Ympyrä halkaisija @@ -219,15 +219,23 @@ Ympyrä kulmista - + - Ympyrä halkasija + Ympyrä halkasija Ympyrä keskeltä - + + + Puoliympyrä halkaisija + + + + Neljännesympyrä säde + + Piirrä teksti @@ -339,14 +347,6 @@ 3D-Win symbolieditori - - - - - - - - symboli diff --git a/main.cpp b/main.cpp index 328a646..a61e36b 100644 --- a/main.cpp +++ b/main.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "symedit.h" @@ -43,7 +44,10 @@ int main(int argc, char *argv[]) QString filename; const QStringList arguments = parser.positionalArguments(); if ( arguments.size() ) - filename = arguments.at(0); + { + if ( !QDir::isAbsolutePath(filename = arguments.at(0)) ) + filename.insert(0, '/').insert(0, QDir::currentPath()); + } bool transfer = parser.isSet(transferoption); QString symbol = parser.value(symboloption); QString language = parser.value(languageoption); diff --git a/main.qml b/main.qml index 32b64c9..7471dbb 100644 --- a/main.qml +++ b/main.qml @@ -91,7 +91,7 @@ ApplicationWindow MenuTool { text: qsTrId("id_menu_tool_rect_center"); tool: Editor.Tool.RectCenter } MenuSeparator { } MenuTool { text: qsTrId("id_menu_tool_circle_corner"); tool: Editor.Tool.CircleCorner } - MenuTool { text: qsTrId("id_menu_tool_circle_radius"); tool: Editor.Tool.CircleRadius } + MenuTool { text: qsTrId("id_menu_tool_circle_diameter"); tool: Editor.Tool.CircleDiameter } MenuTool { text: qsTrId("id_menu_tool_circle_center"); tool: Editor.Tool.CircleCenter } MenuSeparator { } MenuTool { text: qsTrId("id_menu_tool_arc_semi"); tool: Editor.Tool.ArcSemi } @@ -155,10 +155,10 @@ ApplicationWindow BarTool { image: "image/rectangle_center.png"; tooltip: qsTrId("id_tooltip_tool_rect_center"); tool: Editor.Tool.RectCenter } BarSeparator { } BarTool { image: "image/circle_corner.png"; tooltip: qsTrId("id_tooltip_tool_circle_corner"); tool: Editor.Tool.CircleCorner } - BarTool { image: "image/circle_radius.png"; tooltip: qsTrId("id_tooltip_tool_circle_radius"); tool: Editor.Tool.CircleRadius } + BarTool { image: "image/circle_diameter.png"; tooltip: qsTrId("id_tooltip_tool_circle_diameter"); tool: Editor.Tool.CircleDiameter } BarTool { image: "image/circle_center.png"; tooltip: qsTrId("id_tooltip_tool_circle_center"); tool: Editor.Tool.CircleCenter } BarSeparator { } - BarTool { image: "image/semi_radius.png"; tooltip: qsTrId("id_tooltip_tool_semi_radius"); tool: Editor.Tool.ArcSemi } + BarTool { image: "image/semi_diameter.png"; tooltip: qsTrId("id_tooltip_tool_semi_diameter"); tool: Editor.Tool.ArcSemi } BarTool { image: "image/quarter_radius.png"; tooltip: qsTrId("id_tooltip_tool_quarter_radius"); tool: Editor.Tool.ArcQuarter } BarSeparator { } BarTool { image: "image/text.png"; tooltip: qsTrId("id_tooltip_tool_text"); tool: Editor.Tool.Text } diff --git a/qml.qrc b/qml.qrc index a72d62c..8224bc9 100644 --- a/qml.qrc +++ b/qml.qrc @@ -9,7 +9,6 @@ image/rectangle_center.png image/rectangle_corner.png image/circle_corner.png - image/circle_radius.png image/circle_center.png image/rotate_left.png image/rotate_right.png @@ -35,7 +34,8 @@ image/info_icon&48.png image/zoom_icon&48.png image/bubble_icon&48.png - image/semi_radius.png image/quarter_radius.png + image/circle_diameter.png + image/semi_diameter.png diff --git a/symedit.cpp b/symedit.cpp index 9b14525..7f65edd 100644 --- a/symedit.cpp +++ b/symedit.cpp @@ -89,11 +89,7 @@ SymEditManager::SymEditManager(const QString& filename, const QString& symbol) Settings.Load(); if ( !FileName.isEmpty() ) - { - QUrl fileurl; - fileurl.fromLocalFile(FileName); - open(fileurl); - } + open(FileName); if ( !symbol.isEmpty() ) Symbol.Load(symbol); @@ -439,58 +435,6 @@ bool SymEditManager::raiseItem(int dir) return false; } -//! Open symbol file. -/*! - \param fileurl File name as URL. - \return True for success. -*/ -bool SymEditManager::open(QUrl fileurl) -{ - QString filestring = fileurl.toString(); - int index = filestring.lastIndexOf('/') + 1; - QString directory = filestring.left(index); - setTextSetting("Directory", directory); - - QString filename = fileurl.toLocalFile(); - QFile file(filename); - if ( file.open(QIODevice::ReadOnly | QIODevice::Text) ) - { - QTextStream input(&file); - Symbol.Load(input.readLine()); - FileName = filename; - return true; - } - return false; -} - -//! Save symbol file. -/*! - \param fileurl File name as URL. - \return True for success. -*/ -bool SymEditManager::save(QUrl fileurl) -{ - QString filename = FileName; - if ( !fileurl.isEmpty() ) - { - QString filestring = fileurl.toString(); - int index = filestring.lastIndexOf('/') + 1; - QString directory = filestring.left(index); - setTextSetting("Directory", directory); - filename = fileurl.toLocalFile(); - } - - QFile file(filename); - if ( file.open(QIODevice::WriteOnly | QIODevice::Text) ) - { - QTextStream output(&file); - output << getSymbol(); - FileName = filename; - return true; - } - return false; -} - //! Undo edit operation. /*! \param undo True undoes, false redoes. @@ -543,3 +487,72 @@ void SymEditManager::help(QString topic) const path.append("/help/fin/index.html"); QDesktopServices::openUrl(QUrl(path)); } + +//! Open symbol file. +/*! + \param fileurl File name as URL. + \return True for success. +*/ +bool SymEditManager::open(QUrl fileurl) +{ + QString filestring = fileurl.toString(); + int index = filestring.lastIndexOf('/') + 1; + QString directory = filestring.left(index); + setTextSetting("Directory", directory); + return open(fileurl.toLocalFile()); +} + +//! Save symbol file. +/*! + \param fileurl File name as URL. + \return True for success. +*/ +bool SymEditManager::save(QUrl fileurl) +{ + QString filename = FileName; + if ( !fileurl.isEmpty() ) + { + QString filestring = fileurl.toString(); + int index = filestring.lastIndexOf('/') + 1; + QString directory = filestring.left(index); + setTextSetting("Directory", directory); + filename = fileurl.toLocalFile(); + } + return save(filename); +} + +//! Open symbol file. +/*! + \param filename Full file path. + \return True for success. +*/ +bool SymEditManager::open(const QString& filename) +{ + QFile file(filename); + if ( file.open(QIODevice::ReadOnly | QIODevice::Text) ) + { + QTextStream input(&file); + Symbol.Load(input.readLine()); + FileName = filename; + return true; + } + return false; +} + +//! Save symbol file. +/*! + \param filename Full file path. + \return True for success. +*/ +bool SymEditManager::save(const QString& filename) +{ + QFile file(filename); + if ( file.open(QIODevice::WriteOnly | QIODevice::Text) ) + { + QTextStream output(&file); + output << getSymbol(); + FileName = filename; + return true; + } + return false; +} diff --git a/symedit.h b/symedit.h index 89223f0..03129da 100644 --- a/symedit.h +++ b/symedit.h @@ -81,11 +81,14 @@ public: Q_INVOKABLE void rotateSymbol(int dir); Q_INVOKABLE bool raiseItem(int dir); + Q_INVOKABLE bool undo(bool undo); + Q_INVOKABLE void help(QString topic) const; + Q_INVOKABLE bool open(QUrl fileurl); Q_INVOKABLE bool save(QUrl fileurl); - Q_INVOKABLE bool undo(bool undo); - Q_INVOKABLE void help(QString topic) const; + bool open(const QString& filename); + bool save(const QString& filename); private: void undosave(); diff --git a/symedit.pro b/symedit.pro index 68e2b75..e91ed44 100644 --- a/symedit.pro +++ b/symedit.pro @@ -43,7 +43,6 @@ DISTFILES += \ lupdate.sh \ image/circle_center.kra \ image/circle_corner.kra \ - image/circle_radius.kra \ image/delete.kra \ image/polyline.kra \ image/rectangle_center.kra \ @@ -67,4 +66,7 @@ DISTFILES += \ help/eng/usage.rst \ help/eng/Makefile \ help/eng/conf.py \ - LICENSE + LICENSE \ + image/circle_diameter.kra \ + image/semi_diameter.kra \ + image/quarter_radius.kra -- cgit v1.2.3