1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-15 06:52:34 +02:00

Merge branch 'master' into 66-port-screenplay-from-qmake-to-cmake

This commit is contained in:
Elias Steurer 2020-04-23 09:45:30 +02:00
commit 27d298e8b3
27 changed files with 339 additions and 153 deletions

View File

@ -65,7 +65,7 @@ Everyone can contribute with code, design, documentation or translation. Visit o
1. Install latest [git + git-lfs](https://git-scm.com/)
2. Clone ScreenPlay
``` bash
git clone https://gitlab.com/kelteseth/ScreenPlay.git
git clone --recursive https://gitlab.com/kelteseth/ScreenPlay.git
```
3. Download the latest [__Qt 5.14__](https://www.qt.io/download-qt-installer). Earlier versions are not supported!
4. Start install-dependencies.bat to download dependencies into the Common/ folder
@ -74,6 +74,7 @@ git clone https://gitlab.com/kelteseth/ScreenPlay.git
.\install-dependencies.bat
//Linux
sudo apt install git gcc cmake build-essential libgl1-mesa-dev
chmod +x install-dependencies.sh
.\install-dependencies.sh
```
@ -102,7 +103,7 @@ chmod +x install-dependencies.sh
1. Install dependencies for your distro:
``` bash
# Debian/Ubuntu
sudo apt install build-essential libgl1-mesa-dev
sudo apt install build-essential libgl1-mesa-dev lld
# Fedora/RHEL/CentOS (yum)
sudo yum groupinstall "C Development Tools and Libraries"

View File

@ -5,7 +5,10 @@ CONFIG += c++17
TARGETPATH = ScreenPlay
include($$PWD/../Common/qt-google-analytics/qt-google-analytics.pri)
include($$PWD/../Common/qt-breakpad/qt-breakpad.pri)
!unix {
include($$PWD/../Common/qt-breakpad/qt-breakpad.pri)
}
ICON = favicon.ico
@ -69,7 +72,6 @@ HEADERS += \
INCLUDEPATH += \
$$PWD/src/\
CONFIG(debug, debug|release) {
install_assets.path = $${OUT_PWD}/assets/fonts
} else {
@ -78,6 +80,20 @@ CONFIG(debug, debug|release) {
install_assets.files += $$PWD/assets/fonts/NotoSansCJKkr-Regular.otf
win32: ARCH_OS = x64-windows
unix:!macx { ARCH_OS = x64-linux}
macx: ARCH_OS = x64-osx
CONFIG(debug, debug|release){
ARCH_OS_BUILD = $$ARCH_OS/debug
} else {
ARCH_OS_BUILD = $$ARCH_OS
}
INCLUDEPATH += $$PWD/../Common/vcpkg/installed/$$ARCH_OS/include
DEPENDPATH += $$PWD/../Common/vcpkg/installed/$$ARCH_OS/include
win32 {
RC_ICONS += favicon.ico
CONFIG(debug, debug|release) {
@ -86,75 +102,30 @@ win32 {
install_it.path = $${OUT_PWD}/release/
}
INCLUDEPATH += $$PWD/../Common/vcpkg/installed/x64-windows/include
DEPENDPATH += $$PWD/../Common/vcpkg/installed/x64-windows/include
LIBS += -luser32
LIBS += -L$$PWD/../Common/vcpkg/installed/x64-windows/lib/ -llibzippp
CONFIG(debug, debug|release) {
install_it.files += $$PWD/../Common/vcpkg/installed/x64-windows/debug/bin/zip.dll \
$$PWD/../Common/vcpkg/installed/x64-windows/debug/bin/zlibd1.dll \
$$PWD/../Common/vcpkg/installed/x64-windows/debug/bin/libzippp.dll \
$$PWD/../Common/vcpkg/installed/x64-windows/debug/bin/bz2d.dll \
$$PWD/../Common/vcpkg/installed/x64-windows/debug/bin/libcrypto-1_1-x64.dll \
$$PWD/../Common/vcpkg/installed/x64-windows/debug/bin/libssl-1_1-x64.dll \
} else {
install_it.files += $$PWD/../Common/vcpkg/installed/x64-windows/bin/zip.dll \
$$PWD/../Common/vcpkg/installed/x64-windows/bin/zlib1.dll \
$$PWD/../Common/vcpkg/installed/x64-windows/bin/libzippp.dll \
$$PWD/../Common/vcpkg/installed/x64-windows/bin/bz2.dll \
$$PWD/../Common/vcpkg/installed/x64-windows/bin/libcrypto-1_1-x64.dll \
$$PWD/../Common/vcpkg/installed/x64-windows/bin/libssl-1_1-x64.dll \
}
}
LIBS += -L$$PWD/../Common/vcpkg/installed/x64-windows/lib/ -llibzippp
macx {
LIBS += -L$$PWD/ThirdParty/steam/redistributable_bin/osx32/ -lsteam_api
DEPENDPATH += $$PWD/ThirdParty/steam/redistributable_bin/osx32
INCLUDEPATH += $$PWD/ThirdParty/steam/
DEPENDPATH += $$PWD/ThirdParty/steam/
LIBS += -L$$PWD/ThirdParty/steam/lib/osx32/ -lsdkencryptedappticket
steam_data.files += steam_appid.txt
steam_data.path = Contents/MacOS
steam_data_lib.files += $$PWD/ThirdParty/steam/redistributable_bin/osx32/libsteam_api.dylib
steam_data_lib.path = Contents/MacOS/
QMAKE_BUNDLE_DATA += steam_data
QMAKE_BUNDLE_DATA += steam_data_lib
install_it.files += $$PWD/../Common/vcpkg/installed/$$ARCH_OS_BUILD/bin/zip.dll \
$$PWD/../Common/vcpkg/installed/$$ARCH_OS_BUILD/bin/zlibd1.dll \
$$PWD/../Common/vcpkg/installed/$$ARCH_OS_BUILD/bin/libzippp.dll \
$$PWD/../Common/vcpkg/installed/$$ARCH_OS_BUILD/bin/bz2d.dll \
$$PWD/../Common/vcpkg/installed/$$ARCH_OS_BUILD/bin/libcrypto-1_1-x64.dll \
$$PWD/../Common/vcpkg/installed/$$ARCH_OS_BUILD/bin/libssl-1_1-x64.dll \
}
unix {
INCLUDEPATH += $$PWD/../Common/vcpkg/installed/x64-linux/include
DEPENDPATH += $$PWD/../Common/vcpkg/installed/x64-linux/include
LIBS += -L$$PWD/../Common/vcpkg/installed/x64-linux/lib/ -llibzippp -lzip
install_it.path = $${OUT_PWD}
CONFIG(debug, debug|release) {
install_it.files += $$PWD/../Common/vcpkg/installed/x64-linux/debug/bin/zip.so \
$$PWD/../Common/vcpkg/installed/x64-linux/debug/bin/zlibd1.so \
$$PWD/../Common/vcpkg/installed/x64-linux/debug/bin/libzippp.so \
$$PWD/../Common/vcpkg/installed/x64-linux/debug/bin/bz2d.so \
$$PWD/../Common/vcpkg/installed/x64-linux/debug/bin/libcrypto-1_1-x64.so \
$$PWD/../Common/vcpkg/installed/x64-linux/debug/bin/libssl-1_1-x64.so \
CONFIG(debug, debug|release){
#lbz2d uses d
LIBS += -L$$PWD/../Common/vcpkg/installed/$$ARCH_OS_BUILD/lib/ -llibzippp -lzip -lbz2d -lz -lcrypto -lssl -ldl
} else {
install_it.files += $$PWD/../Common/vcpkg/installed/x64-linux/bin/zip.so \
$$PWD/../Common/vcpkg/installed/x64-linux/bin/zlib1.so \
$$PWD/../Common/vcpkg/installed/x64-linux/bin/libzippp.so \
$$PWD/../Common/vcpkg/installed/x64-linux/bin/bz2.so \
$$PWD/../Common/vcpkg/installed/x64-linux/bin/libcrypto-1_1-x64.so \
$$PWD/../Common/vcpkg/installed/x64-linux/bin/libssl-1_1-x64.so \
LIBS += -L$$PWD/../Common/vcpkg/installed/$$ARCH_OS_BUILD/lib/ -llibzippp -lzip -lbz2 -lz -lcrypto -lssl -ldl
}
}

View File

@ -51,8 +51,10 @@ App::App()
QGuiApplication::setApplicationName("ScreenPlay");
QGuiApplication::setApplicationVersion("0.10.1");
QGuiApplication::setQuitOnLastWindowClosed(false);
#ifdef Q_OS_WINDOWS
QtBreakpad::init(QDir::current().absolutePath());
#endif
QFontDatabase::addApplicationFont(":/assets/fonts/LibreBaskerville-Italic.ttf");
@ -123,7 +125,7 @@ void App::init()
m_telemetry->setNetworkAccessManager(nam);
m_telemetry->setSendInterval(1000);
m_telemetry->startSession();
m_telemetry->sendEvent("version", QGuiApplication::applicationVersion());
m_telemetry->sendEvent("version", QApplication::applicationVersion());
}
m_create = make_unique<Create>(m_globalVariables);
@ -145,7 +147,7 @@ void App::init()
m_installedListModel->init();
// Set visible if the -silent parameter was not set
if (QGuiApplication::instance()->arguments().contains("-silent")) {
if (QApplication::instance()->arguments().contains("-silent")) {
settings()->setSilentStart(true);
}
@ -159,13 +161,13 @@ void App::init()
void App::exit()
{
if (!m_telemetry) {
QGuiApplication::instance()->quit();
QApplication::instance()->quit();
return;
} else {
// Workaround because we cannot force to send exit event
m_telemetry->setSendInterval(5);
m_telemetry->endSession();
QTimer::singleShot(150, []() { QGuiApplication::instance()->quit(); });
QTimer::singleShot(150, []() { QApplication::instance()->quit(); });
}
}
}

View File

@ -16,8 +16,9 @@
#include <memory>
#include "ganalytics.h"
#ifdef Q_OS_WINDOWS
#include "qt_breakpad.h"
#endif
#include "src/create.h"
#include "src/globalvariables.h"
#include "src/installedlistfilter.h"

View File

@ -1,13 +1,13 @@
#include <QGuiApplication>
#include <QApplication>
#include "app.h"
int main(int argc, char* argv[])
{
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QGuiApplication qtGuiApp(argc, argv);
QApplication qtGuiApp(argc, argv);
ScreenPlay::App app;

View File

@ -141,8 +141,8 @@ bool CreateImportVideo::createWallpaperInfo()
emit createWallpaperStateChanged(ImportVideoState::AnalyseVideoFinished);
auto a = pro->readAll();
auto objOptional = Util::parseQByteArrayToQJsonObject(a);
if (!objOptional) {
auto obj = Util::parseQByteArrayToQJsonObject(a);
if (!obj) {
qDebug() << "Error parsing ffmpeg json output";
emit processOutput(pro->readAll());
emit processOutput("Error parsing ffmpeg json output");
@ -150,8 +150,7 @@ bool CreateImportVideo::createWallpaperInfo()
return false;
}
QJsonObject obj = objOptional.value();
if (obj.empty()) {
if (obj->empty()) {
qDebug() << "Error! File could not be parsed.";
emit processOutput("Error! File could not be parsed.");
@ -163,7 +162,7 @@ bool CreateImportVideo::createWallpaperInfo()
pro->close();
// Check for audio and video streams
QJsonArray arrayStream = obj.value("streams").toArray();
QJsonArray arrayStream = obj->value("streams").toArray();
bool hasAudioStream { false };
bool hasVideoStream { false };
@ -204,7 +203,7 @@ bool CreateImportVideo::createWallpaperInfo()
return false;
}
QJsonObject objFormat = obj.value("format").toObject();
QJsonObject objFormat = obj->value("format").toObject();
// Get video length
bool okParseDuration = false;
@ -221,7 +220,7 @@ bool CreateImportVideo::createWallpaperInfo()
m_length = length;
// Get framerate
QJsonArray arrSteams = obj.value("streams").toArray();
QJsonArray arrSteams = obj->value("streams").toArray();
if (arrSteams.empty()) {
qDebug() << "Error container does not have any video streams";
emit processOutput("Error container does not have any video streams");

View File

@ -130,10 +130,10 @@ void InstalledListModel::loadInstalledContent()
if (auto obj = Util::openJsonFileToObject(projectItemPath)) {
if (obj.value().isEmpty())
if (obj->isEmpty())
continue;
if (!obj.value().contains("file") || !obj.value().contains("type"))
if (!obj->contains("file") || !obj->contains("type"))
continue;
QStringList availableTypes {
@ -147,8 +147,8 @@ void InstalledListModel::loadInstalledContent()
"standaloneWidget"
};
if (availableTypes.contains(obj.value().value("type").toString())) {
emit addInstalledItem(obj.value(), item.baseName());
if (availableTypes.contains(obj->value("type").toString())) {
emit addInstalledItem(*obj, item.baseName());
}
counter += 1;

View File

@ -25,9 +25,9 @@ MonitorListModel::MonitorListModel(QObject* parent)
{
loadMonitors();
auto* guiAppInst = dynamic_cast<QGuiApplication*>(QGuiApplication::instance());
connect(guiAppInst, &QGuiApplication::screenAdded, this, &MonitorListModel::screenAdded);
connect(guiAppInst, &QGuiApplication::screenRemoved, this, &MonitorListModel::screenRemoved);
auto* guiAppInst = dynamic_cast<QApplication*>(QApplication::instance());
connect(guiAppInst, &QApplication::screenAdded, this, &MonitorListModel::screenAdded);
connect(guiAppInst, &QApplication::screenRemoved, this, &MonitorListModel::screenRemoved);
}
/*!

View File

@ -3,7 +3,7 @@
#include <QAbstractListModel>
#include <QApplication>
#include <QDebug>
#include <QGuiApplication>
#include <QApplication>
#include <QRect>
#include <QScreen>
#include <QSize>
@ -100,7 +100,7 @@ public slots:
QRect getAbsoluteDesktopSize() const
{
auto* app = static_cast<QGuiApplication*>(QGuiApplication::instance());
auto* app = static_cast<QApplication*>(QApplication::instance());
return app->screens().at(0)->availableVirtualGeometry();
}

View File

@ -49,10 +49,8 @@ void ScreenPlayManager::createWallpaper(
if (m_telemetry) {
m_telemetry->sendEvent("wallpaper", "start");
}
QString path = absoluteStoragePath;
if (absoluteStoragePath.contains("file:///"))
path = path.remove("file:///");
QString path = QUrl(absoluteStoragePath).toLocalFile();
std::sort(monitorIndex.begin(), monitorIndex.end());
@ -159,7 +157,7 @@ void ScreenPlayManager::removeAllWallpapers()
return;
}
QJsonObject oldConfig = configOptional.value();
QJsonObject oldConfig = *configOptional;
QJsonObject oldConfigProfile = oldConfig.value("profiles").toArray().first().toObject();
QJsonObject profileDefault;
@ -208,8 +206,8 @@ bool ScreenPlayManager::removeWallpaperAt(int at)
}
if (auto appID = m_monitorListModel->getAppIDByMonitorIndex(at)) {
m_sdkconnector->closeWallpaper(appID.value());
m_monitorListModel->closeWallpaper(appID.value());
m_sdkconnector->closeWallpaper(*appID);
m_monitorListModel->closeWallpaper(*appID);
decreaseActiveWallpaperCounter();
return true;
}
@ -239,9 +237,9 @@ void ScreenPlayManager::setWallpaperValue(const int index, const QString& key, c
{
if (auto appID = m_monitorListModel->getAppIDByMonitorIndex(index)) {
m_sdkconnector->setWallpaperValue(appID.value(), key, value);
m_sdkconnector->setWallpaperValue(*appID, key, value);
if (auto wallpaper = getWallpaperByAppID(appID.value())) {
if (auto wallpaper = getWallpaperByAppID(*appID)) {
}
}
}
@ -286,7 +284,7 @@ bool ScreenPlayManager::saveWallpaperProfile(const QString& profileName, const Q
return false;
}
QJsonObject oldConfig = configOptional.value();
QJsonObject oldConfig = *configOptional;
QJsonObject oldConfigProfile = oldConfig.value("profiles").toArray().first().toObject();
QJsonArray oldWallpaperArray = oldConfigProfile.value("wallpaper").toArray();
QJsonArray newWallpaperArray;
@ -337,14 +335,14 @@ void ScreenPlayManager::loadWallpaperProfiles()
return;
}
std::optional<QVersionNumber> version = Util::getVersionNumberFromString(configObj.value().value("version").toString());
std::optional<QVersionNumber> version = Util::getVersionNumberFromString(configObj->value("version").toString());
if (version && version.value() != m_globalVariables->version()) {
qWarning() << "Version missmatch fileVersion: " << version.value().toString() << "m_version: " << m_globalVariables->version().toString();
if (version && *version != m_globalVariables->version()) {
qWarning() << "Version missmatch fileVersion: " << version->toString() << "m_version: " << m_globalVariables->version().toString();
return;
}
QJsonArray activeProfilesTmp = configObj.value().value("profiles").toArray();
QJsonArray activeProfilesTmp = configObj->value("profiles").toArray();
if (activeProfilesTmp.size() > 1) {
qWarning() << "We currently only support one profile!";

View File

@ -1,6 +1,6 @@
#pragma once
#include <QGuiApplication>
#include <QApplication>
#include <QObject>
#include <QPoint>
#include <QProcess>

View File

@ -96,7 +96,7 @@ Settings::Settings(const shared_ptr<GlobalVariables>& globalVariables,
* not generate warnings.
*/
QDir dir;
QString path = QGuiApplication::instance()->applicationDirPath() + "/../../workshop/content/672870";
QString path = QApplication::instance()->applicationDirPath() + "/../../workshop/content/672870";
if (!dir.mkpath(path)) {
qWarning() << "Could not create steam workshop path for path: " << path;
} else {
@ -123,6 +123,10 @@ Settings::Settings(const shared_ptr<GlobalVariables>& globalVariables,
void Settings::writeJsonFileFromResource(const QString& filename)
{
QFile file(m_globalVariables->localSettingsPath().toString() + "/" + filename + ".json");
QDir directory(m_globalVariables->localSettingsPath().toString());
if(!directory.exists()){
directory.mkpath(directory.path());
}
QFile defaultSettings(":/" + filename + ".json");
file.open(QIODevice::WriteOnly | QIODevice::Text);
@ -160,6 +164,11 @@ void Settings::setupWidgetAndWindowPaths()
m_globalVariables->setWidgetExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWidget/debug/ScreenPlayWidget.exe"));
m_globalVariables->setWallpaperExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWallpaper/debug/ScreenPlayWallpaper.exe"));
#endif
#ifdef Q_OS_LINUX
m_globalVariables->setWidgetExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWidget/ScreenPlayWidget"));
m_globalVariables->setWallpaperExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWallpaper/ScreenPlayWallpaper"));
#endif
}
// We need to detect the right base path so we can copy later the example projects
@ -244,7 +253,7 @@ void Settings::setupLanguage()
*/
bool Settings::retranslateUI()
{
auto* app = static_cast<QGuiApplication*>(QGuiApplication::instance());
auto* app = static_cast<QApplication*>(QApplication::instance());
QString langCode = QVariant::fromValue(language()).toString();
langCode = langCode.toLower();
QFile tsFile;

View File

@ -4,7 +4,7 @@
#include <QDir>
#include <QFile>
#include <QFontDatabase>
#include <QGuiApplication>
#include <QApplication>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
@ -203,8 +203,9 @@ public slots:
settings.sync();
} else {
settings.remove("ScreenPlay");
#endif
}
#endif
setqSetting("Autostart", autostart);

View File

@ -28,7 +28,7 @@ Util::Util(QNetworkAccessManager* networkAccessManager, QObject* parent)
// This gives us nice clickable output in QtCreator
qSetMessagePattern("%{if-category}%{category}: %{endif}%{message}\n Loc: [%{file}:%{line}]");
QString path = QGuiApplication::instance()->applicationDirPath() + "/";
QString path = QApplication::instance()->applicationDirPath() + "/";
QFile fileFFMPEG;
QFile fileFFPROBE;
@ -49,7 +49,7 @@ Util::Util(QNetworkAccessManager* networkAccessManager, QObject* parent)
*/
void Util::copyToClipboard(const QString& text) const
{
auto* clipboard = QGuiApplication::clipboard();
auto* clipboard = QApplication::clipboard();
clipboard->setText(text);
}
@ -67,7 +67,7 @@ std::optional<QJsonObject> Util::openJsonFileToObject(const QString& path)
QJsonDocument jsonDocument;
QJsonParseError parseError {};
jsonDocument = QJsonDocument::fromJson(jsonString.value().toUtf8(), &parseError);
jsonDocument = QJsonDocument::fromJson(jsonString->toUtf8(), &parseError);
if (!(parseError.error == QJsonParseError::NoError)) {
qWarning() << "Settings Json Parse Error: " << parseError.errorString();
@ -302,7 +302,7 @@ void Util::downloadFFMPEG()
#ifdef Q_OS_WIN
req.setUrl(QUrl("https://ffmpeg.zeranoe.com/builds/win64/static/" + ffmpegVersion + "-win64-static.zip"));
#elif defined(Q_OS_OSX)
req.setUrl(QUrl("https://ffmpeg.zeranoe.com/builds/macos64/static/" + ffmpegVersion + "-win64-static.zip"));
req.setUrl(QUrl("https://ffmpeg.zeranoe.com/builds/macos64/static/" + ffmpegVersion + "-macos64-static.zip"));
#endif
setAquireFFMPEGStatus(AquireFFMPEGStatus::Download);
@ -322,7 +322,7 @@ void Util::downloadFFMPEG()
return;
}
string path = QGuiApplication::instance()->applicationDirPath().toStdString() + "/";
string path = QApplication::instance()->applicationDirPath().toStdString() + "/";
ZipEntry entryFFMPEG;
std::string entryFFMPEGPath;

View File

@ -5,7 +5,7 @@
#include <QDateTime>
#include <QDebug>
#include <QDir>
#include <QGuiApplication>
#include <QApplication>
#include <QJsonDocument>
#include <QJsonObject>
#include <QNetworkAccessManager>

View File

@ -6,7 +6,6 @@ DEFINES += QT_DEPRECATED_WARNINGS
TARGETPATH = ScreenPlayWallpaper
include($$PWD/../Common/qt-breakpad/qt-breakpad.pri)
RESOURCES += \
@ -20,15 +19,8 @@ SOURCES += \
HEADERS += \
src/basewindow.h \
unix{
SOURCES += \
src/linuxwindow.cpp
HEADERS += \
src/linuxwindow.h
}
win32 {
include($$PWD/../Common/qt-breakpad/qt-breakpad.pri)
LIBS += -luser32
SOURCES += \
src/windowsdesktopproperties.cpp \
@ -75,10 +67,18 @@ macx {
src/macwindow.h
}
unix {
unix:!macx {
install_it.path = $${OUT_PWD}/
LIBS += -lX11
SOURCES += \
src/linuxwindow.cpp
HEADERS += \
src/linuxwindow.h
CONFIG(debug, debug|release) {
install_it.files += \
$$PWD/../Common/vcpkg/installed/x64-linux/debug/bin/libcrypto-1_1-x64.so \

View File

@ -6,6 +6,8 @@
#include <QtWebEngine>
#if defined(Q_OS_WIN)
#include "qt_breakpad.h"
#include "src/winwindow.h"
#endif
@ -18,18 +20,15 @@
#endif
#include "../ScreenPlaySDK/screenplaysdk.h"
#include "qt_breakpad.h"
int main(int argc, char* argv[])
{
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QApplication app(argc, argv);
QtBreakpad::init(QDir::current().absolutePath());
// This gives us nice clickable output in QtCreator
qSetMessagePattern("%{if-category}%{category}: %{endif}%{message}\n Loc: [%{file}:%{line}]");
@ -41,6 +40,8 @@ int main(int argc, char* argv[])
//Set the monitor number to test
#if defined(Q_OS_WIN)
QtBreakpad::init(QDir::current().absolutePath());
//WinWindow window1({ 0 }, "test", "appid", "1", "fill");
//WinWindow window2({ 1 }, "test", "appid", "1", "fill");
//WinWindow window3({ 2 }, "test", "appid", "1", "fill");
@ -48,7 +49,7 @@ int main(int argc, char* argv[])
WinWindow window({ 0 }, "C:/Program Files (x86)/Steam/steamapps/workshop/content/672870/1958068745", "appid", "1", "fill", true);
#endif
#if defined(Q_OS_LINUX)
LinuxWindow window(QVector<int>{ 0 }, "test", "appid", "1", "fill");
LinuxWindow window({ 0 }, "/home/graphicscore/Desktop/wallpapers/MechaGirl", "appid", "1", "fill", false);
#endif
#if defined(Q_OS_OSX)
MacWindow window({ 0 }, "test", "appid", "1", "fill");
@ -115,15 +116,15 @@ int main(int argc, char* argv[])
#endif
#if defined(Q_OS_LINUX)
LinuxWindow window(list, argumentList.at(2), argumentList.at(3), argumentList.at(4), argumentList.at(5));
LinuxWindow window(list, argumentList.at(2), argumentList.at(3), argumentList.at(4), argumentList.at(5), checkWallpaperVisible);
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &window, &LinuxWindow::destroyThis);
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &window, &LinuxWindow::messageReceived);
#endif
#if defined(Q_OS_OSX)
MacWindow window(list, argumentList.at(2), argumentList.at(3), argumentList.at(5));
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &MacWindow, &MacWindow::destroyThis);
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &MacWindow, &MacWindow::messageReceived);
MacWindow window(list, argumentList.at(2), argumentList.at(3), argumentList.at(4), argumentList.at(5));
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &window, &MacWindow::destroyThis);
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &window, &MacWindow::messageReceived);
#endif
return app.exec();

View File

@ -1,14 +1,173 @@
#include "linuxwindow.h"
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/Xproto.h>
#include <X11/Xutil.h>
LinuxWindow::LinuxWindow(QVector<int> activeScreensList, QString projectPath, QString id, QString volume, const QString fillmode, QObject* parent)
: BaseWindow(projectPath)
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#define WIDTH 512
#define HEIGHT 384
#define OPAQUE 0xffffffff
#define NAME "xwinwrap"
#define ATOM(a) XInternAtom(display, #a, False)
/*
*
*
*
* This code is non functional only here for testing!
*
*
*
*/
LinuxWindow::LinuxWindow(QVector<int> activeScreensList, QString projectPath, QString id, QString volume, const QString fillmode, const bool checkWallpaperVisible, QObject* parent)
: BaseWindow(projectPath, activeScreensList, checkWallpaperVisible)
{
m_window.setWidth(1920);
m_window.setHeight(1080);
m_window.show();
setAppID(id);
bool ok = false;
float volumeParsed = volume.toFloat(&ok);
if (!ok) {
qFatal("Could not parse volume");
}
setVolume(volumeParsed);
setFillMode(fillmode);
// Ether for one Screen or for all
if ((QApplication::screens().length() == activeScreensList.length()) && (activeScreensList.length() != 1)) {
setupWallpaperForAllScreens();
} else if (activeScreensList.length() == 1) {
setupWallpaperForOneScreen(activeScreensList.at(0));
setCanFade(true);
} else if (activeScreensList.length() > 1) {
setupWallpaperForMultipleScreens(activeScreensList);
}
setWidth(m_window.width());
setHeight(m_window.height());
m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
m_window.rootContext()->setContextProperty("window", this);
//m_window.rootContext()->setContextProperty("desktopProperties", &m_windowsDesktopProperties);
// Instead of setting "renderType: Text.NativeRendering" every time
// we can set it here once :)
m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering);
m_window.setSource(QUrl("qrc:/mainWindow.qml"));
Window window = m_window.winId();
Display* display = XOpenDisplay("");
XSetWindowAttributes attrs = { ParentRelative, 0L, 0, 0L, 0, 0,
Always, 0L, 0L, False, StructureNotifyMask | ExposureMask | ButtonPressMask | ButtonReleaseMask, 0L, False, 0, 0 };
XWMHints wmHint;
Atom xa;
int flags;
flags |= CWBorderPixel | CWColormap;
XChangeWindowAttributes(display, window, flags, &attrs);
wmHint.flags = InputHint | StateHint;
wmHint.input = true;
wmHint.initial_state = WithdrawnState;
XSetWMProperties(display, window, NULL, NULL, NULL,
0, NULL, &wmHint, NULL);
xa = ATOM(_NET_WM_WINDOW_TYPE);
Atom prop;
xa = ATOM(_MOTIF_WM_HINTS);
if (xa != None) {
long prop[5] = { 2, 0, 0, 0, 0 };
XChangeProperty(display, window, xa, xa, 32,
PropModeReplace, (unsigned char*)prop, 5);
}
xa = ATOM(_NET_WM_STATE);
if (xa != None) {
Atom xa_prop = ATOM(_NET_WM_STATE_BELOW);
XChangeProperty(display, window, xa, XA_ATOM, 32,
PropModeAppend, (unsigned char*)&xa_prop, 1);
}
xa = ATOM(_NET_WM_DESKTOP);
if (xa != None) {
CARD32 xa_prop = 0xFFFFFFFF;
XChangeProperty(display, window, xa, XA_CARDINAL, 32,
PropModeAppend, (unsigned char*)&xa_prop, 1);
}
xa = ATOM(_NET_WM_STATE);
if (xa != None) {
Atom xa_prop = ATOM(_NET_WM_STATE_STICKY);
XChangeProperty(display, window, xa, XA_ATOM, 32,
PropModeAppend, (unsigned char*)&xa_prop, 1);
}
xa = ATOM(_NET_WM_STATE);
if (xa != None) {
Atom xa_prop = ATOM(_NET_WM_STATE_SKIP_TASKBAR);
XChangeProperty(display, window, xa, XA_ATOM, 32,
PropModeAppend, (unsigned char*)&xa_prop, 1);
}
xa = ATOM(_NET_WM_STATE);
if (xa != None) {
Atom xa_prop = ATOM(_NET_WM_STATE_SKIP_PAGER);
XChangeProperty(display, window, xa, XA_ATOM, 32,
PropModeAppend, (unsigned char*)&xa_prop, 1);
}
XMapWindow(display, window);
XSync(display, window);
/*QObject::connect(&m_checkForFullScreenWindowTimer, &QTimer::timeout, this, &WinWindow::checkForFullScreenWindow);
if (checkWallpaperVisible) {
m_checkForFullScreenWindowTimer.start(10);
}
QTimer::singleShot(1000, [this]() {
setupWindowMouseHook();
});*/
/*********/
/*bool ok = false;
float volumeParsed = volume.toFloat(&ok);
if (!ok) {
qFatal("Could not parse volume");
}
setVolume(volumeParsed);
// WARNING: Setting Window flags must be called *here*!
@ -20,7 +179,19 @@ LinuxWindow::LinuxWindow(QVector<int> activeScreensList, QString projectPath, QS
// Instead of setting "renderType: Text.NativeRendering" every time
// we can set it here once :)
m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering);
m_window.setSource(QUrl("qrc:/mainWindow.qml"));
m_window.setSource(QUrl("qrc:/mainWindow.qml"));*/
}
void LinuxWindow::setupWallpaperForOneScreen(int activeScreen)
{
}
void LinuxWindow::setupWallpaperForAllScreens()
{
}
void LinuxWindow::setupWallpaperForMultipleScreens(const QVector<int>& activeScreensList)
{
}
void LinuxWindow::setVisible(bool show)
@ -32,4 +203,3 @@ void LinuxWindow::destroyThis()
{
QCoreApplication::quit();
}

View File

@ -17,7 +17,7 @@ class LinuxWindow : public BaseWindow
{
Q_OBJECT
public:
explicit LinuxWindow(QVector<int> activeScreensList, QString projectPath, QString id, QString volume, const QString fillmode,QObject *parent = nullptr);
explicit LinuxWindow(QVector<int> activeScreensList, QString projectPath, QString id, QString volume, const QString fillmode,const bool checkWallpaperVisible, QObject *parent = nullptr);
signals:
@ -26,5 +26,8 @@ public slots:
void destroyThis() override;
private:
QQuickView m_window;
void setupWallpaperForOneScreen(int activeScreen);
void setupWallpaperForAllScreens();
void setupWallpaperForMultipleScreens(const QVector<int>& activeScreensList);
};

View File

@ -1,4 +1,4 @@
#pragma oncer
#pragma once
#include <QApplication>

View File

@ -1,7 +1,12 @@
#include "macwindow.h"
MacWindow::MacWindow(QVector<int>& activeScreensList, QString projectPath, QString id, QString volume, QObject* parent)
: BaseWindow(projectPath)
MacWindow::MacWindow(
const QVector<int> &activeScreensList,
const QString &projectPath,
const QString &id,
const QString &volume,
const QString &fillmode)
: BaseWindow(projectPath, activeScreensList, false)
{
setAppID(id);
bool ok = false;
@ -11,6 +16,20 @@ MacWindow::MacWindow(QVector<int>& activeScreensList, QString projectPath, QStri
}
setVolume(volumeParsed);
// Ether for one Screen or for all
if ((QApplication::screens().length() == activeScreensList.length()) && (activeScreensList.length() != 1)) {
//setupWallpaperForAllScreens();
} else if (activeScreensList.length() == 1) {
//setupWallpaperForOneScreen(activeScreensList.at(0));
auto* screen = QGuiApplication::screens().at(0);
m_window.setWidth(screen->geometry().width());
m_window.setHeight(screen->geometry().height());
} else if (activeScreensList.length() > 1) {
//setupWallpaperForMultipleScreens(activeScreensList);
}
// WARNING: Setting Window flags must be called *here*!
Qt::WindowFlags flags = m_window.flags();
m_window.setFlags(flags | Qt::FramelessWindowHint | Qt::Desktop);
@ -18,9 +37,14 @@ MacWindow::MacWindow(QVector<int>& activeScreensList, QString projectPath, QStri
m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
m_window.rootContext()->setContextProperty("window", this);
// Instead of setting "renderType: Text.NativeRendering" every time
// we can set it here once :)
m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering);
m_window.setSource(QUrl("qrc:/mainWindow.qml"));
MacIntegration* macIntegration = new MacIntegration(this);
macIntegration->SetBackgroundLevel(&m_window);
}
void MacWindow::setVisible(bool show)
@ -32,7 +56,3 @@ void MacWindow::destroyThis()
{
QCoreApplication::quit();
}
void MacWindow::messageReceived(QString key, QString value)
{
}

View File

@ -12,19 +12,24 @@
#include <QVector>
#include "basewindow.h"
#include "macintegration.h"
class MacWindow : public BaseWindow
{
Q_OBJECT
public:
explicit MacWindow(QVector<int>& activeScreensList, QString projectPath, QString id, QString volume,QObject *parent = nullptr);
explicit MacWindow(
const QVector<int>& activeScreensList,
const QString& projectPath,
const QString& id,
const QString& volume,
const QString& fillmode);
signals:
public slots:
void setVisible(bool show) override;
void destroyThis() override;
void messageReceived(QString key, QString value) override;
private:
QQuickView m_window;
};

View File

@ -242,7 +242,7 @@ void WinWindow::setupWallpaperForMultipleScreens(const QVector<int>& activeScree
void WinWindow::setupWindowMouseHook()
{
// MUST be called before setting hook for events!
if (type() == BaseWindow::WallpaperType::Qml) {
if (type() != BaseWindow::WallpaperType::Video) {
winGlobalHook = &m_window;
if (!(mouseHook = SetWindowsHookEx(WH_MOUSE_LL, MouseHookCallback, nullptr, 0))) {
qDebug() << "Faild to install mouse hook!";
@ -316,7 +316,7 @@ void WinWindow::checkForFullScreenWindow()
HMONITOR wallpaper = MonitorFromWindow(m_windowHandle, dwFlags);
int monitorIndex = GetMonitorIndex(monitor);
int wallpaperIndex = GetMonitorIndex(wallpaper);
// qDebug() << monitorIndex << wallpaperIndex;
// qDebug() << monitorIndex << wallpaperIndex;
// If the window that has WS_MAXIMIZE is at the same monitor as this wallpaper
if (monitorIndex == wallpaperIndex) {

View File

@ -1,4 +1,4 @@
#include <QGuiApplication>
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QStringList>
@ -7,10 +7,10 @@
int main(int argc, char* argv[])
{
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QGuiApplication app(argc, argv);
QApplication app(argc, argv);
QStringList argumentList = app.arguments();

View File

@ -13,7 +13,7 @@ WidgetWindow::WidgetWindow(const QString projectPath, const QString appid, const
};
if (!availableTypes.contains(m_type)) {
QGuiApplication::exit(-4);
QApplication::exit(-4);
}
Qt::WindowFlags flags = m_window.flags();

View File

@ -2,7 +2,7 @@
#include <QDebug>
#include <QFile>
#include <QGuiApplication>
#include <QApplication>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonParseError>

View File

@ -8,4 +8,9 @@ git checkout origin/master
chmod +x bootstrap-vcpkg.sh
./bootstrap-vcpkg.sh
chmod +x vcpkg
if [[ "$OSTYPE" == "darwin"* ]]; then
./vcpkg install libzippp:x64-osx nlohmann-json:x64-osx openssl-unix:x64-osx libzip:x64-osx
else
./vcpkg install libzippp:x64-linux nlohmann-json:x64-linux openssl-unix:x64-linux libzip:x64-linux
fi