Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_dlg_adjustment_layer.cc
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006 Boudewijn Rempt <boud@valdyas.org>
3 * SPDX-FileCopyrightText: 2008 Cyrille Berger <cberger@cberger.net>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
9#include <klocalizedstring.h>
10#include <kstandardguiitem.h>
11
12#include <QGroupBox>
13#include <QLayout>
14#include <QGridLayout>
15#include <QPixmap>
16#include <QDialogButtonBox>
17
18#include "filter/kis_filter.h"
19#include "kis_config_widget.h"
21#include "kis_paint_device.h"
22#include "kis_transaction.h"
23#include "kis_node.h"
25#include <kis_config.h>
26#include "KisViewManager.h"
27#include <kis_icon_utils.h>
28
29
32 KisPaintDeviceSP paintDevice,
33 const QString &layerName,
34 const QString &caption,
35 KisViewManager *view, QWidget *parent)
36 : KoDialog(parent, Qt::Dialog)
37 , m_node(node)
38 , m_nodeFilterInterface(nfi)
39 , m_currentFilter(0)
40 , m_customName(false)
41 , m_layerName(layerName)
42{
43 setCaption(caption);
45
46 QWidget * page = new QWidget(this);
47 wdgFilterNodeCreation.setupUi(page);
48 setMainWidget(page);
49
50 wdgFilterNodeCreation.filterGalleryToggle->setChecked(wdgFilterNodeCreation.filterSelector->isFilterGalleryVisible());
51 wdgFilterNodeCreation.filterGalleryToggle->setIcon(KisIconUtils::loadIcon("sidebaricon"));
52 wdgFilterNodeCreation.filterGalleryToggle->setMaximumWidth(wdgFilterNodeCreation.filterGalleryToggle->height());
53 connect(wdgFilterNodeCreation.filterSelector, SIGNAL(sigFilterGalleryToggled(bool)), wdgFilterNodeCreation.filterGalleryToggle, SLOT(setChecked(bool)));
54 connect(wdgFilterNodeCreation.filterGalleryToggle, SIGNAL(toggled(bool)), wdgFilterNodeCreation.filterSelector, SLOT(showFilterGallery(bool)));
55 connect(wdgFilterNodeCreation.filterSelector, SIGNAL(sigSizeChanged()), this, SLOT(slotFilterWidgetSizeChanged()));
56
57 KGuiItem::assign(wdgFilterNodeCreation.buttonBox->button(QDialogButtonBox::Ok), KStandardGuiItem::ok());
58 KGuiItem::assign(wdgFilterNodeCreation.buttonBox->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
59 connect(wdgFilterNodeCreation.buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
60 connect(wdgFilterNodeCreation.buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
61
62 wdgFilterNodeCreation.filterSelector->setView(view);
63 wdgFilterNodeCreation.filterSelector->showFilterGallery(KisConfig(true).showFilterGalleryLayerMaskDialog());
64
65 wdgFilterNodeCreation.filterSelector->setPaintDevice(false, paintDevice);
66 wdgFilterNodeCreation.layerName->setText(layerName);
67
68 connect(wdgFilterNodeCreation.filterSelector, SIGNAL(configurationChanged()), SLOT(slotConfigChanged()));
69 connect(wdgFilterNodeCreation.layerName, SIGNAL(textChanged(QString)), SLOT(slotNameChanged(QString)));
70
72}
73
78
80{
81 Q_UNUSED(text);
82 m_customName = !text.isEmpty();
84}
85
87{
88 KisFilterConfigurationSP config = wdgFilterNodeCreation.filterSelector->configuration();
89
90 Q_ASSERT(config);
91
92 return config;
93}
94
96{
97 return wdgFilterNodeCreation.layerName->text();
98}
99
101{
103
105
106 if (m_currentFilter) {
107 m_nodeFilterInterface->setFilter(m_currentFilter->cloneWithResourcesSnapshot());
108 if (!m_customName) {
109 wdgFilterNodeCreation.layerName->blockSignals(true);
110 wdgFilterNodeCreation.layerName->setText(m_layerName + " (" + wdgFilterNodeCreation.filterSelector->currentFilter()->name() + ")");
111 wdgFilterNodeCreation.layerName->blockSignals(false);
112 }
113 }
114
115 m_node->setDirty();
116}
117
119{
120 QWidget::adjustSize();
121}
122
124{
125 QMetaObject::invokeMethod(this, "adjustSize", Qt::QueuedConnection);
126}
127
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void setShowFilterGalleryLayerMaskDialog(bool showFilterGallery) const
Ui::WdgFilterNodeCreation wdgFilterNodeCreation
KisDlgAdjustmentLayer(KisNodeSP node, KisNodeFilterInterface *nfi, KisPaintDeviceSP paintDevice, const QString &layerName, const QString &caption, KisViewManager *view, QWidget *parent=0)
KisNodeFilterInterface * m_nodeFilterInterface
void slotNameChanged(const QString &)
KisFilterConfigurationSP filterConfiguration() const
KisFilterConfigurationSP m_currentFilter
virtual void setFilter(KisFilterConfigurationSP filterConfig, bool checkCompareConfig=true)
A dialog base class with standard buttons and predefined layouts.
Definition KoDialog.h:116
void enableButtonOk(bool state)
Definition KoDialog.cpp:615
void setMainWidget(QWidget *widget)
Definition KoDialog.cpp:354
virtual void setCaption(const QString &caption)
Definition KoDialog.cpp:498
void setButtons(ButtonCodes buttonMask)
Definition KoDialog.cpp:195
QIcon loadIcon(const QString &name)
virtual void setDirty()
Definition kis_node.cpp:577