mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-22 18:52:30 +01:00
Merge commit '79303414787998cc6b537ed6eb79a8b4df7eb891' into dev
This commit is contained in:
commit
9b99e7b5ce
19
.gitlab-ci.yml
Normal file
19
.gitlab-ci.yml
Normal file
@ -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/
|
@ -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 += \
|
||||
|
@ -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;
|
||||
|
@ -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: [
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -195,14 +195,6 @@ bool Create::createWallpaperVideoPreview(CreateWallpaperData& createWallpaperDat
|
||||
emit createWallpaperStateChanged(Create::State::ConvertingPreviewVideo);
|
||||
|
||||
proConvertPreviewMP4.data()->start();
|
||||
|
||||
QScopedPointer<QTimer> 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<QProcess> 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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "settings.h"
|
||||
#include <QGuiApplication>
|
||||
|
||||
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);
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
||||
|
36
ScreenPlaySysInfo/cpu.cpp
Normal file
36
ScreenPlaySysInfo/cpu.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
#include "cpu.h"
|
||||
#include <QtQml/qqml.h>
|
||||
|
||||
#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;
|
||||
// }
|
||||
}
|
78
ScreenPlaySysInfo/cpu.h
Normal file
78
ScreenPlaySysInfo/cpu.h
Normal file
@ -0,0 +1,78 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <qt_windows.h>
|
||||
#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;
|
||||
};
|
8
ScreenPlaySysInfo/ram.cpp
Normal file
8
ScreenPlaySysInfo/ram.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "ram.h"
|
||||
#include <QtQml/qqml.h>
|
||||
#include <qmetatype.h>
|
||||
RAM::RAM(QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
|
||||
}
|
39
ScreenPlaySysInfo/ram.h
Normal file
39
ScreenPlaySysInfo/ram.h
Normal file
@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
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;
|
||||
};
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include "screenplaysysinfo_plugin.h"
|
||||
#include "sysinfo.h"
|
||||
|
||||
#include <qmetatype.h>
|
||||
#include <qqml.h>
|
||||
|
||||
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<SysInfo>(uri, 1, 0, "SysInfo",ScreenPlaySysInfoSingleton);
|
||||
}
|
||||
qmlRegisterSingletonType<SysInfo>(uri, 1, 0, "SysInfo", ScreenPlaySysInfoSingleton);
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -1,16 +1,39 @@
|
||||
#ifndef SYSINFO_H
|
||||
#define SYSINFO_H
|
||||
#pragma once
|
||||
|
||||
#include "cpu.h"
|
||||
#include "ram.h"
|
||||
#include <QQuickItem>
|
||||
#include <QSharedPointer>
|
||||
#include <memory>
|
||||
|
||||
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;
|
||||
};
|
||||
|
@ -1,5 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>main.qml</file>
|
||||
<file>assets/image/noisy-texture-3.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -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
|
||||
|
BIN
ScreenPlayWidget/assets/image/noisy-texture-3.png
Normal file
BIN
ScreenPlayWidget/assets/image/noisy-texture-3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.0 KiB |
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<QQmlApplicationEngine>(new QQmlApplicationEngine());
|
||||
m_quickRenderer = QSharedPointer<QQuickView>(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
|
||||
}
|
||||
|
@ -6,12 +6,15 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonParseError>
|
||||
#include <QPoint>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlContext>
|
||||
#include <QQuickView>
|
||||
#include <QtQuick/QQuickView>
|
||||
#include <QtQuick/QQuickWindow>
|
||||
#include <QQuickWindow>
|
||||
#include <QSharedPointer>
|
||||
#include <QString>
|
||||
#include <QWindow>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <qt_windows.h>
|
||||
|
||||
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<QQmlApplicationEngine> m_quickRenderer = nullptr;
|
||||
QSharedPointer<QQuickView> m_quickRenderer;
|
||||
};
|
||||
|
18
scripts/build.bat
Normal file
18
scripts/build.bat
Normal file
@ -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!"
|
||||
|
40
scripts/package.bat
Normal file
40
scripts/package.bat
Normal file
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user