[graphics/krita] libs/ui/animation: Handle media encoder formats without preferences

Carsten Hartenfels <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit cad2ab016487274245f0ec82d8af49974581bd35 by Carsten Hartenfels.
Committed on 27/07/2026 at 16:06.
Pushed by hartenfels into branch 'master'.

Handle media encoder formats without preferences

By letting them return a null preferences widget. This will display a
message about the format not having preferences and will show just a
close button in the dialog instead of pointless reset, OK and cancel
buttons.

M  +19   -7    libs/ui/animation/KisMediaEncoderFormatPreferencesDialog.cpp

https://invent.kde.org/graphics/krita/-/commit/cad2ab016487274245f0ec82d8af49974581bd35

diff --git a/libs/ui/animation/KisMediaEncoderFormatPreferencesDialog.cpp b/libs/ui/animation/KisMediaEncoderFormatPreferencesDialog.cpp
index ac52953ee55..9a499c4d25e 100644
--- a/libs/ui/animation/KisMediaEncoderFormatPreferencesDialog.cpp
+++ b/libs/ui/animation/KisMediaEncoderFormatPreferencesDialog.cpp
@@ -4,9 +4,12 @@
 #include "KisMediaEncoderFormatPreferencesDialog.h"
 
 #include <QDialogButtonBox>
+#include <QLabel>
 #include <QPushButton>
 #include <QVBoxLayout>
 
+#include <klocalizedstring.h>
+
 #include "KisMediaEncoderWrapper.h"
 
 KisMediaEncoderPreferencesDialog::KisMediaEncoderPreferencesDialog(KisMediaEncoderFormat *format,
@@ -18,18 +21,27 @@ KisMediaEncoderPreferencesDialog::KisMediaEncoderPreferencesDialog(KisMediaEncod
     resize(400, 300);
     QVBoxLayout *dlgLayout = new QVBoxLayout(this);
 
+    QDialogButtonBox *buttons;
     m_widget = format->createPreferencesWidget(preferences);
-    dlgLayout->addWidget(m_widget, 1);
+    if (m_widget) {
+        dlgLayout->addWidget(m_widget, 1);
+        buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Reset);
+    } else {
+        QLabel *noPreferencesLabel = new QLabel(i18n("This format has no preferences."));
+        noPreferencesLabel->setAlignment(Qt::AlignCenter);
+        noPreferencesLabel->setWordWrap(true);
+        dlgLayout->addWidget(noPreferencesLabel);
+        buttons = new QDialogButtonBox(QDialogButtonBox::Close);
+    }
 
-    QDialogButtonBox *buttons =
-        new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Reset);
     dlgLayout->addWidget(buttons);
     connect(buttons, &QDialogButtonBox::accepted, this, &KisMediaEncoderPreferencesDialog::accept);
     connect(buttons, &QDialogButtonBox::rejected, this, &KisMediaEncoderPreferencesDialog::reject);
-    connect(buttons->button(QDialogButtonBox::Reset),
-            &QPushButton::clicked,
-            this,
-            &KisMediaEncoderPreferencesDialog::slotReset);
+
+    QPushButton *resetButton = buttons->button(QDialogButtonBox::Reset);
+    if (resetButton) {
+        connect(resetButton, &QPushButton::clicked, this, &KisMediaEncoderPreferencesDialog::slotReset);
+    }
 }
 
 QVariant KisMediaEncoderPreferencesDialog::preferences() const
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.