Commit d77ad205 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Merge remote-tracking branch 'origin' into rempt/T379-resource-management

parents 300e706e 411dc860
......@@ -3,8 +3,8 @@ SET(PREFIX_ext_gmic "${EXTPREFIX}" )
# Download the gmic sources
ExternalProject_Add( ext_gmic_base
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://gmic.eu/files/source/gmic_2.2.3.tar.gz
URL_HASH SHA1=43f975a462a842be5eeff70d8d372476547163b0
URL https://gmic.eu/files/source/gmic_2.3.0.tar.gz
URL_HASH SHA1=fb994a625c0757fd21af7dc14fb717f08ced76b3
SOURCE_DIR gmic
......@@ -19,8 +19,8 @@ ExternalProject_Add( ext_gmic_base
# FIXME: Forcing CMAKE_BUILD_TYPE to Release
ExternalProject_Add( ext_gmic_qt
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://github.com/c-koi/gmic-qt/archive/v.2.2.3.tar.gz
URL_HASH SHA1=a3c889de09031d34754c9bb3bd1004a2f67713c6
URL https://github.com/c-koi/gmic-qt/archive/v.2.3.0.tar.gz
URL_HASH SHA1=485fdcd67a89bc33fafa9c9335c80ca515be242a
PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/desktop_icon.diff
SOURCE_DIR gmic-qt
......
......@@ -14,12 +14,16 @@ ACTIONFILES=`find . -name \*.action`
./action_i18n.pl --context=action $ACTIONFILES >> rc.cpp
# extracti18n.pl extracts additional data from brushes, palettes etc.
perl extracti18n.pl > i18ndata
perl extracti18n.pl >> rc.cpp
# Extract the name of configuration pages in the metadata editor plugin.
$EXTRACTATTR --attr=MetaDataEditor,name --context='metadata editor page' \
plugins/extensions/metadataeditor/editors/*.xmlgui >> rc.cpp
# Ignore sdk/templates which contains templates for writing future plugins.
# Also ignore crashreporter, it has it's own catalog
# None of the placeholder strings inside will be seen by users.
kundo2_aware_xgettext krita.pot i18ndata rc.cpp \
kundo2_aware_xgettext krita.pot rc.cpp \
`find . -name \*.cc -o -name \*.h -o -name \*.cpp | \
grep -v '/tests/' | grep -v './sdk/templates' | grep -v './krita/crashreporter/'`
......@@ -27,4 +31,4 @@ kundo2_aware_xgettext krita.pot i18ndata rc.cpp \
$XGETTEXT -L Python `find . -name \*.py` -j -o $podir/krita.pot
# Clean up
rm -f i18ndata rc.cpp
rm -f rc.cpp
......@@ -22,9 +22,13 @@
use strict;
use warnings;
sub printi18n($$) {
sub printi18n($$$$) {
if ($_[0] ne "")
{
if ($_[3] > 0)
{
print "// i18n: file: ".$_[2].":".$_[3]."\n";
}
print "i18nc(\"".$_[1]."\",\"".$_[0]."\");\n";
}
}
......@@ -49,13 +53,13 @@ foreach my $filename (@filenames)
my @splited = split(/: /, $lines[1]);
my $name = $splited[1];
chomp($name);
printi18n($name, $filename);
printi18n($name, $filename, $filename, 2);
}
else
{
my $name = $lines[0];
chomp($name);
printi18n($name, $filename);
printi18n($name, $filename, $filename, 1);
}
}
else
......@@ -70,13 +74,13 @@ foreach my $filename (@filenames)
{
read(FILE, $bytes, 12);
read(FILE, my $name, $size - 21);
printi18n($name, $filename);
printi18n($name, $filename, $filename, -1);
}
else
{
read(FILE, $bytes, 20);
read(FILE, my $name, $size - 29);
printi18n($name, $filename);
printi18n($name, $filename, $filename, -1);
}
}
else
......@@ -85,7 +89,7 @@ foreach my $filename (@filenames)
my $size = unpack("N", $bytes);
read(FILE, $bytes, 20);
read(FILE, my $name, $size - 25);
printi18n($name, $filename);
printi18n($name, $filename, $filename, -1);
}
}
}
......
......@@ -1635,6 +1635,16 @@
<isCheckable>false</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="ToolReferenceImages">
<icon></icon>
<text>Reference Images Tool</text>
<whatsThis></whatsThis>
<toolTip>Reference Images Tool</toolTip>
<iconText>Reference Images Tool</iconText>
<shortcut></shortcut>
<isCheckable>false</isCheckable>
<statusTip></statusTip>
</Action>
</Actions>
<Actions category="Blending Modes">
......
......@@ -31,6 +31,9 @@
#include <QLocale>
#include <QSettings>
#include <QByteArray>
#include <QMessageBox>
#include <QOperatingSystemVersion>
#include <time.h>
......@@ -38,6 +41,7 @@
#include <KisLoggingManager.h>
#include <KoConfig.h>
#include <KoResourcePaths.h>
#include <kis_config.h>
#include "data/splash/splash_screen.xpm"
#include "data/splash/splash_holidays.xpm"
......@@ -56,9 +60,7 @@
#include <stdlib.h>
#include <kis_tablet_support_win.h>
#include <kis_tablet_support_win8.h>
#include <kis_config.h>
#include <QLibrary>
#include <QMessageBox>
#elif defined HAVE_X11
#include <kis_xi2_event_filter.h>
......@@ -335,30 +337,51 @@ extern "C" int main(int argc, char **argv)
app.setSplashScreen(splash);
}
#if defined Q_OS_WIN
KisConfig cfg;
bool supportedWindowsVersion = true;
#if QT_VERSION >= 0x050900
QOperatingSystemVersion osVersion = QOperatingSystemVersion::current();
if (osVersion.type() == QOperatingSystemVersion::Windows) {
if (osVersion.majorVersion() >= QOperatingSystemVersion::Windows7.majorVersion()) {
supportedWindowsVersion = true;
}
else {
supportedWindowsVersion = false;
if (cfg.readEntry("WarnedAboutUnsupportedWindows", false)) {
QMessageBox::information(0,
i18nc("@title:window", "Krita: Warning"),
i18n("You are running an unsupported version of Windows: %1.\n"
"This is not recommended. Do not report any bugs.\n"
"Please update to a supported version of Windows: Windows 7, 8, 8.1 or 10.").arg(osVersion.name()));
cfg.writeEntry("WarnedAboutUnsupportedWindows", true);
}
}
}
#endif
{
KisConfig cfg;
if (cfg.useWin8PointerInput() && !KisTabletSupportWin8::isAvailable()) {
cfg.setUseWin8PointerInput(false);
}
if (!cfg.useWin8PointerInput()) {
bool hasWinTab = KisTabletSupportWin::init();
if (!hasWinTab) {
if (!hasWinTab && supportedWindowsVersion) {
if (KisTabletSupportWin8::isPenDeviceAvailable()) {
// Use WinInk automatically
cfg.setUseWin8PointerInput(true);
} else if (!cfg.readEntry("WarnedAboutMissingWinTab", false)) {
if (KisTabletSupportWin8::isAvailable()) {
QMessageBox::information(nullptr,
i18n("Krita Tablet Support"),
i18n("Cannot load WinTab driver and no Windows Ink pen devices are found. If you have a drawing tablet, please make sure the tablet driver is properly installed."),
QMessageBox::Ok, QMessageBox::Ok);
i18n("Krita Tablet Support"),
i18n("Cannot load WinTab driver and no Windows Ink pen devices are found. If you have a drawing tablet, please make sure the tablet driver is properly installed."),
QMessageBox::Ok, QMessageBox::Ok);
} else {
QMessageBox::information(nullptr,
i18n("Krita Tablet Support"),
i18n("Cannot load WinTab driver. If you have a drawing tablet, please make sure the tablet driver is properly installed."),
QMessageBox::Ok, QMessageBox::Ok);
i18n("Krita Tablet Support"),
i18n("Cannot load WinTab driver. If you have a drawing tablet, please make sure the tablet driver is properly installed."),
QMessageBox::Ok, QMessageBox::Ok);
}
cfg.writeEntry("WarnedAboutMissingWinTab", true);
}
......
......@@ -63,7 +63,7 @@ void KoCanvasControllerWidget::Private::setDocumentOffset()
// If it isn't an OpenGL canvas
if (qobject_cast<QOpenGLWidget*>(canvasWidget) == 0) {
QPoint diff = q->documentOffset() - pt;
canvasWidget->scroll(diff.x(), diff.y());
canvasWidget->scroll(diff.x(), diff.y(), canvasWidget->rect());
}
}
......
......@@ -26,6 +26,7 @@
#include <QVector>
#include <QDomElement>
#include <QLocale>
#include <QColor>
#include <klocalizedstring.h>
......@@ -110,6 +111,26 @@ namespace KisDomUtils {
}
inline QString qColorToQString(QColor color)
{
// color channels will usually have 0-255
QString customColor = QString::number(color.red()).append(",")
.append(QString::number(color.green())).append(",")
.append(QString::number(color.blue())).append(",")
.append(QString::number(color.alpha()));
return customColor;
}
inline QColor qStringToQColor(QString colorString)
{
QStringList colorComponents = colorString.split(',');
return QColor(colorComponents[0].toInt(), colorComponents[1].toInt(), colorComponents[2].toInt(), colorComponents[3].toInt());
}
/**
* Save a value of type QRect into an XML tree. A child for \p parent
* is created and assigned a tag \p tag. The corresponding value can
......
......@@ -116,7 +116,7 @@ void KisGeneratorLayer::update()
QVector<QRect> dirtyRegion;
Q_FOREACH (const QRect &rc, processRegion) {
Q_FOREACH (const QRect &rc, processRegion.rects()) {
KisProcessingInformation dstCfg(originalDevice,
rc.topLeft(),
KisSelectionSP());
......
......@@ -22,6 +22,7 @@
#include <ksharedconfig.h>
#include <kconfiggroup.h>
#include <klocalizedstring.h>
#include <KoColorSpaceRegistry.h>
#include <KoColorProfile.h>
......@@ -409,6 +410,11 @@ QObject *Krita::fromVariant(const QVariant& v)
return 0;
}
QString Krita::krita_i18n(const QString &text)
{
return i18n(text.toUtf8().constData());
}
void Krita::mainWindowAdded(KisMainWindow *kisWindow)
{
Q_FOREACH(Extension *extension, d->extensions) {
......
......@@ -327,6 +327,8 @@ add_document_to_window()
// Internal only: for use with mikro.py
static QObject *fromVariant(const QVariant& v);
static QString krita_i18n(const QString &text);
private Q_SLOTS:
void mainWindowAdded(KisMainWindow *window);
......
......@@ -55,7 +55,7 @@ struct KoColorSet::Private {
KoColorSet::PaletteType paletteType;
QByteArray data;
QString comment;
qint32 columns;
qint32 columns {0}; // Set the default value that the GIMP uses...
QVector<KoColorSetEntry> colors; //ungrouped colors
QStringList groupNames; //names of the groups, this is used to determine the order they are in.
QMap<QString, QVector<KoColorSetEntry>> groups; //grouped colors.
......@@ -99,15 +99,13 @@ KoColorSet::KoColorSet(const QString& filename)
: KoResource(filename)
, d(new Private())
{
// Implemented in KoResource class
d->columns = 0; // Set the default value that the GIMP uses...
}
KoColorSet::KoColorSet()
: KoResource(QString())
, d(new Private())
{
d->columns = 0; // Set the default value that the GIMP uses...
}
/// Create an copied palette
......@@ -592,6 +590,7 @@ bool KoColorSet::loadGpl()
QStringList lines = s.split('\n', QString::SkipEmptyParts);
if (lines.size() < 3) {
warnPigment << "Not enough lines in palette file: " << filename();
return false;
}
......@@ -600,22 +599,27 @@ bool KoColorSet::loadGpl()
KoColorSetEntry e;
// Read name
if (!lines[0].startsWith("GIMP") || !lines[1].startsWith("Name: ")) {
if (!lines[0].startsWith("GIMP") || !lines[1].toLower().contains("name")) {
warnPigment << "Illegal Gimp palette file: " << filename();
return false;
}
setName(i18n(lines[1].mid(strlen("Name: ")).trimmed().toLatin1()));
setName(i18n(lines[1].split(":")[1].trimmed().toLatin1()));
index = 2;
// Read columns
if (lines[index].startsWith("Columns: ")) {
columns = lines[index].mid(strlen("Columns: ")).trimmed();
if (lines[index].toLower().contains("columns")) {
columns = lines[index].split(":")[1].trimmed();
d->columns = columns.toInt();
index = 3;
}
for (qint32 i = index; i < lines.size(); i++) {
if (lines[i].startsWith('#')) {
d->comment += lines[i].mid(1).trimmed() + ' ';
} else if (!lines[i].isEmpty()) {
......@@ -731,7 +735,7 @@ bool KoColorSet::loadPsp()
g = qBound(0, g, 255);
b = qBound(0, b, 255);
e.setColor(KoColor(QColor(r, g, b),
e.setColor(KoColor(QColor(r, g, b),
KoColorSpaceRegistry::instance()->rgb8()));
QString name = a.join(" ");
......
......@@ -236,6 +236,7 @@ public:
, lastMod(firstMod)
, nserver(new KisNameServer(1))
, imageIdleWatcher(2000 /*ms*/)
, globalAssistantsColor(KisConfig().defaultAssistantsColor())
, savingLock(&savingMutex)
, batchMode(false)
{
......@@ -266,10 +267,12 @@ public:
, preActivatedNode(0) // the node is from another hierarchy!
, imageIdleWatcher(2000 /*ms*/)
, assistants(rhs.assistants) // WARNING: assistants should not store pointers to the document!
, globalAssistantsColor(rhs.globalAssistantsColor)
, gridConfig(rhs.gridConfig)
, savingLock(&savingMutex)
, batchMode(rhs.batchMode)
{
// TODO: clone assistants
}
~Private() {
......@@ -324,6 +327,8 @@ public:
QList<KisPaintingAssistantSP> assistants;
QColor globalAssistantsColor;
KisSharedPtr<KisReferenceImagesLayer> referenceImagesLayer;
KisGridConfig gridConfig;
......@@ -1790,3 +1795,13 @@ QString KisDocument::exportErrorToUserMessage(KisImportExportFilter::ConversionS
{
return errorMessage.isEmpty() ? KisImportExportFilter::conversionStatusString(status) : errorMessage;
}
void KisDocument::setAssistantsGlobalColor(QColor color)
{
d->globalAssistantsColor = color;
}
QColor KisDocument::assistantsGlobalColor()
{
return d->globalAssistantsColor;
}
......@@ -590,6 +590,12 @@ public:
/// @replace the current list of assistants with @param value
void setAssistants(const QList<KisPaintingAssistantSP> &value);
void setAssistantsGlobalColor(QColor color);
QColor assistantsGlobalColor();
/**
* Get existing reference images layer or null if none exists.
*/
......
......@@ -1230,7 +1230,7 @@ KisDlgPreferences::KisDlgPreferences(QWidget* parent, const char* name)
QPushButton *restoreDefaultsButton = button(QDialogButtonBox::RestoreDefaults);
restoreDefaultsButton->setText("Restore Defaults");
restoreDefaultsButton->setText(i18nc("@action:button", "Restore Defaults"));
connect(this, SIGNAL(accepted()), m_inputConfiguration, SLOT(saveChanges()));
connect(this, SIGNAL(rejected()), m_inputConfiguration, SLOT(revertChanges()));
......
......@@ -1971,6 +1971,17 @@ void KisConfig::setCalculateAnimationCacheInBackground(bool value)
m_cfg.writeEntry("calculateAnimationCacheInBackground", value);
}
QColor KisConfig::defaultAssistantsColor(bool defaultValue) const
{
static const QColor defaultColor = QColor(176, 176, 176, 255);
return defaultValue ? defaultColor : m_cfg.readEntry("defaultAssistantsColor", defaultColor);
}
void KisConfig::setDefaultAssistantsColor(const QColor &color) const
{
m_cfg.writeEntry("defaultAssistantsColor", color);
}
#include <QDomDocument>
#include <QDomElement>
......
......@@ -561,6 +561,9 @@ public:
bool calculateAnimationCacheInBackground(bool defaultValue = false) const;
void setCalculateAnimationCacheInBackground(bool value);
QColor defaultAssistantsColor(bool defaultValue = false) const;
void setDefaultAssistantsColor(const QColor &color) const;
template<class T>
void writeEntry(const QString& name, const T& value) {
m_cfg.writeEntry(name, value);
......
......@@ -423,10 +423,10 @@ void KisLayerManager::convertNodeToPaintLayer(KisNodeSP source)
layer->setCompositeOpId(newCompositeOp);
KisNodeSP parent = source->parent();
KisNodeSP above = source;
KisNodeSP above = source->prevSibling();
while (parent && !parent->allowAsChild(layer)) {
above = above->parent();
above = above ? above->parent() : source->parent();
parent = above ? above->parent() : 0;
}
......@@ -435,8 +435,8 @@ void KisLayerManager::convertNodeToPaintLayer(KisNodeSP source)
}
m_commandsAdapter->beginMacro(kundo2_i18n("Convert to a Paint Layer"));
m_commandsAdapter->addNode(layer, parent, above);
m_commandsAdapter->removeNode(source);
m_commandsAdapter->addNode(layer, parent, above);
m_commandsAdapter->endMacro();
}
......
......@@ -622,11 +622,13 @@ void KisNodeManager::slotSomethingActivatedNodeImpl(KisNodeSP node)
void KisNodeManager::slotNonUiActivatedNode(KisNodeSP node)
{
if (node == activeNode()) return;
// the node must still be in the graph, some asynchronous
// signals may easily break this requirement
KIS_SAFE_ASSERT_RECOVER_RETURN(!node || node->graphListener());
if (node && !node->graphListener()) {
node = 0;
}
if (node == activeNode()) return;
slotSomethingActivatedNodeImpl(node);
......@@ -640,11 +642,13 @@ void KisNodeManager::slotNonUiActivatedNode(KisNodeSP node)
void KisNodeManager::slotUiActivatedNode(KisNodeSP node)
{
if (node == activeNode()) return;
// the node must still be in the graph, some asynchronous
// signals may easily break this requirement
KIS_SAFE_ASSERT_RECOVER_RETURN(!node || node->graphListener());
if (node && !node->graphListener()) {
node = 0;
}
if (node == activeNode()) return;
slotSomethingActivatedNodeImpl(node);
......
......@@ -22,8 +22,10 @@
#include "kis_painting_assistant.h"
#include "kis_coordinates_converter.h"
#include "kis_debug.h"
#include "kis_dom_utils.h"
#include <kis_canvas2.h>
#include "kis_tool.h"
#include "kis_config.h"
#include <KoStore.h>
......@@ -117,7 +119,6 @@ void KisPaintingAssistantHandle::uncache()
}
}
struct KisPaintingAssistant::Private {
QString id;
QString name;
......@@ -129,7 +130,6 @@ struct KisPaintingAssistant::Private {
KisPaintingAssistantHandleSP topLeft, bottomLeft, topRight, bottomRight, topMiddle, bottomMiddle, rightMiddle, leftMiddle;
KisCanvas2* m_canvas = 0;
struct TranslationInvariantTransform {
qreal m11, m12, m21, m22;
TranslationInvariantTransform() { }
......@@ -140,17 +140,12 @@ struct KisPaintingAssistant::Private {
} cachedTransform;
QColor assistantGlobalColor; // color to paint with if a custom color is not set
QColor assistantGlobalColorCache = QColor(Qt::red); // color to paint with if a custom color is not set
bool useCustomColor = false;
QColor assistantCustomColor;
QColor assistantCustomColor = KisConfig().defaultAssistantsColor();
};
void KisPaintingAssistant::setAssistantGlobalColor(QColor color)
{
d->assistantGlobalColor = color;
}
bool KisPaintingAssistant::useCustomColor()
{
return d->useCustomColor;
......@@ -166,14 +161,19 @@ void KisPaintingAssistant::setAssistantCustomColor(QColor color)
d->assistantCustomColor = color;
}
QColor KisPaintingAssistant::assistantsGlobalColor()
QColor KisPaintingAssistant::assistantCustomColor()
{
return d->assistantGlobalColor;
return d->assistantCustomColor;
}
QColor KisPaintingAssistant::assistantCustomColor()
void KisPaintingAssistant::setAssistantGlobalColorCache(const QColor &color)
{
return d->assistantCustomColor;
d->assistantGlobalColorCache = color;
}
QColor KisPaintingAssistant::effectiveAssistantColor() const
{
return d->useCustomColor ? d->assistantCustomColor : d->assistantGlobalColorCache;
}
KisPaintingAssistant::KisPaintingAssistant(const QString& id, const QString& name) : d(new Private)
......@@ -198,15 +198,14 @@ void KisPaintingAssistant::setSnappingActive(bool set)
void KisPaintingAssistant::drawPath(QPainter& painter, const QPainterPath &path, bool isSnappingOn)
{
QColor paintingColor = useCustomColor() ? assistantCustomColor() : d->assistantGlobalColor;
int alpha = paintingColor.alpha();
QColor paintingColor = effectiveAssistantColor();
if (!isSnappingOn) {
alpha = alpha *0.2;
paintingColor.setAlpha(0.2 * paintingColor.alpha());
}
painter.save();
QPen pen_a(QColor(paintingColor.red(), paintingColor.green(), paintingColor.blue(), alpha), 2);
QPen pen_a(paintingColor, 2);
pen_a.setCosmetic(true);
painter.setPen(pen_a);
painter.drawPath(path);
......@@ -215,10 +214,8 @@ void KisPaintingAssistant::drawPath(QPainter& painter, const QPainterPath &path,
void KisPaintingAssistant::drawPreview(QPainter& painter, const QPainterPath &path)
{
QColor paintingColor = useCustomColor() ? assistantCustomColor() : d->assistantGlobalColor;
painter.save();
QPen pen_a(paintingColor, 1);
QPen pen_a(effectiveAssistantColor(), 1);
pen_a.setStyle(Qt::SolidLine);
pen_a.setCosmetic(true);
painter.setPen(pen_a);
......@@ -284,6 +281,7 @@ void KisPaintingAssistant::addHandle(KisPaintingAssistantHandleSP handle, Handle
void KisPaintingAssistant::drawAssistant(QPainter& gc, const QRectF& updateRect, const KisCoordinatesConverter* converter, bool useCache, KisCanvas2* canvas, bool assistantVisible, bool previewVisible)
{
Q_UNUSED(updateRect);
Q_UNUSED(previewVisible);
findPerspectiveAssistantHandleLocation();
......@@ -309,7 +307,9 @@ void KisPaintingAssistant::drawAssistant(QPainter& gc, const QRectF& updateRect,
QPixmap cached;
bool found = QPixmapCache::find(d->cached, &cached);
if (!(found && d->cachedTransform == transform && d->cachedRect.translated(widgetBound.topLeft()).contains(paintRect))) {
if (!(found &&
d->cachedTransform == transform &&
d->cachedRect.translated(widgetBound.topLeft()).contains(paintRect))) {
const QRect cacheRect = gc.viewport().adjusted(-100, -100, 100, 100).intersected(widgetBound);
Q_ASSERT(!cacheRect.isEmpty());
......@@ -365,7 +365,7 @@ QByteArray KisPaintingAssistant::saveXml(QMap<KisPaintingAssistantHandleSP, int>
xml.writeAttribute("type",d->id);
xml.writeAttribute("active", QString::number(d->isSnappingActive));
xml.writeAttribute("useCustomColor", QString::number(d->useCustomColor));
xml.writeAttribute("customColor", KisPaintingAssistantsDecoration::qColorToQString(d->assistantCustomColor));
xml.writeAttribute("customColor", KisDomUtils::qColorToQString(d->assistantCustomColor));
......@@ -420,13 +420,13 @@ void KisPaintingAssistant::loadXml(KoStore* store, QMap<int, KisPaintingAssistan
usingColor = true;
}
setUseCustomColor(usingColor);
}
if ( xml.attributes().hasAttribute("customColor")) {
QStringRef customColor = xml.attributes().value("customColor");
setAssistantCustomColor( KisPaintingAssistantsDecoration::qStringToQColor(customColor.toString()) );
setAssistantCustomColor( KisDomUtils::qStringToQColor(customColor.toString()) );
}
......
......@@ -114,10 +114,7 @@ public:
void replaceHandle(KisPaintingAssistantHandleSP _handle, KisPaintingAssistantHandleSP _with);
void addHandle(KisPaintingAssistantHandleSP handle, HandleType type);
/// grabs the assistant color/opacity specified from the tool options
/// each assistant might have to use this differently, so just save a reference
void setAssistantGlobalColor(QColor color);
QColor assistantsGlobalColor();
QColor effectiveAssistantColor() const;
/// should this assistant use a custom color for the display? global color will be used if this is false
bool useCustomColor();
......@@ -127,6 +124,8 @@ public:
void setAssistantCustomColor(QColor color);
QColor assistantCustomColor();
void setAssistantGlobalColorCache(const QColor &color);
virtual void drawAssistant(QPainter& gc, const QRectF& updateRect, const KisCoordinatesConverter *converter, bool cached = true,KisCanvas2 *canvas=0, bool assistantVisible=true, bool previewVisible=true);
void uncache();
......
......@@ -42,6 +42,7 @@ struct KisPaintingAssistantsDecoration::Private {
, snapOnlyOneAssistant(true)
, firstAssistant(0)
, aFirstStroke(false)
, m_handleSize(14)
{}
bool assistantVisible;
......@@ -50,10 +51,9 @@ struct KisPaintingAssistantsDecoration::Private {
KisPaintingAssistantSP firstAssistant;
KisPaintingAssistantSP selectedAssistant;
bool aFirstStroke;
QColor m_globalAssistantsColor = QColor(176, 176, 176, 255); // kis_assistant_tool has same default color specified
bool m_isEditingAssistants = false;
bool m_outlineVisible = false;
int m_handleSize = 14; // size of editor handles on assistants
int m_handleSize; // size of editor handles on assistants
// move, visibility, delete icons for each assistant. These only display while the assistant tool is active
// these icons will be covered by the kis_paintint_assistant_decoration with things like the perspective assistant
......@@ -90,6 +90,7 @@ void KisPaintingAssistantsDecoration::addAssistant(KisPaintingAssistantSP assist
if (assistants.contains(assistant)) return;
assistants.append(assistant);
assistant->setAssistantGlobalColorCache(view()->document()->assistantsGlobalColor());
view()->document()->setAssistants(assistants);
setVisible(!assistants.isEmpty());
......@@ -206,8 +207,6 @@ void KisPaintingAssistantsDecoration::drawDecoration(QPainter& gc, const QRectF&
}
Q_FOREACH (KisPaintingAssistantSP assistant, assistants()) {
assistant->setAssistantGlobalColor(globalAssistantsColor());
assistant->drawAssistant(gc, updateRect, converter, true, canvas, assistantVisibility(), d->m_outlineVisible);
if (isEditingAssistants()) {
......@@ -227,7 +226,7 @@ void KisPaintingAssistantsDecoration::drawHandles(KisPaintingAssistantSP assista