1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-15 06:52:34 +02:00

Fixed macOS compilation by replacing std::optional obj.value() that throws with *obj

This commit is contained in:
Elias Steurer 2020-04-20 16:36:49 +02:00
parent 3a8c686043
commit a837bd3fe7
8 changed files with 38 additions and 34 deletions

View File

@ -141,8 +141,8 @@ bool CreateImportVideo::createWallpaperInfo()
emit createWallpaperStateChanged(ImportVideoState::AnalyseVideoFinished);
auto a = pro->readAll();
auto objOptional = Util::parseQByteArrayToQJsonObject(a);
if (!objOptional) {
auto obj = Util::parseQByteArrayToQJsonObject(a);
if (!obj) {
qDebug() << "Error parsing ffmpeg json output";
emit processOutput(pro->readAll());
emit processOutput("Error parsing ffmpeg json output");
@ -150,8 +150,7 @@ bool CreateImportVideo::createWallpaperInfo()
return false;
}
QJsonObject obj = objOptional.value();
if (obj.empty()) {
if (obj->empty()) {
qDebug() << "Error! File could not be parsed.";
emit processOutput("Error! File could not be parsed.");
@ -163,7 +162,7 @@ bool CreateImportVideo::createWallpaperInfo()
pro->close();
// Check for audio and video streams
QJsonArray arrayStream = obj.value("streams").toArray();
QJsonArray arrayStream = obj->value("streams").toArray();
bool hasAudioStream { false };
bool hasVideoStream { false };
@ -204,7 +203,7 @@ bool CreateImportVideo::createWallpaperInfo()
return false;
}
QJsonObject objFormat = obj.value("format").toObject();
QJsonObject objFormat = obj->value("format").toObject();
// Get video length
bool okParseDuration = false;
@ -221,7 +220,7 @@ bool CreateImportVideo::createWallpaperInfo()
m_length = length;
// Get framerate
QJsonArray arrSteams = obj.value("streams").toArray();
QJsonArray arrSteams = obj->value("streams").toArray();
if (arrSteams.empty()) {
qDebug() << "Error container does not have any video streams";
emit processOutput("Error container does not have any video streams");

View File

@ -130,10 +130,10 @@ void InstalledListModel::loadInstalledContent()
if (auto obj = Util::openJsonFileToObject(projectItemPath)) {
if (obj.value().isEmpty())
if (obj->isEmpty())
continue;
if (!obj.value().contains("file") || !obj.value().contains("type"))
if (!obj->contains("file") || !obj->contains("type"))
continue;
QStringList availableTypes {
@ -147,8 +147,8 @@ void InstalledListModel::loadInstalledContent()
"standaloneWidget"
};
if (availableTypes.contains(obj.value().value("type").toString())) {
emit addInstalledItem(obj.value(), item.baseName());
if (availableTypes.contains(obj->value("type").toString())) {
emit addInstalledItem(*obj, item.baseName());
}
counter += 1;

View File

@ -157,7 +157,7 @@ void ScreenPlayManager::removeAllWallpapers()
return;
}
QJsonObject oldConfig = configOptional.value();
QJsonObject oldConfig = *configOptional;
QJsonObject oldConfigProfile = oldConfig.value("profiles").toArray().first().toObject();
QJsonObject profileDefault;
@ -203,8 +203,8 @@ bool ScreenPlayManager::removeWallpaperAt(int at)
}
if (auto appID = m_monitorListModel->getAppIDByMonitorIndex(at)) {
m_sdkconnector->closeWallpaper(appID.value());
m_monitorListModel->closeWallpaper(appID.value());
m_sdkconnector->closeWallpaper(*appID);
m_monitorListModel->closeWallpaper(*appID);
decreaseActiveWallpaperCounter();
return true;
}
@ -235,9 +235,9 @@ void ScreenPlayManager::setWallpaperValue(const int index, const QString& key, c
{
if (auto appID = m_monitorListModel->getAppIDByMonitorIndex(index)) {
m_sdkconnector->setWallpaperValue(appID.value(), key, value);
m_sdkconnector->setWallpaperValue(*appID, key, value);
if (auto wallpaper = getWallpaperByAppID(appID.value())) {
if (auto wallpaper = getWallpaperByAppID(*appID)) {
}
}
}
@ -282,7 +282,7 @@ bool ScreenPlayManager::saveWallpaperProfile(const QString& profileName, const Q
return false;
}
QJsonObject oldConfig = configOptional.value();
QJsonObject oldConfig = *configOptional;
QJsonObject oldConfigProfile = oldConfig.value("profiles").toArray().first().toObject();
QJsonArray oldWallpaperArray = oldConfigProfile.value("wallpaper").toArray();
QJsonArray newWallpaperArray;
@ -333,14 +333,14 @@ void ScreenPlayManager::loadWallpaperProfiles()
return;
}
std::optional<QVersionNumber> version = Util::getVersionNumberFromString(configObj.value().value("version").toString());
std::optional<QVersionNumber> version = Util::getVersionNumberFromString(configObj->value("version").toString());
if (version && version.value() != m_globalVariables->version()) {
qWarning() << "Version missmatch fileVersion: " << version.value().toString() << "m_version: " << m_globalVariables->version().toString();
if (version && *version != m_globalVariables->version()) {
qWarning() << "Version missmatch fileVersion: " << version->toString() << "m_version: " << m_globalVariables->version().toString();
return;
}
QJsonArray activeProfilesTmp = configObj.value().value("profiles").toArray();
QJsonArray activeProfilesTmp = configObj->value("profiles").toArray();
if (activeProfilesTmp.size() > 1) {
qWarning() << "We currently only support one profile!";

View File

@ -67,7 +67,7 @@ std::optional<QJsonObject> Util::openJsonFileToObject(const QString& path)
QJsonDocument jsonDocument;
QJsonParseError parseError {};
jsonDocument = QJsonDocument::fromJson(jsonString.value().toUtf8(), &parseError);
jsonDocument = QJsonDocument::fromJson(jsonString->toUtf8(), &parseError);
if (!(parseError.error == QJsonParseError::NoError)) {
qWarning() << "Settings Json Parse Error: " << parseError.errorString();

View File

@ -122,9 +122,9 @@ int main(int argc, char* argv[])
#endif
#if defined(Q_OS_OSX)
MacWindow window(list, argumentList.at(2), argumentList.at(3), argumentList.at(5));
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &MacWindow, &MacWindow::destroyThis);
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &MacWindow, &MacWindow::messageReceived);
MacWindow window(list, argumentList.at(2), argumentList.at(3), argumentList.at(4), argumentList.at(5));
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &window, &MacWindow::destroyThis);
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &window, &MacWindow::messageReceived);
#endif
return app.exec();

View File

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

View File

@ -1,7 +1,12 @@
#include "macwindow.h"
MacWindow::MacWindow(QVector<int>& activeScreensList, QString projectPath, QString id, QString volume, QObject* parent)
: BaseWindow(projectPath)
MacWindow::MacWindow(
const QVector<int> &activeScreensList,
const QString &projectPath,
const QString &id,
const QString &volume,
const QString &fillmode)
: BaseWindow(projectPath, activeScreensList, false)
{
setAppID(id);
bool ok = false;
@ -32,7 +37,3 @@ void MacWindow::destroyThis()
{
QCoreApplication::quit();
}
void MacWindow::messageReceived(QString key, QString value)
{
}

View File

@ -17,14 +17,18 @@ class MacWindow : public BaseWindow
{
Q_OBJECT
public:
explicit MacWindow(QVector<int>& activeScreensList, QString projectPath, QString id, QString volume,QObject *parent = nullptr);
explicit MacWindow(
const QVector<int>& activeScreensList,
const QString& projectPath,
const QString& id,
const QString& volume,
const QString& fillmode);
signals:
public slots:
void setVisible(bool show) override;
void destroyThis() override;
void messageReceived(QString key, QString value) override;
private:
QQuickView m_window;
};