mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 03:22:33 +01:00
Fix live reloading
The path contain invalid file:/// We now simply save the base path and use this variable
This commit is contained in:
parent
36c6f627cf
commit
8e8b8b0480
@ -32,9 +32,10 @@ int main(int argc, char* argv[])
|
|||||||
// For testing purposes when starting the ScreenPlayWallpaper directly.
|
// For testing purposes when starting the ScreenPlayWallpaper directly.
|
||||||
if (argumentList.length() == 1) {
|
if (argumentList.length() == 1) {
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
WinWindow window1({ 0 }, "test", "appID=test", "1", "fill", "videoWallpaper", true, true);
|
// WinWindow window1({ 0 }, "test", "appID=test", "1", "fill", "videoWallpaper", true, true);
|
||||||
|
WinWindow window1({ 0 }, "C:/Program Files (x86)/Steam/steamapps/workshop/content/672870/_tmp_171806", "appID=test", "1", "fill", "videoWallpaper", true, true);
|
||||||
#elif defined(Q_OS_LINUX)
|
#elif defined(Q_OS_LINUX)
|
||||||
LinuxWindow window({ 0 }, "/home/graphicscore/Desktop/wallpapers/MechaGirl", "appid", "1", "fill", false);
|
LinuxWindow window({ 0 }, "test", "appid", "1", "fill", false);
|
||||||
#elif defined(Q_OS_OSX)
|
#elif defined(Q_OS_OSX)
|
||||||
MacWindow window({ 0 }, "test", "appid", "1", "fill");
|
MacWindow window({ 0 }, "test", "appid", "1", "fill");
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,7 +37,7 @@ BaseWindow::BaseWindow(
|
|||||||
}
|
}
|
||||||
|
|
||||||
setAppID(appID);
|
setAppID(appID);
|
||||||
|
setContentBasePath(projectFilePath);
|
||||||
setOSVersion(QSysInfo::productVersion());
|
setOSVersion(QSysInfo::productVersion());
|
||||||
|
|
||||||
if (projectFilePath == "test") {
|
if (projectFilePath == "test") {
|
||||||
@ -209,13 +209,22 @@ QString BaseWindow::getApplicationPath()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief This public slot is for QML usage.
|
\brief This public slot is for QML usage. We limit the change event updates
|
||||||
|
to every 50ms, because the filesystem can be very trigger happy
|
||||||
|
with multiple change events per second.
|
||||||
*/
|
*/
|
||||||
void BaseWindow::setupLiveReloading()
|
void BaseWindow::setupLiveReloading()
|
||||||
{
|
{
|
||||||
auto reloadQMLLambda = [this]() { emit reloadQML(type()); };
|
auto reloadQMLLambda = [this]() {
|
||||||
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, reloadQMLLambda);
|
m_liveReloadLimiter.stop();
|
||||||
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::fileChanged, this, reloadQMLLambda);
|
emit reloadQML(type());
|
||||||
const QFileInfo file { m_fullContentPath };
|
};
|
||||||
m_fileSystemWatcher.addPaths({ file.path(), m_fullContentPath });
|
auto timeoutLambda = [this]() {
|
||||||
|
m_liveReloadLimiter.start(50);
|
||||||
|
};
|
||||||
|
|
||||||
|
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, timeoutLambda);
|
||||||
|
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::fileChanged, this, timeoutLambda);
|
||||||
|
QObject::connect(&m_liveReloadLimiter, &QTimer::timeout, this, reloadQMLLambda);
|
||||||
|
m_fileSystemWatcher.addPaths({ m_contentBasePath });
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,7 @@ public:
|
|||||||
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
|
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
|
||||||
Q_PROPERTY(QString basePath READ basePath WRITE setBasePath NOTIFY basePathChanged)
|
Q_PROPERTY(QString basePath READ basePath WRITE setBasePath NOTIFY basePathChanged)
|
||||||
Q_PROPERTY(QString fullContentPath READ fullContentPath WRITE setFullContentPath NOTIFY fullContentPathChanged)
|
Q_PROPERTY(QString fullContentPath READ fullContentPath WRITE setFullContentPath NOTIFY fullContentPathChanged)
|
||||||
|
Q_PROPERTY(QString contentBasePath READ contentBasePath WRITE setContentBasePath NOTIFY contentBasePathChanged)
|
||||||
Q_PROPERTY(QString fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
|
Q_PROPERTY(QString fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
|
||||||
|
|
||||||
Q_PROPERTY(bool loops READ loops WRITE setLoops NOTIFY loopsChanged)
|
Q_PROPERTY(bool loops READ loops WRITE setLoops NOTIFY loopsChanged)
|
||||||
@ -113,6 +114,7 @@ public:
|
|||||||
QString basePath() const { return m_basePath; }
|
QString basePath() const { return m_basePath; }
|
||||||
bool debugMode() const { return m_debugMode; }
|
bool debugMode() const { return m_debugMode; }
|
||||||
ScreenPlaySDK* sdk() const { return m_sdk.get(); }
|
ScreenPlaySDK* sdk() const { return m_sdk.get(); }
|
||||||
|
const QString& contentBasePath() const { return m_contentBasePath; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void qmlExit();
|
void qmlExit();
|
||||||
@ -142,6 +144,8 @@ signals:
|
|||||||
void debugModeChanged(bool debugMode);
|
void debugModeChanged(bool debugMode);
|
||||||
void sdkChanged(ScreenPlaySDK* sdk);
|
void sdkChanged(ScreenPlaySDK* sdk);
|
||||||
|
|
||||||
|
void contentBasePathChanged(const QString&);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void destroyThis() { }
|
virtual void destroyThis() { }
|
||||||
virtual void setVisible(bool show) { Q_UNUSED(show) }
|
virtual void setVisible(bool show) { Q_UNUSED(show) }
|
||||||
@ -340,6 +344,14 @@ public slots:
|
|||||||
emit sdkChanged(sdk);
|
emit sdkChanged(sdk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setContentBasePath(const QString& contentBasePath)
|
||||||
|
{
|
||||||
|
if (m_contentBasePath == contentBasePath)
|
||||||
|
return;
|
||||||
|
m_contentBasePath = contentBasePath;
|
||||||
|
emit contentBasePathChanged(m_contentBasePath);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupLiveReloading();
|
void setupLiveReloading();
|
||||||
|
|
||||||
@ -370,4 +382,6 @@ private:
|
|||||||
QString m_basePath;
|
QString m_basePath;
|
||||||
bool m_debugMode = false;
|
bool m_debugMode = false;
|
||||||
std::unique_ptr<ScreenPlaySDK> m_sdk;
|
std::unique_ptr<ScreenPlaySDK> m_sdk;
|
||||||
|
QString m_contentBasePath;
|
||||||
|
QTimer m_liveReloadLimiter;
|
||||||
};
|
};
|
||||||
|
@ -123,7 +123,6 @@ void WinWindow::setupWindowMouseHook()
|
|||||||
qInfo() << "Faild to install mouse hook!";
|
qInfo() << "Faild to install mouse hook!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qInfo() << "Setup mousehook";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,6 +145,9 @@ WinWindow::WinWindow(
|
|||||||
|
|
||||||
{
|
{
|
||||||
auto* guiAppInst = dynamic_cast<QApplication*>(QApplication::instance());
|
auto* guiAppInst = dynamic_cast<QApplication*>(QApplication::instance());
|
||||||
|
connect(this, &BaseWindow::reloadQML, this, [this]() {
|
||||||
|
clearComponentCache();
|
||||||
|
});
|
||||||
connect(guiAppInst, &QApplication::screenAdded, this, &WinWindow::configureWindowGeometry);
|
connect(guiAppInst, &QApplication::screenAdded, this, &WinWindow::configureWindowGeometry);
|
||||||
connect(guiAppInst, &QApplication::screenRemoved, this, &WinWindow::configureWindowGeometry);
|
connect(guiAppInst, &QApplication::screenRemoved, this, &WinWindow::configureWindowGeometry);
|
||||||
connect(guiAppInst, &QApplication::primaryScreenChanged, this, &WinWindow::configureWindowGeometry);
|
connect(guiAppInst, &QApplication::primaryScreenChanged, this, &WinWindow::configureWindowGeometry);
|
||||||
@ -187,7 +189,7 @@ WinWindow::WinWindow(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasWindowScaling) {
|
if (hasWindowScaling) {
|
||||||
qInfo() << "scaling";
|
qInfo() << "Monitor with scaling detected!";
|
||||||
configureWindowGeometry();
|
configureWindowGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +204,8 @@ WinWindow::WinWindow(
|
|||||||
setupWindowMouseHook();
|
setupWindowMouseHook();
|
||||||
});
|
});
|
||||||
|
|
||||||
sdk()->start();
|
if (!debugMode)
|
||||||
|
sdk()->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinWindow::setVisible(bool show)
|
void WinWindow::setVisible(bool show)
|
||||||
|
Loading…
Reference in New Issue
Block a user