Commit 38c4fc32 authored by Wolthera van Hövell's avatar Wolthera van Hövell 🛍

Merge branch 'master' into krita-testing-wolthera

parents 54776118 e308ed0f
......@@ -14,6 +14,9 @@ ExternalProject_Add(
INSTALL_DIR ${EXTPREFIX_qt}
CONFIGURE_COMMAND <SOURCE_DIR>/configure.bat -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdoc -skip qtenginio -skip qtgraphicaleffects -skip qtlocation -skip qtmultimedia -skip qtsensors -skip qtserialport -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip qtxmlpatterns -no-sql-sqlite -nomake examples -nomake tools -no-compile-examples -no-dbus -no-iconv -no-angle -no-ssl -no-openssl -no-wmf-backend -no-qml-debug -no-libproxy -no-system-proxies -no-nis -no-icu -no-mtdev -opensource -confirm-license -release -opengl desktop -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -prefix ${EXTPREFIX_qt}
# use this line for building Qt with debugging info enabled
#CONFIGURE_COMMAND <SOURCE_DIR>/configure.bat -release -force-debug-info -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdoc -skip qtenginio -skip qtgraphicaleffects -skip qtlocation -skip qtmultimedia -skip qtsensors -skip qtserialport -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip qtxmlpatterns -no-sql-sqlite -nomake examples -nomake tools -no-compile-examples -no-dbus -no-iconv -no-angle -no-ssl -no-openssl -no-wmf-backend -no-qml-debug -no-libproxy -no-system-proxies -no-nis -no-icu -no-mtdev -opensource -confirm-license -release -opengl desktop -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -prefix ${EXTPREFIX_qt}
BUILD_COMMAND nmake
INSTALL_COMMAND nmake install
UPDATE_COMMAND ""
......
......@@ -357,10 +357,10 @@
</Action>
<Action name="hmirror_action">
<icon>symmetry-horizontal</icon>
<text>Set horizontal mirror mode</text>
<text>Horizontal Mirror Tool</text>
<whatsThis></whatsThis>
<toolTip>Set horizontal mirror mode</toolTip>
<iconText>Set horizontal mirror mode</iconText>
<toolTip>Horizontal Mirror Tool</toolTip>
<iconText>Horizontal Mirror Tool</iconText>
<activationFlags>10000</activationFlags>
<shortcut></shortcut>
<isCheckable>true</isCheckable>
......@@ -368,10 +368,10 @@
</Action>
<Action name="vmirror_action">
<icon>symmetry-vertical</icon>
<text>Set vertical mirror mode</text>
<text>Vertical Mirror Tool</text>
<whatsThis></whatsThis>
<toolTip>Set vertical mirror mode</toolTip>
<iconText>Set vertical mirror mode</iconText>
<toolTip>Vertical Mirror Tool</toolTip>
<iconText>Vertical Mirror Tool</iconText>
<activationFlags>10000</activationFlags>
<shortcut></shortcut>
<isCheckable>true</isCheckable>
......
......@@ -72,8 +72,10 @@ void KoCreatePathTool::paint(QPainter &painter, const KoViewConverter &converter
KoShape::applyConversion(painter, converter);
painter.setPen(Qt::blue);
painter.setBrush(Qt::white); //TODO make configurable
QPen pen(QBrush(Qt::blue), 1);
pen.setCosmetic(true);
painter.setPen(pen);
painter.setBrush(Qt::white);
const bool firstPoint = (d->firstPoint == d->activePoint);
......@@ -90,9 +92,9 @@ void KoCreatePathTool::paint(QPainter &painter, const KoViewConverter &converter
// check if we have to color the first point
if (d->mouseOverFirstPoint) {
painter.setBrush(Qt::red); //TODO make configurable
painter.setBrush(Qt::red);
} else {
painter.setBrush(Qt::white); //TODO make configurable
painter.setBrush(Qt::white);
}
d->firstPoint->paint(painter, d->handleRadius, KoPathPoint::Node);
......@@ -104,8 +106,10 @@ void KoCreatePathTool::paint(QPainter &painter, const KoViewConverter &converter
painter.save();
painter.setTransform(d->hoveredPoint->parent()->absoluteTransformation(&converter), true);
KoShape::applyConversion(painter, converter);
painter.setPen(Qt::blue);
painter.setBrush(Qt::white); //TODO make configurable
QPen pen(QBrush(Qt::blue), 1);
pen.setCosmetic(true);
painter.setPen(pen);
painter.setBrush(Qt::white);
d->hoveredPoint->paint(painter, d->handleRadius, KoPathPoint::Node);
painter.restore();
}
......
......@@ -33,7 +33,7 @@ class QString;
/**
* A factory for KoShape objects. This factory differs from the public KoShapeFactorBase
* class that this class really creates the shape; it's the plugin entry point for the
* actualy shape plugins.
* actually shape plugins.
*/
class KRITAFLAKE_EXPORT KoDeferredShapeFactoryBase : public QObject
{
......
......@@ -47,7 +47,7 @@ class KisConfigWidget;
* pixels.
*
* in-out processing is typically filtering: @see KisFilter.
* out-only processing is typiccaly generating: @see KisGenerator.
* out-only processing is typically generating: @see KisGenerator.
*
* Information about the area that needs to be processed is contained
* @see KisProcessingInformation and @see KisConstProcessingInformation.
......
......@@ -242,13 +242,15 @@ int KisCageTransformWorker::Private::
tryGetValidIndex(const QPoint &cellPt)
{
int index = -1;
return
cellPt.x() >= 0 &&
if (cellPt.x() >= 0 &&
cellPt.y() >= 0 &&
cellPt.x() < gridSize.width() - 1 &&
cellPt.y() < gridSize.height() - 1 &&
(index = allToValidPointsMap[GridIterationTools::pointToIndex(cellPt, gridSize)]) >= 0, index;
cellPt.y() < gridSize.height() - 1) {
index = allToValidPointsMap[GridIterationTools::pointToIndex(cellPt, gridSize)];
}
return index;
}
......
......@@ -110,8 +110,8 @@ struct Q_DECL_HIDDEN KisPainter::Private {
qint32 maskImageWidth;
qint32 maskImageHeight;
QPointF axesCenter;
bool mirrorHorizontaly;
bool mirrorVerticaly;
bool mirrorHorizontally;
bool mirrorVertically;
bool isOpacityUnit; // TODO: move into ParameterInfo
KoCompositeOp::ParameterInfo paramInfo;
KoColorConversionTransformation::Intent renderingIntent;
......@@ -168,8 +168,8 @@ void KisPainter::init()
d->fillPainter = 0;
d->maskImageWidth = 255;
d->maskImageHeight = 255;
d->mirrorHorizontaly = false;
d->mirrorVerticaly = false;
d->mirrorHorizontally = false;
d->mirrorVertically = false;
d->isOpacityUnit = true;
d->paramInfo = KoCompositeOp::ParameterInfo();
d->renderingIntent = KoColorConversionTransformation::internalRenderingIntent();
......@@ -1275,7 +1275,7 @@ void KisPainter::fillPainterPath(const QPainterPath& path)
void KisPainter::fillPainterPath(const QPainterPath& path, const QRect &requestedRect)
{
if (d->mirrorHorizontaly || d->mirrorVerticaly) {
if (d->mirrorHorizontally || d->mirrorVertically) {
QTransform C1 = QTransform::fromTranslate(-d->axesCenter.x(), -d->axesCenter.y());
QTransform C2 = QTransform::fromTranslate(d->axesCenter.x(), d->axesCenter.y());
......@@ -1283,21 +1283,21 @@ void KisPainter::fillPainterPath(const QPainterPath& path, const QRect &requeste
QPainterPath newPath;
QRect newRect;
if (d->mirrorHorizontaly) {
if (d->mirrorHorizontally) {
t = C1 * QTransform::fromScale(-1,1) * C2;
newPath = t.map(path);
newRect = t.mapRect(requestedRect);
d->fillPainterPathImpl(newPath, newRect);
}
if (d->mirrorVerticaly) {
if (d->mirrorVertically) {
t = C1 * QTransform::fromScale(1,-1) * C2;
newPath = t.map(path);
newRect = t.mapRect(requestedRect);
d->fillPainterPathImpl(newPath, newRect);
}
if (d->mirrorHorizontaly && d->mirrorVerticaly) {
if (d->mirrorHorizontally && d->mirrorVertically) {
t = C1 * QTransform::fromScale(-1,-1) * C2;
newPath = t.map(path);
newRect = t.mapRect(requestedRect);
......@@ -2602,21 +2602,21 @@ KisPaintOp* KisPainter::paintOp() const
return d->paintOp;
}
void KisPainter::setMirrorInformation(const QPointF& axesCenter, bool mirrorHorizontaly, bool mirrorVerticaly)
void KisPainter::setMirrorInformation(const QPointF& axesCenter, bool mirrorHorizontally, bool mirrorVertically)
{
d->axesCenter = axesCenter;
d->mirrorHorizontaly = mirrorHorizontaly;
d->mirrorVerticaly = mirrorVerticaly;
d->mirrorHorizontally = mirrorHorizontally;
d->mirrorVertically = mirrorVertically;
}
void KisPainter::copyMirrorInformation(KisPainter* painter)
{
painter->setMirrorInformation(d->axesCenter, d->mirrorHorizontaly, d->mirrorVerticaly);
painter->setMirrorInformation(d->axesCenter, d->mirrorHorizontally, d->mirrorVertically);
}
bool KisPainter::hasMirroring() const
{
return d->mirrorHorizontaly || d->mirrorVerticaly;
return d->mirrorHorizontally || d->mirrorVertically;
}
void KisPainter::setMaskImageSize(qint32 width, qint32 height)
......@@ -2665,7 +2665,7 @@ void KisPainter::setColorConversionFlags(KoColorConversionTransformation::Conver
void KisPainter::renderMirrorMaskSafe(QRect rc, KisFixedPaintDeviceSP dab, bool preserveDab)
{
if (!d->mirrorHorizontaly && !d->mirrorVerticaly) return;
if (!d->mirrorHorizontally && !d->mirrorVertically) return;
KisFixedPaintDeviceSP dabToProcess = dab;
if (preserveDab) {
......@@ -2676,7 +2676,7 @@ void KisPainter::renderMirrorMaskSafe(QRect rc, KisFixedPaintDeviceSP dab, bool
void KisPainter::renderMirrorMaskSafe(QRect rc, KisPaintDeviceSP dab, int sx, int sy, KisFixedPaintDeviceSP mask, bool preserveMask)
{
if (!d->mirrorHorizontaly && !d->mirrorVerticaly) return;
if (!d->mirrorHorizontally && !d->mirrorVertically) return;
KisFixedPaintDeviceSP maskToProcess = mask;
if (preserveMask) {
......@@ -2693,7 +2693,7 @@ void KisPainter::renderMirrorMask(QRect rc, KisFixedPaintDeviceSP dab)
int mirrorX = -((x+rc.width()) - d->axesCenter.x()) + d->axesCenter.x();
int mirrorY = -((y+rc.height()) - d->axesCenter.y()) + d->axesCenter.y();
if (d->mirrorHorizontaly && d->mirrorVerticaly){
if (d->mirrorHorizontally && d->mirrorVertically){
dab->mirror(true, false);
bltFixed(mirrorX, y, dab, 0,0,rc.width(),rc.height());
dab->mirror(false,true);
......@@ -2702,11 +2702,11 @@ void KisPainter::renderMirrorMask(QRect rc, KisFixedPaintDeviceSP dab)
bltFixed(x, mirrorY, dab, 0,0,rc.width(),rc.height());
}
else if (d->mirrorHorizontaly){
else if (d->mirrorHorizontally){
dab->mirror(true, false);
bltFixed(mirrorX, y, dab, 0,0,rc.width(),rc.height());
}
else if (d->mirrorVerticaly){
else if (d->mirrorVertically){
dab->mirror(false, true);
bltFixed(x, mirrorY, dab, 0,0,rc.width(),rc.height());
}
......@@ -2721,7 +2721,7 @@ void KisPainter::renderMirrorMask(QRect rc, KisFixedPaintDeviceSP dab, KisFixedP
int mirrorX = -((x+rc.width()) - d->axesCenter.x()) + d->axesCenter.x();
int mirrorY = -((y+rc.height()) - d->axesCenter.y()) + d->axesCenter.y();
if (d->mirrorHorizontaly && d->mirrorVerticaly){
if (d->mirrorHorizontally && d->mirrorVertically){
dab->mirror(true, false);
mask->mirror(true, false);
bltFixedWithFixedSelection(mirrorX,y, dab, mask, rc.width() ,rc.height() );
......@@ -2734,12 +2734,12 @@ void KisPainter::renderMirrorMask(QRect rc, KisFixedPaintDeviceSP dab, KisFixedP
mask->mirror(true, false);
bltFixedWithFixedSelection(x,mirrorY, dab, mask, rc.width() ,rc.height() );
}else if (d->mirrorHorizontaly){
}else if (d->mirrorHorizontally){
dab->mirror(true, false);
mask->mirror(true, false);
bltFixedWithFixedSelection(mirrorX,y, dab, mask, rc.width() ,rc.height() );
}else if (d->mirrorVerticaly){
}else if (d->mirrorVertically){
dab->mirror(false, true);
mask->mirror(false, true);
bltFixedWithFixedSelection(x,mirrorY, dab, mask, rc.width() ,rc.height() );
......@@ -2749,7 +2749,7 @@ void KisPainter::renderMirrorMask(QRect rc, KisFixedPaintDeviceSP dab, KisFixedP
void KisPainter::renderMirrorMask(QRect rc, KisPaintDeviceSP dab){
if (d->mirrorHorizontaly || d->mirrorVerticaly){
if (d->mirrorHorizontally || d->mirrorVertically){
KisFixedPaintDeviceSP mirrorDab = new KisFixedPaintDevice(dab->colorSpace());
QRect dabRc( QPoint(0,0), QSize(rc.width(),rc.height()) );
mirrorDab->setRect(dabRc);
......@@ -2763,7 +2763,7 @@ void KisPainter::renderMirrorMask(QRect rc, KisPaintDeviceSP dab){
void KisPainter::renderMirrorMask(QRect rc, KisPaintDeviceSP dab, int sx, int sy, KisFixedPaintDeviceSP mask)
{
if (d->mirrorHorizontaly || d->mirrorVerticaly){
if (d->mirrorHorizontally || d->mirrorVertically){
KisFixedPaintDeviceSP mirrorDab = new KisFixedPaintDevice(dab->colorSpace());
QRect dabRc( QPoint(0,0), QSize(rc.width(),rc.height()) );
mirrorDab->setRect(dabRc);
......@@ -2784,13 +2784,13 @@ void KisPainter::renderDabWithMirroringNonIncremental(QRect rc, KisPaintDeviceSP
rects << rc;
if (d->mirrorHorizontaly && d->mirrorVerticaly){
if (d->mirrorHorizontally && d->mirrorVertically){
rects << QRect(mirrorX, y, rc.width(), rc.height());
rects << QRect(mirrorX, mirrorY, rc.width(), rc.height());
rects << QRect(x, mirrorY, rc.width(), rc.height());
} else if (d->mirrorHorizontaly) {
} else if (d->mirrorHorizontally) {
rects << QRect(mirrorX, y, rc.width(), rc.height());
} else if (d->mirrorVerticaly) {
} else if (d->mirrorVertically) {
rects << QRect(x, mirrorY, rc.width(), rc.height());
}
......
......@@ -613,7 +613,7 @@ public:
*/
KisPaintOp* paintOp() const;
void setMirrorInformation(const QPointF &axesCenter, bool mirrorHorizontaly, bool mirrorVerticaly);
void setMirrorInformation(const QPointF &axesCenter, bool mirrorHorizontally, bool mirrorVertically);
/**
* copy the mirror information to other painter
......
......@@ -115,7 +115,6 @@ private:
KisImageWSP m_image;
KisNodeSP m_node;
KisProcessingApplicator::ProcessingFlags m_flags;
bool m_finalUpdate;
};
class EmitImageSignalsCommand : public KisCommandUtils::FlipFlopCommand
......@@ -156,7 +155,6 @@ private:
private:
KisImageWSP m_image;
KisImageSignalVector m_emitSignals;
bool m_finalUpdate;
};
......
......@@ -144,7 +144,7 @@ private:
/**
* Set information about the author
* This sets what is actualy saved to file. The public method setAuthorInfo() can be used to set
* This sets what is actually saved to file. The public method setAuthorInfo() can be used to set
* values that overide what is fetched from the author profile. During saveParameters() author
* profile and any overrides is combined resulting in calls to this method.
* @param info the kind of information to set
......
......@@ -479,6 +479,29 @@ qreal KisCanvasResourceProvider::opacity() const
return m_resourceManager->resource(Opacity).toReal();
}
void KisCanvasResourceProvider::setSelectionAction(int action)
{
m_resourceManager->setResource(SelectionAction, action);
emit sigSelectionActionChanged(action);
}
int KisCanvasResourceProvider::selectionAction()
{
return m_resourceManager->resource(SelectionAction).toInt();
}
void KisCanvasResourceProvider::setSelectionMode(int mode)
{
m_resourceManager->setResource(SelectionMode, mode);
emit sigSelectionModeChanged(mode);
}
int KisCanvasResourceProvider::selectionMode()
{
return m_resourceManager->resource(SelectionMode).toInt();
}
void KisCanvasResourceProvider::setGlobalAlphaLock(bool lock)
{
m_resourceManager->setResource(GlobalAlphaLock, lock);
......
......@@ -75,7 +75,9 @@ public:
GlobalAlphaLock,
PreviousPaintOpPreset,
EffectiveZoom, ///<-Used only by painting tools for non-displaying purposes
PresetAllowsLod
PresetAllowsLod,
SelectionAction,
SelectionMode
};
......@@ -162,6 +164,12 @@ public:
///Notify that the workspace is loaded and settings can be read
void notifyLoadingWorkspace(KisWorkspaceResource* workspace);
int selectionAction();
void setSelectionAction(int action);
int selectionMode();
void setSelectionMode(int mode);
public Q_SLOTS:
void slotSetFGColor(const KoColor& c);
......@@ -204,6 +212,8 @@ Q_SIGNALS:
void sigOpacityChanged(qreal);
void sigSavingWorkspace(KisWorkspaceResource* workspace);
void sigLoadingWorkspace(KisWorkspaceResource* workspace);
void sigSelectionActionChanged(const int);
void sigSelectionModeChanged(const int);
void mirrorModeChanged();
void moveMirrorVerticalCenter();
......
......@@ -25,6 +25,7 @@
#include <QObject>
#include <QImage>
#include <QMessageBox>
#include <QCheckBox>
#include <QBuffer>
#include <QGlobalStatic>
......@@ -250,17 +251,29 @@ KisPaintDeviceSP KisClipboard::clip(const QRect &imageBounds, bool showPopup)
return KisPaintDeviceSP(0);
KisConfig cfg;
quint32 behaviour = cfg.pasteBehaviour();
bool saveColorSetting = false;
if (behaviour == PASTE_ASK && showPopup) {
// Ask user each time.
QMessageBox mb(qApp->activeWindow());
mb.setWindowTitle(i18nc("@title:window", "Pasting data from simple source"));
mb.setText(i18n("The image data you are trying to paste has no color profile information.\n\nOn the web and in simple applications the data are supposed to be in sRGB color format.\nImporting as web will show it as it is supposed to look.\nMost monitors are not perfect though so if you made the image yourself\nyou might want to import it as it looked on you monitor.\n\nHow do you want to interpret these data?"));
QCheckBox dontPrompt(i18n("Remember"), &mb);
dontPrompt.blockSignals(true);
mb.setWindowTitle(i18nc("@title:window", "Missing Color Profile"));
mb.setText(i18n("The image data you are trying to paste has no color profile information. How do you want to interpret these data? \n\n As Web (sRGB) - Use standard colors that are displayed from computer monitors. This is the most common way that images are stored. \n\nAs on Monitor - If you know a bit about color management and want to use your monitor to determine the color profile.\n\n"));
// the order of how you add these buttons matters as it determines the index.
mb.addButton(i18n("As &Web"), QMessageBox::AcceptRole);
mb.addButton(i18n("As on &Monitor"), QMessageBox::AcceptRole);
mb.addButton(i18n("Cancel"), QMessageBox::RejectRole);
mb.addButton(&dontPrompt, QMessageBox::ActionRole);
behaviour = mb.exec();
......@@ -268,6 +281,9 @@ KisPaintDeviceSP KisClipboard::clip(const QRect &imageBounds, bool showPopup)
return 0;
}
saveColorSetting = dontPrompt.isChecked(); // should we save this option to the config for next time?
}
const KoColorSpace * cs;
......@@ -289,6 +305,12 @@ KisPaintDeviceSP KisClipboard::clip(const QRect &imageBounds, bool showPopup)
QPoint diff = imageBounds.center() - clipBounds.center();
clip->setX(diff.x());
clip->setY(diff.y());
// save the persion's selection to the configuration if the option is checked
if (saveColorSetting) {
cfg.setPasteBehaviour(behaviour);
}
}
return clip;
......
......@@ -128,8 +128,6 @@ QVariant KisMimeData::retrieveData(const QString &mimetype, QVariant::Type prefe
KisConfig cfg;
KisDocument *doc = createDocument(m_nodes);
doc->image()->refreshGraph();
doc->image()->waitForDone();
return doc->image()->projection()->convertToQImage(cfg.displayProfile(QApplication::desktop()->screenNumber(qApp->activeWindow())),
KoColorConversionTransformation::internalRenderingIntent(),
......
......@@ -54,7 +54,9 @@ struct MoveNodeStruct {
newParent(_parent),
newAbove(_above),
oldParent(_node->parent()),
oldAbove(_node->prevSibling())
oldAbove(_node->prevSibling()),
suppressNewParentRefresh(false),
suppressOldParentRefresh(false)
{
}
......@@ -87,7 +89,7 @@ struct MoveNodeStruct {
}
void doRedoUpdates() {
if (oldParent) {
if (oldParent && !suppressOldParentRefresh) {
image->refreshGraphAsync(oldParent);
}
......@@ -97,7 +99,7 @@ struct MoveNodeStruct {
}
void doUndoUpdates() {
if (newParent) {
if (newParent && !suppressNewParentRefresh) {
image->refreshGraphAsync(newParent);
}
......@@ -106,6 +108,16 @@ struct MoveNodeStruct {
}
}
void resolveParentCollisions(MoveNodeStruct *rhs) const {
if (rhs->newParent == newParent) {
rhs->suppressNewParentRefresh = true;
}
if (rhs->oldParent == oldParent) {
rhs->suppressOldParentRefresh = true;
}
}
KisImageSP image;
KisNodeSP node;
KisNodeSP newParent;
......@@ -113,6 +125,8 @@ struct MoveNodeStruct {
KisNodeSP oldParent;
KisNodeSP oldAbove;
bool suppressNewParentRefresh;
bool suppressOldParentRefresh;
};
typedef QSharedPointer<MoveNodeStruct> MoveNodeStructSP;
......@@ -149,6 +163,13 @@ private:
bool result = hash->value(moveStruct->node)->tryMerge(*moveStruct);
KIS_ASSERT_RECOVER_NOOP(result);
} else {
MovedNodesHash::const_iterator it = hash->constBegin();
MovedNodesHash::const_iterator end = hash->constEnd();
for (; it != end; ++it) {
it.value()->resolveParentCollisions(moveStruct.data());
}
hash->insert(moveStruct->node, moveStruct);
}
}
......
......@@ -33,6 +33,12 @@ class KisPostExecutionUndoAdapter;
class KisRecordedPaintAction;
class KoPattern;
/**
* @brief The KisResourcesSnapshot class takes a snapshot of the various resources
* like colors and settings used at the begin of a stroke or a recording so subsequent
* changes don't impact the running stroke. The main reason for the snapshot is that the
* user can *change* the options while the stroke is being executed in the background.
*/
class KRITAUI_EXPORT KisResourcesSnapshot : public KisShared
{
public:
......
......@@ -20,12 +20,12 @@
#include <QKeyEvent>
#include "kis_selection_options.h"
#include "kis_canvas2.h"
#include "KisViewManager.h"
#include "kis_canvas_resource_provider.h"
KisSelectionToolConfigWidgetHelper::KisSelectionToolConfigWidgetHelper(const QString &windowTitle)
: m_optionsWidget(0),
m_selectionAction(SELECTION_REPLACE),
m_selectionMode(PIXEL_SELECTION),
m_windowTitle(windowTitle)
{
}
......@@ -35,9 +35,15 @@ void KisSelectionToolConfigWidgetHelper::createOptionWidget(KisCanvas2 *canvas,
m_optionsWidget = new KisSelectionOptions(canvas);
Q_CHECK_PTR(m_optionsWidget);
// slotCanvasResourceChanged... yuck
m_resourceProvider = canvas->viewManager()->resourceProvider();
// connect(m_resourceProvider->resourceManager(), &KisCanvasResourceManager::canvasResourceChanged,
// this, KisSelectionToolConfigWidgetHelper::slotCanvasResourceChanged);
m_optionsWidget->setObjectName(toolId + "option widget");
m_optionsWidget->setWindowTitle(m_windowTitle);
m_optionsWidget->setAction(m_selectionAction);
m_optionsWidget->setAction(selectionAction());
m_optionsWidget->setMode(selectionMode());
// See https://bugs.kde.org/show_bug.cgi?id=316896
QWidget *specialSpacer = new QWidget(m_optionsWidget);
......@@ -45,8 +51,14 @@ void KisSelectionToolConfigWidgetHelper::createOptionWidget(KisCanvas2 *canvas,
specialSpacer->setFixedSize(0, 0);
m_optionsWidget->layout()->addWidget(specialSpacer);
connect(m_optionsWidget, SIGNAL(actionChanged(int)), this, SLOT(slotSetAction(int)));
connect(m_optionsWidget, SIGNAL(modeChanged(int)), this, SLOT(slotSetSelectionMode(int)));
connect(m_optionsWidget, &KisSelectionOptions::actionChanged,
this, &KisSelectionToolConfigWidgetHelper::slotWidgetActionChanged);
connect(m_optionsWidget, &KisSelectionOptions::modeChanged,
this, &KisSelectionToolConfigWidgetHelper::slotWidgetModeChanged);
connect(m_resourceProvider, &KisCanvasResourceProvider::sigSelectionActionChanged,
this, &KisSelectionToolConfigWidgetHelper::slotGlobalActionChanged);
connect(m_resourceProvider, &KisCanvasResourceProvider::sigSelectionModeChanged,
this, &KisSelectionToolConfigWidgetHelper::slotGlobalModeChanged);
m_optionsWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
m_optionsWidget->adjustSize();
......@@ -59,44 +71,58 @@ KisSelectionOptions* KisSelectionToolConfigWidgetHelper::optionWidget() const
SelectionMode KisSelectionToolConfigWidgetHelper::selectionMode() const
{
return m_selectionMode;
return (SelectionMode)m_resourceProvider->selectionMode();
}
SelectionAction KisSelectionToolConfigWidgetHelper::selectionAction() const
{
return m_selectionAction;
return (SelectionAction)m_resourceProvider->selectionAction();
}
void KisSelectionToolConfigWidgetHelper::slotSetAction(int action)
void KisSelectionToolConfigWidgetHelper::slotWidgetActionChanged(int action)
{
if (action >= SELECTION_REPLACE && action <= SELECTION_INTERSECT && m_selectionAction != action) {
m_selectionAction = (SelectionAction)action;
if (action >= SELECTION_REPLACE && action <= SELECTION_INTERSECT) {
m_optionsWidget->setAction(action);
m_resourceProvider->setSelectionAction(action);
emit selectionActionChanged(action);
}
}
void KisSelectionToolConfigWidgetHelper::slotSetSelectionMode(int mode)
void KisSelectionToolConfigWidgetHelper::slotWidgetModeChanged(int mode)
{
m_optionsWidget->setMode(mode);
m_resourceProvider->setSelectionMode(mode);
emit selectionModeChanged(mode);
}
void KisSelectionToolConfigWidgetHelper::slotGlobalActionChanged(int action)
{
m_selectionMode = (SelectionMode)mode;
m_optionsWidget->setAction(action);
}
void KisSelectionToolConfigWidgetHelper::slotGlobalModeChanged(int mode)
{
m_optionsWidget->setMode(mode);
}
bool KisSelectionToolConfigWidgetHelper::processKeyPressEvent(QKeyEvent *event)
{
event->accept();
switch(event->key()) {
case Qt::Key_A:
slotSetAction(SELECTION_ADD);
slotWidgetActionChanged(SELECTION_ADD);
break;
case Qt::Key_S:
slotSetAction(SELECTION_SUBTRACT);
slotWidgetActionChanged(SELECTION_SUBTRACT);