1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00

Add new sdk project. ScreenPlay now uses an new process for every wallpaper and communicates via the official ScreenPlaySDK !

This commit is contained in:
kelteseth 2018-02-12 15:35:08 +01:00
parent 569a65ab15
commit ad342fc258
19 changed files with 437 additions and 74 deletions

View File

@ -2,4 +2,6 @@ TEMPLATE = subdirs
SUBDIRS = \
ScreenPlay/ScreenPlay.pro \
ScreenPlayWindow/ScreenPlayWindow.pro \
ScreenPlaySDK/Screenplaysdk.pro
ScreenPlayWindow.depends = ScreenPlaySDK

View File

@ -19,7 +19,8 @@ SOURCES += main.cpp \
src/steamworkshoplistmodel.cpp \
src/workshopitem.cpp \
src/widgetbridge.cpp \
src/installedlistfilter.cpp
src/installedlistfilter.cpp \
src/sdkconnector.cpp
RESOURCES += \
Resources.qrc \
@ -40,7 +41,8 @@ HEADERS += \
src/steamworkshoplistmodel.h \
src/workshopitem.h \
src/widgetbridge.h \
src/installedlistfilter.h
src/installedlistfilter.h \
src/sdkconnector.h
INCLUDEPATH += \
$$PWD/ThirdParty/ \

View File

