Commit f9750d6e authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Add menu option to reset the Kdenlive config file

Phabricator task: https://phabricator.kde.org/T10985
parent 6b7ba3b2
Pipeline #3904 passed with stage
in 14 minutes and 57 seconds
......@@ -40,6 +40,7 @@ class Profile;
} // namespace Mlt
#define EXIT_RESTART (42)
#define EXIT_CLEAN_RESTART (43)
#define pCore Core::self()
/**
......
......@@ -131,7 +131,7 @@ signals:
// Screengrab method changed between fullsceen and region, update rec monitor
void updateFullScreenGrab();
/** @brief A settings changed that requires a Kdenlive restart, trigger it */
void restartKdenlive();
void restartKdenlive(bool resetConfig = false);
void checkTabPosition();
/** @brief Switch between merged / separate channels for audio thumbs */
void audioThumbFormatChanged();
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kdenlive" version="160" translationDomain="kdenlive">
<kpartgui name="kdenlive" version="161" translationDomain="kdenlive">
<MenuBar>
<Menu name="file" >
<Action name="dvd_wizard" />
......@@ -222,6 +222,9 @@
<Action name="themes_menu" />
<Action name="styles_menu" />
</Menu>
<Menu name="help" >
<Action name="reset_config" />
</Menu>
</MenuBar>
<ToolBar name="timelineToolBar" fullWidth="true" newline="true" noMerge="1" position="bottom">
<text>Timeline Toolbar</text>
......
......@@ -220,10 +220,25 @@ int main(int argc, char *argv[])
int result = app.exec();
Core::clean();
if (EXIT_RESTART == result) {
if (result == EXIT_RESTART || result == EXIT_CLEAN_RESTART) {
qCDebug(KDENLIVE_LOG) << "restarting app";
if (result == EXIT_CLEAN_RESTART) {
// Delete config file
KSharedConfigPtr config = KSharedConfig::openConfig();
if (config->name().contains(QLatin1String("kdenlive"))) {
// Make sure we delete our config file
QFile f(QStandardPaths::locate(QStandardPaths::ConfigLocation, config->name(), QStandardPaths::LocateFile));
if (f.exists()) {
qDebug()<<" = = = =\nGOT Deleted file: "<<f.fileName();
f.remove();
}
}
}
QStringList progArgs = QString(*argv).split(QLatin1Char(' '), QString::SkipEmptyParts);
// Remove app name
progArgs.takeFirst();
auto *restart = new QProcess;
restart->start(app.applicationFilePath(), QStringList());
restart->start(app.applicationFilePath(), progArgs);
restart->waitForReadyRead();
restart->waitForFinished(1000);
result = EXIT_SUCCESS;
......
......@@ -368,7 +368,7 @@ void MainWindow::init()
iconAction->setChecked(KdenliveSettings::force_breeze());
addAction(QStringLiteral("force_icon_theme"), iconAction);
connect(iconAction, &QAction::triggered, this, &MainWindow::forceIconSet);
// Close non-general docks for the initial layout
// only show important ones
m_undoViewDock->close();
......@@ -1135,6 +1135,13 @@ void MainWindow::setupActions()
QIcon::fromTheme(QStringLiteral("media-record")));
addAction(QStringLiteral("project_clean"), i18n("Clean Project"), this, SLOT(slotCleanProject()), QIcon::fromTheme(QStringLiteral("edit-clear")));
QAction *resetAction = new QAction(QIcon::fromTheme(QStringLiteral("reload")), i18n("Reset configuration"), this);
addAction(QStringLiteral("reset_config"), resetAction);
connect(resetAction, &QAction::triggered, [&]() {
slotRestart(true);
});
addAction("project_adjust_profile", i18n("Adjust Profile to Current Clip"), pCore->bin(), SLOT(adjustProjectProfileToItem()));
......@@ -2137,9 +2144,14 @@ void MainWindow::slotCheckTabPosition()
}
}
void MainWindow::slotRestart()
void MainWindow::slotRestart(bool clean)
{
m_exitCode = EXIT_RESTART;
if (clean) {
if (KMessageBox::questionYesNo(this, i18n("This will deleted Kdenlive's configuration file and restart the application. Do you want to proceed ?")) != KMessageBox::Yes) {
return;
}
}
m_exitCode = clean ? EXIT_CLEAN_RESTART : EXIT_RESTART;
QApplication::closeAllWindows();
}
......
......@@ -434,7 +434,7 @@ private slots:
void slotThemeChanged(const QString &name);
/** @brief Close Kdenlive and try to restart it */
void slotRestart();
void slotRestart(bool clean = false);
void triggerKey(QKeyEvent *ev);
/** @brief Update monitor overlay actions on monitor switch */
void slotUpdateMonitorOverlays(int id, int code);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment