diff --git a/libs/ui/forms/wdgpaintopsettings.ui b/libs/ui/forms/wdgpaintopsettings.ui
index 4392019496..7f6e9b4916 100644
--- a/libs/ui/forms/wdgpaintopsettings.ui
+++ b/libs/ui/forms/wdgpaintopsettings.ui
@@ -1,788 +1,775 @@
WdgPaintOpSettings
0
0
- 1245
+ 1313
436
Brush Editor
-
Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
0
0
Presets
-
-
0
0
Engine:
-
0
0
-
0
0
-
0
0
0
120
1677215
1677215
-
-
22
22
-
Qt::Horizontal
5
10
-
0
0
0
0
22
22
false
false
-
0
-
6
-
0
0
30
30
30
30
QFrame::Box
QFrame::Sunken
true
-
0
0
10
75
true
current brush
-
180
0
-
0
0
16777215
28
Save
-
0
0
16777215
28
Cancel
-
Qt::Horizontal
148
56
-
0
0
26
26
QFrame::Box
QFrame::Sunken
-
0
0
Current Brush Engine
-
0
0
30
30
30
30
false
-
0
0
24
24
24
24
-
0
0
26
26
26
26
-
...
-
7
-
-
+
0
0
600
80
600
80
false
Qt::DefaultContextMenu
QFrame::StyledPanel
QFrame::Raised
0
Qt::ScrollBarAlwaysOff
Qt::ScrollBarAlwaysOff
true
Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
QPainter::Antialiasing|QPainter::HighQualityAntialiasing|QPainter::SmoothPixmapTransform
QGraphicsView::AnchorViewCenter
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
0
4
100
0
QFrame::NoFrame
QFrame::Plain
0
-
5
5
0
5
5
-
-
0
0
60
0
-
Qt::Horizontal
40
20
-
8
-
0
0
16777215
28
Overwrite Brush
-
0
0
16777215
28
Save New Brush Preset...
-
false
5
5
5
5
5
-
-
Scratchpad
-
QFrame::NoFrame
QFrame::Plain
0
0
0
0
0
0
-
0
0
250
0
-
-
Fill area with brush preset icon
-
Fill area with current image
-
Fill area with gradient
-
Fill area with background color
-
Reset area to white
KisScratchPad
QWidget
1
KisPresetLivePreviewView
QGraphicsView
kis_preset_live_preview_view.h
1
KisPresetSelectorStrip
QWidget
kis_preset_selector_strip.h
1
KisLodAvailabilityWidget
QWidget
kis_lod_availability_widget.h
1
diff --git a/libs/ui/widgets/kis_lod_availability_widget.cpp b/libs/ui/widgets/kis_lod_availability_widget.cpp
index 56f15019a6..c4f728602c 100644
--- a/libs/ui/widgets/kis_lod_availability_widget.cpp
+++ b/libs/ui/widgets/kis_lod_availability_widget.cpp
@@ -1,253 +1,254 @@
/*
* Copyright (c) 2015 Dmitry Kazakov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_lod_availability_widget.h"
#include
#include
#include
#include
#include
#include
#include "kis_config.h"
#include
#include
#include "kis_signals_blocker.h"
namespace {
/**
* These strings are added intentionally so we could relayout the threshold slider after
* the string freeze for 4.0. Please translate them :)
*/
static const KLocalizedString stringForInstantPreviewThreshold1 = ki18nc("@label:slider", "Threshold:");
static const KLocalizedString stringForInstantPreviewThreshold2 = ki18nc("@label:slider", "Instant preview threshold:");
}
struct KisLodAvailabilityWidget::Private
{
Private() : chkLod(0), resourceManager(0) {}
QCheckBox *chkLod;
QPushButton *btnLod;
QScopedPointer thresholdMenu;
KisDoubleSliderSpinBox *thresholdSlider = 0;
KoCanvasResourceManager *resourceManager;
KisPaintopLodLimitations limitations;
bool thresholdSupported = true;
bool sizeThresholdPassed();
};
KisLodAvailabilityWidget::KisLodAvailabilityWidget(QWidget *parent)
: QWidget(parent),
m_d(new Private)
{
m_d->chkLod = new QCheckBox(this);
m_d->btnLod = new QPushButton(this);
m_d->btnLod->setFlat(true);
connect(m_d->btnLod, SIGNAL(clicked()), SLOT(showLodToolTip()));
{
m_d->thresholdMenu.reset(new QMenu());
- m_d->thresholdMenu->addSection(i18n("Enable after:"));
m_d->btnLod->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_d->btnLod, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(showLodThresholdWidget(QPoint)));
KisConfig cfg(true);
m_d->thresholdSlider = new KisDoubleSliderSpinBox(m_d->thresholdMenu.data());
m_d->thresholdSlider->setRange(0, cfg.readEntry("maximumBrushSize", 1000), 2);
m_d->thresholdSlider->setValue(100);
m_d->thresholdSlider->setSingleStep(1);
m_d->thresholdSlider->setExponentRatio(3.0);
+ m_d->thresholdSlider->setPrefix(i18n("Enable after:"));
m_d->thresholdSlider->setSuffix(i18n(" px"));
m_d->thresholdSlider->setBlockUpdateSignalOnDrag(true);
QWidgetAction *sliderAction = new QWidgetAction(this);
sliderAction->setDefaultWidget(m_d->thresholdSlider);
m_d->thresholdMenu->addAction(sliderAction);
}
QHBoxLayout *layout = new QHBoxLayout;
+ layout->setContentsMargins(9, 9, 9, 9);
layout->addWidget(m_d->chkLod);
layout->addWidget(m_d->btnLod);
- layout->setSpacing(0);
+ layout->addStretch(1);
setLayout(layout);
// set no limitations
setLimitations(m_d->limitations);
connect(m_d->chkLod, SIGNAL(toggled(bool)), SIGNAL(sigUserChangedLodAvailability(bool)));
connect(m_d->thresholdSlider, SIGNAL(valueChanged(qreal)), SIGNAL(sigUserChangedLodThreshold(qreal)));
}
KisLodAvailabilityWidget::~KisLodAvailabilityWidget()
{
}
void KisLodAvailabilityWidget::showLodToolTip()
{
QToolTip::showText(QCursor::pos(), m_d->btnLod->toolTip(), m_d->btnLod);
}
void KisLodAvailabilityWidget::showLodThresholdWidget(const QPoint &pos)
{
Q_UNUSED(pos);
if (m_d->thresholdSupported) {
m_d->thresholdMenu->popup(QCursor::pos());
}
}
void KisLodAvailabilityWidget::setLimitations(const KisPaintopLodLimitations &l)
{
QString limitationsText;
Q_FOREACH (const KoID &id, l.limitations) {
limitationsText.append("");
limitationsText.append(id.name());
limitationsText.append("");
}
QString blockersText;
Q_FOREACH (const KoID &id, l.blockers) {
blockersText.append("");
blockersText.append(id.name());
blockersText.append("");
}
bool isBlocked = !l.blockers.isEmpty();
bool isLimited = !l.limitations.isEmpty();
m_d->thresholdSupported =
m_d->resourceManager ?
m_d->resourceManager->resource(KisCanvasResourceProvider::LodSizeThresholdSupported).toBool() :
true;
bool isBlockedByThreshold = !m_d->sizeThresholdPassed() && m_d->thresholdSupported;
const QString text = !isBlocked && !isBlockedByThreshold && isLimited ?
i18n("(Instant Preview)*") : i18n("Instant Preview");
QString toolTip;
if (isBlocked) {
toolTip = i18nc("@info:tooltip",
"Instant Preview Mode is "
"disabled by the following options:"
"
", blockersText);
} else if (isBlockedByThreshold) {
const qreal lodThreshold = m_d->resourceManager->resource(KisCanvasResourceProvider::LodSizeThreshold).toDouble();
const qreal size = m_d->resourceManager->resource(KisCanvasResourceProvider::Size).toDouble();
toolTip = i18nc("@info:tooltip",
"Instant Preview Mode is "
"disabled by instant preview threshold. "
"Please right-click here to change the threshold"
"
- Brush size %1
"
"- Threshold: %2
",
size, lodThreshold);
} else if (isLimited) {
toolTip = i18nc("@info:tooltip",
"Instant Preview may look different "
"from the final result. In case of troubles "
"try disabling the following options:"
"
", limitationsText);
} else {
toolTip = i18nc("@info:tooltip", "Instant Preview Mode is available
");
}
{
QFont font;
font.setStrikeOut(isBlocked || isBlockedByThreshold);
m_d->chkLod->setEnabled(!isBlocked);
m_d->btnLod->setEnabled(!isBlocked);
m_d->btnLod->setFont(font);
m_d->btnLod->setText(text);
m_d->btnLod->setToolTip(toolTip);
if (isBlocked) {
/**
* If LoD is really blocked by some limitation we sneakly reset
* the checkbox to let the user know it is fully disabled.
*/
KisSignalsBlocker b(m_d->chkLod);
m_d->chkLod->setChecked(false);
}
}
m_d->limitations = l;
if (m_d->resourceManager) {
const bool lodAvailableForUse =
!isBlocked && !isBlockedByThreshold &&
m_d->resourceManager->resource(KisCanvasResourceProvider::LodAvailability).toBool();
m_d->resourceManager->setResource(KisCanvasResourceProvider::EffectiveLodAvailablility, lodAvailableForUse);
}
}
void KisLodAvailabilityWidget::slotUserChangedLodAvailability(bool value)
{
KisSignalsBlocker b(m_d->chkLod);
m_d->chkLod->setChecked(value);
setLimitations(m_d->limitations);
}
void KisLodAvailabilityWidget::slotUserChangedLodThreshold(qreal value)
{
KisSignalsBlocker b(m_d->thresholdSlider);
m_d->thresholdSlider->setValue(value);
setLimitations(m_d->limitations);
}
void KisLodAvailabilityWidget::slotUserChangedSize(qreal value)
{
Q_UNUSED(value);
setLimitations(m_d->limitations);
}
void KisLodAvailabilityWidget::setCanvasResourceManager(KoCanvasResourceManager *resourceManager)
{
m_d->resourceManager = resourceManager;
}
bool KisLodAvailabilityWidget::Private::sizeThresholdPassed()
{
if (!resourceManager) return true;
const qreal lodThreshold = resourceManager->resource(KisCanvasResourceProvider::LodSizeThreshold).toDouble();
const qreal size = resourceManager->resource(KisCanvasResourceProvider::Size).toDouble();
return size >= lodThreshold;
}