Commit 52880e6c authored by Moritz Molch's avatar Moritz Molch

Add togglebutton to show / hide the filtertree in filterdialogs

REVIEW:123004
parent aca15c31
......@@ -45,6 +45,7 @@ select_shape.png
shade.png
shear_horizontal.png
shear_vertical.png
sidebaricon.png
tablet.png
tool_screenshot.png
transparency-disabled.png
......
......@@ -25,6 +25,12 @@
#include <QLayout>
#include <QGridLayout>
#include <QTimer>
#include <QIcon>
#include <QImage>
#include <QPixmap>
#include <KStandardDirs>
#include <QPushButton>
#include <QDialogButtonBox>
#include "filter/kis_filter.h"
#include "kis_config_widget.h"
......@@ -50,13 +56,22 @@ KisDlgAdjustmentLayer::KisDlgAdjustmentLayer(KisNodeSP node,
, m_layerName(layerName)
{
setCaption(caption);
setButtons(Ok | Cancel);
setDefaultButton(Ok);
setButtons(None);
QWidget * page = new QWidget(this);
wdgFilterNodeCreation.setupUi(page);
setMainWidget(page);
wdgFilterNodeCreation.filterGalleryToggle->setChecked(wdgFilterNodeCreation.filterSelector->isFilterGalleryVisible());
wdgFilterNodeCreation.filterGalleryToggle->setIcon(QPixmap(KGlobal::dirs()->findResource("data", "krita/pics/sidebaricon.png")));
wdgFilterNodeCreation.filterGalleryToggle->setMaximumWidth(wdgFilterNodeCreation.filterGalleryToggle->height());
connect(wdgFilterNodeCreation.filterSelector, SIGNAL(sigFilterGalleryToggled(bool)), wdgFilterNodeCreation.filterGalleryToggle, SLOT(setChecked(bool)));
connect(wdgFilterNodeCreation.filterGalleryToggle, SIGNAL(toggled(bool)), wdgFilterNodeCreation.filterSelector, SLOT(showFilterGallery(bool)));
connect(wdgFilterNodeCreation.filterSelector, SIGNAL(sigSizeChanged()), this, SLOT(slotFilterWidgetSizeChanged()));
connect(wdgFilterNodeCreation.buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(wdgFilterNodeCreation.buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
wdgFilterNodeCreation.filterSelector->setView(view);
wdgFilterNodeCreation.filterSelector->showFilterGallery(KisConfig().showFilterGalleryLayerMaskDialog());
......@@ -113,4 +128,14 @@ void KisDlgAdjustmentLayer::slotConfigChanged()
m_node->setDirty();
}
void KisDlgAdjustmentLayer::adjustSize()
{
QWidget::adjustSize();
}
void KisDlgAdjustmentLayer::slotFilterWidgetSizeChanged()
{
QMetaObject::invokeMethod(this, "adjustSize", Qt::QueuedConnection);
}
#include "kis_dlg_adjustment_layer.moc"
......@@ -60,13 +60,15 @@ public:
KisFilterConfiguration * filterConfiguration() const;
QString layerName() const;
protected Q_SLOTS:
public Q_SLOTS:
void adjustSize();
protected Q_SLOTS:
void slotNameChanged(const QString &);
void slotConfigChanged();
void slotFilterWidgetSizeChanged();
private:
KisNodeSP m_node;
KisNodeFilterInterface *m_nodeFilterInterface;
Ui::WdgFilterNodeCreation wdgFilterNodeCreation;
......
......@@ -20,6 +20,8 @@
#include "kis_dlg_filter.h"
#include <KStandardDirs>
#include <QPushButton>
#include <filter/kis_filter.h>
#include <filter/kis_filter_configuration.h>
#include <kis_filter_mask.h>
......@@ -67,6 +69,13 @@ KisDlgFilter::KisDlgFilter(KisViewManager *view, KisNodeSP node, KisFilterManage
d->uiFilterDialog.pushButtonCreateMaskEffect->show();
connect(d->uiFilterDialog.pushButtonCreateMaskEffect, SIGNAL(pressed()), SLOT(createMask()));
d->uiFilterDialog.filterGalleryToggle->setChecked(d->uiFilterDialog.filterSelection->isFilterGalleryVisible());
d->uiFilterDialog.filterGalleryToggle->setIcon(QPixmap(KGlobal::dirs()->findResource("data", "krita/pics/sidebaricon.png")));
d->uiFilterDialog.filterGalleryToggle->setMaximumWidth(d->uiFilterDialog.filterGalleryToggle->height());
connect(d->uiFilterDialog.filterSelection, SIGNAL(sigFilterGalleryToggled(bool)), d->uiFilterDialog.filterGalleryToggle, SLOT(setChecked(bool)));
connect(d->uiFilterDialog.filterGalleryToggle, SIGNAL(toggled(bool)), d->uiFilterDialog.filterSelection, SLOT(showFilterGallery(bool)));
connect(d->uiFilterDialog.filterSelection, SIGNAL(sigSizeChanged()), this, SLOT(slotFilterWidgetSizeChanged()));
if (node->inherits("KisMask")) {
d->uiFilterDialog.pushButtonCreateMaskEffect->setVisible(false);
}
......@@ -75,7 +84,7 @@ KisDlgFilter::KisDlgFilter(KisViewManager *view, KisNodeSP node, KisFilterManage
connect(d->uiFilterDialog.buttonBox, SIGNAL(accepted()), SLOT(accept()));
connect(d->uiFilterDialog.buttonBox, SIGNAL(rejected()), SLOT(reject()));
connect(d->uiFilterDialog.checkBoxPreview, SIGNAL(stateChanged(int)), SLOT(previewCheckBoxChange(int)));
connect(d->uiFilterDialog.pushButtonPreview, SIGNAL(toggled(bool)), SLOT(pushButtonPreviewToggled(bool)));
connect(d->uiFilterDialog.filterSelection, SIGNAL(configurationChanged()), SLOT(filterSelectionChanged()));
......@@ -83,7 +92,7 @@ KisDlgFilter::KisDlgFilter(KisViewManager *view, KisNodeSP node, KisFilterManage
connect(this, SIGNAL(rejected()), SLOT(slotOnReject()));
KConfigGroup group(KGlobal::config(), "filterdialog");
d->uiFilterDialog.checkBoxPreview->setChecked(group.readEntry("showPreview", true));
d->uiFilterDialog.pushButtonPreview->setChecked(group.readEntry("showPreview", true));
}
KisDlgFilter::~KisDlgFilter()
......@@ -120,7 +129,7 @@ void KisDlgFilter::updatePreview()
{
if (!d->uiFilterDialog.filterSelection->configuration()) return;
if (d->uiFilterDialog.checkBoxPreview->isChecked()) {
if (d->uiFilterDialog.pushButtonPreview->isChecked()) {
KisSafeFilterConfigurationSP config(d->uiFilterDialog.filterSelection->configuration());
startApplyingFilter(config);
}
......@@ -128,6 +137,16 @@ void KisDlgFilter::updatePreview()
d->uiFilterDialog.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
}
void KisDlgFilter::adjustSize()
{
QWidget::adjustSize();
}
void KisDlgFilter::slotFilterWidgetSizeChanged()
{
QMetaObject::invokeMethod(this, "adjustSize", Qt::QueuedConnection);
}
void KisDlgFilter::slotOnAccept()
{
if (!d->filterManager->isStrokeRunning()) {
......@@ -170,7 +189,7 @@ void KisDlgFilter::createMask()
accept();
}
void KisDlgFilter::previewCheckBoxChange(int state)
void KisDlgFilter::pushButtonPreviewToggled(bool state)
{
if (state) {
updatePreview();
......@@ -179,7 +198,7 @@ void KisDlgFilter::previewCheckBoxChange(int state)
}
KConfigGroup group(KGlobal::config(), "filterdialog");
group.writeEntry("showPreview", d->uiFilterDialog.checkBoxPreview->isChecked());
group.writeEntry("showPreview", d->uiFilterDialog.pushButtonPreview->isChecked());
group.config()->sync();
}
......
......@@ -48,17 +48,23 @@ protected Q_SLOTS:
void createMask();
void previewCheckBoxChange(int state);
void pushButtonPreviewToggled(bool state);
void filterSelectionChanged();
virtual void resizeEvent(QResizeEvent* );
public Q_SLOTS:
void adjustSize();
private:
void startApplyingFilter(KisSafeFilterConfigurationSP config);
void setDialogTitle(KisFilterSP f);
void updatePreview();
private slots:
void slotFilterWidgetSizeChanged();
private:
struct Private;
KisDlgFilter::Private* const d;
......
......@@ -2,24 +2,13 @@
<ui version="4.0">
<class>FilterDialog</class>
<widget class="QDialog" name="FilterDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>325</width>
<height>112</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>12</number>
</property>
<item>
<widget class="KisFilterSelectorWidget" name="filterSelection" native="true">
<property name="sizePolicy">
......@@ -31,17 +20,30 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0,0,0,0,0">
<property name="spacing">
<number>3</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="pushButtonCreateMaskEffect">
<property name="enabled">
<widget class="QPushButton" name="filterGalleryToggle">
<property name="text">
<string notr="true"/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonPreview">
<property name="text">
<string>Create Filter Mask</string>
<string>Preview</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
......@@ -52,25 +54,30 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<width>1</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkBoxPreview">
<widget class="QPushButton" name="pushButtonCreateMaskEffect">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Preview</string>
<string>Create Filter Mask</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
......@@ -88,10 +95,6 @@
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>checkBoxPreview</tabstop>
<tabstop>pushButtonCreateMaskEffect</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
......@@ -2,21 +2,7 @@
<ui version="4.0">
<class>WdgFilterNodeCreation</class>
<widget class="QWidget" name="WdgFilterNodeCreation">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>456</width>
<height>328</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1">
<property name="spacing">
<number>8</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0">
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
......@@ -54,6 +40,27 @@
<item>
<widget class="KisFilterSelectorWidget" name="filterSelector" native="true"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="filterGalleryToggle">
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
......
......@@ -25,6 +25,8 @@
#include <QLabel>
#include <QComboBox>
#include <QPushButton>
#include <QScrollArea>
#include <QLayout>
#include "ui_wdgfilterselector.h"
......@@ -65,9 +67,11 @@ struct KisFilterSelectorWidget::Private {
KisFiltersModel* filtersModel;
QGridLayout *widgetLayout;
KisViewManager *view;
bool showFilterGallery;
};
KisFilterSelectorWidget::KisFilterSelectorWidget(QWidget* parent) : d(new Private)
KisFilterSelectorWidget::KisFilterSelectorWidget(QWidget* parent)
: d(new Private)
{
Q_UNUSED(parent);
setObjectName("KisFilterSelectorWidget");
......@@ -77,12 +81,15 @@ KisFilterSelectorWidget::KisFilterSelectorWidget(QWidget* parent) : d(new Privat
d->currentFilter = 0;
d->filtersModel = 0;
d->view = 0;
d->showFilterGallery = true;
d->uiFilterSelector.setupUi(this);
d->widgetLayout = new QGridLayout(d->uiFilterSelector.centralWidgetHolder);
d->widgetLayout->setContentsMargins(0,0,0,0);
d->widgetLayout->setHorizontalSpacing(0);
showFilterGallery(false);
connect(d->uiFilterSelector.filtersSelector, SIGNAL(clicked(const QModelIndex&)), SLOT(setFilterIndex(const QModelIndex &)));
connect(d->uiFilterSelector.filtersSelector, SIGNAL(activated(const QModelIndex&)), SLOT(setFilterIndex(const QModelIndex &)));
......@@ -134,21 +141,19 @@ void KisFilterSelectorWidget::setPaintDevice(bool showAll, KisPaintDeviceSP _pai
void KisFilterSelectorWidget::showFilterGallery(bool visible)
{
QList<int> sizes;
int currentCentralWidgetWidth = d->currentCentralWidget ? d->currentCentralWidget->width() : 0;
if (visible) {
d->uiFilterSelector.filtersSelector->setMidLineWidth(150);
sizes << d->uiFilterSelector.filtersSelector->sizeHint().width() << currentCentralWidgetWidth;
} else {
d->uiFilterSelector.filtersSelector->setMidLineWidth(0);
sizes << 0 << currentCentralWidgetWidth;
if (d->showFilterGallery == visible) {
return;
}
d->showFilterGallery = visible;
update();
emit sigFilterGalleryToggled(visible);
emit sigSizeChanged();
}
bool KisFilterSelectorWidget::isFilterGalleryVisible() const
{
return true;
return d->showFilterGallery;
}
KisFilterSP KisFilterSelectorWidget::currentFilter() const
......@@ -181,6 +186,7 @@ void KisFilterSelectorWidget::setFilter(KisFilterSP f)
d->currentFilterConfigurationWidget = 0;
d->currentCentralWidget = new QLabel(i18n("No configuration options"),
d->uiFilterSelector.centralWidgetHolder);
d->uiFilterSelector.scrollArea->setMinimumSize(d->currentCentralWidget->sizeHint());
qobject_cast<QLabel*>(d->currentCentralWidget)->setAlignment(Qt::AlignCenter);
} else {
d->uiFilterSelector.comboBoxPresets->setEnabled(true);
......@@ -188,11 +194,14 @@ void KisFilterSelectorWidget::setFilter(KisFilterSP f)
d->currentFilterConfigurationWidget = widget;
d->currentCentralWidget = widget;
widget->layout()->setContentsMargins(0,0,0,0);
d->currentFilterConfigurationWidget->setView(d->view);
d->currentFilterConfigurationWidget->blockSignals(true);
d->currentFilterConfigurationWidget->setConfiguration(
d->currentFilter->defaultConfiguration(d->paintDevice));
d->currentFilterConfigurationWidget->blockSignals(false);
d->uiFilterSelector.scrollArea->setContentsMargins(0,0,0,0);
d->uiFilterSelector.scrollArea->setMinimumWidth(widget->sizeHint().width() + 18);
connect(d->currentFilterConfigurationWidget, SIGNAL(sigConfigurationUpdated()), this, SIGNAL(configurationChanged()));
}
......@@ -204,7 +213,8 @@ void KisFilterSelectorWidget::setFilter(KisFilterSP f)
// Add the widget to the layout
d->currentCentralWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
d->widgetLayout->addWidget(d->currentCentralWidget, 0 , 0);
showFilterGallery(isFilterGalleryVisible());
update();
}
void KisFilterSelectorWidget::setFilterIndex(const QModelIndex& idx)
......@@ -248,6 +258,27 @@ void KisFilterSelectorWidget::editConfigurations()
editor.exec();
}
void KisFilterSelectorWidget::update()
{
d->uiFilterSelector.filtersSelector->setVisible(d->showFilterGallery);
if (d->showFilterGallery) {
setMinimumWidth(qMax(sizeHint().width(), 700));
d->uiFilterSelector.scrollArea->setMinimumHeight(400);
setMinimumHeight(d->uiFilterSelector.widget->sizeHint().height());
if (d->currentFilter) {
bool v = d->uiFilterSelector.filtersSelector->blockSignals(true);
d->uiFilterSelector.filtersSelector->setCurrentIndex(d->filtersModel->indexForFilter(d->currentFilter->id()));
d->uiFilterSelector.filtersSelector->blockSignals(v);
}
}
else {
if (d->currentCentralWidget) {
d->uiFilterSelector.scrollArea->setMinimumHeight(qMin(400, d->currentCentralWidget->sizeHint().height()));
}
setMinimumSize(d->uiFilterSelector.widget->sizeHint());
}
}
KisFilterConfiguration* KisFilterSelectorWidget::configuration()
{
if (d->currentFilterConfigurationWidget) {
......@@ -278,5 +309,12 @@ void KisFilterTree::activateFilter(QModelIndex idx)
emit activated(idx);
}
#include "kis_filter_selector_widget.moc"
void KisFilterSelectorWidget::setVisible(bool visible)
{
QWidget::setVisible(visible);
if (visible) {
update();
}
}
#include "kis_filter_selector_widget.moc"
......@@ -49,15 +49,20 @@ public:
void setView(KisViewManager *view);
void setPaintDevice(bool showAll, KisPaintDeviceSP);
KisFilterConfiguration* configuration();
void showFilterGallery(bool visible);
bool isFilterGalleryVisible() const;
KisFilterSP currentFilter() const;
public Q_SLOTS:
void setVisible(bool visible);
void showFilterGallery(bool visible);
protected Q_SLOTS:
void slotBookmarkedFilterConfigurationSelected(int);
void setFilterIndex(const QModelIndex&);
void editConfigurations();
void update();
Q_SIGNALS:
void configurationChanged();
void sigFilterGalleryToggled(bool visible);
void sigSizeChanged();
private:
struct Private;
Private* const d;
......
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