mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-09-02 08:39:49 +02:00
Fix displaying wallpaper
This commit is contained in:
parent
31757b4e31
commit
a7394dfb06
@ -38,7 +38,10 @@ void redirectMessageOutputToMainWindow(QtMsgType type, const QMessageLogContext&
|
||||
ScreenPlaySDK::ScreenPlaySDK(QQuickItem* parent)
|
||||
: QQuickItem(parent)
|
||||
{
|
||||
// Redirect all messages from this to ScreenPlay
|
||||
global_sdkPtr = this;
|
||||
qInstallMessageHandler(redirectMessageOutputToMainWindow);
|
||||
|
||||
m_socket.setServerName("ScreenPlay");
|
||||
connect(&m_socket, &QLocalSocket::connected, this, &ScreenPlaySDK::connected);
|
||||
connect(&m_socket, &QLocalSocket::disconnected, this, &ScreenPlaySDK::disconnected);
|
||||
@ -47,8 +50,6 @@ ScreenPlaySDK::ScreenPlaySDK(QQuickItem* parent)
|
||||
connect(&m_socket, QOverload<QLocalSocket::LocalSocketError>::of(&QLocalSocket::error), this, &ScreenPlaySDK::error);
|
||||
m_socket.connectToServer();
|
||||
|
||||
// Redirect all messages from this to ScreenPlay
|
||||
qInstallMessageHandler(redirectMessageOutputToMainWindow);
|
||||
}
|
||||
|
||||
ScreenPlaySDK::~ScreenPlaySDK()
|
||||
|
@ -18,8 +18,17 @@ int main(int argc, char* argv[])
|
||||
|
||||
QtWebEngine::initialize();
|
||||
|
||||
bool debug = false;
|
||||
if (debug) {
|
||||
QVector<int> list;
|
||||
list.append(0);
|
||||
WinWindow window(list, "D:/672870/_tmp_135011", "argumentList.at(3)", "1");
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
// 6 parameter + 1 OS working directory default paramter
|
||||
QStringList argumentList = app.arguments();
|
||||
qDebug() << argumentList;
|
||||
if (argumentList.length() != 7) {
|
||||
return -3;
|
||||
}
|
||||
@ -33,6 +42,9 @@ int main(int argc, char* argv[])
|
||||
if (monitorNumbers.length() == 1) {
|
||||
bool canParseMonitorNumber = false;
|
||||
int monitor = monitorNumbers.toInt(&canParseMonitorNumber);
|
||||
if (!canParseMonitorNumber) {
|
||||
qFatal("Could not parse monitor id to diplay wallpaper");
|
||||
}
|
||||
list.append(monitor);
|
||||
} else {
|
||||
QStringList activeScreensList = monitorNumbers.split(",");
|
||||
@ -50,7 +62,7 @@ int main(int argc, char* argv[])
|
||||
// See screenplay.h @ScreenPlayWallpaper constructor how the args get created
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
WinWindow window = WinWindow(list, argumentList.at(2), argumentList.at(3), argumentList.at(5));
|
||||
WinWindow window(list, argumentList.at(2), argumentList.at(3), argumentList.at(5));
|
||||
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &window, &WinWindow::destroyThis);
|
||||
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &window, &WinWindow::messageReceived);
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
import QtQuick 2.13
|
||||
import QtWebEngine 1.8
|
||||
import QtQuick 2.12
|
||||
import QtWebEngine 1.7
|
||||
import net.aimber.wallpaper 1.0
|
||||
|
||||
Rectangle {
|
||||
|
@ -76,6 +76,8 @@ signals:
|
||||
void typeChanged(WallpaperType type);
|
||||
void fullContentPathChanged(QString fullContentPath);
|
||||
void appIDChanged(QString appID);
|
||||
void qmlExit();
|
||||
void qmlSceneValueReceived(QString key, QString value);
|
||||
|
||||
public slots:
|
||||
virtual void destroyThis() {}
|
||||
|
@ -30,14 +30,14 @@ WinWindow::WinWindow(QVector<int>& activeScreensList, QString projectPath, QStri
|
||||
qFatal("No worker window found");
|
||||
}
|
||||
|
||||
// WARNING: Window flags must be called *here*!
|
||||
// WARNING: Setting Window flags must be called *here*!
|
||||
Qt::WindowFlags flags = m_window.flags();
|
||||
m_window.setFlags(flags | Qt::FramelessWindowHint);
|
||||
SetWindowLongPtr(m_windowHandle, GWL_STYLE, WS_CHILDWINDOW);
|
||||
SetWindowLongPtr(m_windowHandle, GWL_EXSTYLE, WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | WS_EX_NOACTIVATE);
|
||||
|
||||
// Windows coordante system begins at 0x0 at the
|
||||
// main monitor upper left and not at the most left top monitor
|
||||
// main monitors upper left and not at the most left top monitor
|
||||
calcOffsets();
|
||||
|
||||
// Ether for one Screen or for all
|
||||
@ -50,7 +50,7 @@ WinWindow::WinWindow(QVector<int>& activeScreensList, QString projectPath, QStri
|
||||
m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
|
||||
m_window.rootContext()->setContextProperty("window", this);
|
||||
m_window.rootContext()->setContextProperty("desktopProperties", &m_windowsDesktopProperties);
|
||||
m_window.setSource(QUrl("qrc:/main.qml"));
|
||||
m_window.setSource(QUrl("qrc:/qml/main.qml"));
|
||||
|
||||
// Let QML decide when were are read to show the window
|
||||
ShowWindow(m_windowHandle, SW_HIDE);
|
||||
@ -69,6 +69,11 @@ void WinWindow::destroyThis()
|
||||
{
|
||||
ShowWindow(m_windowHandle, SW_HIDE);
|
||||
|
||||
// Force refresh so that we display the regular
|
||||
// desktop wallpaper again
|
||||
ShowWindow(m_windowHandleWorker, SW_HIDE);
|
||||
ShowWindow(m_windowHandleWorker, SW_SHOW);
|
||||
|
||||
QCoreApplication::quit();
|
||||
}
|
||||
|
||||
@ -79,9 +84,6 @@ void WinWindow::messageReceived(QString key, QString value)
|
||||
|
||||
void WinWindow::calcOffsets()
|
||||
{
|
||||
// Recalculate window coordiantes because of point (0,0)
|
||||
// Is at the origin monitor or the most left
|
||||
|
||||
for (int i = 0; i < QApplication::screens().count(); i++) {
|
||||
QScreen* screen = QApplication::screens().at(i);
|
||||
if (screen->availableGeometry().x() < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user