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

Fix file handling in various places for Mac OS support

This commit is contained in:
Dominik Louven 2018-11-26 22:30:30 +01:00
parent a0dc8efd75
commit bed40fee31
3 changed files with 15 additions and 11 deletions

View File

@ -24,9 +24,9 @@ void ScreenPlay::createWallpaper(int monitorIndex, QUrl absoluteStoragePath, QSt
m_settings->increaseActiveWallpaperCounter(); m_settings->increaseActiveWallpaperCounter();
QVector<int> tmpMonitorIndex; QVector<int> tmpMonitorIndex;
tmpMonitorIndex.append(monitorIndex); tmpMonitorIndex.append(monitorIndex);
m_screenPlayWallpaperList.append(QSharedPointer<ScreenPlayWallpaper>(new ScreenPlayWallpaper(tmpMonitorIndex, absoluteStoragePath.toString(), previewImage, volume, fillMode, type, this))); m_screenPlayWallpaperList.append(QSharedPointer<ScreenPlayWallpaper>(new ScreenPlayWallpaper(tmpMonitorIndex, absoluteStoragePath.toLocalFile(), previewImage, volume, fillMode, type, this)));
m_mlm->setWallpaperActiveMonitor(m_qGuiApplication->screens().at(monitorIndex), absoluteStoragePath.toString() + "/" + previewImage); m_mlm->setWallpaperActiveMonitor(m_qGuiApplication->screens().at(monitorIndex), absoluteStoragePath.toLocalFile() + "/" + previewImage);
} }
void ScreenPlay::createWidget(QUrl absoluteStoragePath, QString previewImage) void ScreenPlay::createWidget(QUrl absoluteStoragePath, QString previewImage)
@ -36,9 +36,9 @@ void ScreenPlay::createWidget(QUrl absoluteStoragePath, QString previewImage)
return; return;
} }
QString fullPath = absoluteStoragePath.toString() + "/" + project.m_file.toString(); QString fullPath = absoluteStoragePath.toLocalFile() + "/" + project.m_file.toString();
m_screenPlayWidgetList.append(QSharedPointer<ScreenPlayWidget>(new ScreenPlayWidget(absoluteStoragePath.toString(), previewImage, fullPath, this))); m_screenPlayWidgetList.append(QSharedPointer<ScreenPlayWidget>(new ScreenPlayWidget(absoluteStoragePath.toLocalFile(), previewImage, fullPath, this)));
} }
void ScreenPlay::removeAllWallpaper() void ScreenPlay::removeAllWallpaper()

View File

@ -212,7 +212,7 @@ public:
m_projectPath = projectPath; m_projectPath = projectPath;
m_fullPath = fullPath; m_fullPath = fullPath;
m_previewImage = previewImage; m_previewImage = previewImage;
m_process = new QProcess(this); m_process = new QProcess(this); //PLS LESS BEHINDERT @Elias
QStringList proArgs; QStringList proArgs;
proArgs.append(m_projectPath); proArgs.append(m_projectPath);
@ -223,9 +223,13 @@ public:
if (fullPath.endsWith(".exe")) { if (fullPath.endsWith(".exe")) {
m_process->setProgram(fullPath); m_process->setProgram(fullPath);
} else if (fullPath.endsWith(".qml")) { } else if (fullPath.endsWith(".qml")) {
m_process->setProgram(parent->m_settings->getScreenPlayWidgetPath().toString()); m_process->setProgram(parent->m_settings->getScreenPlayWidgetPath().path());
} }
qDebug() << m_process->program(); qDebug() << m_process->program();
connect(m_process,&QProcess::errorOccurred, this, [](QProcess::ProcessError error){
qDebug() << "error: " << error;
});
m_process->start(); m_process->start();
} }

View File

@ -14,7 +14,7 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo
QFile configTmp; QFile configTmp;
QString appConfigLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation); QString appConfigLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
m_localSettingsPath = QUrl(appConfigLocation); m_localSettingsPath = QUrl::fromUserInput(appConfigLocation);
if (!QDir(appConfigLocation).exists()) { if (!QDir(appConfigLocation).exists()) {
if (!QDir().mkpath(appConfigLocation)) { if (!QDir().mkpath(appConfigLocation)) {
qWarning("ERROR: Cloud not create install dir"); qWarning("ERROR: Cloud not create install dir");
@ -92,7 +92,7 @@ Settings::~Settings()
QString Settings::loadProject(QString file) QString Settings::loadProject(QString file)
{ {
QFile configTmp; QFile configTmp;
file = file.replace("file:///", ""); //file = file.replace("file:///", "");
configTmp.setFileName(file); configTmp.setFileName(file);
configTmp.open(QIODevice::ReadOnly | QIODevice::Text); configTmp.open(QIODevice::ReadOnly | QIODevice::Text);
return configTmp.readAll(); return configTmp.readAll();
@ -104,7 +104,7 @@ void Settings::loadActiveProfiles()
QJsonObject configObj; QJsonObject configObj;
QJsonArray activeProfilesTmp; QJsonArray activeProfilesTmp;
QFile configTmp; QFile configTmp;
configTmp.setFileName(m_localSettingsPath.toString() + "/settings.json"); configTmp.setFileName(m_localSettingsPath.toLocalFile() + "/settings.json");
configTmp.open(QIODevice::ReadOnly | QIODevice::Text); configTmp.open(QIODevice::ReadOnly | QIODevice::Text);
QString config = configTmp.readAll(); QString config = configTmp.readAll();
@ -155,7 +155,7 @@ void Settings::writeSingleSettingConfig(QString name, QVariant value)
QJsonObject configObj; QJsonObject configObj;
QFile configTmp; QFile configTmp;
configTmp.setFileName(m_localSettingsPath.toString() + "/settings.json"); configTmp.setFileName(m_localSettingsPath.toLocalFile() + "/settings.json");
configTmp.open(QIODevice::ReadOnly | QIODevice::Text); configTmp.open(QIODevice::ReadOnly | QIODevice::Text);
QString config = configTmp.readAll(); QString config = configTmp.readAll();
configJsonDocument = QJsonDocument::fromJson(config.toUtf8(), &parseError); configJsonDocument = QJsonDocument::fromJson(config.toUtf8(), &parseError);
@ -264,7 +264,7 @@ void Settings::setPlayAll(bool isPlaying)
void Settings::createDefaultConfig() void Settings::createDefaultConfig()
{ {
QFile file(m_localSettingsPath.toString() + "/settings.json"); QFile file(m_localSettingsPath.toLocalFile() + "/settings.json");
QFile defaultSettings(":/settings.json"); QFile defaultSettings(":/settings.json");
file.open(QIODevice::WriteOnly | QIODevice::Text); file.open(QIODevice::WriteOnly | QIODevice::Text);