Showing with 130 additions and 28 deletions.
  1. +23 −18 .travis.yml
  2. +4 −0 CMakeLists.txt
  3. +80 −0 cmake/travis-mac.sh
  4. +1 −1 src/kst/kst2.desktop
  5. +2 −0 src/kst/x-kst.xml
  6. +18 −9 src/libkstapp/plotrenderitem.cpp
  7. +2 −0 src/libkstapp/plotrenderitem.h
41 changes: 23 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,30 @@
# Travis-CI Build for kst2
# see travis-ci.org for details

sudo: required
dist: trusty
#language: cpp


install:
- sudo apt-get -y update
- sudo apt-get -y install cmake g++-mingw-w64-i686 g++-mingw-w64-x86-64
#- sudo apt-get update
#- sudo apt-get remove cmake mingw32-binutils mingw32-runtime mingw32 mingw-w64 g++-mingw-w64 gcc-mingw-w64
#- sudo apt-get install m4 bison flex nsis-common nsis qt4-dev-tools subversion
#- sudo apt-get install libc6:i386 libgcc1:i386 gcc-4.6-base:i386 libstdc++5:i386 libstdc++6:i386 # cmake is 32bit

script:
#- ./cmake/travis.sh qt4
- ./cmake/travis.sh qt5
#- ./cmake/travis.sh qt5 x64
matrix:
include:
- os: osx
osx_image: xcode8.3
script: ./cmake/travis-mac.sh
- os: linux
sudo: required
dist: trusty


install:
- sudo apt-get -y update
- sudo apt-get -y install cmake g++-mingw-w64-i686 g++-mingw-w64-x86-64
#- sudo apt-get update
#- sudo apt-get remove cmake mingw32-binutils mingw32-runtime mingw32 mingw-w64 g++-mingw-w64 gcc-mingw-w64
#- sudo apt-get install m4 bison flex nsis-common nsis qt4-dev-tools subversion
#- sudo apt-get install libc6:i386 libgcc1:i386 gcc-4.6-base:i386 libstdc++5:i386 libstdc++6:i386 # cmake is 32bit

script:
#- ./cmake/travis.sh qt4
- ./cmake/travis.sh qt5
#- ./cmake/travis.sh qt5 x64

branches:
only:
- master

4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ if(APPLE OR kst_clang)
set(kst_pch 0 CACHE BOOL "Disable pch on Mac, not supported yet" FORCE)
endif()

if (APPLE)
set(CMAKE_MACOSX_RPATH 1)
endif()

if(kst_merge_files)
set(kst_pch 0 CACHE BOOL "Disable pch because we build merged" FORCE)
endif()
Expand Down
80 changes: 80 additions & 0 deletions cmake/travis-mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash

# Unofficial bash strict mode -- http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'


# Install dependencies
brew install qt gsl netcdf cfitsio libgetdata
export PATH="/usr/local/opt/qt/bin:$PATH"


# Build kst
./get-translations

mkdir -p build
cd build
rm -fr ./build # to allow us to run this script multiple times
cmake -Dkst_qt5=1 -Dkst_svnversion=1 -Dkst_dataobjects=1 -Dkst_3rdparty=1 -Dkst_release=1 ..
make -j7


# Add Qt to kst2.app, and replace references to the Qt outside of kst2.app with references
# to Qt inside kst2.app.
macdeployqt ./build/bin/kst2.app

lib_folders=(./build/bin/kst2.app/Contents/plugins/ ./build/bin/kst2.app/Contents/Frameworks/)
to_replace=()

# Copy external libraries to Frameworks and add the names of external libraries to to_replace.
# We don't do this for Qt libraries, because macdeployqt already did that for us.
for folder in "${lib_folders[@]}"; do
to_copy=($(find -E $folder -regex '.*\.(dylib|so)' -type f -exec otool -L {} \; | sort | uniq | grep '^\t/usr/local' | sed -e $'s/^\t//g' | sed -e $'s/ .*//g'))
echo "${to_copy[@]}" | xargs -J % cp -f % ./build/bin/kst2.app/Contents/Frameworks
to_replace+=("${to_copy[@]}")
chmod 755 $folder/*
done


# Remove references to external libraries.
# We're really stupid here and just try to replace all external references in everything in
# Frameworks and plugins.
# TODO(joshua): Use otool -L to figure out what to replace
for orig_lib in "${to_replace[@]}"; do
new_lib=$(echo $orig_lib | sed -e 's,.*/,@rpath/,g')
echo "Running install_name_tool on libraries to replace $orig_lib with $new_lib"
for folder in "${lib_folders[@]}"; do
files=($(find -E $folder -regex '.*\.(dylib|so)' -type f))
for file in "${files[@]}"; do
install_name_tool -change $orig_lib $new_lib $file
done
done
done