@ -1,5 +1,6 @@
#include <QDebug>
#include <QDir>
#include <QFontDatabase>
#include <QGuiApplication>
#include <QIcon>
#include <QLibrary>
@ -11,31 +12,31 @@
#include <QQuickStyle>
#include <QQuickView>
#include <QScreen>
#include <QStringList>
#include <QTimer>
#include <QTransform>
#include <QUrl>
#include <QVariant>
#include <QWindow>
#include <QtQuick/QQuickItem>
#include <QFontDatabase>
#include <qt_windows.h>
#include <QStringList>
#include <QTransform>
#include "installedlistfilter.h"
#include "installedlistmodel.h"
#include "monitorlistmodel.h"
#include "packagefilehandler.h"
#include "profilelistmodel.h"
#include "quazip5/quazip.h"
#include "settings.h"
#include "steam/steam_api.h"
#include "steamworkshop.h"
#include "steamworkshoplistmodel.h"
#include "widget.h"
#include "widgetbridge.h"
#include "installedlistfilter.h"
#include "sdkconnector.h"
int main(int argc, char* argv[])
{
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseOpenGLES);
@ -45,7 +46,7 @@ int main(int argc, char* argv[])
trsl.load(":/languages/ScreenPlay_de.qm");
app.installTranslator(&trsl);
QObject::connect(&app,&QGuiApplication::screenRemoved,[&]() { qDebug() << "removed"; });
QObject::connect(&app, &QGuiApplication::screenRemoved, [&]() { qDebug() << "removed"; });
QFontDatabase::addApplicationFont(":/assets/fonts/LibreBaskerville-Italic.ttf");
QFontDatabase::addApplicationFont(":/assets/fonts/Roboto-Light.ttf");
@ -61,7 +62,6 @@ int main(int argc, char* argv[])
QCoreApplication::setApplicationVersion("0.1.0");
app.setWindowIcon(QIcon(":/assets/icons/favicon.ico"));
bool steamErrorRestart = false;
bool steamErrorAPIInit = false;
@ -80,15 +80,19 @@ int main(int argc, char* argv[])
PackageFileHandler packageFileHandler;
ProfileListModel profileListModel;
SteamWorkshopListModel steamWorkshopListModel;
WidgetBridge widgetBridge;
SDKConnector sdkConnector;
InstalledListFilter installedListFilter(&installedListModel);
// Create settings in the end because for now it depends on
// such things as the profile list model to complete
// It will also set the m_absoluteStoragePath in profileListModel and installedListModel
Settings settings(&profileListModel, &monitorListModel, &installedListModel, steamID);
Settings settings(&profileListModel, &monitorListModel, &installedListModel, &sdkConnector, steamID);
#ifdef QT_DEBUG
settings.setScreenPlayWindowPath(QUrl("C:/Users/Eli/Code/Qt/build-ScreenPlay-Desktop-Debug/ScreenPlayWindow/debug/ScreenPlayWindow.exe"));
#elif QT_NO_DEBUG
settings.setScreenPlayWindowPath(QUrl("ScreenPlayWindow.exe"));
#endif
SteamWorkshop steamWorkshop(steamID, &steamWorkshopListModel, &settings);
// All the list need the default path from the settings
@ -96,7 +100,6 @@ int main(int argc, char* argv[])
profileListModel.loadProfiles();
settings.loadActiveProfiles();
QQmlApplicationEngine mainWindowEngine;
mainWindowEngine.rootContext()->setContextProperty("installedListFilter", &installedListFilter);
mainWindowEngine.rootContext()->setContextProperty("workshopListModel", &steamWorkshopListModel);
@ -117,7 +120,7 @@ int main(int argc, char* argv[])
// Set visible if the -silent parameter was not set
QStringList argumentList = app.arguments();
if(!argumentList.contains("-silent")){
if (!argumentList.contains("-silent")) {
settings.setMainWindowVisible(true);
}
@ -132,10 +135,8 @@ int main(int argc, char* argv[])
timer.setInterval(100);
timer.start();
QObject::connect(&steamWorkshop,&SteamWorkshop::workshopSearchResult,
&steamWorkshopListModel,&SteamWorkshopListModel::append,Qt::QueuedConnection);
QObject::connect(&steamWorkshop, &SteamWorkshop::workshopSearchResult,
&steamWorkshopListModel, &SteamWorkshopListModel::append, Qt::QueuedConnection);
int status = app.exec();

View File

@ -0,0 +1,40 @@
#include "sdkconnector.h"
SDKConnector::SDKConnector(QObject* parent)
: QObject(parent)
{
m_server = QSharedPointer<QLocalServer>(new QLocalServer(this));
connect(m_server.data(), &QLocalServer::newConnection, this, &SDKConnector::newConnection);
if (!m_server.data()->listen("ScreenPlay")) {
qDebug() << "SERVER: Server could not start";
} else {
qDebug() << "SERVER: Server started!";
}
}
void SDKConnector::newConnection()
{
QLocalSocket* socket = m_server.data()->nextPendingConnection();
m_clients.append(socket);
connect(socket,&QLocalSocket::readyRead, [&]() {
qDebug() << socket->readAll();
});
// connect(socket,&QLocalSocket::stateChanged, [&]() {
// switch (socket->state()) {
// case QLocalSocket::UnconnectedState:;
// break;
// case QLocalSocket::ConnectingState:;
// break;
// case QLocalSocket::ConnectedState:;
// break;
// case QLocalSocket::ClosingState:;
// break;
// }
// });
}

View File

@ -0,0 +1,26 @@
#pragma once
#include <QObject>
#include <QLocalSocket>
#include <QLocalServer>
#include <QSharedPointer>
#include <QVector>
#include <QTimer>
class SDKConnector : public QObject
{
Q_OBJECT
public:
explicit SDKConnector(QObject *parent = nullptr);
signals:
public slots:
void newConnection();
private:
QSharedPointer<QLocalServer> m_server;
QVector<QLocalSocket*> m_clients;
};

View File

@ -1,12 +1,13 @@
#include "settings.h"
Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListModel* ilm, AppId_t steamID, QObject* parent)
Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListModel* ilm, SDKConnector* sdkc, AppId_t steamID, QObject* parent)
: QObject(parent)
{
m_plm = plm;
m_mlm = mlm;
m_ilm = ilm;
m_sdkc = sdkc;
m_steamID = steamID;
QFile configTmp;
@ -105,9 +106,8 @@ void Settings::setWallpaper(int monitorIndex, QUrl absoluteStoragePath)
}
}
increaseActiveWallpaperCounter();
auto tmpWallpaper = QSharedPointer<Wallpaper>(new Wallpaper(project, monitor));
QObject::connect(tmpWallpaper.data(),&Wallpaper::destroyed,this, &Settings::destroyWallpaper);
m_wallpapers.append(tmpWallpaper);
m_windows.append(new QProcess());
m_windows.last()->start(m_screenPlayWindowPath.toString());
}
void Settings::setWidget(QUrl absoluteStoragePath)
@ -155,23 +155,23 @@ void Settings::loadActiveProfiles()
QString profileName = activeProfilesTmp.at(i).toObject().value("profile").toString();
QString monitorID = activeProfilesTmp.at(i).toObject().value("monitorID").toString();
Profile profile;
// auto spf = new QSharedPointer<ProjectFile>(new ProjectFile());
// auto spf = new QSharedPointer<ProjectFile>(new ProjectFile());
// if (!m_plm->getProfileByName(profileName, &profile))
// continue;
// if (!m_plm->getProfileByName(profileName, &profile))
// continue;
// if (!m_ilm->getProjectByAbsoluteStoragePath(&profile.m_absolutePath, spf))
// continue;
// if (!m_ilm->getProjectByAbsoluteStoragePath(&profile.m_absolutePath, spf))
// continue;
// constructWallpaper(profile, monitorID, spf);
// constructWallpaper(profile, monitorID, spf);
}
}
}
void Settings::destroyWallpaper(QObject *ref)
void Settings::destroyWallpaper(QObject* ref)
{
for (int i = 0; i < m_wallpapers.count(); ++i) {
if(m_wallpapers.at(i) == ref){
if (m_wallpapers.at(i) == ref) {
m_wallpapers.at(i).data()->deleteLater();
//m_wallpapers.remove(i);
return;
@ -202,7 +202,7 @@ void Settings::writeSingleSettingConfig(QString name, QVariant value)
QFile configTmp;
configTmp.setFileName(m_localSettingsPath.toString() + "/settings.json");
configTmp.open(QIODevice::ReadOnly| QIODevice::Text);
configTmp.open(QIODevice::ReadOnly | QIODevice::Text);
QString config = configTmp.readAll();
configJsonDocument = QJsonDocument::fromJson(config.toUtf8(), &parseError);
@ -227,7 +227,9 @@ void Settings::removeAll()
for (int i = 0; i < m_wallpapers.size(); ++i) {
m_wallpapers.at(i).data()->destroyWallpaper();
}
//m_wallpapers.clear();
for (int i = 0; i < m_windows.size(); ++i) {
}
setActiveWallpaperCounter(0);
}
@ -273,7 +275,6 @@ QString Settings::fixWindowsPath(QString url)
return url.replace("/", "\\\\");
}
void Settings::removeWallpaperAt(int pos)
{
if (pos > 0 && pos > m_wallpapers.size())
@ -298,6 +299,16 @@ void Settings::createDefaultConfig()
defaultSettings.close();
}
QUrl Settings::getScreenPlayWindowPath() const
{
return m_screenPlayWindowPath;
}
void Settings::setScreenPlayWindowPath(const QUrl& screenPlayWindowPath)
{
m_screenPlayWindowPath = screenPlayWindowPath;
}
ActiveProfiles::ActiveProfiles()
{
}

View File

@ -19,7 +19,9 @@
#include <QVector>
#include <QSettings>
#include <QProcess>
#include <QObject>
#include "sdkconnector.h"
#include "installedlistmodel.h"
#include "monitorlistmodel.h"
#include "profile.h"
@ -33,7 +35,7 @@ class Settings : public QObject {
Q_OBJECT
public:
explicit Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListModel* ilm, AppId_t steamID, QObject* parent = nullptr);
explicit Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListModel* ilm, SDKConnector* sdkc, AppId_t steamID, QObject* parent = nullptr);
~Settings();
Q_PROPERTY(Version version READ version)
@ -107,6 +109,9 @@ public:
return m_activeWallpaperCounter;
}
QUrl getScreenPlayWindowPath() const;
void setScreenPlayWindowPath(const QUrl &screenPlayWindowPath);
signals:
void autostartChanged(bool autostart);
void highPriorityStartChanged(bool highPriorityStart);
@ -264,13 +269,17 @@ private:
ProfileListModel* m_plm;
InstalledListModel* m_ilm;
MonitorListModel* m_mlm;
SDKConnector* m_sdkc;
QThread m_thread;
QVector<QSharedPointer<Wallpaper>> m_wallpapers;
QVector<QProcess*> m_widgets;
QVector<QProcess*> m_windows;
QUrl m_localStoragePath;
QUrl m_localSettingsPath;
QUrl m_screenPlayWindowPath;
bool m_hasWorkshopBannerSeen = false;
QString m_decoder;

