diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..a61f26a0 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,19 @@ +stages: + - build + +build:windows: + stage: build + tags: + - vs2017 + - windows + before_script: + - git clean -xdf + - git submodule sync --recursive + - git submodule update --init --recursive + script: + - call scripts/build.bat + - call scripts/package.bat + artifacts: + expire_in: '2 hrs' + paths: + - PACKAGE/ diff --git a/ScreenPlay/ScreenPlay.pro b/ScreenPlay/ScreenPlay.pro index 6ce00e08..3118e52c 100644 --- a/ScreenPlay/ScreenPlay.pro +++ b/ScreenPlay/ScreenPlay.pro @@ -1,5 +1,5 @@ TEMPLATE = app -QT += qml quick widgets quickcontrols2 core +QT += qml quick widgets quickcontrols2 core webengine CONFIG += c++17 CONFIG += qtquickcompiler #DEFINES += QT_NO_DEBUG_OUTPUT QT_NO_WARNING_OUTPUT @@ -73,7 +73,6 @@ installOut.path = $${OUT_PWD}/ install_it.files += assets/templates/config.json \ assets/icons/favicon.ico \ - settings.json \ steam_appid.txt \ ThirdParty/ffmpeg/Windows/avcodec-58.dll \ ThirdParty/ffmpeg/Windows/avdevice-58.dll \ @@ -116,6 +115,8 @@ release { win32 { win32: LIBS += -L$$PWD/ThirdParty/Steam/redistributable_bin/win64/ -lsteam_api64 DEPENDPATH += $$PWD/ThirdParty/Steam/redistributable_bin/win64 + + install_it.files += ThirdParty\steam\redistributable_bin\win64\steam_api64.dll } unix { @@ -126,6 +127,8 @@ unix { DEPENDPATH += $$PWD/ThirdParty/steam/lib/linux64s LIBS += -L$$PWD/ThirdParty/steam/lib/linux64/ -lsdkencryptedappticket + + install_it.files += ThirdParty\steam\redistributable_bin\linux64\libsteam_api.so } DISTFILES += \ diff --git a/ScreenPlay/main.cpp b/ScreenPlay/main.cpp index 10aa12f3..29b514a2 100644 --- a/ScreenPlay/main.cpp +++ b/ScreenPlay/main.cpp @@ -45,10 +45,10 @@ int main(int argc, char* argv[]) { QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QGuiApplication::setAttribute(Qt::AA_UseDesktopOpenGL); QGuiApplication app(argc, argv); app.setQuitOnLastWindowClosed(false); + qSetMessagePattern("%{if-category}%{category}: %{endif}%{message}\n Loc: [%{file}:%{line}]"); QTranslator trsl; diff --git a/ScreenPlay/qml/Create/Wizards/CreateWallpaper/CreateWallpaperWizard.qml b/ScreenPlay/qml/Create/Wizards/CreateWallpaper/CreateWallpaperWizard.qml index 60dbc826..b0c791cc 100644 --- a/ScreenPlay/qml/Create/Wizards/CreateWallpaper/CreateWallpaperWizard.qml +++ b/ScreenPlay/qml/Create/Wizards/CreateWallpaper/CreateWallpaperWizard.qml @@ -78,6 +78,7 @@ Item { Item { id: wrapperSteps + z:10 anchors.fill: parent Text { @@ -398,11 +399,13 @@ Item { PropertyChanges { target: wrapperSteps opacity: 0 + z:0 } PropertyChanges { target: wrapperError opacity: 1 } + } ] transitions: [ diff --git a/ScreenPlay/qml/Create/Wizards/CreateWallpaper/Page_1.qml b/ScreenPlay/qml/Create/Wizards/CreateWallpaper/Page_1.qml index 6f83c736..551b7225 100644 --- a/ScreenPlay/qml/Create/Wizards/CreateWallpaper/Page_1.qml +++ b/ScreenPlay/qml/Create/Wizards/CreateWallpaper/Page_1.qml @@ -1,16 +1,66 @@ import QtQuick 2.9 import QtQuick.Controls 2.3 +import QtQuick.Controls.Material 2.3 +import net.aimber.create 1.0 Item { id: root + Connections { + target: screenPlayCreate + onCreateWallpaperStateChanged: { + print(state) + if (state === Create.State.ConvertingVideoFinished) { + root.state = "finished" + } + } + } + Rectangle { - id: rectangle1 - color: "#eeeeee" - width: parent.width * .5 - radius: 3 + id: wrapperProgressbar + height: parent.height * .5 + z:1 anchors { top: parent.top + right: parent.right + left: parent.left + } + + Text { + id: txtProgress + text: Math.floor(screenPlayCreate.progress) + "%" + font.pixelSize: 42 + color: "#626262" + renderType: Text.NativeRendering + anchors { + horizontalCenter: parent.horizontalCenter + bottom: progressBar.top + bottomMargin: 30 + } + } + + ProgressBar { + id: progressBar + value: screenPlayCreate.progress + from: 0 + to: 100 + anchors { + horizontalCenter: parent.horizontalCenter + bottom: parent.bottom + bottomMargin: 30 + } + } + } + + Rectangle { + id: wrapperFFMPEGOutput + color: "#eeeeee" + radius: 3 + z:1 + anchors { + top: wrapperProgressbar.bottom + topMargin: 30 + right: parent.right bottom: parent.bottom left: parent.left } @@ -18,6 +68,7 @@ Item { Flickable { anchors.fill: parent focus: true + clip: true contentHeight: txtFFMPEG.paintedHeight ScrollBar.vertical: ScrollBar { snapMode: ScrollBar.SnapOnRelease @@ -33,26 +84,79 @@ Item { } wrapMode: Text.WordWrap color: "#626262" + text: "asasas" renderType: Text.NativeRendering height: txtFFMPEG.paintedHeight + } + } + } + + Item { + id: wrapperFinished + z:0 + anchors.fill: parent + opacity: 0 + + Text { + id: txtDone + text: qsTr("Video creation successful!") + font.pixelSize: 42 + color: Material.color(Material.Green) + renderType: Text.NativeRendering + anchors { + horizontalCenter: parent.horizontalCenter + top: parent.top + topMargin: 30 } } } + Connections { target: screenPlayCreate onProcessOutput: { - txtFFMPEG.text = text + txtFFMPEG.text += text } } - - Rectangle { - id: rectangle - width: parent.width * .5 - anchors { - top: parent.top - bottom: parent.bottom - right: parent.right + states: [ + State { + name: "finished" + PropertyChanges { + target: wrapperProgressbar + opacity:0 + } + PropertyChanges { + target: wrapperFFMPEGOutput + opacity:0 + } + PropertyChanges { + target: wrapperFinished + opacity:1 + } } - } + ] + transitions: [ + Transition { + from: "0" + to: "finished" + PropertyAnimation { + target: wrapperFFMPEGOutput + duration: 200 + property: "opacity" + easing.type: Easing.InOutQuad + } + PropertyAnimation { + target: wrapperProgressbar + duration: 200 + property: "opacity" + easing.type: Easing.InOutQuad + } + PropertyAnimation { + target: wrapperFinished + duration: 200 + property: "opacity" + easing.type: Easing.InOutQuad + } + } + ] } diff --git a/ScreenPlay/qml/Settings/SettingsHeader.qml b/ScreenPlay/qml/Settings/SettingsHeader.qml index 879fc57e..2f2acd2a 100644 --- a/ScreenPlay/qml/Settings/SettingsHeader.qml +++ b/ScreenPlay/qml/Settings/SettingsHeader.qml @@ -71,7 +71,7 @@ Item { font.family: "Roboto" anchors{ top:parent.top - topMargin: 3 + topMargin: 0 left:parent.left leftMargin: 30 } @@ -104,7 +104,7 @@ Item { PropertyChanges { target: txtHeadline - anchors.topMargin: 3 + anchors.topMargin: 0 opacity: 1 } } diff --git a/ScreenPlay/src/create.cpp b/ScreenPlay/src/create.cpp index 7e6550e6..554ac7cd 100644 --- a/ScreenPlay/src/create.cpp +++ b/ScreenPlay/src/create.cpp @@ -195,14 +195,6 @@ bool Create::createWallpaperVideoPreview(CreateWallpaperData& createWallpaperDat emit createWallpaperStateChanged(Create::State::ConvertingPreviewVideo); proConvertPreviewMP4.data()->start(); - - QScopedPointer processOutputTimer(new QTimer()); - - // connect(processOutputTimer.data(), &QTimer::timeout, [&]() { - // qDebug() << "### " << proConvertPreviewMP4.data()->readAll(); - // this->processOutput(proConvertPreviewMP4.data()->readAll()); - // }); - processOutputTimer.data()->start(100); proConvertPreviewMP4.data()->waitForFinished(-1); if (proConvertPreviewMP4.data()->exitStatus() == QProcess::NormalExit) { qDebug() << "normal exit"; @@ -211,19 +203,17 @@ bool Create::createWallpaperVideoPreview(CreateWallpaperData& createWallpaperDat } QString tmpErr = proConvertPreviewMP4.data()->readAllStandardError(); if (!tmpErr.isEmpty()) { - qDebug() << tmpErr; - qDebug() << proConvertPreviewMP4.data()->readAllStandardOutput(); - qDebug() << proConvertPreviewMP4.data()->readAll(); - emit processOutput(tmpErr); - emit createWallpaperStateChanged(Create::State::ConvertingPreviewVideoError); - return false; + QFile previewVideo(createWallpaperData.exportPath + "/preview.mp4"); + if (!previewVideo.exists() && !(previewVideo.size() > 0)) { + emit processOutput(tmpErr); + emit createWallpaperStateChanged(Create::State::ConvertingPreviewVideoError); + return false; + } } - // qDebug() << proConvertPreviewMP4.data()->program() << proConvertPreviewMP4.data()->arguments(); - // qDebug() << "Done converting video to preview" << proConvertPreviewMP4.data()->readAll() << "\n" - // << proConvertPreviewMP4.data()->readAllStandardError(); + this->processOutput(proConvertPreviewMP4.data()->readAll()); proConvertPreviewMP4.data()->close(); - processOutputTimer.data()->stop(); + emit createWallpaperStateChanged(Create::State::ConvertingPreviewVideoFinished); /* @@ -250,14 +240,15 @@ bool Create::createWallpaperVideoPreview(CreateWallpaperData& createWallpaperDat #endif proConvertGif.data()->start(); proConvertGif.data()->waitForFinished(-1); - if (!proConvertGif.data()->readAllStandardError().isEmpty()) { - emit createWallpaperStateChanged(Create::State::ConvertingPreviewGifError); - return false; + QString tmpErrGif = proConvertGif.data()->readAllStandardError(); + if (!tmpErrGif.isEmpty()) { + QFile previewGif(createWallpaperData.exportPath + "/preview.gif"); + if (!previewGif.exists() && !(previewGif.size() > 0)) { + emit createWallpaperStateChanged(Create::State::ConvertingPreviewGifError); + return false; + } } - // qDebug() << proConvertGif.data()->program() << proConvertGif.data()->arguments(); - // qDebug() << "Done converting video to preview" << proConvertGif.data()->readAll() << "\n" - // << proConvertGif.data()->readAllStandardError(); this->processOutput(proConvertPreviewMP4.data()->readAll()); proConvertGif.data()->close(); emit createWallpaperStateChanged(Create::State::ConvertingPreviewGifFinished); @@ -267,6 +258,74 @@ bool Create::createWallpaperVideoPreview(CreateWallpaperData& createWallpaperDat bool Create::createWallpaperVideo(CreateWallpaperData& createWallpaperData) { + emit createWallpaperStateChanged(Create::State::ConvertingVideo); + + QStringList args; + args.append("-hide_banner"); + args.append("-y"); + args.append("-stats"); + args.append("-i"); + args.append(createWallpaperData.videoPath); + args.append("-c:v"); + args.append("libvpx-vp9"); + args.append("-crf"); + args.append("30"); + args.append("-threads"); + args.append("16"); + args.append("-slices"); + args.append("16"); + args.append("-cpu-used"); + args.append("4"); + args.append("-pix_fmt"); + args.append("yuv420p"); + args.append("-b:v"); + args.append("0"); + args.append(createWallpaperData.exportPath + "/video.webm"); + + QScopedPointer proConvertVideo(new QProcess()); + proConvertVideo.data()->setArguments(args); + proConvertVideo.data()->setProcessChannelMode(QProcess::MergedChannels); + proConvertVideo.data()->setProgram(QApplication::applicationDirPath() + "/ffmpeg.exe"); + qDebug() << "Start converting video"; + + connect(proConvertVideo.data(), &QProcess::readyReadStandardOutput, this, [&]() { + QString tmpOut = proConvertVideo.data()->readAllStandardOutput(); + auto tmpList = tmpOut.split(QRegExp("\\s+"), QString::SkipEmptyParts); + if (tmpList.length() > 2) { + bool ok = false; + float currentFrame = QString(tmpList.at(1)).toFloat(&ok); + + if (!ok) + return; + + float progress = currentFrame / createWallpaperData.length; + + this->setProgress(progress); + } + this->processOutput(tmpOut); + }); + + // For some reason we only get output if we use execute instead of start....?! +#ifdef Q_OS_WIN + //proConvertVideo.data()->execute(QApplication::applicationDirPath() + "/ffmpeg.exe", args); +#endif + proConvertVideo.data()->start(QIODevice::ReadOnly); + proConvertVideo.data()->waitForFinished(-1); + QString out = proConvertVideo.data()->readAllStandardOutput(); + + this->processOutput(out); + QString tmpErrVideo = proConvertVideo.data()->readAllStandardError(); + if (!tmpErrVideo.isEmpty()) { + QFile video(createWallpaperData.exportPath + "/video.webm"); + if (!video.exists() && !(video.size() > 0)) { + emit createWallpaperStateChanged(Create::State::ConvertingVideoError); + return false; + } + } + + proConvertVideo.data()->close(); + emit createWallpaperStateChanged(Create::State::ConvertingVideoFinished); + return true; } diff --git a/ScreenPlay/src/create.h b/ScreenPlay/src/create.h index 19567163..c58a836d 100644 --- a/ScreenPlay/src/create.h +++ b/ScreenPlay/src/create.h @@ -36,6 +36,7 @@ public: explicit Create(Settings* st, QMLUtilities* util, QObject* parent = nullptr); Q_PROPERTY(QString workingDir READ workingDir WRITE setWorkingDir NOTIFY workingDirChanged) + Q_PROPERTY(float progress READ progress WRITE setProgress NOTIFY progressChanged) Create() {} ~Create() {} @@ -55,6 +56,9 @@ public: ConvertingPreviewGif, ConvertingPreviewGifFinished, ConvertingPreviewGifError, + ConvertingVideo, + ConvertingVideoFinished, + ConvertingVideoError, Finished, ErrorUnknown, }; @@ -66,11 +70,18 @@ public: return m_workingDir; } + float progress() const + { + return m_progress; + } + signals: void createWallpaperStateChanged(Create::State state); void processOutput(QString text); void workingDirChanged(QString workingDir); + void progressChanged(float progress); + public slots: void copyProject(QString relativeProjectPath, QString toPath); bool copyRecursively(const QString& srcFilePath, const QString& tgtFilePath); @@ -92,9 +103,20 @@ public slots: emit workingDirChanged(m_workingDir); } + void setProgress(float progress) + { + if (qFuzzyCompare(m_progress, progress)) + return; + + qDebug() << progress; + m_progress = progress; + emit progressChanged(m_progress); + } + private: Settings* m_settings; QMLUtilities* m_utils; QString m_workingDir; + float m_progress = 0.0f; }; diff --git a/ScreenPlay/src/settings.cpp b/ScreenPlay/src/settings.cpp index 8efb7fcb..6576c18c 100644 --- a/ScreenPlay/src/settings.cpp +++ b/ScreenPlay/src/settings.cpp @@ -1,4 +1,5 @@ #include "settings.h" +#include Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListModel* ilm, SDKConnector* sdkc, AppId_t steamID, QGuiApplication* app, QObject* parent) : QObject(parent) @@ -12,7 +13,7 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo m_qGuiApplication = app; QFile configTmp; - QString appConfigLocation = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation); + QString appConfigLocation = QGuiApplication::applicationDirPath(); m_localSettingsPath = QUrl(appConfigLocation); if (!QDir(appConfigLocation).exists()) { if (!QDir().mkdir(appConfigLocation)) { @@ -30,7 +31,7 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo } QJsonDocument configJsonDocument; - QJsonParseError parseError{}; + QJsonParseError parseError {}; QJsonObject configObj; configTmp.open(QIODevice::ReadOnly | QIODevice::Text); @@ -150,7 +151,7 @@ void Settings::writeSingleSettingConfig(QString name, QVariant value) { QJsonDocument configJsonDocument; - QJsonParseError parseError{}; + QJsonParseError parseError {}; QJsonObject configObj; QFile configTmp; @@ -263,7 +264,7 @@ void Settings::setPlayAll(bool isPlaying) void Settings::createDefaultConfig() { - QFile file(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/settings.json"); + QFile file(QGuiApplication::applicationDirPath() + "/settings.json"); QFile defaultSettings(":/settings.json"); file.open(QIODevice::WriteOnly | QIODevice::Text); diff --git a/ScreenPlay/src/settings.h b/ScreenPlay/src/settings.h index 586392df..866fc939 100644 --- a/ScreenPlay/src/settings.h +++ b/ScreenPlay/src/settings.h @@ -232,6 +232,7 @@ public slots: writeSingleSettingConfig("absoluteStoragePath", cleanedPath); m_ilm->setabsoluteStoragePath(cleanedPath.toString()); + m_localStoragePath = cleanedPath.toString(); emit localStoragePathChanged(cleanedPath.toString()); m_ilm->reset(); m_ilm->loadScreens(); diff --git a/ScreenPlaySysInfo/ScreenPlaySysInfo.pro b/ScreenPlaySysInfo/ScreenPlaySysInfo.pro index 77fdc807..6d6dfc15 100644 --- a/ScreenPlaySysInfo/ScreenPlaySysInfo.pro +++ b/ScreenPlaySysInfo/ScreenPlaySysInfo.pro @@ -9,11 +9,15 @@ uri = net.aimber.sysinfo # Input SOURCES += \ screenplaysysinfo_plugin.cpp \ - sysinfo.cpp + sysinfo.cpp \ + cpu.cpp \ + ram.cpp HEADERS += \ screenplaysysinfo_plugin.h \ - sysinfo.h + sysinfo.h \ + cpu.h \ + ram.h DISTFILES = qmldir diff --git a/ScreenPlaySysInfo/cpu.cpp b/ScreenPlaySysInfo/cpu.cpp new file mode 100644 index 00000000..9cb13626 --- /dev/null +++ b/ScreenPlaySysInfo/cpu.cpp @@ -0,0 +1,36 @@ +#include "cpu.h" +#include + +#define STATUS_SUCCESS 0 +#define STATUS_INFO_LENGTH_MISMATCH 0xC0000004 + +CPU::CPU(QObject *parent) : QObject(parent) +{ + + // signal obj, signal function pointer, slot obj, slot function pointer + connect(&m_updateTimer,&QTimer::timeout,this,&CPU::update); + m_updateTimer.start(m_tickRate); +} + + +void CPU::update() +{ +// long status = 0; +// unsigned long bufSize = c_BufferSize; +// byte* buf = (bufSize > 0) ? new BYTE[bufSize] : nullptr; + + + +// status = c_NtQuerySystemInformation(SystemProcessorPerformanceInformation, buf, bufSize, &size); + +// switch (status) { +// case STATUS_INFO_LENGTH_MISMATCH: +// qWarning() << "Warning: Status info length mismatch!"; +// break; +// case STATUS_SUCCESS: + +// break; +// default: +// break; +// } +} diff --git a/ScreenPlaySysInfo/cpu.h b/ScreenPlaySysInfo/cpu.h new file mode 100644 index 00000000..8484e43a --- /dev/null +++ b/ScreenPlaySysInfo/cpu.h @@ -0,0 +1,78 @@ +#pragma once + +#include +#include +#include + +#ifdef Q_OS_WIN +#include +#endif + +// https://github.com/rainmeter/rainmeter/blob/master/Library/MeasureCPU.cpp + +typedef LONG(WINAPI* FPNTQSI)(UINT, PVOID, ULONG, PULONG); + +class CPU : public QObject { + Q_OBJECT + + Q_PROPERTY(float usage READ usage NOTIFY usageChanged) + Q_PROPERTY(int tickRate READ tickRate WRITE setTickRate NOTIFY tickRateChanged) + +public: + explicit CPU(QObject* parent = nullptr); + + + float usage() const + { + return m_usage; + } + + int tickRate() const + { + return m_tickRate; + } + +signals: + + void usageChanged(float usage); + + void tickRateChanged(int tickRate); + +public slots: + void update(); + + void setUsage(float usage) + { + qWarning("Floating point comparison needs context sanity check"); + if (qFuzzyCompare(m_usage, usage)) + return; + + m_usage = usage; + emit usageChanged(m_usage); + } + + void setTickRate(int tickRate) + { + if (m_tickRate == tickRate) + return; + + qDebug() << "hat sich was geƤndert"; + + m_tickRate = tickRate; + emit tickRateChanged(m_tickRate); + } + +private: + float m_usage = 42.0f; + + int m_Processor; + + double m_OldTime[2]; + + static FPNTQSI c_NtQuerySystemInformation; + + static int c_NumOfProcessors; + static ULONG c_BufferSize; + int m_tickRate = 500; + QTimer m_updateTimer; +}; diff --git a/ScreenPlaySysInfo/ram.cpp b/ScreenPlaySysInfo/ram.cpp new file mode 100644 index 00000000..3f813dfc --- /dev/null +++ b/ScreenPlaySysInfo/ram.cpp @@ -0,0 +1,8 @@ +#include "ram.h" +#include +#include +RAM::RAM(QObject* parent) + : QObject(parent) +{ + +} diff --git a/ScreenPlaySysInfo/ram.h b/ScreenPlaySysInfo/ram.h new file mode 100644 index 00000000..f5fe98ae --- /dev/null +++ b/ScreenPlaySysInfo/ram.h @@ -0,0 +1,39 @@ +#pragma once + +#include +#include + +class RAM : public QObject { + Q_OBJECT + Q_PROPERTY(float usage READ usage NOTIFY usageChanged) + +public: + explicit RAM(QObject* parent = nullptr); + + float usage() const + { + return m_usage; + } + +signals: + + void usageChanged(float usage); + +public slots: + void exe(){ + qDebug() << "aa"; + } + void setUsage(float usage) + { + qWarning("Floating point comparison needs context sanity check"); + if (qFuzzyCompare(m_usage, usage)) + return; + + m_usage = usage; + emit usageChanged(m_usage); + } + +private: + float m_usage = 42.0f; +}; + diff --git a/ScreenPlaySysInfo/screenplaysysinfo_plugin.cpp b/ScreenPlaySysInfo/screenplaysysinfo_plugin.cpp index c7f1bec1..250b64ed 100644 --- a/ScreenPlaySysInfo/screenplaysysinfo_plugin.cpp +++ b/ScreenPlaySysInfo/screenplaysysinfo_plugin.cpp @@ -1,9 +1,9 @@ #include "screenplaysysinfo_plugin.h" #include "sysinfo.h" - +#include #include -QObject *ScreenPlaySysInfoSingleton(QQmlEngine *engine, QJSEngine *scriptEngine) +QObject* ScreenPlaySysInfoSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) { Q_UNUSED(engine) Q_UNUSED(scriptEngine) @@ -11,9 +11,9 @@ QObject *ScreenPlaySysInfoSingleton(QQmlEngine *engine, QJSEngine *scriptEngine) return new SysInfo(); } -void ScreenPlaySysInfoPlugin::registerTypes(const char *uri) +void ScreenPlaySysInfoPlugin::registerTypes(const char* uri) { // @uri net.aimber.sysinfo - qmlRegisterSingletonType(uri, 1, 0, "SysInfo",ScreenPlaySysInfoSingleton); -} + qmlRegisterSingletonType(uri, 1, 0, "SysInfo", ScreenPlaySysInfoSingleton); +} diff --git a/ScreenPlaySysInfo/sysinfo.cpp b/ScreenPlaySysInfo/sysinfo.cpp index b1dc6f68..9db4bcea 100644 --- a/ScreenPlaySysInfo/sysinfo.cpp +++ b/ScreenPlaySysInfo/sysinfo.cpp @@ -3,13 +3,13 @@ SysInfo::SysInfo(QQuickItem *parent): QQuickItem(parent) { - // By default, QQuickItem does not draw anything. If you subclass - // QQuickItem to create a visual item, you will need to uncomment the - // following line and re-implement updatePaintNode() - - // setFlag(ItemHasContents, true); + // FIXME Elias 2018 QQmlEngine cannot handle smartpointers yet.... + m_ram = new RAM(); + m_cpu = new CPU(); } SysInfo::~SysInfo() { + delete m_cpu; + delete m_ram; } diff --git a/ScreenPlaySysInfo/sysinfo.h b/ScreenPlaySysInfo/sysinfo.h index cf22e58a..27f8a7be 100644 --- a/ScreenPlaySysInfo/sysinfo.h +++ b/ScreenPlaySysInfo/sysinfo.h @@ -1,16 +1,39 @@ -#ifndef SYSINFO_H -#define SYSINFO_H +#pragma once +#include "cpu.h" +#include "ram.h" #include +#include +#include -class SysInfo : public QQuickItem -{ +class SysInfo : public QQuickItem { Q_OBJECT Q_DISABLE_COPY(SysInfo) -public: - SysInfo(QQuickItem *parent = nullptr); - ~SysInfo(); -}; + Q_PROPERTY(RAM* ram READ ram NOTIFY ramChanged) + Q_PROPERTY(CPU* cpu READ cpu NOTIFY cpuChanged) -#endif // SYSINFO_H +public: + SysInfo(QQuickItem* parent = nullptr); + ~SysInfo(); + + RAM* ram() const + { + return m_ram; + } + + CPU* cpu() const + { + return m_cpu; + } + +public slots: + +signals: + void ramChanged(RAM* ram); + void cpuChanged(CPU* cpu); + +private: + RAM* m_ram; + CPU* m_cpu; +}; diff --git a/ScreenPlayWidget/SPWidgetResources.qrc b/ScreenPlayWidget/SPWidgetResources.qrc index 5f6483ac..466227d4 100644 --- a/ScreenPlayWidget/SPWidgetResources.qrc +++ b/ScreenPlayWidget/SPWidgetResources.qrc @@ -1,5 +1,6 @@ main.qml + assets/image/noisy-texture-3.png diff --git a/ScreenPlayWidget/ScreenPlayWidget.pro b/ScreenPlayWidget/ScreenPlayWidget.pro index c448b48b..76b3a4ed 100644 --- a/ScreenPlayWidget/ScreenPlayWidget.pro +++ b/ScreenPlayWidget/ScreenPlayWidget.pro @@ -1,5 +1,5 @@ -QT += quick -CONFIG += c++11 +QT += quick qml quickcontrols2 core charts widgets gui +CONFIG += c++17 CONFIG += qtquickcompiler # The following define makes your compiler emit warnings if you use # any feature of Qt which as been marked deprecated (the exact warnings diff --git a/ScreenPlayWidget/assets/image/noisy-texture-3.png b/ScreenPlayWidget/assets/image/noisy-texture-3.png new file mode 100644 index 00000000..3ef73675 Binary files /dev/null and b/ScreenPlayWidget/assets/image/noisy-texture-3.png differ diff --git a/ScreenPlayWidget/main.qml b/ScreenPlayWidget/main.qml index 928e4639..731d0caf 100644 --- a/ScreenPlayWidget/main.qml +++ b/ScreenPlayWidget/main.qml @@ -1,14 +1,42 @@ import QtQuick 2.9 import net.aimber.screenplaysdk 1.0 -import QtQuick.Window 2.3 import QtQuick.Controls 2.3 -Window { +Item { id: mainWindow visible: true - width: 250 - height: 250 - flags: Qt.SplashScreen | Qt.ToolTip | Qt.SplashScreen + anchors.fill: parent + + Rectangle { + id:bgColor + anchors.fill: parent + color: "white" + //color: "#1A1F22" + opacity: .15 + } + + Image { + id: bg + source: "qrc:/assets/image/noisy-texture-3.png" + anchors.fill: parent + opacity: .05 + fillMode: Image.Tile + } + + + MouseArea { + id: mouseArea + anchors.fill: parent + + onPressed: { + backend.setClickPos(Qt.point(mouse.x, mouse.y)) + } + + onPositionChanged: { + backend.setPos(mouse.x, mouse.y) + } + + } ScreenPlaySDK { id: spSDK @@ -53,48 +81,4 @@ Window { } } } - - Connections{ - target: loader.item - ignoreUnknownSignals: true - onSizeChanged:{ - print(size) - mainWindow.width = size.width - mainWindow.height = size.height - } - } - - MouseArea { - property point clickPos: "1,1" - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - z:99 - - onPressed: { - clickPos = Qt.point(mouse.x, mouse.y) - } - - onPositionChanged: { - var delta = Qt.point(mouse.x - clickPos.x, mouse.y - clickPos.y) - var new_x = mainWindow.x + delta.x - var new_y = mainWindow.y + delta.y - mainWindow.x = new_x - mainWindow.y = new_y - } - - onClicked: { - if (mouse.button === Qt.RightButton) { - contextMenu.popup() - } - } - } - Menu { - id: contextMenu - MenuItem { - text: qsTr("Close") - onClicked: { - Qt.quit(); - } - } - } } diff --git a/ScreenPlayWidget/src/spwidgetmainwindow.cpp b/ScreenPlayWidget/src/spwidgetmainwindow.cpp index 234fb47a..0338cc58 100644 --- a/ScreenPlayWidget/src/spwidgetmainwindow.cpp +++ b/ScreenPlayWidget/src/spwidgetmainwindow.cpp @@ -3,8 +3,15 @@ SPWidgetmainwindow::SPWidgetmainwindow(QString projectPath, QString appid, QScreen* parent) : QWindow(parent) { + m_appID = appid; + m_hwnd = (HWND)this->winId(); + Qt::WindowFlags flags = this->flags(); + this->setWidth(500); + this->setHeight(300); + this->setFlags(flags | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::BypassWindowManagerHint | Qt::SplashScreen); + QFile configTmp; QJsonDocument configJsonDocument; QJsonParseError parseError; @@ -20,11 +27,80 @@ SPWidgetmainwindow::SPWidgetmainwindow(QString projectPath, QString appid, QScre m_project = configJsonDocument.object(); QString fullPath = projectPath + "/" + m_project.value("file").toString(); - m_quickRenderer = QSharedPointer(new QQmlApplicationEngine()); + m_quickRenderer = QSharedPointer(new QQuickView(this)); m_quickRenderer.data()->rootContext()->setContextProperty("backend", this); - m_quickRenderer.data()->load(QUrl("qrc:/main.qml")); + m_quickRenderer.data()->setColor(Qt::transparent); + m_quickRenderer.data()->setWidth(this->width()); + m_quickRenderer.data()->setHeight(this->height()); + m_quickRenderer.data()->setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView); + + m_quickRenderer.data()->setSource(QUrl("qrc:/main.qml")); +#ifdef Q_OS_WIN + SetWindowBlur(m_hwnd); +#endif + show(); + m_quickRenderer.data()->show(); emit setWidgetSource(fullPath); - } +void SPWidgetmainwindow::setSize(QSize size) +{ + this->setWidth(size.width()); + this->setHeight(size.height()); + m_quickRenderer.data()->setWidth(size.width()); + m_quickRenderer.data()->setHeight(size.height()); +} + +void SPWidgetmainwindow::setPos(int xPos, int yPos) +{ + + QPoint delta((xPos - m_clickPos.x()), (yPos - m_clickPos.y())); + int new_x = x() + delta.x(); + int new_y = y() + delta.y(); + + setPosition(QPoint(new_x, new_y)); +} + +void SPWidgetmainwindow::setClickPos(const QPoint &clickPos) +{ + m_clickPos = clickPos; +} + +void SPWidgetmainwindow::SetWindowBlur(HWND hWnd) +{ +#ifdef Q_OS_WIN + + const HINSTANCE hModule = LoadLibrary(TEXT("user32.dll")); + if (hModule) { + struct ACCENTPOLICY { + int nAccentState; + int nFlags; + int nColor; + int nAnimationId; + }; + struct WINCOMPATTRDATA { + int nAttribute; + PVOID pData; + ULONG ulDataSize; + }; + enum class Accent { + DISABLED = 0, + GRADIENT = 1, + TRANSPARENTGRADIENT = 2, + BLURBEHIND = 3, + ACRYLIC = 4, + INVALID = 5 + }; + typedef BOOL(WINAPI * pSetWindowCompositionAttribute)(HWND, WINCOMPATTRDATA*); + const pSetWindowCompositionAttribute SetWindowCompositionAttribute = (pSetWindowCompositionAttribute)GetProcAddress(hModule, "SetWindowCompositionAttribute"); + if (SetWindowCompositionAttribute) { + ACCENTPOLICY policy = { (int)Accent::BLURBEHIND, 0, 0, 0 }; // ACCENT_ENABLE_BLURBEHIND=3... + WINCOMPATTRDATA data = { 19, &policy, sizeof(ACCENTPOLICY) }; // WCA_ACCENT_POLICY=19 + SetWindowCompositionAttribute(hWnd, &data); + } + FreeLibrary(hModule); + } + +#endif +} diff --git a/ScreenPlayWidget/src/spwidgetmainwindow.h b/ScreenPlayWidget/src/spwidgetmainwindow.h index 41f91c4f..1872ff1b 100644 --- a/ScreenPlayWidget/src/spwidgetmainwindow.h +++ b/ScreenPlayWidget/src/spwidgetmainwindow.h @@ -6,12 +6,15 @@ #include #include #include +#include #include -#include +#include +#include +#include #include #include #include -#include +#include class SPWidgetmainwindow : public QWindow { Q_OBJECT @@ -45,6 +48,7 @@ signals: void setWidgetSource(QString source); public slots: + void setSize(QSize size); void setAppID(QString appID) { if (m_appID == appID) @@ -70,11 +74,17 @@ public slots: emit projectConfigChanged(m_projectConfig); } + void setPos(int xPos, int yPos); + void setClickPos(const QPoint& clickPos); + void SetWindowBlur(HWND hWnd); + private: QString m_appID; QString m_type = "qmlWidget"; QString m_projectConfig; QJsonObject m_project; + HWND m_hwnd; + QPoint m_clickPos = { 0, 0 }; - QSharedPointer m_quickRenderer = nullptr; + QSharedPointer m_quickRenderer; }; diff --git a/scripts/build.bat b/scripts/build.bat new file mode 100644 index 00000000..38794df2 --- /dev/null +++ b/scripts/build.bat @@ -0,0 +1,18 @@ +setlocal EnableExtensions + +set PATH=%PATH%;C:\Qt\Tools\QtCreator\bin +set PATH=%PATH%;C:\Qt\5.11.2\msvc2017_64\bin +set root=%cd% + +call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsx86_amd64.bat" + +mkdir BUILD +cd BUILD + +echo "Begin build of ScreenPlay " +qmake.exe ../ScreenPlay.pro -spec win32-msvc "CONFIG+=release" +jom.exe qmake_all +jom.exe -j8 +jom.exe install +echo "Build ScreenPlay finished!" + diff --git a/scripts/package.bat b/scripts/package.bat new file mode 100644 index 00000000..1d7ef32c --- /dev/null +++ b/scripts/package.bat @@ -0,0 +1,40 @@ +setlocal EnableExtensions + +set PATH=%PATH%;C:\Qt\Tools\QtCreator\bin +set PATH=%PATH%;C:\Qt\5.11.2\msvc2017_64\bin +set root=%cd% + +call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsx86_amd64.bat" + +echo "Begin packaging" + +mkdir PACKAGE +cd BUILD + +echo "Copy ScreenPlay" +xcopy /s /y ScreenPlay\release ..\PACKAGE +echo "Copy ScreenPlaySDK" +xcopy /s /y ScreenPlaySDK\release ..\PACKAGE +echo "Copy ScreenPlayWidget" +xcopy /s /y ScreenPlayWidget\release ..\PACKAGE +echo "Copy ScreenPlayWindow" +xcopy /s /y ScreenPlayWindow\release ..\PACKAGE +echo "Copy ScreenPlayWorkshop" +xcopy /s /y ScreenPlayWorkshop\release ..\PACKAGE + +xcopy C:\Qt\Tools\QtCreator\bin\libeay32.dll ..\PACKAGE +xcopy C:\Qt\Tools\QtCreator\bin\ssleay32.dll ..\PACKAGE + + +cd .. + +windeployqt.exe --release --qmldir ScreenPlay/qml PACKAGE/ScreenPlay.exe + +cd PACKAGE + +del /f *.cpp +del /f *.moc +del /f *.h +del /f *.obj +del /f *.res +