# Zip it!
date=$(date -u +"%Y.%m.%d-%H.%M")
bundle_name="kst-plot-$date-macos.zip"
pushd ./build/bin
zip -r "../../$bundle_name" ./kst2.app
popd


# Deploy it
kstbinary=kst-build
rm -rf $kstbinary
mkdir $kstbinary
cd $kstbinary
git init --quiet
git config user.name "travis"
git config user.email travis@noreply.org
git remote add origin git@github.com:Kst-plot/$kstbinary.git
git fetch origin master --quiet
git checkout master
git branch -D macos || true
git checkout -b macos
cp -f ../$bundle_name .
git add $bundle_name
git commit --quiet -m "Update Mac binary"
git push --quiet origin HEAD -f
2 changes: 1 addition & 1 deletion src/kst/kst2.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Exec=kst2 %f
Icon=kst
X-DocPath=kst2/index.html
MimeType=application/x-kst;
Categories=Qt;KDE;Education;Science;
Categories=Qt;KDE;Education;Science;DataVisualization;
Name=Kst2
Name[ast]=Kst2
Name[bs]=Kst2
Expand Down
2 changes: 2 additions & 0 deletions src/kst/x-kst.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
<comment xml:lang="ca">Fitxer de sessió del Kst</comment>
<comment xml:lang="ca@valencia">Fitxer de sessió del Kst</comment>
<comment xml:lang="cs">Soubor sezení Kst</comment>
<comment xml:lang="de">Kst-Sitzungsdatei</comment>
<comment xml:lang="es">Archivo de sesión de Kst</comment>
<comment xml:lang="it">File di sessione Kst</comment>
<comment xml:lang="nl">Sessiebestand in Kst</comment>
<comment xml:lang="pt">Ficheiro de Sessão do Kst</comment>
<comment xml:lang="sk">Súbor sedenia Kst</comment>
Expand Down
27 changes: 18 additions & 9 deletions src/libkstapp/plotrenderitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,14 +462,17 @@ void PlotRenderItem::keyPressEvent(QKeyEvent *event) {
return;
}

const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
if (modifiers & Qt::SHIFT) {
// show cursor as Qt::SizeVerCursor only on mouse events
// because shift is also used for arrow key controlled zooming
} else if (modifiers & Qt::CTRL) {
view()->setCursor(Qt::SizeHorCursor);
Qt::KeyboardModifiers modifiers = 0;


if (event->key()== Qt::Key_Shift) {
modifiers |= Qt::ShiftModifier;
} else if (event->key() == Qt::Key_Control) {
modifiers |= Qt::ControlModifier;
}

setCursorsMode(_lastPos, modifiers);

ViewItem::keyPressEvent(event);

updateSelectionRect();
Expand All @@ -483,9 +486,9 @@ void PlotRenderItem::keyReleaseEvent(QKeyEvent *event) {
}
const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
if (modifiers & Qt::SHIFT || zoomOnlyMode() == View::ZoomOnlyY) {
view()->setCursor(Qt::SizeVerCursor);
//view()->setCursor(Qt::SizeVerCursor);
} else if (modifiers & Qt::CTRL || zoomOnlyMode() == View::ZoomOnlyX) {
view()->setCursor(Qt::SizeHorCursor);
//view()->setCursor(Qt::SizeHorCursor);
} else {
view()->setCursor(Qt::CrossCursor);
QList<PlotItem*> plots = sharedOrTiedPlots(true, true);
Expand Down Expand Up @@ -762,11 +765,17 @@ void PlotRenderItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {

QPointF p = event->pos();

setCursorsMode(p);
}


void PlotRenderItem::setCursorsMode(QPointF p, Qt::KeyboardModifiers modifiers_in) {

double y = (p.y() - rect().bottom())/(rect().top()-rect().bottom())*(plotItem()->yMax()-plotItem()->yMin())+plotItem()->yMin();
double x = (p.x() - rect().left())/(rect().right()-rect().left())*(plotItem()->xMax()-plotItem()->xMin())+plotItem()->xMin();

_hoverPos = p;
const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers() | modifiers_in;
if (modifiers & Qt::SHIFT || zoomOnlyMode() == View::ZoomOnlyY) {
_lastPos = p;
view()->setCursor(Qt::SizeVerCursor);
Expand Down
2 changes: 2 additions & 0 deletions src/libkstapp/plotrenderitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ class PlotRenderItem : public ViewItem
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);

void setCursorsMode(QPointF p, Qt::KeyboardModifiers modifiers=0);

virtual QPainterPath shape() const;

private Q_SLOTS:
Expand Down