View File

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

View File

@ -0,0 +1,34 @@
TEMPLATE = lib
TARGET = ScreenPlaySDK
QT += qml quick
CONFIG += plugin c++11
TARGET = $$qtLibraryTarget($$TARGET)
uri = net.aimber.screenplaysdk
# Input
SOURCES += \
screenplay-sdk_plugin.cpp \
screenplaysdk.cpp
HEADERS += \
screenplay-sdk_plugin.h \
screenplaysdk.h
DISTFILES = qmldir
!equals(_PRO_FILE_PWD_, $$OUT_PWD) {
copy_qmldir.target = $$OUT_PWD/qmldir
copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir
copy_qmldir.commands = $(COPY_FILE) \"$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)\"
QMAKE_EXTRA_TARGETS += copy_qmldir
PRE_TARGETDEPS += $$copy_qmldir.target
}
qmldir.files = qmldir
installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /)
qmldir.path = $$installPath
target.path = $$installPath
INSTALLS += target qmldir

2
ScreenPlaySDK/qmldir Normal file
View File

@ -0,0 +1,2 @@
module net.aimber.screenplaysdk
plugin ScreenPlaySDK

View File

@ -0,0 +1,11 @@
#include "screenplay-sdk_plugin.h"
#include "screenplaysdk.h"
#include <qqml.h>
void ScreenPlay_SDKPlugin::registerTypes(const char *uri)
{
// @uri net.aimber.screenplaysdk
qmlRegisterType<ScreenPlaySDK>(uri, 1, 0, "ScreenPlaySDK");
}

