[krita/krita/3.3] libs/ui: [Feature] Allow access to the filter configuration xml.
Boudewijn Rempt
null at kde.org
Sat Oct 14 08:59:36 UTC 2017
Git commit 8a81e76d866e4710e3a1b0e427a6f6ab1ef4659a by Boudewijn Rempt, on behalf of Wolthera van Hövell tot Westerflier.
Committed on 14/10/2017 at 08:38.
Pushed by rempt into branch 'krita/3.3'.
[Feature] Allow access to the filter configuration xml.
This feature allows users to get the XML of the filterconfiguration directly, and thus allows them to edit the values directly, or more importantly, copy paste filters via text based media for working with teams, or just for sharing their favourite filter configurations.
So this will allow...
1. Users sharing filters in a team production.
2. Users sharing favourite filters as we store bookmarked filters in the kritarc, and thus everytime the configuration is reset, filter configs are lost.
3. Help users with determining how to make python InfoObjects for filters.
CCMAIL:Kimageshop at kde.org
Differential Revision: https://phabricator.kde.org/D8248
M +10 -0 libs/ui/forms/wdgfilterselector.ui
M +33 -0 libs/ui/widgets/kis_filter_selector_widget.cc
M +2 -1 libs/ui/widgets/kis_filter_selector_widget.h
https://commits.kde.org/krita/8a81e76d866e4710e3a1b0e427a6f6ab1ef4659a
diff --git a/libs/ui/forms/wdgfilterselector.ui b/libs/ui/forms/wdgfilterselector.ui
index 168a927592e..ac4ecdf3f9c 100644
--- a/libs/ui/forms/wdgfilterselector.ui
+++ b/libs/ui/forms/wdgfilterselector.ui
@@ -125,6 +125,16 @@
</property>
</widget>
</item>
+ <item>
+ <widget class="QPushButton" name="btnXML">
+ <property name="toolTip">
+ <string>Get the XML for the current filter configuration.</string>
+ </property>
+ <property name="text">
+ <string>XML</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
diff --git a/libs/ui/widgets/kis_filter_selector_widget.cc b/libs/ui/widgets/kis_filter_selector_widget.cc
index 31450a5a365..a19408446f7 100644
--- a/libs/ui/widgets/kis_filter_selector_widget.cc
+++ b/libs/ui/widgets/kis_filter_selector_widget.cc
@@ -27,6 +27,10 @@
#include <QPushButton>
#include <QScrollArea>
#include <QLayout>
+#include <QDialogButtonBox>
+#include <QPlainTextEdit>
+#include <QDomDocument>
+#include <QDomElement>
#include "ui_wdgfilterselector.h"
@@ -97,6 +101,7 @@ KisFilterSelectorWidget::KisFilterSelectorWidget(QWidget* parent)
connect(d->uiFilterSelector.comboBoxPresets, SIGNAL(activated(int)),
SLOT(slotBookmarkedFilterConfigurationSelected(int)));
connect(d->uiFilterSelector.pushButtonEditPressets, SIGNAL(pressed()), SLOT(editConfigurations()));
+ connect(d->uiFilterSelector.btnXML, SIGNAL(clicked()), this, SLOT(showXMLdialog()));
}
KisFilterSelectorWidget::~KisFilterSelectorWidget()
@@ -152,6 +157,32 @@ void KisFilterSelectorWidget::showFilterGallery(bool visible)
emit sigSizeChanged();
}
+void KisFilterSelectorWidget::showXMLdialog()
+{
+ if (currentFilter()->showConfigurationWidget()) {
+ QDialog *xmlDialog = new QDialog();
+ xmlDialog->setMinimumWidth(500);
+ xmlDialog->setWindowTitle(i18n("Filter configuration XML"));
+ QVBoxLayout *xmllayout = new QVBoxLayout(xmlDialog);
+ QPlainTextEdit *text = new QPlainTextEdit(xmlDialog);
+ KisFilterConfigurationSP config = configuration();
+ text->setPlainText(config->toXML());
+ xmllayout->addWidget(text);
+ QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel, xmlDialog);
+ connect(buttons, SIGNAL(accepted()), xmlDialog, SLOT(accept()));
+ connect(buttons, SIGNAL(rejected()), xmlDialog, SLOT(reject()));
+ xmllayout->addWidget(buttons);
+ if (xmlDialog->exec()==QDialog::Accepted) {
+ QDomDocument doc;
+ doc.setContent(text->toPlainText());
+ config->fromXML(doc.documentElement());
+ if (config) {
+ d->currentFilterConfigurationWidget->setConfiguration(config);
+ }
+ }
+ }
+}
+
bool KisFilterSelectorWidget::isFilterGalleryVisible() const
{
return d->showFilterGallery;
@@ -183,6 +214,7 @@ void KisFilterSelectorWidget::setFilter(KisFilterSP f)
if (!widget) { // No widget, so display a label instead
d->uiFilterSelector.comboBoxPresets->setEnabled(false);
d->uiFilterSelector.pushButtonEditPressets->setEnabled(false);
+ d->uiFilterSelector.btnXML->setEnabled(false);
d->currentFilterConfigurationWidget = 0;
d->currentCentralWidget = new QLabel(i18n("No configuration options"),
@@ -192,6 +224,7 @@ void KisFilterSelectorWidget::setFilter(KisFilterSP f)
} else {
d->uiFilterSelector.comboBoxPresets->setEnabled(true);
d->uiFilterSelector.pushButtonEditPressets->setEnabled(true);
+ d->uiFilterSelector.btnXML->setEnabled(true);
d->currentFilterConfigurationWidget = widget;
d->currentCentralWidget = widget;
diff --git a/libs/ui/widgets/kis_filter_selector_widget.h b/libs/ui/widgets/kis_filter_selector_widget.h
index a7ee794106e..f9340bcce1f 100644
--- a/libs/ui/widgets/kis_filter_selector_widget.h
+++ b/libs/ui/widgets/kis_filter_selector_widget.h
@@ -37,7 +37,7 @@ class QHideEvent;
class QShowEvent;
/**
- * XXX
+ * Widget for selecting the filter. This shows the widget if there is any.
*/
class KisFilterSelectorWidget : public QWidget
{
@@ -59,6 +59,7 @@ protected Q_SLOTS:
void setFilterIndex(const QModelIndex&);
void editConfigurations();
void update();
+ void showXMLdialog();
Q_SIGNALS:
void configurationChanged();
void sigFilterGalleryToggled(bool visible);
More information about the kimageshop
mailing list