1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-05 18:42:29 +01:00

Merge branch 'feature/qml-loadfromfile' into 'dev'

Implement loadFromFile function for qml usage

See merge request kelteseth/ScreenPlay!21
This commit is contained in:
Elias Steurer (Kelteseth) 2020-03-10 06:43:32 +00:00
commit 907719dd88
4 changed files with 35 additions and 2 deletions

View File

@ -45,7 +45,7 @@ int main(int argc, char* argv[])
//WinWindow window2({ 1 }, "test", "appid", "1", "fill");
//WinWindow window3({ 2 }, "test", "appid", "1", "fill");
WinWindow window({ 0 }, "C:/Program Files (x86)/Steam/steamapps/workshop/content/672870/1954178242", "appid", "1", "fill", true);
WinWindow window({ 0 }, "H:/SteamLibrary/SteamApps/workshop/content/672870/MechaGirl", "appid", "1", "fill", false);
#endif
#if defined(Q_OS_LINUX)
LinuxWindow window(QVector<int>{ 0 }, "test", "appid", "1", "fill");

View File

@ -62,11 +62,12 @@ BaseWindow::BaseWindow(QString projectFilePath, const QVector<int> activeScreens
qFatal("No type was specified inside the json object!");
}
setBasePath(projectFilePath);
setFullContentPath("file:///" + projectFilePath + "/" + projectObject.value("file").toString());
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &BaseWindow::reloadQML);
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::fileChanged, this, &BaseWindow::reloadQML);
m_fileSystemWatcher.addPaths({projectFilePath, projectFilePath + "/" + projectObject.value("file").toString()});
m_fileSystemWatcher.addPaths({ projectFilePath, projectFilePath + "/" + projectObject.value("file").toString() });
if (projectObject.value("type") == "videoWallpaper") {
setType(BaseWindow::WallpaperType::Video);
@ -143,3 +144,13 @@ void BaseWindow::messageReceived(QString key, QString value)
emit qmlSceneValueReceived(key, value);
}
QString BaseWindow::loadFromFile(const QString& filename)
{
QFile file;
file.setFileName(basePath() + "/" + filename);
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
return file.readAll();
}
return "";
}

View File

@ -24,6 +24,7 @@ public:
Q_PROPERTY(QVector<int> activeScreensList READ activeScreensList WRITE setActiveScreensList NOTIFY activeScreensListChanged)
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
Q_PROPERTY(QString basePath READ basePath WRITE setBasePath NOTIFY basePathChanged)
Q_PROPERTY(QString fullContentPath READ fullContentPath WRITE setFullContentPath NOTIFY fullContentPathChanged)
Q_PROPERTY(QString fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
@ -138,6 +139,11 @@ public:
return m_visualsPaused;
}
QString basePath() const
{
return m_basePath;
}
signals:
void qmlExit();
void reloadQML();
@ -161,11 +167,15 @@ signals:
void checkWallpaperVisibleChanged(bool checkWallpaperVisible);
void visualsPausedChanged(bool visualsPaused);
void basePathChanged(QString basePath);
public slots:
virtual void destroyThis() { }
virtual void setVisible(bool show) { Q_UNUSED(show) }
virtual void messageReceived(QString key, QString value) final;
QString loadFromFile(const QString& filename);
QString getApplicationPath()
{
return QApplication::applicationDirPath();
@ -345,6 +355,15 @@ public slots:
emit visualsPausedChanged(m_visualsPaused);
}
void setBasePath(QString basePath)
{
if (m_basePath == basePath)
return;
m_basePath = basePath;
emit basePathChanged(m_basePath);
}
private:
bool m_checkWallpaperVisible { false };
bool m_visualsPaused { false };
@ -368,4 +387,5 @@ private:
int m_height { 0 };
QVector<int> m_activeScreensList;
QFileSystemWatcher m_fileSystemWatcher;
QString m_basePath;
};

View File

@ -127,6 +127,8 @@ WinWindow::WinWindow(
if (checkWallpaperVisible) {
m_checkForFullScreenWindowTimer.start(10);
}
setupWindowMouseHook();
}
void WinWindow::setVisible(bool show)