1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-02 08:39:49 +02: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:
Elias 2019-03-24 16:52:07 +01:00
parent 970aeea99f
commit 9b606a79bc
6 changed files with 43 additions and 38 deletions

View File

@ -13,8 +13,8 @@ DEFINES += QT_DEPRECATED_WARNINGS
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
SPWidgetmain.cpp \
src/spwidgetmainwindow.cpp
main.cpp \
src/widgetwindow.cpp
RESOURCES += \
SPWidgetResources.qrc
@ -57,4 +57,4 @@ QML_DESIGNER_IMPORT_PATH =
HEADERS += \
src/spwidgetmainwindow.h
src/widgetwindow.h

View File

@ -2,7 +2,7 @@
#include <QQmlApplicationEngine>
#include <QStringList>
#include "src/spwidgetmainwindow.h"
#include "src/widgetwindow.h"
#include "../ScreenPlaySDK/screenplaysdk.h"
int main(int argc, char* argv[])
@ -12,18 +12,25 @@ int main(int argc, char* argv[])
ScreenPlaySDK sdk;
QGuiApplication app(argc, argv);
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) {
return -3;
}
SPWidgetmainwindow spwmw(argumentList.at(1), argumentList.at(2));
//SPWidgetmainwindow spwmw("D:/672870/xkcd","asasasasd" );
WidgetWindow spwmw(argumentList.at(1), argumentList.at(2));
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &spwmw, &SPWidgetmainwindow::destroyThis);
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &spwmw, &SPWidgetmainwindow::messageReceived);
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &spwmw, &WidgetWindow::destroyThis);
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &spwmw, &WidgetWindow::messageReceived);
return app.exec();
}

View File

@ -1,8 +1,8 @@
#include "spwidgetmainwindow.h"
#include "widgetwindow.h"
#include <QCoreApplication>
SPWidgetmainwindow::SPWidgetmainwindow(QString projectPath, QString appid, QObject* parent)
WidgetWindow::WidgetWindow(QString projectPath, QString appid, QObject* parent)
: QObject(parent)
{
@ -10,7 +10,7 @@ SPWidgetmainwindow::SPWidgetmainwindow(QString projectPath, QString appid, QObje
m_hwnd = reinterpret_cast<HWND>(m_window.winId());
Qt::WindowFlags flags = m_window.flags();
m_window.setWidth(500);
m_window.setWidth(300);
m_window.setHeight(300);
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.setColor(Qt::transparent);
m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
m_window.setSource(QUrl("qrc:/main.qml"));
#ifdef Q_OS_WIN
@ -42,23 +41,23 @@ SPWidgetmainwindow::SPWidgetmainwindow(QString projectPath, QString appid, QObje
emit setWidgetSource(fullPath);
}
void SPWidgetmainwindow::setSize(QSize size)
void WidgetWindow::setSize(QSize size)
{
m_window.setWidth(size.width());
m_window.setHeight(size.height());
}
void SPWidgetmainwindow::destroyThis()
void WidgetWindow::destroyThis()
{
QCoreApplication::quit();
}
void SPWidgetmainwindow::messageReceived(QString key, QString value)
void WidgetWindow::messageReceived(QString key, QString 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()));
@ -68,14 +67,14 @@ void SPWidgetmainwindow::setPos(int xPos, int yPos)
m_window.setPosition(QPoint(new_x, new_y));
}
void SPWidgetmainwindow::setClickPos(const QPoint& clickPos)
void WidgetWindow::setClickPos(const QPoint& clickPos)
{
m_clickPos = clickPos;
}
void SPWidgetmainwindow::SetWindowBlur(HWND hWnd)
{
#ifdef Q_OS_WIN
void WidgetWindow::SetWindowBlur(HWND hWnd)
{
const HINSTANCE hModule = LoadLibrary(TEXT("user32.dll"));
if (hModule) {
@ -101,12 +100,11 @@ void SPWidgetmainwindow::SetWindowBlur(HWND hWnd)
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...
ACCENTPOLICY policy = { static_cast<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
}
#endif

View File

@ -8,23 +8,22 @@
#include <QPoint>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QtQuick/QQuickView>
#include <QtQuick/QQuickWindow>
#include <QQuickWindow>
#include <QSharedPointer>
#include <QString>
#include <QWindow>
#include <QtQuick/QQuickView>
#include <QtQuick/QQuickWindow>
#ifdef Q_OS_WIN
#include <qt_windows.h>
#else
typedef long HWND;
#endif
class SPWidgetmainwindow : public QObject {
class WidgetWindow : public QObject {
Q_OBJECT
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 type READ type WRITE setType NOTIFY typeChanged)
@ -83,16 +82,18 @@ public slots:
void setPos(int xPos, int yPos);
void setClickPos(const QPoint& clickPos);
#ifdef Q_OS_WIN
void SetWindowBlur(HWND hWnd);
#endif
private:
QString m_appID;
QString m_type = "qmlWidget";
QString m_projectConfig;
QJsonObject m_project;
#ifdef Q_OS_WIN
HWND m_hwnd;
#endif
QPoint m_clickPos = { 0, 0 };
QQuickView m_window;
};

View File

@ -6,8 +6,8 @@ msvc: LIBS += -luser32
TARGETPATH = ScreenPlayWindow
SOURCES += \
SPWmain.cpp \
#src/SPWmainwindow.cpp \
main.cpp \
src/basewindow.cpp \
src/windowsdesktopproperties.cpp \
src/winwindow.cpp

View File

@ -15,20 +15,19 @@ int main(int argc, char* argv[])
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
QStringList argumentList = app.arguments();
QtWebEngine::initialize();
bool debug = false;
if (debug) {
// If we start with only one argument (app path)
// It means we want to test a single wallpaper
if (argumentList.length() == 1) {
QVector<int> list;
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();
}
// 6 parameter + 1 OS working directory default paramter
QStringList argumentList = app.arguments();
qDebug() << argumentList;
if (argumentList.length() != 7) {
return -3;
}