1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-10-06 09:17:07 +02:00

Refactor code

This commit is contained in:
Elias Steurer 2020-12-28 17:26:15 +01:00
parent 550982e3e3
commit d3f2b7724a
6 changed files with 24 additions and 18 deletions

View File

@ -48,13 +48,12 @@ Create::Create()
void Create::createWallpaperStart(QString videoPath, Create::VideoCodec codec)
{
clearFfmpegOutput();
videoPath.remove("file:///");
videoPath = Util::toLocal(videoPath);
QDir dir;
dir.cd(m_globalVariables->localStoragePath().toLocalFile());
const QDir dir(m_globalVariables->localStoragePath().toLocalFile());
// Create a temp dir so we can later alter it to the workshop id
auto folderName = QString("_tmp_" + QTime::currentTime().toString()).replace(":", "");
const auto folderName = QString("_tmp_" + QTime::currentTime().toString()).replace(":", "");
if (!dir.mkdir(folderName)) {
emit createWallpaperStateChanged(CreateImportVideo::ImportVideoState::CreateTmpFolderError);
@ -89,8 +88,8 @@ void Create::createWallpaperStart(QString videoPath, Create::VideoCodec codec)
*/
void Create::saveWallpaper(QString title, QString description, QString filePath, QString previewImagePath, QString youtube, Create::VideoCodec codec, QVector<QString> tags)
{
filePath.remove("file:///");
previewImagePath.remove("file:///");
filePath = Util::toLocal(filePath);
previewImagePath = Util::toLocal(previewImagePath);
emit createWallpaperStateChanged(CreateImportVideo::ImportVideoState::CopyFiles);

View File

@ -36,14 +36,8 @@ CreateImportVideo::CreateImportVideo(const QString& videoPath, const QString& ex
m_codecs = codecs;
m_process = std::make_unique<QProcess>(this);
#ifdef Q_OS_WIN
const QString fileEnding = ".exe";
#else
const QString fileEnding = "";
#endif
m_ffprobeExecutable = QApplication::applicationDirPath() + "/ffprobe" + fileEnding;
m_ffmpegExecutable = QApplication::applicationDirPath() + "/ffmpeg" + fileEnding;
m_ffprobeExecutable = QApplication::applicationDirPath() + "/ffprobe" + Util::executableEnding();
m_ffmpegExecutable = QApplication::applicationDirPath() + "/ffmpeg" + Util::executableEnding();
}
/*!

View File

@ -171,7 +171,7 @@ void InstalledListModel::loadInstalledContent()
if (obj->isEmpty())
continue;
if (!obj->contains("file") || !obj->contains("type"))
if (!obj->contains("type"))
continue;
if (GlobalVariables::getAvailableTypes().contains(obj->value("type").toString())) {

View File

@ -106,6 +106,18 @@ QString Util::generateRandomString(quint32 length)
return randomString;
}
/*!
\brief Return .exe in windows otherwise empty string.
*/
QString Util::executableEnding()
{
#ifdef Q_OS_WIN
return ".exe";
#else
return "";
#endif
}
/*!
\brief Parses a version from a given QString. The QString must be looke like this:
1.0.0 - Major.Minor.Patch. A fixed position is used for parsing (at 0,2,4).

View File

@ -122,6 +122,7 @@ public slots:
static QString toString(const QStringList& list);
static QString toLocal(const QString& url);
static QString generateRandomString(quint32 length = 32);
static QString executableEnding();
void setNavigation(QString nav)
{

View File

@ -19,8 +19,8 @@ WidgetWindow::WidgetWindow(
QObject::connect(m_sdk.get(), &ScreenPlaySDK::incommingMessage, this, &WidgetWindow::messageReceived);
QStringList availableTypes {
"QMLWidget",
"HTMLWidget"
"qmlWidget",
"htmlWidget"
};
if (!availableTypes.contains(m_type, Qt::CaseSensitivity::CaseInsensitive)) {
@ -46,7 +46,7 @@ WidgetWindow::WidgetWindow(
} else {
QFile configTmp;
QJsonDocument configJsonDocument;
QJsonParseError parseError{};
QJsonParseError parseError {};
configTmp.setFileName(projectPath + "/project.json");
configTmp.open(QIODevice::ReadOnly | QIODevice::Text);