From 44ece72c7204269e6abcf04e761e35cb7a74f311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Fri, 16 Aug 2024 21:13:41 +0200 Subject: [PATCH] UI/UX minor Add the option to reinstall default render profiles. --- src/app/GUI/mainwindow.cpp | 29 +++++++++++++++++++++++------ src/app/GUI/mainwindow.h | 3 ++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/app/GUI/mainwindow.cpp b/src/app/GUI/mainwindow.cpp index b3e408ccf..6cd05780d 100644 --- a/src/app/GUI/mainwindow.cpp +++ b/src/app/GUI/mainwindow.cpp @@ -1298,6 +1298,11 @@ void MainWindow::setupMenuBar() "cmdPalette", "Ctrl+Space").toString())); + help->addSeparator(); + help->addAction(QIcon::fromTheme("renderlayers"), + tr("Reinstall default render profiles"), + this, &MainWindow::askInstallRenderPresets); + if (eSettings::instance().fToolBarActionRender) { mRenderVideoAct = mToolbar->addAction(QIcon::fromTheme("render_animation"), tr("Render"), @@ -1474,12 +1479,14 @@ void MainWindow::closedRenderQueueWindow() tr("Queue")); } -void MainWindow::initRenderPresets() +void MainWindow::initRenderPresets(const bool reinstall) { - if (!AppSupport::getSettings("settings", - "firstRunRenderPresets", - true).toBool()) { return; } + const bool doInstall = reinstall ? true : AppSupport::getSettings("settings", + "firstRunRenderPresets", + true).toBool(); + if (!doInstall) { return; } const QString path = AppSupport::getAppOutputProfilesPath(); + if (path.isEmpty() || !QFileInfo(path).isWritable()) { return; } QStringList presets; presets << "001-friction-preset-mp4-h264.conf"; @@ -1491,9 +1498,9 @@ void MainWindow::initRenderPresets() for (const auto &preset : presets) { QString filePath(QString("%1/%2").arg(path, preset)); - if (QFile::exists(filePath)) { continue; } + if (QFile::exists(filePath) && !reinstall) { continue; } QFile file(filePath); - if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { + if (file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) { QFile res(QString(":/presets/render/%1").arg(preset)); if (res.open(QIODevice::ReadOnly | QIODevice::Text)) { file.write(res.readAll()); @@ -1506,6 +1513,16 @@ void MainWindow::initRenderPresets() AppSupport::setSettings("settings", "firstRunRenderPresets", false); } +void MainWindow::askInstallRenderPresets() +{ + const auto result = QMessageBox::question(this, + tr("Install Render Profiles"), + tr("Are you sure you want to install the default render profiles?" + "

Note that a restart of the application is required to detect new profiles.")); + if (result != QMessageBox::Yes) { return; } + initRenderPresets(true); +} + void MainWindow::openWelcomeDialog() { mStackWidget->setCurrentIndex(mStackIndexWelcome); diff --git a/src/app/GUI/mainwindow.h b/src/app/GUI/mainwindow.h index 77878cf66..0b2ade58b 100644 --- a/src/app/GUI/mainwindow.h +++ b/src/app/GUI/mainwindow.h @@ -439,7 +439,8 @@ class MainWindow : public QMainWindow void openRenderQueueWindow(); void closedRenderQueueWindow(); - void initRenderPresets(); + void initRenderPresets(const bool reinstall = false); + void askInstallRenderPresets(); protected: void keyPressEvent(QKeyEvent *event);