diff options
author | Gard Spreemann <gspreemann@gmail.com> | 2019-01-14 17:45:44 +0100 |
---|---|---|
committer | Gard Spreemann <gspreemann@gmail.com> | 2019-01-14 17:45:44 +0100 |
commit | 8074365997835ec3e93ee2aa1eadb3a794437066 (patch) | |
tree | 6f87d32435c8214c77c9e8103ca4e1d697ae02d5 | |
parent | 5aef304fa112d4b11e401671900877d3c844e07d (diff) | |
parent | d4b6e9839823e27af646a915436462254758e053 (diff) |
Merge tag 'v2.1.2' into debian/sid
-rw-r--r-- | .appveyor.yml | 6 | ||||
-rw-r--r-- | .travis.yml | 49 | ||||
-rwxr-xr-x | deploy-osx.sh | 20 | ||||
-rw-r--r-- | scripts/gh-get.py | 22 | ||||
-rw-r--r-- | scripts/gh-list.py | 11 | ||||
-rw-r--r-- | scripts/gh-push.py | 34 | ||||
-rw-r--r-- | scripts/gh.py | 32 | ||||
-rw-r--r-- | src/data/edge.cpp | 12 | ||||
-rw-r--r-- | src/data/edge.h | 2 | ||||
-rw-r--r-- | src/gui/edgeitem.cpp | 4 | ||||
-rw-r--r-- | src/gui/mainmenu.cpp | 6 | ||||
-rw-r--r-- | src/gui/mainmenu.h | 1 | ||||
-rw-r--r-- | src/gui/mainmenu.ui | 9 | ||||
-rw-r--r-- | src/gui/tikzscene.cpp | 19 | ||||
-rw-r--r-- | src/gui/tikzscene.h | 2 | ||||
-rw-r--r-- | src/gui/undocommands.cpp | 30 | ||||
-rw-r--r-- | src/gui/undocommands.h | 11 | ||||
-rw-r--r-- | src/tikzit.h | 2 | ||||
-rw-r--r-- | tikzit.pro | 2 |
19 files changed, 232 insertions, 42 deletions
diff --git a/.appveyor.yml b/.appveyor.yml index f54801e..9f2828f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -31,9 +31,11 @@ build_script: after_build: - sh: ./deploy-linux.sh - sh: mv dist/tikzit.tar.gz tikzit-linux.tar.gz - - sh: appveyor PushArtifact tikzit-linux.tar.gz + #- sh: appveyor PushArtifact tikzit-linux.tar.gz + - sh: python scripts/gh-push.py tikzit-linux.tar.gz - cmd: deploy-win.bat - cmd: move dist\tikzit.zip tikzit-win.zip - - cmd: appveyor PushArtifact tikzit-win.zip + - cmd: python scripts\gh-push.py tikzit-win.zip + #- cmd: appveyor PushArtifact tikzit-win.zip diff --git a/.travis.yml b/.travis.yml index 52de1f4..056b543 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,43 +1,26 @@ language: cpp - branches: only: - - master - + - master matrix: - include: + include: - os: osx compiler: clang env: - - FILE=tikzit-osx.dmg - - QTVER=511 - - DEPLOY_TIKZIT=1 - # - os: osx - # compiler: clang - # env: - # - FILE=tikzit-osx-mountain.dmg - # - QTVER=56 - # - DEPLOY_TIKZIT=1 - -before_install: - # - '[[ "$TRAVIS_OS_NAME" != osx || "$QTVER" != 56 ]] || curl https://raw.githubusercontent.com/GiovanniBussi/macports-ci/master/macports-ci > macports-ci' - # - '[[ "$TRAVIS_OS_NAME" != osx || "$QTVER" != 56 ]] || source macports-ci install' - - - + - FILE=tikzit-osx.dmg + - QTVER=511 + - DEPLOY_TIKZIT=1 +before_install: install: - - '[[ "$TRAVIS_OS_NAME" != osx || "$QTVER" != 511 ]] || brew install qt5' - - '[[ "$TRAVIS_OS_NAME" != osx || "$QTVER" != 511 ]] || brew link --force qt5' - - '[[ "$TRAVIS_OS_NAME" != osx || "$QTVER" != 511 ]] || brew install poppler --with-qt' - # - '[[ "$TRAVIS_OS_NAME" != osx || "$QTVER" != 56 ]] || sudo port -N -k install qt56' - # - '[[ "$TRAVIS_OS_NAME" != osx || "$QTVER" != 56 ]] || export PATH=/opt/local/libexec/qt5/bin:$PATH' - +- brew update +- brew install qt5 +- brew link --force qt5 +- brew install poppler --with-qt script: - - qmake -v - - qmake -r - - make - - '[[ "$TRAVIS_OS_NAME" != osx ]] || (chmod +x deploy-osx.sh && ./deploy-osx.sh && mv tikzit.dmg $FILE)' - - '[[ "$DEPLOY_TIKZIT" != 1 ]] || curl --upload-file $FILE https://transfer.sh/$FILE' - +- qmake -v +- qmake -r +- make +- '(chmod +x deploy-osx.sh && ./deploy-osx.sh && mv tikzit.dmg $FILE)' +- python scripts/gh-push.py $FILE notifications: - email: false
\ No newline at end of file + email: false diff --git a/deploy-osx.sh b/deploy-osx.sh index 98043c0..dd9efcd 100755 --- a/deploy-osx.sh +++ b/deploy-osx.sh @@ -4,10 +4,24 @@ # copy in libraries and set (most) library paths macdeployqt tikzit.app -# macdeployqt misses this path for some reason, so fix it +# macdeployqt doesn't fix the path to libpoppler for some reason, so we do it by hand cd tikzit.app/Contents/Frameworks -install_name_tool -id "@executable_path/../Frameworks/libpoppler.83.dylib" libpoppler.83.dylib -install_name_tool -change /usr/local/Cellar/poppler/0.72.0/lib/libpoppler.83.dylib "@executable_path/../Frameworks/libpoppler.83.dylib" libpoppler-qt5.1.dylib + +POPPLER_QT=`ls libpoppler-qt*` +POPPLER_PATH=`otool -L $POPPLER_QT | sed -n 's!.*\(/usr.*\(libpoppler\..*dylib\)\).*!\1!p'` +POPPLER_LIB=`otool -L $POPPLER_QT | sed -n 's!.*\(/usr.*\(libpoppler\..*dylib\)\).*!\2!p'` + +echo "Found $POPPLER_QT and $POPPLER_LIB" + +if [ "$POPPLER_PATH" != "" ]; then + echo "Replacing $POPPLER_PATH with relative path..." + install_name_tool -id "@executable_path/../Frameworks/$POPPLER_LIB" $POPPLER_LIB + install_name_tool -change $POPPLER_PATH "@executable_path/../Frameworks/$POPPLER_LIB" $POPPLER_QT +else + echo "Poppler already has relative path, so nothing to do." +fi + + cd ../../.. # create DMG diff --git a/scripts/gh-get.py b/scripts/gh-get.py new file mode 100644 index 0000000..bf95d97 --- /dev/null +++ b/scripts/gh-get.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +from gh import gh, pr +import sys, os + +filter = None +if len(sys.argv) == 2: + filter = sys.argv[1] + +tok = os.getenv('GITHUB_TOKEN') + +draft = [r for r in gh('releases') if r['draft']][0] + +for a in draft['assets']: + if filter == None or filter in a['name']: + print('Downloading ' + a['name']) + b = gh('releases/assets/%s?access_token=%s' % (a['id'], tok), + ['-L', '-H', 'Accept: application/octet-stream'], + parse=False, quiet=False, auth=False) + f = open(a['name'], 'w') + f.write(b) + f.close() diff --git a/scripts/gh-list.py b/scripts/gh-list.py new file mode 100644 index 0000000..a2e7955 --- /dev/null +++ b/scripts/gh-list.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python + +from gh import gh, pr +import os + +tok = os.getenv('GITHUB_TOKEN') + +draft = [r for r in gh('releases') if r['draft']][0] + +for a in draft['assets']: + print(a['browser_download_url']) diff --git a/scripts/gh-push.py b/scripts/gh-push.py new file mode 100644 index 0000000..dd3b940 --- /dev/null +++ b/scripts/gh-push.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +import sys, os, re +from gh import gh + +if len(sys.argv) != 2: + print("Usage: python gh-push.py FILENAME") + sys.exit(1) + +f = sys.argv[1] +fname = os.path.basename(f) + +print('Pulling info on draft release...') +draft = [r for r in gh('releases') if r['draft']][0] +print('Found: ' + draft['name']) + +existing = [a for a in draft['assets'] if a['name'] == fname] +if (len(existing) > 0): + print('Asset %s exists, deleting.' % fname) + gh('releases/assets/' + str(existing[0]['id']), + ['-X', 'DELETE']) + +print('Uploading %s...' % f) + +upload_url = re.sub( + '\\{.*\\}', '?name=' + fname, + draft['upload_url']) + +resp = gh(upload_url, [ + '-H', 'Content-type: application/octet-stream', + '--data-binary', '@' + f + ]) + +print('Done.') diff --git a/scripts/gh.py b/scripts/gh.py new file mode 100644 index 0000000..81db1b2 --- /dev/null +++ b/scripts/gh.py @@ -0,0 +1,32 @@ +import sys, os, json +from subprocess import Popen, PIPE + +api_url = 'https://api.github.com/repos/tikzit/tikzit' + +tok = os.getenv('GITHUB_TOKEN', '') + +if tok == '': + print("Must set GITHUB_TOKEN environment variable.") + sys.exit(1) + +# pretty-print JSON responses +def pr(j): print(json.dumps(j, indent=2)) + +# call GitHub API with curl +def gh(s, args=[], quiet=True, parse=True, auth=True): + cmd = (["curl"] + + (["-s"] if quiet else []) + + args + + (["-H", "Authorization: token " + tok] if auth else []) + + [s if 'https://' in s else api_url + '/' + s]) + # ONLY UN-COMMENT FOR TESTING: + # print(' '.join(cmd)) + p = Popen(cmd, stdout=PIPE) + resp = p.stdout.read() + if parse: return json.loads(resp if resp else '{}') + else: return resp + +def get_release(n): + rs = [r for r in gh('releases') if r['name'] == n] + if len(rs) > 0: return rs[0] + else: return None diff --git a/src/data/edge.cpp b/src/data/edge.cpp index fcd9959..4803547 100644 --- a/src/data/edge.cpp +++ b/src/data/edge.cpp @@ -365,6 +365,18 @@ void Edge::setWeight(qreal weight) _weight = weight;
}
+void Edge::reverse()
+{
+ Node *n = _source;
+ _source = _target;
+ _target = n;
+ int a = _inAngle;
+ _inAngle = _outAngle;
+ _outAngle = a;
+ _bend = -_bend;
+ updateData();
+}
+
int Edge::tikzLine() const
{
return _tikzLine;
diff --git a/src/data/edge.h b/src/data/edge.h index 909824b..954145f 100644 --- a/src/data/edge.h +++ b/src/data/edge.h @@ -81,6 +81,8 @@ public: void setOutAngle(int outAngle);
void setWeight(qreal weight);
+ void reverse();
+
int tikzLine() const;
void setTikzLine(int tikzLine);
diff --git a/src/gui/edgeitem.cpp b/src/gui/edgeitem.cpp index 454a276..45ae159 100644 --- a/src/gui/edgeitem.cpp +++ b/src/gui/edgeitem.cpp @@ -167,11 +167,11 @@ void EdgeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidge QRectF rect = fm.boundingRect("<>"); if (sc->highlightHeads()) { - QPointF headMark(_edge->head().x(), _edge->head().y() + _edge->cpDist() - 0.25); + QPointF headMark(_edge->target()->point().x(), _edge->target()->point().y() + _edge->cpDist() - 0.25); rect.moveCenter(toScreen(headMark)); painter->drawText(rect, Qt::AlignCenter, "<>"); } else if (sc->highlightTails()) { - QPointF tailMark(_edge->tail().x(), _edge->tail().y() + _edge->cpDist() - 0.25); + QPointF tailMark(_edge->source()->point().x(), _edge->source()->point().y() + _edge->cpDist() - 0.25); rect.moveCenter(toScreen(tailMark)); painter->drawText(rect, Qt::AlignCenter, "<>"); } diff --git a/src/gui/mainmenu.cpp b/src/gui/mainmenu.cpp index 6f4f8db..d291390 100644 --- a/src/gui/mainmenu.cpp +++ b/src/gui/mainmenu.cpp @@ -227,6 +227,12 @@ void MainMenu::on_actionExtendRight_triggered() tikzit->activeWindow()->tikzScene()->extendSelectionRight(); } +void MainMenu::on_actionReverse_Edge_Direction_triggered() +{ + if (tikzit->activeWindow() != 0) + tikzit->activeWindow()->tikzScene()->reverseSelectedEdges(); +} + // Tikz void MainMenu::on_actionParse_triggered() diff --git a/src/gui/mainmenu.h b/src/gui/mainmenu.h index 4d672cd..287019c 100644 --- a/src/gui/mainmenu.h +++ b/src/gui/mainmenu.h @@ -65,6 +65,7 @@ public slots: void on_actionExtendDown_triggered(); void on_actionExtendLeft_triggered(); void on_actionExtendRight_triggered(); + void on_actionReverse_Edge_Direction_triggered(); // Tools void on_actionParse_triggered(); diff --git a/src/gui/mainmenu.ui b/src/gui/mainmenu.ui index 08067aa..ddba6f0 100644 --- a/src/gui/mainmenu.ui +++ b/src/gui/mainmenu.ui @@ -72,6 +72,7 @@ <addaction name="separator"/> <addaction name="menuReorder"/> <addaction name="menuTransform"/> + <addaction name="actionReverse_Edge_Direction"/> </widget> <widget class="QMenu" name="menuTikz"> <property name="title"> @@ -365,6 +366,14 @@ <string>Preferences...</string> </property> </action> + <action name="actionReverse_Edge_Direction"> + <property name="text"> + <string>Reverse Edge Direction</string> + </property> + <property name="shortcut"> + <string>Ctrl+/</string> + </property> + </action> <addaction name="menuFile"/> <addaction name="menuEdit"/> <addaction name="menuView"/> diff --git a/src/gui/tikzscene.cpp b/src/gui/tikzscene.cpp index 4d14f43..9ef4c20 100644 --- a/src/gui/tikzscene.cpp +++ b/src/gui/tikzscene.cpp @@ -212,6 +212,25 @@ void TikzScene::reorderSelection(bool toFront) _tikzDocument->undoStack()->push(cmd); } +void TikzScene::reverseSelectedEdges() +{ + // grab all the edges which are either selected themselves, or where + // both their source and target nodes are selected + QSet<Edge*> es; + foreach (Edge *e, graph()->edges()) { + if ((_edgeItems[e] && _edgeItems[e]->isSelected()) || + (_nodeItems[e->source()] && _nodeItems[e->target()] && + _nodeItems[e->source()]->isSelected() && + _nodeItems[e->target()]->isSelected())) + { + es << e; + } + } + + ReverseEdgesCommand *cmd = new ReverseEdgesCommand(this, es); + _tikzDocument->undoStack()->push(cmd); +} + void TikzScene::refreshZIndices() { qreal z = 0.0; diff --git a/src/gui/tikzscene.h b/src/gui/tikzscene.h index 3e46f6d..e2068eb 100644 --- a/src/gui/tikzscene.h +++ b/src/gui/tikzscene.h @@ -77,6 +77,8 @@ public: void reorderSelection(bool toFront); + void reverseSelectedEdges(); + void getSelection(QSet<Node*> &selNodes, QSet<Edge*> &selEdges); QSet<Node*> getSelectedNodes(); diff --git a/src/gui/undocommands.cpp b/src/gui/undocommands.cpp index 82b9455..91509ed 100644 --- a/src/gui/undocommands.cpp +++ b/src/gui/undocommands.cpp @@ -539,3 +539,33 @@ void ReorderCommand::redo() _scene->refreshZIndices(); GraphUpdateCommand::redo(); } + +ReverseEdgesCommand::ReverseEdgesCommand(TikzScene *scene, + QSet<Edge *> edgeSet, + QUndoCommand *parent) : + GraphUpdateCommand(scene, parent), _edgeSet(edgeSet) +{ +} + +void ReverseEdgesCommand::undo() +{ + EdgeItem *ei; + foreach (Edge *e, _edgeSet) { + e->reverse(); + ei = _scene->edgeItems()[e]; + if (ei) ei->readPos(); + } + GraphUpdateCommand::undo(); +} + +void ReverseEdgesCommand::redo() +{ + EdgeItem *ei; + foreach (Edge *e, _edgeSet) { + e->reverse(); + ei = _scene->edgeItems()[e]; + if (ei) ei->readPos(); + } + GraphUpdateCommand::redo(); +} + diff --git a/src/gui/undocommands.h b/src/gui/undocommands.h index ff51c90..42fed30 100644 --- a/src/gui/undocommands.h +++ b/src/gui/undocommands.h @@ -78,6 +78,17 @@ private: int _newOutAngle; }; +class ReverseEdgesCommand : public GraphUpdateCommand +{ +public: + explicit ReverseEdgesCommand(TikzScene *scene, QSet<Edge*> edgeSet, + QUndoCommand *parent = nullptr); + void undo() override; + void redo() override; +private: + QSet<Edge*> _edgeSet; +}; + class DeleteCommand : public GraphUpdateCommand { public: diff --git a/src/tikzit.h b/src/tikzit.h index 743e3f0..855efeb 100644 --- a/src/tikzit.h +++ b/src/tikzit.h @@ -49,7 +49,7 @@ #ifndef TIKZIT_H #define TIKZIT_H -#define TIKZIT_VERSION "2.1.1" +#define TIKZIT_VERSION "2.1.2" #include "mainwindow.h" #include "mainmenu.h" @@ -2,7 +2,7 @@ QT += core gui widgets network -VERSION = 2.1.1 +VERSION = 2.1.2 test { CONFIG += testcase |