Commit 25edf681 authored by Julius Künzel's avatar Julius Künzel 💬
Browse files

Port KMessageBox to twoActions where not violating string freeze

This introduces a compat header to make porting easier.
Inspired by kdevelop/kdevelop!397
parent 8030f80a
Pipeline #271578 passed with stage
in 7 minutes and 23 seconds
......@@ -52,6 +52,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "utils/thumbnailcache.hpp"
#include "xml/xml.hpp"
#include "utils/KMessageBox_KdenliveCompat.h"
#include <KActionMenu>
#include <KColorScheme>
#include <KIO/ApplicationLauncherJob>
......@@ -4342,12 +4343,12 @@ void Bin::showTitleWidget(const std::shared_ptr<ProjectClip> &clip)
newprops.insert(QStringLiteral("force_reload"), QStringLiteral("2"));
if (!path.isEmpty()) {
// we are editing an external file, asked if we want to detach from that file or save the result to that title file.
if (KMessageBox::questionYesNo(pCore->window(),
i18n("You are editing an external title clip (%1). Do you want to save your changes to the title "
"file or save the changes for this project only?",
path),
i18n("Save Title"), KGuiItem(i18n("Save to title file")),
KGuiItem(i18n("Save in project only"))) == KMessageBox::Yes) {
if (KMessageBox::questionTwoActions(pCore->window(),
i18n("You are editing an external title clip (%1). Do you want to save your changes to the title "
"file or save the changes for this project only?",
path),
i18n("Save Title"), KGuiItem(i18n("Save to title file")),
KGuiItem(i18n("Save in project only"))) == KMessageBox::PrimaryAction) {
// save to external file
dia_ui.saveTitle(QUrl::fromLocalFile(path));
return;
......
......@@ -18,6 +18,7 @@
#include <mlt++/Mlt.h>
#include <mlt++/MltProperties.h>
#include "utils/KMessageBox_KdenliveCompat.h"
#include <KEncodingProber>
#include <KLocalizedString>
#include <KMessageBox>
......@@ -1094,8 +1095,8 @@ void SubtitleModel::copySubtitle(const QString &path, bool checkOverwrite)
QFile prev(path);
if (prev.exists()) {
if (checkOverwrite || !path.endsWith(QStringLiteral(".srt"))) {
if (KMessageBox::questionYesNo(QApplication::activeWindow(), i18n("File %1 already exists.\nDo you want to overwrite it?", path)) ==
KMessageBox::No) {
if (KMessageBox::questionTwoActions(QApplication::activeWindow(), i18n("File %1 already exists.\nDo you want to overwrite it?", path), {},
KStandardGuiItem::overwrite(), KStandardGuiItem::cancel()) == KMessageBox::SecondaryAction) {
return;
}
}
......
......@@ -35,6 +35,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "xml/xml.hpp"
#include "kdenlive_debug.h"
#include "utils/KMessageBox_KdenliveCompat.h"
#include <KImageCache>
#include <KLocalizedString>
#include <KMessageBox>
......@@ -1803,8 +1804,8 @@ QStringList ProjectClip::updatedAnalysisData(const QString &name, const QString
}
QString current = getProducerProperty("kdenlive:clipanalysis." + name);
if (!current.isEmpty()) {
if (KMessageBox::questionYesNo(QApplication::activeWindow(), i18n("Clip already contains analysis data %1", name), QString(), KGuiItem(i18n("Merge")),
KGuiItem(i18n("Add"))) == KMessageBox::Yes) {
if (KMessageBox::questionTwoActions(QApplication::activeWindow(), i18n("Clip already contains analysis data %1", name), QString(),
KGuiItem(i18n("Merge")), KStandardGuiItem::add()) == KMessageBox::Yes) {
// Merge data
// TODO MLT7: convert to Mlt::Animation
/*auto &profile = pCore->getCurrentProfile();
......
......@@ -30,6 +30,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "timeline2/view/timelinewidget.h"
#include <mlt++/MltRepository.h>
#include "utils/KMessageBox_KdenliveCompat.h"
#include <KMessageBox>
#include <QCoreApplication>
#include <QDir>
......@@ -96,8 +97,9 @@ bool Core::build(const QString &packageType, bool testMode)
QFile lockFile(QDir::temp().absoluteFilePath(QStringLiteral("kdenlivelock")));
if (lockFile.exists()) {
// a previous instance crashed, propose to delete config files
if (KMessageBox::questionYesNo(QApplication::activeWindow(),
i18n("Kdenlive crashed on last startup.\nDo you want to reset the configuration files ?")) == KMessageBox::Yes) {
if (KMessageBox::questionTwoActions(QApplication::activeWindow(),
i18n("Kdenlive crashed on last startup.\nDo you want to reset the configuration files ?"), {},
KStandardGuiItem::reset(), KStandardGuiItem::cont()) == KMessageBox::PrimaryAction) {
// Release startup crash lock file
QFile lockFile(QDir::temp().absoluteFilePath(QStringLiteral("kdenlivelock")));
lockFile.remove();
......
......@@ -38,6 +38,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#else
#include <KIO/JobUiDelegate>
#endif
#include "utils/KMessageBox_KdenliveCompat.h"
#include <KIO/OpenUrlJob>
#include <KLineEdit>
#include <KMessageBox>
......@@ -1771,7 +1772,8 @@ void KdenliveSettingsDialog::removeDictionary()
}
QString currentModel = m_speechListWidget->currentItem()->text();
if (!currentModel.isEmpty() && dir.cd(currentModel)) {
if (KMessageBox::questionYesNo(this, i18n("Delete folder:\n%1", dir.absolutePath())) == KMessageBox::Yes) {
if (KMessageBox::questionTwoActions(this, i18n("Delete folder:\n%1", dir.absolutePath()), {}, KStandardGuiItem::del(), KStandardGuiItem::cancel()) ==
KMessageBox::PrimaryAction) {
// Make sure we don't accidentally delete a folder that is not ours
if (dir.absolutePath().contains(QLatin1String("speechmodels"))) {
dir.removeRecursively();
......
......@@ -12,6 +12,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "profiles/profilerepository.hpp"
#include "klocalizedstring.h"
#include "utils/KMessageBox_KdenliveCompat.h"
#include <KMessageBox>
#include <KMessageWidget>
......@@ -195,7 +196,8 @@ bool ProfilesDialog::askForSave()
if (!m_profileIsModified) {
return true;
}
if (KMessageBox::questionYesNo(this, i18n("The custom profile was modified, do you want to save it?")) != KMessageBox::Yes) {
if (KMessageBox::questionTwoActions(this, i18n("The custom profile was modified, do you want to save it?"), {}, KStandardGuiItem::save(),
KStandardGuiItem::discard()) != KMessageBox::PrimaryAction) {
return true;
}
return slotSaveProfile();
......
......@@ -31,6 +31,7 @@
#else
#include <KIO/JobUiDelegate>
#endif
#include "utils/KMessageBox_KdenliveCompat.h"
#include <KIO/OpenFileManagerWindowJob>
#include <KIO/OpenUrlJob>
#include <KLocalizedString>
......@@ -615,7 +616,8 @@ void RenderWidget::slotPrepareExport(bool delayedRendering, const QString &scrip
}
m_view.infoMessage->hide();
if (QFile::exists(m_view.out_file->url().toLocalFile())) {
if (KMessageBox::warningYesNo(this, i18n("Output file already exists. Do you want to overwrite it?")) != KMessageBox::Yes) {
if (KMessageBox::warningTwoActions(this, i18n("Output file already exists. Do you want to overwrite it?"), {}, KStandardGuiItem::overwrite(),
KStandardGuiItem::cancel()) != KMessageBox::PrimaryAction) {
return;
}
}
......@@ -790,7 +792,8 @@ QString RenderWidget::generatePlaylistFile(bool delayedRendering)
filename.append(fileExtension);
}
if (projectFolder.exists(newFilename)) {
if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", filename)) == KMessageBox::No) {
if (KMessageBox::questionTwoActions(this, i18n("File %1 already exists.\nDo you want to overwrite it?", filename), {},
KStandardGuiItem::overwrite(), KStandardGuiItem::cancel()) == KMessageBox::PrimaryAction) {
return {};
}
}
......@@ -1719,7 +1722,8 @@ void RenderWidget::slotStartScript()
QString destination = item->data(1, Qt::UserRole).toString();
int out = item->data(1, Qt::UserRole + 2).toInt();
if (QFile::exists(destination)) {
if (KMessageBox::warningYesNo(this, i18n("Output file already exists. Do you want to overwrite it?")) != KMessageBox::Yes) {
if (KMessageBox::warningTwoActions(this, i18n("Output file already exists. Do you want to overwrite it?"), {}, KStandardGuiItem::overwrite(),
KStandardGuiItem::cancel()) != KMessageBox::PrimaryAction) {
return;
}
}
......
......@@ -30,6 +30,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include <config-kdenlive.h>
#include "utils/KMessageBox_KdenliveCompat.h"
#include <KBookmark>
#include <KBookmarkManager>
#include <KIO/CopyJob>
......@@ -1631,7 +1632,7 @@ void KdenliveDoc::switchProfile(ProfileParam *pf, const QString &clipName)
if (KdenliveSettings::default_profile().isEmpty()) {
// Default project format not yet confirmed, propose
QString currentProfileDesc = pCore->getCurrentProfile()->description();
KMessageBox::ButtonCode answer = KMessageBox::questionYesNoCancel(
KMessageBox::ButtonCode answer = KMessageBox::questionTwoActionsCancel(
QApplication::activeWindow(),
i18n("Your default project profile is %1, but your clip's profile (%2) is %3.\nDo you want to change default profile for future projects?",
currentProfileDesc, clipName, profile->description()),
......
......@@ -30,6 +30,7 @@
#include <QVBoxLayout>
#include <QWheelEvent>
#include "utils/KMessageBox_KdenliveCompat.h"
#include <KDualAction>
#include <KLocalizedString>
#include <KMessageBox>
......@@ -495,8 +496,8 @@ void CollapsibleEffectView::slotSaveEffect()
}
if (dir.exists(name + QStringLiteral(".xml")))
if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", name + QStringLiteral(".xml"))) ==
KMessageBox::No) {
if (KMessageBox::questionTwoActions(this, i18n("File %1 already exists.\nDo you want to overwrite it?", name + QStringLiteral(".xml")), {},
KStandardGuiItem::overwrite(), KStandardGuiItem::cancel()) == KMessageBox::SecondaryAction) {
return;
}
......
......@@ -28,6 +28,7 @@
#include <QTreeView>
#include <QVBoxLayout>
#include "utils/KMessageBox_KdenliveCompat.h"
#include <KMessageBox>
#include <utility>
......@@ -544,7 +545,8 @@ void EffectStackView::slotSaveStack()
QString effectfilename = name + QStringLiteral(".xml");
if (description.trimmed().isEmpty()) {
if (KMessageBox::questionYesNo(this, i18n("No description provided. \nSave effect with no description?")) == KMessageBox::No) {
if (KMessageBox::questionTwoActions(this, i18n("No description provided. \nSave effect with no description?"), {}, KStandardGuiItem::save(),
KStandardGuiItem::dontSave()) == KMessageBox::SecondaryAction) {
return;
}
}
......@@ -555,7 +557,8 @@ void EffectStackView::slotSaveStack()
}
if (dir.exists(effectfilename)) {
if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", effectfilename)) == KMessageBox::No) {
if (KMessageBox::questionTwoActions(this, i18n("File %1 already exists.\nDo you want to overwrite it?", effectfilename), {},
KStandardGuiItem::overwrite(), KStandardGuiItem::cancel()) == KMessageBox::SecondaryAction) {
return;
}
}
......
......@@ -8,6 +8,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "layoutmanagement.h"
#include "core.h"
#include "mainwindow.h"
#include "utils/KMessageBox_KdenliveCompat.h"
#include <KMessageBox>
#include <QButtonGroup>
#include <QDialog>
......@@ -278,8 +279,9 @@ std::pair<QString, QString> LayoutManagement::saveLayout(const QString &layout,
if (layouts.hasKey(saveName)) {
// Layout already exists
int res = KMessageBox::questionYesNo(pCore->window(), i18n("The layout %1 already exists. Do you want to replace it?", layoutName));
if (res != KMessageBox::ButtonCode::Yes) {
int res = KMessageBox::questionTwoActions(pCore->window(), i18n("The layout %1 already exists. Do you want to replace it?", layoutName), {},
KStandardGuiItem::overwrite(), KStandardGuiItem::cancel());
if (res != KMessageBox::ButtonCode::PrimaryAction) {
return {nullptr, nullptr};
}
}
......
......@@ -69,6 +69,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "jogshuttle/jogmanager.h"
#endif
#include "utils/KMessageBox_KdenliveCompat.h"
#include <KAboutData>
#include <KActionCollection>
#include <KActionMenu>
......@@ -932,18 +933,18 @@ bool MainWindow::queryClose()
if (m_renderWidget) {
int waitingJobs = m_renderWidget->waitingJobsCount();
if (waitingJobs > 0) {
switch (
KMessageBox::warningYesNoCancel(this,
i18np("You have 1 rendering job waiting in the queue.\nWhat do you want to do with this job?",
"You have %1 rendering jobs waiting in the queue.\nWhat do you want to do with these jobs?", waitingJobs),
QString(), KGuiItem(i18n("Start them now")), KGuiItem(i18n("Delete them")))) {
case KMessageBox::Yes:
switch (KMessageBox::warningTwoActionsCancel(this,
i18np("You have 1 rendering job waiting in the queue.\nWhat do you want to do with this job?",
"You have %1 rendering jobs waiting in the queue.\nWhat do you want to do with these jobs?",
waitingJobs),
QString(), KGuiItem(i18n("Start them now")), KGuiItem(i18n("Delete them")))) {
case KMessageBox::PrimaryAction:
// create script with waiting jobs and start it
if (!m_renderWidget->startWaitingRenderJobs()) {
return false;
}
break;
case KMessageBox::No:
case KMessageBox::SecondaryAction:
// Don't do anything, jobs will be deleted
break;
default:
......
......@@ -8,6 +8,7 @@
#include "core.h"
#include "kdenlivesettings.h"
#include "utils/KMessageBox_KdenliveCompat.h"
#include <KFileItem>
#include <KLocalizedString>
#include <KMessageBox>
......@@ -554,10 +555,10 @@ void ResourceWidget::slotSaveItem(const QString &originalUrl, const QString &acc
}
QString attribution;
if (KMessageBox::questionYesNo(this,
i18n("Be aware that the usage of the resource is maybe restricted by license terms or law!\n"
"Do you want to add license attribution to your Project Notes?"),
QString(), KStandardGuiItem::yes(), KStandardGuiItem::no(), i18n("Remember this decision")) == KMessageBox::Yes) {
if (KMessageBox::questionTwoActions(this,
i18n("Be aware that the usage of the resource is maybe restricted by license terms or law!\n"
"Do you want to add license attribution to your Project Notes?"),
QString(), KStandardGuiItem::yes(), KStandardGuiItem::no(), i18n("Remember this decision")) == KMessageBox::Yes) {
attribution = i18nc("item name, item url, author name, license name, license url",
"This video uses \"%1\" (%2) by \"%3\" licensed under %4. To view a copy of this license, visit %5",
m_currentItem->data(nameRole).toString().isEmpty() ? i18n("Unnamed") : m_currentItem->data(nameRole).toString(),
......
......@@ -11,6 +11,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include <QFontDatabase>
#include <QStandardPaths>
#include "utils/KMessageBox_KdenliveCompat.h"
#include <KLocalizedString>
#include <KMessageBox>
......@@ -150,7 +151,8 @@ void ClipTranscode::slotStartTransCode()
KMessageBox::error(this, i18n("Source and destination file can't be the same"));
return;
}
if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", destination + extension)) == KMessageBox::No) {
if (KMessageBox::questionTwoActions(this, i18n("File %1 already exists.\nDo you want to overwrite it?", destination + extension), {},
KStandardGuiItem::overwrite(), KStandardGuiItem::cancel()) != KMessageBox::PrimaryAction) {
// Abort operation
if (m_automaticMode) {
// inform caller that we aborted
......
......@@ -17,6 +17,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "doc/kdenlivedoc.h"
#include "kdenlive_debug.h"
#include "utils/KMessageBox_KdenliveCompat.h"
#include <KDiskFreeSpaceInfo>
#include <KGuiItem>
#include <KLocalizedString>
......@@ -826,7 +827,8 @@ bool ArchiveWidget::processProjectFile()
m_archiveName.append(QStringLiteral(".tar.gz"));
};
if (QFile::exists(m_archiveName) &&
KMessageBox::questionYesNo(nullptr, i18n("File %1 already exists.\nDo you want to overwrite it?", m_archiveName)) == KMessageBox::No) {
KMessageBox::questionTwoActions(nullptr, i18n("File %1 already exists.\nDo you want to overwrite it?", m_archiveName), {},
KStandardGuiItem::overwrite(), KStandardGuiItem::cancel()) != KMessageBox::PrimaryAction) {
return false;
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
......@@ -839,7 +841,8 @@ bool ArchiveWidget::processProjectFile()
// Make a copy of original project file for extra safety
QString path = archive_url->url().toLocalFile() + QDir::separator() + m_name + QStringLiteral("-backup.kdenlive");
if (QFile::exists(path) && KMessageBox::warningYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", path)) != KMessageBox::Yes) {
if (QFile::exists(path) && KMessageBox::warningTwoActions(this, i18n("File %1 already exists.\nDo you want to overwrite it?", path), {},
KStandardGuiItem::overwrite(), KStandardGuiItem::cancel()) != KMessageBox::PrimaryAction) {
return false;
}
QFile::remove(path);
......@@ -855,7 +858,8 @@ bool ArchiveWidget::processProjectFile()
if (QFileInfo::exists(sub + QStringLiteral(".srt"))) {
QFile subFile(sub + QStringLiteral(".srt"));
path = archive_url->url().toLocalFile() + QDir::separator() + QFileInfo(subFile).fileName();
if (QFile::exists(path) && KMessageBox::warningYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", path)) != KMessageBox::Yes) {
if (QFile::exists(path) && KMessageBox::warningTwoActions(this, i18n("File %1 already exists.\nDo you want to overwrite it?", path), {},
KStandardGuiItem::overwrite(), KStandardGuiItem::cancel()) != KMessageBox::PrimaryAction) {
return false;
}
QFile::remove(path);
......@@ -868,7 +872,8 @@ bool ArchiveWidget::processProjectFile()
if (QFileInfo::exists(sub + QStringLiteral(".ass"))) {
QFile subFile(sub + QStringLiteral(".ass"));
path = archive_url->url().toLocalFile() + QDir::separator() + QFileInfo(subFile).fileName();
if (QFile::exists(path) && KMessageBox::warningYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", path)) != KMessageBox::Yes) {
if (QFile::exists(path) && KMessageBox::warningTwoActions(this, i18n("File %1 already exists.\nDo you want to overwrite it?", path), {},
KStandardGuiItem::overwrite(), KStandardGuiItem::cancel()) != KMessageBox::PrimaryAction) {
return false;
}
QFile::remove(path);
......@@ -881,7 +886,8 @@ bool ArchiveWidget::processProjectFile()
path = archive_url->url().toLocalFile() + QDir::separator() + m_name + QStringLiteral(".kdenlive");
QFile file(path);
if (file.exists() && KMessageBox::warningYesNo(this, i18n("Output file already exists. Do you want to overwrite it?")) != KMessageBox::Yes) {
if (file.exists() && KMessageBox::warningTwoActions(this, i18n("Output file already exists. Do you want to overwrite it?"), {},
KStandardGuiItem::overwrite(), KStandardGuiItem::cancel()) != KMessageBox::PrimaryAction) {
return false;
}
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
......
......@@ -24,6 +24,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "xml/xml.hpp"
#include "kdenlive_debug.h"
#include "utils/KMessageBox_KdenliveCompat.h"
#include <KIO/FileCopyJob>
#include <KLocalizedString>
#include <KMessageBox>
......@@ -372,10 +373,11 @@ void ProjectSettings::slotDeleteUnused()
slotUpdateFiles();
return;
}
if (KMessageBox::warningYesNoList(this,
i18n("This will remove the following files from your hard drive.\nThis action cannot be undone, only use if you know "
"what you are doing.\nAre you sure you want to continue?"),
toDelete, i18n("Delete unused clips")) != KMessageBox::Yes)
if (KMessageBox::warningTwoActionsList(
this,
i18n("This will remove the following files from your hard drive.\nThis action cannot be undone, only use if you know "
"what you are doing.\nAre you sure you want to continue?"),
toDelete, i18n("Delete unused clips"), KStandardGuiItem::del(), KStandardGuiItem::cancel()) != KMessageBox::PrimaryAction)
return;
pCore->projectItemModel()->requestTrashClips(idsToDelete, toDelete);
slotUpdateFiles();
......
......@@ -30,6 +30,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "timeline2/view/timelinecontroller.h"
#include "timeline2/view/timelinewidget.h"
#include "utils/KMessageBox_KdenliveCompat.h"
#include <KActionCollection>
#include <KConfigGroup>
#include <KJob>
......@@ -307,8 +308,8 @@ bool ProjectManager::closeCurrentDocument(bool saveChanges, bool quit)
message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?", m_project->url().fileName());
}
switch (KMessageBox::warningYesNoCancel(pCore->window(), message)) {
case KMessageBox::Yes:
switch (KMessageBox::warningTwoActionsCancel(pCore->window(), message, {}, KStandardGuiItem::save(), KStandardGuiItem::dontSave())) {
case KMessageBox::PrimaryAction:
// save document here. If saving fails, return false;
if (!saveFile()) {
return false;
......@@ -554,8 +555,8 @@ bool ProjectManager::checkForBackupFile(const QUrl &url, bool newFile)
}
if (orphanedFile) {
if (KMessageBox::questionYesNo(nullptr, i18n("Auto-saved file exist. Do you want to recover now?"), i18n("File Recovery"), KGuiItem(i18n("Recover")),
KGuiItem(i18n("Do not recover"))) == KMessageBox::Yes) {
if (KMessageBox::questionTwoActions(nullptr, i18n("Auto-saved file exist. Do you want to recover now?"), i18n("File Recovery"),
KGuiItem(i18n("Recover")), KGuiItem(i18n("Do not recover"))) == KMessageBox::PrimaryAction) {
doOpenFile(url, orphanedFile);
return true;
}
......@@ -637,12 +638,12 @@ void ProjectManager::doOpenFile(const QUrl &url, KAutoSaveFile *stale, bool isBa
KdenliveDoc *doc;
if (!openResult.isSuccessful() && !openResult.isAborted()) {
if (!isBackup) {
int answer = KMessageBox::warningYesNoCancel(
pCore->window(), i18n("Cannot open the project file. Error:\n%1\nDo you want to open a backup file?", openResult.getError()),
i18n("Error opening file"), KGuiItem(i18n("Open Backup")), KGuiItem(i18n("Recover")));
if (answer == KMessageBox::ButtonCode::Yes) { // Open Backup
int answer = KMessageBox::warningTwoActionsCancel(
pCore->window(), i18n("Cannot open the project file. Error:\n%1\nDo you want to open a backup file?", openResult.getError()),
i18n("Error opening file"), KGuiItem(i18n("Open Backup")), KGuiItem(i18n("Recover")));
if (answer == KMessageBox::ButtonCode::PrimaryAction) { // Open Backup
  • Compile error:

    /home/farid/kdenlive/src/project/projectmanager.cpp:644:27: error: no member named 'PrimaryAction' in 'KMessageBox::ButtonCode'; did you mean 'KMessageBox::PrimaryAction'?
                if (answer == KMessageBox::ButtonCode::PrimaryAction) { // Open Backup
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                              KMessageBox::PrimaryAction
Please register or sign in to reply
slotOpenBackup(url);
} else if (answer == KMessageBox::ButtonCode::No) { // Recover
} else if (answer == KMessageBox::ButtonCode::SecondaryAction) { // Recover
// if file was broken by Kdenlive 0.9.4, we can try recovering it. If successful, continue through rest of this function.
openResult = KdenliveDoc::Open(stale ? QUrl::fromLocalFile(stale->fileName()) : url,
QString(), pCore->window()->m_commandStack, true, pCore->window());
......@@ -1133,10 +1134,11 @@ void ProjectManager::saveWithUpdatedProfile(const QString &updatedProfile)
// First backup current project with fps appended
bool saveInTempFile = false;
if (m_project && m_project->isModified()) {
switch (
KMessageBox::warningYesNoCancel(pCore->window(), i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?",
m_project->url().fileName().isEmpty() ? i18n("Untitled") : m_project->url().fileName()))) {
case KMessageBox::Yes:
switch (KMessageBox::warningTwoActionsCancel(pCore->window(),
i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?",
m_project->url().fileName().isEmpty() ? i18n("Untitled") : m_project->url().fileName()),
{}, KStandardGuiItem::save(), KStandardGuiItem::dontSave())) {
case KMessageBox::PrimaryAction:
// save document here. If saving fails, return false;
if (!saveFile()) {
pCore->displayBinMessage(i18n("Project profile change aborted"), KMessageWidget::Information);
......@@ -1269,8 +1271,8 @@ void ProjectManager::saveWithUpdatedProfile(const QString &updatedProfile)
}
}
if (QFile::exists(convertedFile)) {
if (KMessageBox::warningYesNo(qApp->activeWindow(), i18n("Output file %1 already exists.\nDo you want to overwrite it?", convertedFile)) !=
KMessageBox::Yes) {
if (KMessageBox::warningTwoActions(qApp->activeWindow(), i18n("Output file %1 already exists.\nDo you want to overwrite it?", convertedFile), {},
KStandardGuiItem::overwrite(), KStandardGuiItem::cancel()) != KMessageBox::PrimaryAction) {
return;
}
}
......
......@@ -25,6 +25,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "trackmodel.hpp"
#include "transitions/transitionsrepository.hpp"
#include "utils/KMessageBox_KdenliveCompat.h"
#include <KLocalizedString>
#include <KMessageBox>
#include <QApplication>
......@@ -1913,11 +1914,11 @@ bool TimelineFunctions::pasteClips(const std::shared_ptr<TimelineItemModel> &tim
QString sourceFps = copiedItems.documentElement().attribute(QStringLiteral("fps"));
double ratio = 1.;
if (currentFps != sourceFps && !sourceFps.isEmpty()) {
if (KMessageBox::questionYesNo(
if (KMessageBox::questionTwoActions(
pCore->window(),
i18n("The source project has a different framerate (%1fps) than your current project.<br/>Clips or keyframes might be messed up.",
sourceFps),
i18n("Pasting Warning"), KGuiItem(i18n("Paste")), KGuiItem(i18n("Cancel"))) != KMessageBox::Yes) {
i18n("Pasting Warning"), KGuiItem(i18n("Paste")), KStandardGuiItem::cancel()) != KMessageBox::PrimaryAction) {
semaphore.release(1);
return false;
}
......
/*
SPDX-FileCopyrightText: 2022 Friedrich W. H. Kossebau <kossebau@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef KMESSAGEBOX_KDEVCOMPAT
#define KMESSAGEBOX_KDEVCOMPAT
#include <KMessageBox>
#include <kwidgetsaddons_version.h>
// Temporary private porting helper to avoid if-else cluttering of the codebase.
// Once KF5_DEP_VERSION >= 5.100 is reached:
// * rm all #include <KMessageBox_KDevCompat>
// * git rm KMessageBox_KDevCompat
#if KWIDGETSADDONS_VERSION < QT_VERSION_CHECK(5, 100, 0)
namespace KMessageBox {
inline constexpr auto PrimaryAction = KMessageBox::Yes;
inline constexpr auto SecondaryAction = KMessageBox::No;
inline ButtonCode questionTwoActions(QWidget *parent, const QString &text, const QString &title, const KGuiItem &primaryAction, const KGuiItem &secondaryAction,
const QString &dontAskAgainName = QString(), Options options = Notify)
{
return questionYesNo(parent, text, title, primaryAction, secondaryAction, dontAskAgainName, options);
}
inline ButtonCode questionTwoActionsCancel(QWidget *parent, const QString &text, const QString &title, const KGuiItem &primaryAction,
const KGuiItem &secondaryAction, const KGuiItem &cancelAction = KStandardGuiItem::cancel(),
const QString &dontAskAgainName = QString(), Options options = Notify)
{
return questionYesNoCancel(parent, text, title, primaryAction, secondaryAction, cancelAction, dontAskAgainName, options);
}
inline ButtonCode warningTwoActions(QWidget *parent, const QString &text, const QString &title, const KGuiItem &primaryAction, const KGuiItem &secondaryAction,
const QString &dontAskAgainName = QString(), Options options = Options(Notify | Dangerous))
{
return warningYesNo(parent, text, title, primaryAction, secondaryAction, dontAskAgainName, options);
}
inline ButtonCode warningTwoActionsList(QWidget *parent, const QString &text, const QStringList &strlist, const QString &title, const KGuiItem &primaryAction,
const KGuiItem &secondaryAction, const QString &dontAskAgainName = QString(),
Options options = Options(Notify | Dangerous))
{
return warningYesNoList(parent, text, strlist, title, primaryAction, secondaryAction, dontAskAgainName, options);
}
inline ButtonCode warningTwoActionsCancel(QWidget *parent, const QString &text, const QString &title, const KGuiItem &primaryAction,
const KGuiItem &secondaryAction, const KGuiItem &cancelAction = KStandardGuiItem::cancel(),
const QString &dontAskAgainName = QString(), Options options = Options(Notify | Dangerous))
{
return warningYesNoCancel(parent, text, title, primaryAction, secondaryAction, cancelAction, dontAskAgainName, options);
}
} // namespace KMessageBox
#endif
#endif // KMESSAGEBOX_KDEVCOMPAT
Supports Markdown
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