View File

@ -0,0 +1,12 @@
#pragma once
#include <QQmlExtensionPlugin>
class ScreenPlay_SDKPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
void registerTypes(const char *uri);
};

View File

@ -0,0 +1,62 @@
#include "screenplaysdk.h"
ScreenPlaySDK::ScreenPlaySDK(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);
m_socket = QSharedPointer<QLocalSocket>(new QLocalSocket());
m_socket.data()->setServerName("ScreenPlay");
QObject::connect(m_socket.data(), &QLocalSocket::connected, this, &ScreenPlaySDK::connected);
QObject::connect(m_socket.data(), &QLocalSocket::disconnected, this, &ScreenPlaySDK::disconnected);
QObject::connect(m_socket.data(), &QLocalSocket::bytesWritten, this, &ScreenPlaySDK::bytesWritten);
QObject::connect(m_socket.data(), &QLocalSocket::readyRead, this, &ScreenPlaySDK::readyRead);
QObject::connect(m_socket.data(), QOverload<QLocalSocket::LocalSocketError>::of(&QLocalSocket::error), this, &ScreenPlaySDK::error);
m_socket.data()->connectToServer();
}
ScreenPlaySDK::~ScreenPlaySDK()
{
}
void ScreenPlaySDK::connected()
{
setIsConnected(true);
emit sdkConnected();
}
void ScreenPlaySDK::disconnected()
{
setIsConnected(false);
emit sdkDisconnected();
}
void ScreenPlaySDK::bytesWritten(qint64 bytes)
{
}
void ScreenPlaySDK::readyRead()
{
QString tmp = m_socket.data()->readAll();
QJsonParseError err;
QJsonDocument jdoc = QJsonDocument::fromJson(QByteArray::fromStdString(tmp.toStdString()),&err);
if (!(err.error == QJsonParseError::NoError)) {
emit incommingMessageError(tmp);
return;
}
emit incommingMessage(tmp);
}
void ScreenPlaySDK::error(QLocalSocket::LocalSocketError socketError)
{
emit sdkSocketError("Error");
if(socketError == QLocalSocket::LocalSocketError::ConnectionRefusedError){
//QCoreApplication::quit();
}
}

View File

