Merge changes

This commit is contained in:
Victor Tran 2018-08-03 22:38:03 +10:00
commit d8c9806fdf
12 changed files with 176 additions and 12 deletions

View file

@ -1,10 +1,20 @@
language: cpp
os:
- linux
- osx
before_install:
- sudo apt-get update -qq
- sudo apt-get install libqt5core5a libqt5dbus5 libqt5gui5 libqt5x11extras5 qtchooser qt5-default
- export STAGE=before_install
- ./travis.sh
script:
- qmake
- make
- export STAGE=script
- ./travis.sh
compiler:
- gcc
dist: xenial
sudo: required
branches:
except:
- # Do not build tags that we create when we upload to GitHub Releases
- /^(?i:continuous)/

18
appveyor.yml Normal file
View file

@ -0,0 +1,18 @@
version: 1.0.{build}
branches:
only:
- blueprint
skip_tags: true
image: Visual Studio 2017
environment:
REPO_SLUG: vicr123/the-libs
deploy_project: the-libs
deploy_version: ''
deploy_artifact: ''
build_script:
- cmd: >-
appveyor\build.bat
test: off

10
appveyor/build.bat Normal file
View file

@ -0,0 +1,10 @@
if "%APPVEYOR_REPO_TAG_NAME%"=="continuous" (
exit 1
)
set QTDIR=C:\Qt\5.11\msvc2017_64
set PATH=%PATH%;%QTDIR%\bin
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
qmake the-libs.pro
nmake release
nmake install

View file

