Skip to content

Commit

Permalink
UI/UX minor
Browse files Browse the repository at this point in the history
Add the option to reinstall default render profiles.
  • Loading branch information
rodlie committed Aug 16, 2024
1 parent 75d826b commit 9269acb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
29 changes: 23 additions & 6 deletions src/app/GUI/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,11 @@ void MainWindow::setupMenuBar()
QMessageBox::aboutQt(this, tr("About Qt"));
});

help->addSeparator();
help->addAction(QIcon::fromTheme("renderlayers"),
tr("Reinstall default render profiles"),
this, &MainWindow::askInstallRenderPresets);

mToolbar->addAction(QIcon::fromTheme("render_animation"),
tr("Render"),
this, &MainWindow::openRendererWindow);
Expand Down Expand Up @@ -1292,12 +1297,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";
Expand All @@ -1309,9 +1316,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());
Expand All @@ -1324,6 +1331,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?"
"<br><br><i>Note that a restart of the application is required to detect new profiles.</i>"));
if (result != QMessageBox::Yes) { return; }
initRenderPresets(true);
}

void MainWindow::openWelcomeDialog()
{
mStackWidget->setCurrentIndex(mStackIndexWelcome);
Expand Down
3 changes: 2 additions & 1 deletion src/app/GUI/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ class MainWindow : public QMainWindow
void openRenderQueueWindow();
void closedRenderQueueWindow();

void initRenderPresets();
void initRenderPresets(const bool reinstall = false);
void askInstallRenderPresets();

protected:
void keyPressEvent(QKeyEvent *event);
Expand Down

0 comments on commit 9269acb

Please sign in to comment.