@ -0,0 +1,85 @@
#pragma once
#include <QQuickItem>
#include <QObject>
#include <QLocalSocket>
#include <QLocalServer>
#include <QSharedPointer>
#include <QSharedDataPointer>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QByteArray>
#include <QTimer>
class ScreenPlaySDK : public QQuickItem
{
Q_OBJECT
Q_DISABLE_COPY(ScreenPlaySDK)
public:
ScreenPlaySDK(QQuickItem *parent = nullptr);
~ScreenPlaySDK();
Q_PROPERTY(QString contentType READ contentType WRITE setContentType NOTIFY contentTypeChanged)
Q_PROPERTY(bool isConnected READ isConnected WRITE setIsConnected NOTIFY isConnectedChanged)
QString contentType() const
{
return m_contentType;
}
bool isConnected() const
{
return m_isConnected;
}
public slots:
void connected();
void disconnected();
void bytesWritten(qint64 bytes);
void readyRead();
void error(QLocalSocket::LocalSocketError socketError);
void setContentType(QString contentType)
{
if (m_contentType == contentType)
return;
m_contentType = contentType;
if(isConnected()){
m_socket.data()->write(QByteArray(m_contentType.toLatin1()));
m_socket.data()->flush();
m_socket.data()->waitForBytesWritten();
}
emit contentTypeChanged(m_contentType);
}
void setIsConnected(bool isConnected)
{
if (m_isConnected == isConnected)
return;
m_isConnected = isConnected;
emit isConnectedChanged(m_isConnected);
}
signals:
void incommingMessage(QString msg);
void incommingMessageError(QString msg);
void sdkConnected();
void sdkDisconnected();
void sdkSocketError(QString type);
void contentTypeChanged(QString contentType);
void isConnectedChanged(bool isConnected);
private:
QSharedPointer<QLocalSocket> m_socket;
QString m_contentType = "undefined";
bool m_isConnected = false;
};

View File

@ -1,5 +1,5 @@
TEMPLATE = app
QT += qml quick av widgets quickcontrols2
QT += qml quick av widgets quickcontrols2
CONFIG += c++17
@ -28,17 +28,9 @@ CONFIG(debug, debug|release) {
}
install_it.files += assets/templates/config.json \
assets/icons/favicon.ico \
steam_appid.txt \
settings.json \
INSTALLS += install_it
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH += [QtAVSourceCodeDir]/qml
QML_IMPORT_PATH += "C:\msys64\mingw64\share\qt5\qml"
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
@ -59,5 +51,5 @@ win32 {
INCLUDEPATH += "C:\msys64\mingw64\include"
}
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../build-ScreenPlay-Desktop-Release/ScreenPlaySDK/release -llibScreenPlaySDK.dll
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../build-ScreenPlay-Desktop-Debug/ScreenPlaySDK/debug -llibScreenPlaySDKd.dll

View File

@ -1,12 +1,12 @@
#include "src/mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
//QCoreApplication::addLibraryPath("C:/msys64/mingw64/bin");
QApplication a(argc, argv);
MainWindow w;
w.show();
w.close();
MainWindow w;
return a.exec();
}

View File

@ -1,6 +1,54 @@
import QtQuick 2.9
import net.aimber.screenplaysdk 1.0
Rectangle {
color: "orange"
color: "gray"
anchors.fill: parent
ScreenPlaySDK {
contentType: "wallpaper"
onIncommingMessageError: {
name.text = msg
}
onSdkConnected: {
name.text = "connected"
}
onSdkDisconnected: {
name.text = "disconnected"
mainwindow.destroyThis()
}
}
Text {
id: name
text: qsTr("text")
anchors {
horizontalCenter: parent.horizontalCenter
}
y:-100
font.pixelSize: 36
SequentialAnimation {
loops: SequentialAnimation.Infinite
running: true
NumberAnimation {
target: name
property: "y"
duration: 2000
easing.type: Easing.InOutQuad
to:500
}
NumberAnimation {
target: name
property: "y"
duration: 2000
easing.type: Easing.InOutQuad
to:300
}
}
}
}

View File

