diff options
| author | Mikko Syrjä <mikko@3d-system.fi> | 2019-03-14 23:58:56 +0200 |
|---|---|---|
| committer | Mikko Syrjä <mikko@3d-system.fi> | 2019-03-14 23:58:56 +0200 |
| commit | b9e74b0ccea06504a630382ab5eb86341b831db6 (patch) | |
| tree | 826f59abb9d25fb95860e63eccceb2d943bbdfb8 | |
| parent | e5f79528d287a14aa1c2c2a891eef02d436f63de (diff) | |
| download | symedit-b9e74b0ccea06504a630382ab5eb86341b831db6.tar.gz symedit-b9e74b0ccea06504a630382ab5eb86341b831db6.zip | |
Open, save and tool fixes.
| -rw-r--r-- | Editor.qml | 10 | ||||
| -rw-r--r-- | image/circle_diameter.kra (renamed from image/circle_radius.kra) | bin | 462027 -> 462027 bytes | |||
| -rw-r--r-- | image/circle_diameter.png (renamed from image/circle_radius.png) | bin | 1044 -> 1044 bytes | |||
| -rw-r--r-- | image/quarter_radius.kra | bin | 0 -> 453637 bytes | |||
| -rw-r--r-- | image/semi_diameter.kra | bin | 0 -> 457481 bytes | |||
| -rw-r--r-- | image/semi_diameter.png (renamed from image/semi_radius.png) | bin | 822 -> 822 bytes | |||
| -rw-r--r-- | locale/symedit.en_GB.ts | 30 | ||||
| -rw-r--r-- | locale/symedit.fi_FI.ts | 24 | ||||
| -rw-r--r-- | main.cpp | 6 | ||||
| -rw-r--r-- | main.qml | 6 | ||||
| -rw-r--r-- | qml.qrc | 4 | ||||
| -rw-r--r-- | symedit.cpp | 127 | ||||
| -rw-r--r-- | symedit.h | 7 | ||||
| -rw-r--r-- | symedit.pro | 6 |
14 files changed, 121 insertions, 99 deletions
@@ -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_radius.kra b/image/circle_diameter.kra Binary files differindex 259594e..259594e 100644 --- a/image/circle_radius.kra +++ b/image/circle_diameter.kra diff --git a/image/circle_radius.png b/image/circle_diameter.png Binary files differindex 73169c7..73169c7 100644 --- a/image/circle_radius.png +++ b/image/circle_diameter.png diff --git a/image/quarter_radius.kra b/image/quarter_radius.kra Binary files differnew file mode 100644 index 0000000..3c750fd --- /dev/null +++ b/image/quarter_radius.kra diff --git a/image/semi_diameter.kra b/image/semi_diameter.kra Binary files differnew file mode 100644 index 0000000..d40c7b7 --- /dev/null +++ b/image/semi_diameter.kra diff --git a/image/semi_radius.png b/image/semi_diameter.png Binary files differindex 277791b..277791b 100644 --- a/image/semi_radius.png +++ b/image/semi_diameter.png 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 @@ <source></source> <translation>Circle Corner</translation> </message> - <message id="id_menu_tool_circle_radius"> + <message id="id_menu_tool_circle_diameter"> <source></source> - <translation>Circle Radius</translation> + <translation>Circle Diameter</translation> </message> <message id="id_menu_tool_circle_center"> <source></source> @@ -219,15 +219,23 @@ <source></source> <translation>Circle corner</translation> </message> - <message id="id_tooltip_tool_circle_radius"> + <message id="id_tooltip_tool_circle_diameter"> <source></source> - <translation>Circle radius</translation> + <translation>Circle diameter</translation> </message> <message id="id_tooltip_tool_circle_center"> <source></source> <translation>Circle center</translation> </message> - <message id="id_tooltip_tool_text"> + <message id="id_tooltip_tool_semi_diameter"> + <source></source> + <translation>Semicircle diameter</translation> + </message> + <message id="id_tooltip_tool_quarter_radius"> + <source></source> + <translation>Quarter circle radius</translation> + </message> + <message id="id_tooltip_tool_text"> <source></source> <translation>Draw text</translation> </message> @@ -339,14 +347,6 @@ <source></source> <translation>Symbol editor for 3D-Win</translation> </message> - <message id="id_tooltip_tool_semi_radius"> - <source></source> - <translation type="unfinished"></translation> - </message> - <message id="id_tooltip_tool_quarter_radius"> - <source></source> - <translation type="unfinished"></translation> - </message> <message id="id_cli_symbol"> <source></source> <translation>symbol</translation> @@ -357,11 +357,11 @@ </message> <message id="id_cli_language"> <source></source> - <translation>language</translation> + <translation>lang</translation> </message> <message id="id_cli_language_description"> <source></source> - <translation>Application language abbreviation <language>.</translation> + <translation>Application language abbreviation <lang>.</translation> </message> <message id="id_cli_transfer_file"> <source></source> 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 @@ <source></source> <translation>Ympyrä kulmista</translation> </message> - <message id="id_menu_tool_circle_radius"> + <message id="id_menu_tool_circle_diameter"> <source></source> <translation>Ympyrä halkaisija</translation> </message> @@ -219,15 +219,23 @@ <source></source> <translation>Ympyrä kulmista</translation> </message> - <message id="id_tooltip_tool_circle_radius"> + <message id="id_tooltip_tool_circle_diameter"> <source></source> - <translation>Ympyrä halkasija</translation> + <translation>Ympyrä halkasija</translation> </message> <message id="id_tooltip_tool_circle_center"> <source></source> <translation>Ympyrä keskeltä</translation> </message> - <message id="id_tooltip_tool_text"> + <message id="id_tooltip_tool_semi_diameter"> + <source></source> + <translation>Puoliympyrä halkaisija</translation> + </message> + <message id="id_tooltip_tool_quarter_radius"> + <source></source> + <translation>Neljännesympyrä säde</translation> + </message> + <message id="id_tooltip_tool_text"> <source></source> <translation>Piirrä teksti</translation> </message> @@ -339,14 +347,6 @@ <source></source> <translation>3D-Win symbolieditori</translation> </message> - <message id="id_tooltip_tool_semi_radius"> - <source></source> - <translation type="unfinished"></translation> - </message> - <message id="id_tooltip_tool_quarter_radius"> - <source></source> - <translation type="unfinished"></translation> - </message> <message id="id_cli_symbol"> <source></source> <translation>symboli</translation> @@ -3,6 +3,7 @@ #include <QQmlApplicationEngine> #include <QCommandLineParser> #include <QSettings> +#include <QDir> #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); @@ -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 } @@ -9,7 +9,6 @@ <file>image/rectangle_center.png</file> <file>image/rectangle_corner.png</file> <file>image/circle_corner.png</file> - <file>image/circle_radius.png</file> <file>image/circle_center.png</file> <file>image/rotate_left.png</file> <file>image/rotate_right.png</file> @@ -35,7 +34,8 @@ <file>image/info_icon&48.png</file> <file>image/zoom_icon&48.png</file> <file>image/bubble_icon&48.png</file> - <file>image/semi_radius.png</file> <file>image/quarter_radius.png</file> + <file>image/circle_diameter.png</file> + <file>image/semi_diameter.png</file> </qresource> </RCC> 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; +} @@ -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 |
