mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 03:22:33 +01:00
Cleanup widgets and Window. When a developer now opens the widget or window project it opens a instance without screenplay sdk. This makes debugging way easier
This commit is contained in:
parent
970aeea99f
commit
9b606a79bc
@ -13,8 +13,8 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
SPWidgetmain.cpp \
|
main.cpp \
|
||||||
src/spwidgetmainwindow.cpp
|
src/widgetwindow.cpp
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
SPWidgetResources.qrc
|
SPWidgetResources.qrc
|
||||||
@ -57,4 +57,4 @@ QML_DESIGNER_IMPORT_PATH =
|
|||||||
|
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/spwidgetmainwindow.h
|
src/widgetwindow.h
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
#include "src/spwidgetmainwindow.h"
|
#include "src/widgetwindow.h"
|
||||||
#include "../ScreenPlaySDK/screenplaysdk.h"
|
#include "../ScreenPlaySDK/screenplaysdk.h"
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
@ -12,18 +12,25 @@ int main(int argc, char* argv[])
|
|||||||
ScreenPlaySDK sdk;
|
ScreenPlaySDK sdk;
|
||||||
QGuiApplication app(argc, argv);
|
QGuiApplication app(argc, argv);
|
||||||
|
|
||||||
|
|
||||||
QStringList argumentList = app.arguments();
|
QStringList argumentList = app.arguments();
|
||||||
|
|
||||||
|
// If we start with only one argument (app path)
|
||||||
|
// It means we want to test a single widget
|
||||||
|
if (argumentList.length() == 1) {
|
||||||
|
// Todo generic widget
|
||||||
|
WidgetWindow spwmw("D:/672870/xkcd","appid" );
|
||||||
|
|
||||||
|
return app.exec();
|
||||||
|
}
|
||||||
|
|
||||||
if (argumentList.length() != 3) {
|
if (argumentList.length() != 3) {
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPWidgetmainwindow spwmw(argumentList.at(1), argumentList.at(2));
|
WidgetWindow spwmw(argumentList.at(1), argumentList.at(2));
|
||||||
//SPWidgetmainwindow spwmw("D:/672870/xkcd","asasasasd" );
|
|
||||||
|
|
||||||
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &spwmw, &SPWidgetmainwindow::destroyThis);
|
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &spwmw, &WidgetWindow::destroyThis);
|
||||||
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &spwmw, &SPWidgetmainwindow::messageReceived);
|
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &spwmw, &WidgetWindow::messageReceived);
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
#include "spwidgetmainwindow.h"
|
#include "widgetwindow.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
SPWidgetmainwindow::SPWidgetmainwindow(QString projectPath, QString appid, QObject* parent)
|
WidgetWindow::WidgetWindow(QString projectPath, QString appid, QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ SPWidgetmainwindow::SPWidgetmainwindow(QString projectPath, QString appid, QObje
|
|||||||
|
|
||||||
m_hwnd = reinterpret_cast<HWND>(m_window.winId());
|
m_hwnd = reinterpret_cast<HWND>(m_window.winId());
|
||||||
Qt::WindowFlags flags = m_window.flags();
|
Qt::WindowFlags flags = m_window.flags();
|
||||||
m_window.setWidth(500);
|
m_window.setWidth(300);
|
||||||
m_window.setHeight(300);
|
m_window.setHeight(300);
|
||||||
m_window.setFlags(flags | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::BypassWindowManagerHint | Qt::SplashScreen);
|
m_window.setFlags(flags | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::BypassWindowManagerHint | Qt::SplashScreen);
|
||||||
|
|
||||||
@ -31,7 +31,6 @@ SPWidgetmainwindow::SPWidgetmainwindow(QString projectPath, QString appid, QObje
|
|||||||
|
|
||||||
m_window.rootContext()->setContextProperty("backend", this);
|
m_window.rootContext()->setContextProperty("backend", this);
|
||||||
m_window.setColor(Qt::transparent);
|
m_window.setColor(Qt::transparent);
|
||||||
m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
|
|
||||||
|
|
||||||
m_window.setSource(QUrl("qrc:/main.qml"));
|
m_window.setSource(QUrl("qrc:/main.qml"));
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
@ -42,23 +41,23 @@ SPWidgetmainwindow::SPWidgetmainwindow(QString projectPath, QString appid, QObje
|
|||||||
emit setWidgetSource(fullPath);
|
emit setWidgetSource(fullPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPWidgetmainwindow::setSize(QSize size)
|
void WidgetWindow::setSize(QSize size)
|
||||||
{
|
{
|
||||||
m_window.setWidth(size.width());
|
m_window.setWidth(size.width());
|
||||||
m_window.setHeight(size.height());
|
m_window.setHeight(size.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPWidgetmainwindow::destroyThis()
|
void WidgetWindow::destroyThis()
|
||||||
{
|
{
|
||||||
QCoreApplication::quit();
|
QCoreApplication::quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPWidgetmainwindow::messageReceived(QString key, QString value)
|
void WidgetWindow::messageReceived(QString key, QString value)
|
||||||
{
|
{
|
||||||
emit qmlSceneValueReceived(key, value);
|
emit qmlSceneValueReceived(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPWidgetmainwindow::setPos(int xPos, int yPos)
|
void WidgetWindow::setPos(int xPos, int yPos)
|
||||||
{
|
{
|
||||||
|
|
||||||
QPoint delta((xPos - m_clickPos.x()), (yPos - m_clickPos.y()));
|
QPoint delta((xPos - m_clickPos.x()), (yPos - m_clickPos.y()));
|
||||||
@ -68,14 +67,14 @@ void SPWidgetmainwindow::setPos(int xPos, int yPos)
|
|||||||
m_window.setPosition(QPoint(new_x, new_y));
|
m_window.setPosition(QPoint(new_x, new_y));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPWidgetmainwindow::setClickPos(const QPoint& clickPos)
|
void WidgetWindow::setClickPos(const QPoint& clickPos)
|
||||||
{
|
{
|
||||||
m_clickPos = clickPos;
|
m_clickPos = clickPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPWidgetmainwindow::SetWindowBlur(HWND hWnd)
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
void WidgetWindow::SetWindowBlur(HWND hWnd)
|
||||||
|
{
|
||||||
|
|
||||||
const HINSTANCE hModule = LoadLibrary(TEXT("user32.dll"));
|
const HINSTANCE hModule = LoadLibrary(TEXT("user32.dll"));
|
||||||
if (hModule) {
|
if (hModule) {
|
||||||
@ -101,12 +100,11 @@ void SPWidgetmainwindow::SetWindowBlur(HWND hWnd)
|
|||||||
typedef BOOL(WINAPI * pSetWindowCompositionAttribute)(HWND, WINCOMPATTRDATA*);
|
typedef BOOL(WINAPI * pSetWindowCompositionAttribute)(HWND, WINCOMPATTRDATA*);
|
||||||
const pSetWindowCompositionAttribute SetWindowCompositionAttribute = (pSetWindowCompositionAttribute)GetProcAddress(hModule, "SetWindowCompositionAttribute");
|
const pSetWindowCompositionAttribute SetWindowCompositionAttribute = (pSetWindowCompositionAttribute)GetProcAddress(hModule, "SetWindowCompositionAttribute");
|
||||||
if (SetWindowCompositionAttribute) {
|
if (SetWindowCompositionAttribute) {
|
||||||
ACCENTPOLICY policy = { (int)Accent::BLURBEHIND, 0, 0, 0 }; // ACCENT_ENABLE_BLURBEHIND=3...
|
ACCENTPOLICY policy = { static_cast<int>(Accent::BLURBEHIND), 0, 0, 0 }; // ACCENT_ENABLE_BLURBEHIND=3...
|
||||||
WINCOMPATTRDATA data = { 19, &policy, sizeof(ACCENTPOLICY) }; // WCA_ACCENT_POLICY=19
|
WINCOMPATTRDATA data = { 19, &policy, sizeof(ACCENTPOLICY) }; // WCA_ACCENT_POLICY=19
|
||||||
SetWindowCompositionAttribute(hWnd, &data);
|
SetWindowCompositionAttribute(hWnd, &data);
|
||||||
}
|
}
|
||||||
FreeLibrary(hModule);
|
FreeLibrary(hModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
@ -8,23 +8,22 @@
|
|||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QtQuick/QQuickView>
|
|
||||||
#include <QtQuick/QQuickWindow>
|
|
||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
|
#include <QtQuick/QQuickView>
|
||||||
|
#include <QtQuick/QQuickWindow>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <qt_windows.h>
|
#include <qt_windows.h>
|
||||||
#else
|
|
||||||
typedef long HWND;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class SPWidgetmainwindow : public QObject {
|
class WidgetWindow : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SPWidgetmainwindow(QString projectPath, QString appid, QObject* parent = nullptr);
|
explicit WidgetWindow(QString projectPath, QString appid, QObject* parent = nullptr);
|
||||||
|
|
||||||
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
|
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
|
||||||
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
|
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
|
||||||
@ -83,16 +82,18 @@ public slots:
|
|||||||
|
|
||||||
void setPos(int xPos, int yPos);
|
void setPos(int xPos, int yPos);
|
||||||
void setClickPos(const QPoint& clickPos);
|
void setClickPos(const QPoint& clickPos);
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
void SetWindowBlur(HWND hWnd);
|
void SetWindowBlur(HWND hWnd);
|
||||||
|
#endif
|
||||||
private:
|
private:
|
||||||
QString m_appID;
|
QString m_appID;
|
||||||
QString m_type = "qmlWidget";
|
QString m_type = "qmlWidget";
|
||||||
QString m_projectConfig;
|
QString m_projectConfig;
|
||||||
QJsonObject m_project;
|
QJsonObject m_project;
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
HWND m_hwnd;
|
HWND m_hwnd;
|
||||||
|
#endif
|
||||||
QPoint m_clickPos = { 0, 0 };
|
QPoint m_clickPos = { 0, 0 };
|
||||||
|
|
||||||
QQuickView m_window;
|
QQuickView m_window;
|
||||||
|
|
||||||
};
|
};
|
@ -6,8 +6,8 @@ msvc: LIBS += -luser32
|
|||||||
TARGETPATH = ScreenPlayWindow
|
TARGETPATH = ScreenPlayWindow
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
SPWmain.cpp \
|
|
||||||
#src/SPWmainwindow.cpp \
|
#src/SPWmainwindow.cpp \
|
||||||
|
main.cpp \
|
||||||
src/basewindow.cpp \
|
src/basewindow.cpp \
|
||||||
src/windowsdesktopproperties.cpp \
|
src/windowsdesktopproperties.cpp \
|
||||||
src/winwindow.cpp
|
src/winwindow.cpp
|
||||||
|
@ -15,20 +15,19 @@ int main(int argc, char* argv[])
|
|||||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
QStringList argumentList = app.arguments();
|
||||||
QtWebEngine::initialize();
|
QtWebEngine::initialize();
|
||||||
|
|
||||||
bool debug = false;
|
// If we start with only one argument (app path)
|
||||||
if (debug) {
|
// It means we want to test a single wallpaper
|
||||||
|
if (argumentList.length() == 1) {
|
||||||
QVector<int> list;
|
QVector<int> list;
|
||||||
list.append(0);
|
list.append(0);
|
||||||
WinWindow window(list, "D:/672870/_tmp_135011", "argumentList.at(3)", "1");
|
WinWindow window(list, "D:/672870/_tmp_135011", "appid", "1");
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6 parameter + 1 OS working directory default paramter
|
// 6 parameter + 1 OS working directory default paramter
|
||||||
QStringList argumentList = app.arguments();
|
|
||||||
qDebug() << argumentList;
|
|
||||||
if (argumentList.length() != 7) {
|
if (argumentList.length() != 7) {
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user