@ -1,6 +1,5 @@
#include "mainwindow.h"
BOOL WINAPI SearchForWorkerWindow(HWND hwnd, LPARAM lparam)
{
// 0xXXXXXXX "" WorkerW
@ -17,13 +16,16 @@ BOOL WINAPI SearchForWorkerWindow(HWND hwnd, LPARAM lparam)
MainWindow::MainWindow(QScreen* parent)
: QWindow(parent)
{
// for (int var = 0; var < QApplication::screens().count(); ++var) {
// QScreen* screen = QApplication::screens().at(i);
// }
// for (int var = 0; var < QApplication::screens().count(); ++var) {
// QScreen* screen = QApplication::screens().at(i);
// }
setOpacity(0);
this->m_hwnd = (HWND)this->winId();
QScreen* screen = QApplication::screens().at(0);
//setGeometry(screen->geometry());
setScreen(screen);
HWND progman_hwnd = FindWindowW(L"Progman", L"Program Manager");
@ -37,13 +39,12 @@ MainWindow::MainWindow(QScreen* parent)
1000, nullptr);
EnumWindows(SearchForWorkerWindow, reinterpret_cast<LPARAM>(&m_worker_hwnd));
ShowWindow(m_worker_hwnd, SW_HIDE);
ShowWindow(m_hwnd, SW_HIDE);
SetParent(m_hwnd, m_worker_hwnd);
//SetWindowPos(m_worker_hwnd,HWND_BOTTOM,screen->geometry().x(),screen->geometry().y(),screen->geometry().width(),screen->geometry().height(),SWP_SHOWWINDOW);
SetWindowPos(m_hwnd,HWND_BOTTOM,screen->geometry().x(),screen->geometry().y(),screen->size().width(),screen->size().height(),SWP_SHOWWINDOW);
WINDOWINFO objWinInfo;
GetWindowInfo(m_hwnd, &objWinInfo);
qDebug() << objWinInfo.rcClient.bottom << objWinInfo.rcWindow.bottom;
SetWindowPos(m_worker_hwnd, HWND_BOTTOM, screen->geometry().x(), screen->geometry().y(), screen->geometry().width(), screen->geometry().height(), SWP_SHOWWINDOW);
SetWindowPos(m_hwnd, HWND_BOTTOM, screen->geometry().x(), screen->geometry().y(), screen->size().width(), screen->size().height(), SWP_SHOWWINDOW);
SetWindowLongPtr(m_hwnd, GWL_STYLE,
WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU);
@ -54,13 +55,35 @@ MainWindow::MainWindow(QScreen* parent)
this->setFlags(flags | Qt::FramelessWindowHint | Qt::WindowStaysOnBottomHint);
m_quickRenderer = QSharedPointer<QQuickView>(new QQuickView(this));
//m_quickRenderer.data()->engine()->addImportPath("C:/msys64/mingw64/share/qt5/qml");
//m_quickRenderer.data()->engine()->addImportPath("C:/msys64/mingw64/share/qt5");
m_quickRenderer.data()->rootContext()->setContextProperty("mainwindow", this);
m_quickRenderer.data()->setGeometry(screen->geometry());
m_quickRenderer.data()->setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
m_quickRenderer.data()->setSource(QUrl("qrc:/main.qml"));
QPropertyAnimation* animation = new QPropertyAnimation(this, "opacity");
animation->setDuration(250);
animation->setEasingCurve(QEasingCurve::OutCubic);
animation->setStartValue(0);
animation->setEndValue(1);
m_quickRenderer.data()->show();
show();
SetParent(m_hwnd, m_worker_hwnd);
ShowWindow(m_worker_hwnd, SW_SHOWDEFAULT);
ShowWindow(m_hwnd, SW_SHOWDEFAULT);
animation->start();
}
void MainWindow::destroyThis()
{
ShowWindow(m_worker_hwnd, SW_HIDE);
ShowWindow(m_hwnd, SW_HIDE);
QCoreApplication::quit();
}
MainWindow::~MainWindow()

View File

@ -1,27 +1,30 @@
#pragma once
#include <QWindow>
#include <QScreen>
#include <QApplication>
#include <QEasingCurve>
#include <QPropertyAnimation>
#include <QQmlContext>
#include <QQmlEngine>
#include <QScreen>
#include <QSharedPointer>
#include <QtQuick/QQuickWindow>
#include <QWindow>
#include <QtQuick/QQuickView>
#include <QtQuick/QQuickWindow>
#include "qt_windows.h"
class MainWindow : public QWindow
{
class MainWindow : public QWindow {
Q_OBJECT
public:
explicit MainWindow(QScreen *parent = 0);
explicit MainWindow(QScreen* parent = 0);
void init();
~MainWindow();
public slots:
void destroyThis();
private:
HWND m_hwnd;
HWND m_worker_hwnd;
QSharedPointer<QQuickView> m_quickRenderer = nullptr;
};