@ -8,7 +8,11 @@
#include <QStyleFactory>
#include <QSettings>
#ifdef Q_OS_UNIX
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
#define T_OS_UNIX_NOT_MAC
#endif
#ifdef T_OS_UNIX_NOT_MAC
#include <QDBusMessage>
#include <QDBusReply>
#include <QDBusConnection>
@ -20,12 +24,16 @@
# define THELIBSSHARED_EXPORT Q_DECL_IMPORT
#endif
#define THE_LIBS_API_VERSION 1
class THELIBSSHARED_EXPORT theLibsGlobal : public QObject {
Q_OBJECT
public:
static theLibsGlobal* instance();
static float getDPIScaling();
static QStringList searchInPath(QString executable);
public slots:
bool powerStretchEnabled();
@ -41,7 +49,9 @@ class THELIBSSHARED_EXPORT theLibsGlobal : public QObject {
theLibsGlobal();
bool powerStretch = false;
QSettings* themeSettings;
#ifdef T_OS_UNIX_NOT_MAC
QSettings* themeSettings = new QSettings("theSuite", "ts-qtplatform");
#endif
};
#endif // THELIBS_GLOBAL_H

View file

@ -1,10 +1,11 @@
#include "the-libs_global.h"
#include <QDesktopWidget>
#include <QDir>
#include <QDirIterator>
theLibsGlobal::theLibsGlobal() : QObject(NULL) {
#ifdef Q_OS_UNIX
themeSettings = new QSettings("theSuite", "ts-qtplatform")
#ifdef T_OS_UNIX_NOT_MAC
QDBusMessage message = QDBusMessage::createMethodCall("org.thesuite.theshell", "/org/thesuite/Power", "org.thesuite.Power", "powerStretch");
QDBusReply<bool> reply = QDBusConnection::sessionBus().call(message);
if (reply.isValid()) {
@ -37,7 +38,7 @@ void theLibsGlobal::powerStretchChangedPrivate(bool isOn) {
}
bool theLibsGlobal::allowSystemAnimations() {
#ifdef Q_OS_UNIX
#ifdef T_OS_UNIX_NOT_MAC
return themeSettings->value("accessibility/systemAnimations", true).toBool();
#else
return true;
@ -48,3 +49,20 @@ float theLibsGlobal::getDPIScaling() {
float currentDPI = QApplication::desktop()->logicalDpiX();
return currentDPI / (float) 96;
}
QStringList theLibsGlobal::searchInPath(QString executable) {
QStringList executables;
QStringList pathDirs = QString(qgetenv("PATH")).split(":");
for (QString dir : pathDirs) {
QDir path(dir);
QDirIterator i(path);
while (i.hasNext()) {
i.next();
if (i.fileName() == executable) {
executables.append(i.filePath());
}
}
}
return executables;
}

View file

@ -5,6 +5,14 @@
#include <QObject>
#include <QMap>
#include <QVariant>
#include <QCoreApplication>
#ifdef T_OS_UNIX_NOT_MAC
#include <QDBusPendingReply>
#include <QDBusPendingCallWatcher>
#include <QDBusMessage>
#include <QDBusConnection>
#endif
class THELIBSSHARED_EXPORT tNotification : public QObject
{

View file

@ -0,0 +1,5 @@
#include "tnotification.h"
void tNotification::post(bool deleteWhenDone) {
}

View file

@ -1,8 +1,10 @@
#include "tvirtualkeyboard.h"
tVirtualKeyboard::tVirtualKeyboard() : QObject(NULL) {
#ifdef T_OS_UNIX_NOT_MAC
keyboardInterface = new QDBusInterface("org.thesuite.tskbd", "/org/thesuite/tskbd", "org.thesuite.tskbd");
QDBusConnection::sessionBus().connect("org.thesuite.tskbd", "/org/thesuite/tskbd", "org.thesuite.tskbd", "keyboardVisibleChanged", this, SIGNAL(keyboardVisibleChanged(bool)));
#endif
}
tVirtualKeyboard* tVirtualKeyboard::instance() {
@ -15,25 +17,37 @@ tVirtualKeyboard* tVirtualKeyboard::instance() {
}
bool tVirtualKeyboard::isKeyboardRunning() {
#ifdef T_OS_UNIX_NOT_MAC
return QDBusConnection::sessionBus().interface()->registeredServiceNames().value().contains("org.thesuite.tskbd");
#else
return false;
#endif
}
void tVirtualKeyboard::hideKeyboard() {
#ifdef T_OS_UNIX_NOT_MAC
if (isKeyboardRunning()) {
keyboardInterface->call(QDBus::Block, "hideKeyboard");
}
#endif
}
void tVirtualKeyboard::showKeyboard() {
#ifdef T_OS_UNIX_NOT_MAC
if (isKeyboardRunning()) {
keyboardInterface->call(QDBus::Block, "showKeyboard");
}
#endif
}
int tVirtualKeyboard::height() {
#ifdef T_OS_UNIX_NOT_MAC
if (isKeyboardRunning()) {
return keyboardInterface->call(QDBus::Block, "height").arguments().first().toInt();
} else {
return -1;
}
#else
return -1;
#endif
}

View file

@ -1,9 +1,13 @@
#ifndef TVIRTUALKEYBOARD_H
#define TVIRTUALKEYBOARD_H
#include "the-libs_global.h"
#include <QObject>
#ifdef T_OS_UNIX_NOT_MAC
#include <QDBusInterface>
#include <QDBusConnectionInterface>
#endif
class tVirtualKeyboard : public QObject
{
@ -23,7 +27,9 @@ public slots:
private:
tVirtualKeyboard();
#ifdef T_OS_UNIX_NOT_MAC
QDBusInterface* keyboardInterface;
#endif
};
#endif // TVIRTUALKEYBOARD_H

16
tapplication.cpp Normal file
View file

@ -0,0 +1,16 @@
#include "tapplication.h"
#include <QFileOpenEvent>
tApplication::tApplication(int& argc, char** argv) : QApplication(argc, argv)
{
}
bool tApplication::event(QEvent *event) {
if (event->type() == QEvent::FileOpen) {
QFileOpenEvent *openEvent = (QFileOpenEvent*) event;
emit openFile(openEvent->file());
}
return QApplication::event(event);
}

22
tapplication.h Normal file
View file

@ -0,0 +1,22 @@
#ifndef TAPPLICATION_H
#define TAPPLICATION_H
#include "the-libs_global.h"
#include <QApplication>
class THELIBSSHARED_EXPORT tApplication : public QApplication
{
Q_OBJECT
public:
explicit tApplication(int &argc, char **argv);
signals:
void openFile(QString file);
public slots:
private:
bool event(QEvent * event);
};
#endif // TAPPLICATION_H

27
travis.sh Executable file
View file

@ -0,0 +1,27 @@
if [ $STAGE = "script" ]; then
if [ $TRAVIS_OS_NAME = "linux" ]; then
echo "[TRAVIS] Running qmake"
qmake
echo "[TRAVIS] Building project"
make
else
echo "[TRAVIS] Building for macOS"
export PATH="/usr/local/opt/qt/bin:$PATH"
cd ..
mkdir "build-thelibs"
cd "build-thelibs"
echo "[TRAVIS] Running qmake"
qmake "INCLUDEPATH += /usr/local/opt/qt/include" "LIBS += -L/usr/local/opt/qt/lib" ../the-libs/the-libs.pro
echo "[TRAVIS] Building project"
make
fi
elif [ $STAGE = "before_install" ]; then
if [ $TRAVIS_OS_NAME = "linux" ]; then
sudo apt-get update -qq
sudo apt-get install libqt5core5a libqt5dbus5 libqt5gui5 libqt5x11extras5 qtchooser qt5-default
else
echo "[TRAVIS] Preparing to build for macOS"
brew update
brew install qt5
fi
fi