[calligra/calligra/2.9] krita: [FEATURE] Implement MyPaint-style brush outline

Dmitry Kazakov dimula73 at gmail.com
Sun May 10 07:53:40 UTC 2015


Git commit 6b62377c3726568ca32a5f614d0bfb7f4318046e by Dmitry Kazakov.
Committed on 10/05/2015 at 07:52.
Pushed by dkazakov into branch 'calligra/2.9'.

[FEATURE] Implement MyPaint-style brush outline

This patch does two major things:

1) Implements MyPaint-style brush outline, which is simply a circle.
   It is needed when the brush tip is too complex and people do not want
   to be distracted by the details of it.

2) Configuration GUI of the brush cursor is changed. Now you can choose
   separately, which cursor and which outline you want to see in Krita.
   There is no that huge list now! :)

CC:kimageshop at kde.org

M  +9    -9    krita/gemini/MainWindow.cpp
M  +1    -1    krita/image/brushengine/kis_paintop_settings.cpp
M  +2    -1    krita/image/brushengine/kis_paintop_settings.h
M  +34   -13   krita/image/kis_global.h
M  +1    -1    krita/plugins/paintops/chalk/kis_chalk_paintop_settings.cpp
M  +1    -1    krita/plugins/paintops/deform/kis_deform_paintop_settings.cpp
M  +1    -1    krita/plugins/paintops/experiment/kis_experiment_paintop_settings.cpp
M  +1    -1    krita/plugins/paintops/gridbrush/kis_grid_paintop_settings.cpp
M  +1    -15   krita/plugins/paintops/hairy/kis_hairy_paintop_settings.cpp
M  +26   -7    krita/plugins/paintops/libpaintop/kis_brush_based_paintop_settings.cpp
M  +3    -0    krita/plugins/paintops/libpaintop/kis_brush_based_paintop_settings.h
M  +1    -1    krita/plugins/paintops/sketch/kis_sketch_paintop_settings.cpp
M  +1    -1    krita/plugins/paintops/spray/kis_spray_paintop_settings.cpp
M  +2    -2    krita/plugins/tools/defaulttools/kis_tool_brush.cc
M  +2    -1    krita/sketch/MainWindow.cpp
M  +20   -12   krita/ui/dialogs/kis_dlg_preferences.cc
M  +3    -1    krita/ui/dialogs/kis_dlg_preferences.h
M  +23   -12   krita/ui/forms/wdggeneralsettings.ui
M  +110  -6    krita/ui/kis_config.cc
M  +5    -2    krita/ui/kis_config.h
M  +6    -12   krita/ui/tool/kis_tool_freehand.cc
M  +7    -8    krita/ui/tool/kis_tool_paint.cc

http://commits.kde.org/calligra/6b62377c3726568ca32a5f614d0bfb7f4318046e

diff --git a/krita/gemini/MainWindow.cpp b/krita/gemini/MainWindow.cpp
index f8c9c19..16a8250 100644
--- a/krita/gemini/MainWindow.cpp
+++ b/krita/gemini/MainWindow.cpp
@@ -94,7 +94,7 @@ public:
         , sketchView(0)
         , desktopWindow(0)
         , currentView(0)
-        , desktopCursorStyle(CURSOR_STYLE_OUTLINE)
+        , desktopCursorStyle(CURSOR_STYLE_NO_CURSOR)
         , slateMode(false)
         , docked(false)
         , sketchKisView(0)
@@ -123,7 +123,7 @@ public:
     SketchDeclarativeView* sketchView;
     KisMainWindow* desktopWindow;
     QObject* currentView;
-    enumCursorStyle desktopCursorStyle;
+    CursorStyle desktopCursorStyle;
 
     bool slateMode;
     bool docked;
@@ -256,9 +256,9 @@ MainWindow::MainWindow(QStringList fileNames, QWidget* parent, Qt::WindowFlags f
     KisConfig cfg;
     // Store the current setting before we do "things", and heuristic our way to a reasonable
     // default if it's no cursor (that's most likely due to a broken config)
-    if (cfg.cursorStyle() != CURSOR_STYLE_NO_CURSOR)
-        d->desktopCursorStyle = cfg.cursorStyle();
-    cfg.setCursorStyle(CURSOR_STYLE_NO_CURSOR);
+    if (cfg.newCursorStyle() != CURSOR_STYLE_NO_CURSOR)
+        d->desktopCursorStyle = cfg.newCursorStyle();
+    cfg.setNewCursorStyle(CURSOR_STYLE_NO_CURSOR);
     cfg.setUseOpenGL(true);
 
     foreach(QString fileName, fileNames) {
@@ -325,7 +325,7 @@ void MainWindow::switchToSketch()
 
     KisConfig cfg;
     if (d->desktopWindow && centralWidget() == d->desktopWindow) {
-        d->desktopCursorStyle = cfg.cursorStyle();
+        d->desktopCursorStyle = cfg.newCursorStyle();
         view = qobject_cast<KisViewManager*>(d->desktopWindow->activeView());
 
         //Notify the view we are switching away from that we are about to switch away from it
@@ -372,7 +372,7 @@ void MainWindow::sketchChange()
         d->syncObject = 0;
         qApp->processEvents();
         KisConfig cfg;
-        cfg.setCursorStyle(CURSOR_STYLE_NO_CURSOR);
+        cfg.setNewCursorStyle(CURSOR_STYLE_NO_CURSOR);
         emit switchedToSketch();
     }
     if (d->toDesktop)
@@ -416,7 +416,7 @@ void MainWindow::switchToDesktop(bool justLoaded)
         ViewModeSwitchEvent switchedEvent(ViewModeSwitchEvent::SwitchedToDesktopModeEvent, d->sketchView, view, syncObject);
         QApplication::sendEvent(view, &switchedEvent);
         KisConfig cfg;
-        cfg.setCursorStyle(d->desktopCursorStyle);
+        cfg.setNewCursorStyle(d->desktopCursorStyle);
     }
 
     if (d->toSketch && !justLoaded)
@@ -709,7 +709,7 @@ MainWindow::~MainWindow()
 {
     delete d;
     KisConfig cfg;
-    cfg.setCursorStyle(d->desktopCursorStyle);
+    cfg.setNewCursorStyle(d->desktopCursorStyle);
 }
 
 #ifdef Q_OS_WIN
diff --git a/krita/image/brushengine/kis_paintop_settings.cpp b/krita/image/brushengine/kis_paintop_settings.cpp
index 5bdcf7f..9a912c5 100644
--- a/krita/image/brushengine/kis_paintop_settings.cpp
+++ b/krita/image/brushengine/kis_paintop_settings.cpp
@@ -228,7 +228,7 @@ QString KisPaintOpSettings::indirectPaintingCompositeOp() const
 QPainterPath KisPaintOpSettings::brushOutline(const KisPaintInformation &info, OutlineMode mode) const
 {
     QPainterPath path;
-    if (mode == CursorIsOutline) {
+    if (mode == CursorIsOutline || mode == CursorIsCircleOutline) {
         path = ellipseOutline(10, 10, 1.0, 0).translated(info.pos());
     }
 
diff --git a/krita/image/brushengine/kis_paintop_settings.h b/krita/image/brushengine/kis_paintop_settings.h
index eb05d0f..2e57b80 100644
--- a/krita/image/brushengine/kis_paintop_settings.h
+++ b/krita/image/brushengine/kis_paintop_settings.h
@@ -128,7 +128,8 @@ public:
      */
     enum OutlineMode {
         CursorIsOutline = 1, ///< When this mode is set, an outline is painted around the cursor
-        CursorIsNotOutline = 2 ///< Currently, this mode means that there is no outline active. It used to mean using of QImage-based outlines (e.g. for clone tool) but it was not implemented.
+        CursorIsCircleOutline,
+        CursorNoOutline
     };
 
     /**
diff --git a/krita/image/kis_global.h b/krita/image/kis_global.h
index 3004ad8..ec75eae 100644
--- a/krita/image/kis_global.h
+++ b/krita/image/kis_global.h
@@ -41,19 +41,40 @@ const quint8 MAX_SELECTED = UCHAR_MAX;
 const quint8 MIN_SELECTED = 0;
 const quint8 SELECTION_THRESHOLD = 1;
 
-enum enumCursorStyle {
-    CURSOR_STYLE_TOOLICON = 0,
-    CURSOR_STYLE_CROSSHAIR = 1,
-    CURSOR_STYLE_POINTER = 2,
-    CURSOR_STYLE_OUTLINE = 3,
-    CURSOR_STYLE_NO_CURSOR = 4,
-    CURSOR_STYLE_SMALL_ROUND = 5,
-    CURSOR_STYLE_OUTLINE_CENTER_DOT = 6,
-    CURSOR_STYLE_OUTLINE_CENTER_CROSS = 7,
-    CURSOR_STYLE_TRIANGLE_RIGHTHANDED = 8,
-    CURSOR_STYLE_TRIANGLE_LEFTHANDED = 9,
-    CURSOR_STYLE_OUTLINE_TRIANGLE_RIGHTHANDED = 10,
-    CURSOR_STYLE_OUTLINE_TRIANGLE_LEFTHANDED = 11
+enum OutlineStyle {
+    OUTLINE_NONE = 0,
+    OUTLINE_CIRCLE,
+    OUTLINE_FULL
+};
+
+enum CursorStyle {
+    CURSOR_STYLE_NO_CURSOR = 0,
+    CURSOR_STYLE_TOOLICON,
+    CURSOR_STYLE_POINTER,
+    CURSOR_STYLE_SMALL_ROUND,
+    CURSOR_STYLE_CROSSHAIR,
+    CURSOR_STYLE_TRIANGLE_RIGHTHANDED,
+    CURSOR_STYLE_TRIANGLE_LEFTHANDED
+};
+
+enum OldCursorStyle {
+    OLD_CURSOR_STYLE_TOOLICON = 0,
+    OLD_CURSOR_STYLE_CROSSHAIR = 1,
+    OLD_CURSOR_STYLE_POINTER = 2,
+
+    OLD_CURSOR_STYLE_OUTLINE = 3,
+
+    OLD_CURSOR_STYLE_NO_CURSOR = 4,
+    OLD_CURSOR_STYLE_SMALL_ROUND = 5,
+
+    OLD_CURSOR_STYLE_OUTLINE_CENTER_DOT = 6,
+    OLD_CURSOR_STYLE_OUTLINE_CENTER_CROSS = 7,
+
+    OLD_CURSOR_STYLE_TRIANGLE_RIGHTHANDED = 8,
+    OLD_CURSOR_STYLE_TRIANGLE_LEFTHANDED = 9,
+
+    OLD_CURSOR_STYLE_OUTLINE_TRIANGLE_RIGHTHANDED = 10,
+    OLD_CURSOR_STYLE_OUTLINE_TRIANGLE_LEFTHANDED = 11
 };
 
 /*
diff --git a/krita/plugins/paintops/chalk/kis_chalk_paintop_settings.cpp b/krita/plugins/paintops/chalk/kis_chalk_paintop_settings.cpp
index f9d5844..2feac99 100644
--- a/krita/plugins/paintops/chalk/kis_chalk_paintop_settings.cpp
+++ b/krita/plugins/paintops/chalk/kis_chalk_paintop_settings.cpp
@@ -45,7 +45,7 @@ int KisChalkPaintOpSettings::rate() const
 QPainterPath KisChalkPaintOpSettings::brushOutline(const KisPaintInformation &info, OutlineMode mode) const
 {
     QPainterPath path;
-    if (mode == CursorIsOutline) {
+    if (mode == CursorIsOutline || mode == CursorIsCircleOutline) {
         qreal size = getInt(CHALK_RADIUS) * 2 + 1;
         path = ellipseOutline(size, size, 1.0, 0.0);
         path.translate(info.pos());
diff --git a/krita/plugins/paintops/deform/kis_deform_paintop_settings.cpp b/krita/plugins/paintops/deform/kis_deform_paintop_settings.cpp
index 193edf7..3657a64 100644
--- a/krita/plugins/paintops/deform/kis_deform_paintop_settings.cpp
+++ b/krita/plugins/paintops/deform/kis_deform_paintop_settings.cpp
@@ -59,7 +59,7 @@ int KisDeformPaintOpSettings::rate() const
 QPainterPath KisDeformPaintOpSettings::brushOutline(const KisPaintInformation &info, OutlineMode mode) const
 {
     QPainterPath path;
-    if (mode == CursorIsOutline) {
+    if (mode == CursorIsOutline || mode == CursorIsCircleOutline) {
         qreal width = getInt(BRUSH_DIAMETER);
         qreal height = getInt(BRUSH_DIAMETER) * getDouble(BRUSH_ASPECT);
         path = ellipseOutline(width, height, getDouble(BRUSH_SCALE), getDouble(BRUSH_ROTATION));
diff --git a/krita/plugins/paintops/experiment/kis_experiment_paintop_settings.cpp b/krita/plugins/paintops/experiment/kis_experiment_paintop_settings.cpp
index 812fe20..2b6f308 100644
--- a/krita/plugins/paintops/experiment/kis_experiment_paintop_settings.cpp
+++ b/krita/plugins/paintops/experiment/kis_experiment_paintop_settings.cpp
@@ -31,7 +31,7 @@ bool KisExperimentPaintOpSettings::paintIncremental()
 QPainterPath KisExperimentPaintOpSettings::brushOutline(const KisPaintInformation &info, KisPaintOpSettings::OutlineMode mode) const
 {
     QPainterPath path;
-    if (mode == CursorIsOutline) {
+    if (mode == CursorIsOutline || mode == CursorIsCircleOutline) {
 
         QRectF ellipse(0, 0, 3, 3);
         ellipse.translate(-ellipse.center());
diff --git a/krita/plugins/paintops/gridbrush/kis_grid_paintop_settings.cpp b/krita/plugins/paintops/gridbrush/kis_grid_paintop_settings.cpp
index 85e3cb2..04190da 100644
--- a/krita/plugins/paintops/gridbrush/kis_grid_paintop_settings.cpp
+++ b/krita/plugins/paintops/gridbrush/kis_grid_paintop_settings.cpp
@@ -38,7 +38,7 @@ bool KisGridPaintOpSettings::paintIncremental()
 QPainterPath KisGridPaintOpSettings::brushOutline(const KisPaintInformation &info, OutlineMode mode) const
 {
     QPainterPath path;
-    if (mode == CursorIsOutline) {
+    if (mode == CursorIsOutline || mode == CursorIsCircleOutline) {
         qreal sizex = getInt(GRID_WIDTH) * getDouble(GRID_SCALE);
         qreal sizey = getInt(GRID_HEIGHT) * getDouble(GRID_SCALE);
         QRectF rc(0, 0, sizex, sizey);
diff --git a/krita/plugins/paintops/hairy/kis_hairy_paintop_settings.cpp b/krita/plugins/paintops/hairy/kis_hairy_paintop_settings.cpp
index 0ca2069..c216fc1 100644
--- a/krita/plugins/paintops/hairy/kis_hairy_paintop_settings.cpp
+++ b/krita/plugins/paintops/hairy/kis_hairy_paintop_settings.cpp
@@ -36,21 +36,7 @@ KisHairyPaintOpSettings::KisHairyPaintOpSettings()
 
 QPainterPath KisHairyPaintOpSettings::brushOutline(const KisPaintInformation &info, OutlineMode mode) const
 {
-    QPainterPath path;
-    if (mode == CursorIsOutline) {
-        KisBrushBasedPaintopOptionWidget *widget = dynamic_cast<KisBrushBasedPaintopOptionWidget*>(optionsWidget());
-
-        if (!widget) {
-            return KisPaintOpSettings::brushOutline(info, mode);
-        }
-
-        KisBrushSP brush = widget->brush();
-
-        qreal additionalScale = brush->scale() * getDouble(HAIRY_BRISTLE_SCALE);
-
-        return outlineFetcher()->fetchOutline(info, this, brush->outline(), additionalScale, brush->angle());
-    }
-    return path;
+    return brushOutlineImpl(info, mode, getDouble(HAIRY_BRISTLE_SCALE));
 }
 
 void KisHairyPaintOpSettings::fromXML(const QDomElement& elt)
diff --git a/krita/plugins/paintops/libpaintop/kis_brush_based_paintop_settings.cpp b/krita/plugins/paintops/libpaintop/kis_brush_based_paintop_settings.cpp
index 4e74af3..fc19c0e 100644
--- a/krita/plugins/paintops/libpaintop/kis_brush_based_paintop_settings.cpp
+++ b/krita/plugins/paintops/libpaintop/kis_brush_based_paintop_settings.cpp
@@ -51,19 +51,38 @@ int KisBrushBasedPaintOpSettings::rate() const
     return getInt(AIRBRUSH_RATE);
 }
 
-QPainterPath KisBrushBasedPaintOpSettings::brushOutline(const KisPaintInformation &info, OutlineMode mode) const
+QPainterPath KisBrushBasedPaintOpSettings::brushOutlineImpl(const KisPaintInformation &info, OutlineMode mode, qreal additionalScale) const
 {
-    if (mode != CursorIsOutline) return QPainterPath();
+    QPainterPath path;
+
+    if (mode == CursorIsOutline || mode == CursorIsCircleOutline) {
+        KisBrushBasedPaintopOptionWidget *widget = dynamic_cast<KisBrushBasedPaintopOptionWidget*>(optionsWidget());
+
+        if (!widget) {
+            return KisPaintOpSettings::brushOutline(info, mode);
+        }
+
+
+        KisBrushSP brush = widget->brush();
+        qreal finalScale = brush->scale() * additionalScale;
 
-    KisBrushBasedPaintopOptionWidget *widget = dynamic_cast<KisBrushBasedPaintopOptionWidget*>(optionsWidget());
+        QPainterPath realOutline = brush->outline();
 
-    if (!widget) {
-        return KisPaintOpSettings::brushOutline(info, mode);
+        if (mode == CursorIsCircleOutline) {
+            QPainterPath ellipse;
+            ellipse.addEllipse(realOutline.boundingRect());
+            realOutline = ellipse;
+        }
+
+        path = outlineFetcher()->fetchOutline(info, this, realOutline, finalScale, brush->angle());
     }
 
-    KisBrushSP brush = widget->brush();
+    return path;
+}
 
-    return outlineFetcher()->fetchOutline(info, this, brush->outline(), brush->scale(), brush->angle());
+QPainterPath KisBrushBasedPaintOpSettings::brushOutline(const KisPaintInformation &info, OutlineMode mode) const
+{
+    return brushOutlineImpl(info, mode, 1.0);
 }
 
 bool KisBrushBasedPaintOpSettings::isValid() const
diff --git a/krita/plugins/paintops/libpaintop/kis_brush_based_paintop_settings.h b/krita/plugins/paintops/libpaintop/kis_brush_based_paintop_settings.h
index 1cb320b..28551e1 100644
--- a/krita/plugins/paintops/libpaintop/kis_brush_based_paintop_settings.h
+++ b/krita/plugins/paintops/libpaintop/kis_brush_based_paintop_settings.h
@@ -46,6 +46,9 @@ public:
 
     ///Reimplemented
     virtual bool isLoadable();
+
+protected:
+    QPainterPath brushOutlineImpl(const KisPaintInformation &info, OutlineMode mode, qreal additionalScale) const;
 };
 
 #endif // KIS_BRUSH_BASED_PAINTOP_SETTINGS_H
diff --git a/krita/plugins/paintops/sketch/kis_sketch_paintop_settings.cpp b/krita/plugins/paintops/sketch/kis_sketch_paintop_settings.cpp
index aae19f3..cff9652 100644
--- a/krita/plugins/paintops/sketch/kis_sketch_paintop_settings.cpp
+++ b/krita/plugins/paintops/sketch/kis_sketch_paintop_settings.cpp
@@ -55,7 +55,7 @@ QPainterPath KisSketchPaintOpSettings::brushOutline(const KisPaintInformation &i
     KisBrushBasedPaintopOptionWidget *widget = dynamic_cast<KisBrushBasedPaintopOptionWidget*>(optionsWidget());
     QPainterPath path;
 
-    if (widget && mode == CursorIsOutline) {
+    if (widget && (mode == CursorIsOutline || mode == CursorIsCircleOutline)) {
         KisBrushSP brush = widget->brush();
         // just circle supported
         qreal diameter = qMax(brush->width(), brush->height());
diff --git a/krita/plugins/paintops/spray/kis_spray_paintop_settings.cpp b/krita/plugins/paintops/spray/kis_spray_paintop_settings.cpp
index 4594af6..abd87cc 100644
--- a/krita/plugins/paintops/spray/kis_spray_paintop_settings.cpp
+++ b/krita/plugins/paintops/spray/kis_spray_paintop_settings.cpp
@@ -51,7 +51,7 @@ int KisSprayPaintOpSettings::rate() const
 QPainterPath KisSprayPaintOpSettings::brushOutline(const KisPaintInformation &info, OutlineMode mode) const
 {
     QPainterPath path;
-    if (mode == CursorIsOutline) {
+    if (mode == CursorIsOutline || mode == CursorIsCircleOutline) {
         qreal width = getInt(SPRAY_DIAMETER);
         qreal height = getInt(SPRAY_DIAMETER) * getDouble(SPRAY_ASPECT);
         path = ellipseOutline(width, height, getDouble(SPRAY_SCALE), getDouble(SPRAY_ROTATION));
diff --git a/krita/plugins/tools/defaulttools/kis_tool_brush.cc b/krita/plugins/tools/defaulttools/kis_tool_brush.cc
index 5aecbe5..ac6ef8b 100644
--- a/krita/plugins/tools/defaulttools/kis_tool_brush.cc
+++ b/krita/plugins/tools/defaulttools/kis_tool_brush.cc
@@ -215,13 +215,13 @@ void KisToolBrush::setUseScalableDistance(bool value)
 void KisToolBrush::resetCursorStyle()
 {
     KisConfig cfg;
-    enumCursorStyle cursorStyle = cfg.cursorStyle();
+    CursorStyle cursorStyle = cfg.newCursorStyle();
 
     // When the stabilizer is in use, we avoid using the brush outline cursor,
     // because it would hide the real position of the cursor to the user,
     // yielding unexpected results.
     if (smoothingOptions()->smoothingType() == KisSmoothingOptions::STABILIZER
-        && cursorStyle == CURSOR_STYLE_OUTLINE) {
+        && cursorStyle != CURSOR_STYLE_NO_CURSOR) {
         useCursor(KisCursor::roundCursor());
     } else {
         KisToolFreehand::resetCursorStyle();
diff --git a/krita/sketch/MainWindow.cpp b/krita/sketch/MainWindow.cpp
index a4c31c1..89f8b68 100644
--- a/krita/sketch/MainWindow.cpp
+++ b/krita/sketch/MainWindow.cpp
@@ -90,7 +90,8 @@ MainWindow::MainWindow(QStringList fileNames, QWidget* parent, Qt::WindowFlags f
     Q_UNUSED(KisPaintOpRegistry::instance());
 
     KisConfig cfg;
-    cfg.setCursorStyle(CURSOR_STYLE_NO_CURSOR);
+    cfg.setNewCursorStyle(CURSOR_STYLE_NO_CURSOR);
+    cfg.setNewOutlineStyle(OUTLINE_NONE);
     cfg.setUseOpenGL(true);
 
     foreach(QString fileName, fileNames) {
diff --git a/krita/ui/dialogs/kis_dlg_preferences.cc b/krita/ui/dialogs/kis_dlg_preferences.cc
index df1122d..314f093 100644
--- a/krita/ui/dialogs/kis_dlg_preferences.cc
+++ b/krita/ui/dialogs/kis_dlg_preferences.cc
@@ -84,20 +84,21 @@ GeneralTab::GeneralTab(QWidget *_parent, const char *_name)
 {
     KisConfig cfg;
 
+    m_cmbCursorShape->addItem(i18n("No Cursor"));
     m_cmbCursorShape->addItem(i18n("Tool Icon"));
-    m_cmbCursorShape->addItem(i18n("Crosshair"));
     m_cmbCursorShape->addItem(i18n("Arrow"));
-    m_cmbCursorShape->addItem(i18n("Brush Outline"));
-    m_cmbCursorShape->addItem(i18n("No Cursor"));
     m_cmbCursorShape->addItem(i18n("Small Circle"));
-    m_cmbCursorShape->addItem(i18n("Brush Outline with Small Circle"));
-    m_cmbCursorShape->addItem(i18n("Brush Outline with Crosshair"));
+    m_cmbCursorShape->addItem(i18n("Crosshair"));
     m_cmbCursorShape->addItem(i18n("Triangle Righthanded"));
     m_cmbCursorShape->addItem(i18n("Triangle Lefthanded"));
-    m_cmbCursorShape->addItem(i18n("Brush Outline with Triangle Righthanded"));
-    m_cmbCursorShape->addItem(i18n("Brush Outline with Triangle Lefthanded"));
 
-    m_cmbCursorShape->setCurrentIndex(cfg.cursorStyle());
+    m_cmbOutlineShape->addItem(i18n("No Outline"));
+    m_cmbOutlineShape->addItem(i18n("Circle Outline"));
+    m_cmbOutlineShape->addItem(i18n("Preview Outline"));
+
+    m_cmbCursorShape->setCurrentIndex(cfg.newCursorStyle());
+    m_cmbOutlineShape->setCurrentIndex(cfg.newOutlineStyle());
+
     chkShowRootLayer->setChecked(cfg.showRootLayer());
 
     int autosaveInterval = cfg.autoSaveInterval();
@@ -124,7 +125,8 @@ void GeneralTab::setDefault()
 {
     KisConfig cfg;
 
-    m_cmbCursorShape->setCurrentIndex(cfg.cursorStyle(true));
+    m_cmbCursorShape->setCurrentIndex(cfg.newCursorStyle(true));
+    m_cmbOutlineShape->setCurrentIndex(cfg.newOutlineStyle(true));
     chkShowRootLayer->setChecked(cfg.showRootLayer(true));
     m_autosaveCheckBox->setChecked(cfg.autoSaveInterval(true) > 0);
     //convert to minutes
@@ -142,9 +144,14 @@ void GeneralTab::setDefault()
     m_chkCompressKra->setChecked(cfg.compressKra(true));
 }
 
-enumCursorStyle GeneralTab::cursorStyle()
+CursorStyle GeneralTab::cursorStyle()
+{
+    return (CursorStyle)m_cmbCursorShape->currentIndex();
+}
+
+OutlineStyle GeneralTab::outlineStyle()
 {
-    return (enumCursorStyle)m_cmbCursorShape->currentIndex();
+    return (OutlineStyle)m_cmbOutlineShape->currentIndex();
 }
 
 bool GeneralTab::showRootLayer()
@@ -856,7 +863,8 @@ bool KisDlgPreferences::editPreferences()
     if (baccept) {
         // General settings
         KisConfig cfg;
-        cfg.setCursorStyle(dialog->m_general->cursorStyle());
+        cfg.setNewCursorStyle(dialog->m_general->cursorStyle());
+        cfg.setNewOutlineStyle(dialog->m_general->outlineStyle());
         cfg.setShowRootLayer(dialog->m_general->showRootLayer());
         cfg.setShowOutlineWhilePainting(dialog->m_general->showOutlineWhilePainting());
         cfg.setHideSplashScreen(dialog->m_general->hideSplashScreen());
diff --git a/krita/ui/dialogs/kis_dlg_preferences.h b/krita/ui/dialogs/kis_dlg_preferences.h
index 14bc1d9..7070545 100644
--- a/krita/ui/dialogs/kis_dlg_preferences.h
+++ b/krita/ui/dialogs/kis_dlg_preferences.h
@@ -63,7 +63,9 @@ public:
 
     GeneralTab(QWidget *parent = 0, const char *name = 0);
 
-    enumCursorStyle cursorStyle();
+    CursorStyle cursorStyle();
+    OutlineStyle outlineStyle();
+
     bool showRootLayer();
     int autoSaveInterval();
     void setDefault();
diff --git a/krita/ui/forms/wdggeneralsettings.ui b/krita/ui/forms/wdggeneralsettings.ui
index 062bfef..76ee18c 100644
--- a/krita/ui/forms/wdggeneralsettings.ui
+++ b/krita/ui/forms/wdggeneralsettings.ui
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>606</width>
-    <height>520</height>
+    <height>577</height>
    </rect>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout">
@@ -39,13 +39,32 @@
       <item row="0" column="1">
        <widget class="QComboBox" name="m_cmbCursorShape"/>
       </item>
-      <item row="1" column="1">
+      <item row="2" column="1">
        <widget class="QCheckBox" name="m_showOutlinePainting">
         <property name="text">
          <string>Show brush outline while painting</string>
         </property>
        </widget>
       </item>
+      <item row="1" column="1">
+       <widget class="QComboBox" name="m_cmbOutlineShape"/>
+      </item>
+      <item row="1" column="0">
+       <widget class="QLabel" name="textLabel1_2">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string>Outline shape:</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+        </property>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>
@@ -139,14 +158,14 @@
           <property name="text">
            <string/>
           </property>
-          <property name="color">
+          <property name="color" stdset="0">
            <color>
             <red>0</red>
             <green>0</green>
             <blue>0</blue>
            </color>
           </property>
-          <property name="defaultColor">
+          <property name="defaultColor" stdset="0">
            <color>
             <red>0</red>
             <green>0</green>
@@ -179,11 +198,7 @@
        </layout>
       </item>
      </layout>
-     <zorder>m_cmbMDIType</zorder>
-     <zorder>label_2</zorder>
-     <zorder>label_5</zorder>
      <zorder></zorder>
-     <zorder>m_backgroundimage</zorder>
     </widget>
    </item>
    <item>
@@ -333,10 +348,6 @@
     </spacer>
    </item>
   </layout>
-  <zorder>groupBox</zorder>
-  <zorder>groupBox_2</zorder>
-  <zorder>label_2</zorder>
-  <zorder>groupBox_3</zorder>
  </widget>
  <customwidgets>
   <customwidget>
diff --git a/krita/ui/kis_config.cc b/krita/ui/kis_config.cc
index 3617a05..55771bd 100644
--- a/krita/ui/kis_config.cc
+++ b/krita/ui/kis_config.cc
@@ -206,16 +206,120 @@ void KisConfig::defImageResolution(double res) const
     m_cfg.writeEntry("imageResolutionDef", res*72.0);
 }
 
-enumCursorStyle KisConfig::cursorStyle(bool defaultValue) const
+void cleanOldCursorStyleKeys(KConfigGroup &cfg)
 {
-    return (enumCursorStyle) (defaultValue ?
-                CURSOR_STYLE_OUTLINE :
-                m_cfg.readEntry("cursorStyleDef", int(CURSOR_STYLE_OUTLINE)));
+    if (cfg.hasKey("newCursorStyle") &&
+        cfg.hasKey("newOutlineStyle")) {
+
+        cfg.deleteEntry("cursorStyleDef");
+    }
+}
+
+CursorStyle KisConfig::newCursorStyle(bool defaultValue) const
+{
+    if (defaultValue) {
+        return CURSOR_STYLE_NO_CURSOR;
+    }
+
+
+    int style = m_cfg.readEntry("newCursorStyle", int(-1));
+
+    if (style < 0) {
+        // old style format
+        style = m_cfg.readEntry("cursorStyleDef", int(OLD_CURSOR_STYLE_OUTLINE));
+
+        switch (style) {
+        case OLD_CURSOR_STYLE_TOOLICON:
+            style = CURSOR_STYLE_TOOLICON;
+            break;
+        case OLD_CURSOR_STYLE_CROSSHAIR:
+        case OLD_CURSOR_STYLE_OUTLINE_CENTER_CROSS:
+            style = CURSOR_STYLE_CROSSHAIR;
+            break;
+        case OLD_CURSOR_STYLE_POINTER:
+            style = CURSOR_STYLE_POINTER;
+            break;
+        case OLD_CURSOR_STYLE_OUTLINE:
+        case OLD_CURSOR_STYLE_NO_CURSOR:
+            style = CURSOR_STYLE_NO_CURSOR;
+            break;
+        case OLD_CURSOR_STYLE_SMALL_ROUND:
+        case OLD_CURSOR_STYLE_OUTLINE_CENTER_DOT:
+            style = CURSOR_STYLE_SMALL_ROUND;
+            break;
+        case OLD_CURSOR_STYLE_TRIANGLE_RIGHTHANDED:
+        case OLD_CURSOR_STYLE_OUTLINE_TRIANGLE_RIGHTHANDED:
+            style = CURSOR_STYLE_TRIANGLE_RIGHTHANDED;
+            break;
+        case OLD_CURSOR_STYLE_TRIANGLE_LEFTHANDED:
+        case OLD_CURSOR_STYLE_OUTLINE_TRIANGLE_LEFTHANDED:
+            style = CURSOR_STYLE_TRIANGLE_LEFTHANDED;
+            break;
+        default:
+            style = -1;
+        }
+    }
+
+    cleanOldCursorStyleKeys(m_cfg);
+
+    if (style < 0) {
+        style = CURSOR_STYLE_NO_CURSOR;
+    }
+
+    return (CursorStyle) style;
+}
+
+void KisConfig::setNewCursorStyle(CursorStyle style)
+{
+    m_cfg.writeEntry("newCursorStyle", (int)style);
+}
+
+OutlineStyle KisConfig::newOutlineStyle(bool defaultValue) const
+{
+    if (defaultValue) {
+        return OUTLINE_FULL;
+    }
+
+    int style = m_cfg.readEntry("newOutlineStyle", int(-1));
+
+    if (style < 0) {
+        // old style format
+        style = m_cfg.readEntry("cursorStyleDef", int(OLD_CURSOR_STYLE_OUTLINE));
+
+        switch (style) {
+        case OLD_CURSOR_STYLE_TOOLICON:
+        case OLD_CURSOR_STYLE_CROSSHAIR:
+        case OLD_CURSOR_STYLE_POINTER:
+        case OLD_CURSOR_STYLE_NO_CURSOR:
+        case OLD_CURSOR_STYLE_SMALL_ROUND:
+        case OLD_CURSOR_STYLE_TRIANGLE_RIGHTHANDED:
+        case OLD_CURSOR_STYLE_TRIANGLE_LEFTHANDED:
+            style = OUTLINE_NONE;
+            break;
+        case OLD_CURSOR_STYLE_OUTLINE:
+        case OLD_CURSOR_STYLE_OUTLINE_CENTER_DOT:
+        case OLD_CURSOR_STYLE_OUTLINE_CENTER_CROSS:
+        case OLD_CURSOR_STYLE_OUTLINE_TRIANGLE_RIGHTHANDED:
+        case OLD_CURSOR_STYLE_OUTLINE_TRIANGLE_LEFTHANDED:
+            style = OUTLINE_FULL;
+            break;
+        default:
+            style = -1;
+        }
+    }
+
+    cleanOldCursorStyleKeys(m_cfg);
+
+    if (style < 0) {
+        style = OUTLINE_FULL;
+    }
+
+    return (OutlineStyle) style;
 }
 
-void KisConfig::setCursorStyle(enumCursorStyle style) const
+void KisConfig::setNewOutlineStyle(OutlineStyle style)
 {
-    m_cfg.writeEntry("cursorStyleDef", (int)style);
+    m_cfg.writeEntry("newOutlineStyle", (int)style);
 }
 
 bool KisConfig::useDirtyPresets(bool defaultValue) const
diff --git a/krita/ui/kis_config.h b/krita/ui/kis_config.h
index e7c72f2..f68f881 100644
--- a/krita/ui/kis_config.h
+++ b/krita/ui/kis_config.h
@@ -99,8 +99,11 @@ public:
      */
     void defColorProfile(const QString & depth) const;
 
-    enumCursorStyle cursorStyle(bool defaultCursorStyle = false) const;
-    void setCursorStyle(enumCursorStyle style) const;
+    CursorStyle newCursorStyle(bool defaultValue = false) const;
+    void setNewCursorStyle(CursorStyle style);
+
+    OutlineStyle newOutlineStyle(bool defaultValue = false) const;
+    void setNewOutlineStyle(OutlineStyle style);
 
     /// get the profile the user has selected for the given screen
     QString monitorProfile(int screen) const;
diff --git a/krita/ui/tool/kis_tool_freehand.cc b/krita/ui/tool/kis_tool_freehand.cc
index f2c32f2..7b2bacf 100644
--- a/krita/ui/tool/kis_tool_freehand.cc
+++ b/krita/ui/tool/kis_tool_freehand.cc
@@ -89,35 +89,29 @@ void KisToolFreehand::resetCursorStyle()
 {
     KisConfig cfg;
 
-    switch (cfg.cursorStyle()) {
-    case CURSOR_STYLE_CROSSHAIR:
-    case CURSOR_STYLE_OUTLINE_CENTER_CROSS:
-        useCursor(KisCursor::crossCursor());
+    switch (cfg.newCursorStyle()) {
+    case CURSOR_STYLE_NO_CURSOR:
+        useCursor(KisCursor::blankCursor());
         break;
     case CURSOR_STYLE_POINTER:
         useCursor(KisCursor::arrowCursor());
         break;
-    case CURSOR_STYLE_NO_CURSOR:
-        useCursor(KisCursor::blankCursor());
-        break;
     case CURSOR_STYLE_SMALL_ROUND:
-    case CURSOR_STYLE_OUTLINE_CENTER_DOT:
         useCursor(KisCursor::roundCursor());
         break;
-    case CURSOR_STYLE_OUTLINE:
-        useCursor(KisCursor::blankCursor());
+    case CURSOR_STYLE_CROSSHAIR:
+        useCursor(KisCursor::crossCursor());
         break;
     case CURSOR_STYLE_TRIANGLE_RIGHTHANDED:
-    case CURSOR_STYLE_OUTLINE_TRIANGLE_RIGHTHANDED:
         useCursor(KisCursor::triangleRightHandedCursor());
         break;
     case CURSOR_STYLE_TRIANGLE_LEFTHANDED:
-    case CURSOR_STYLE_OUTLINE_TRIANGLE_LEFTHANDED:
         useCursor(KisCursor::triangleLeftHandedCursor());
         break;
     case CURSOR_STYLE_TOOLICON:
     default:
         KisToolPaint::resetCursorStyle();
+        break;
     }
 }
 
diff --git a/krita/ui/tool/kis_tool_paint.cc b/krita/ui/tool/kis_tool_paint.cc
index c836742..00aa2a1 100644
--- a/krita/ui/tool/kis_tool_paint.cc
+++ b/krita/ui/tool/kis_tool_paint.cc
@@ -167,7 +167,7 @@ void KisToolPaint::deactivate()
 QPainterPath KisToolPaint::tryFixBrushOutline(const QPainterPath &originalOutline)
 {
     KisConfig cfg;
-    if (cfg.cursorStyle() != CURSOR_STYLE_OUTLINE) return originalOutline;
+    if (cfg.newOutlineStyle() == OUTLINE_NONE) return originalOutline;
 
     const qreal minThresholdSize = cfg.outlineSizeMinimum();
 
@@ -555,19 +555,18 @@ void KisToolPaint::requestUpdateOutline(const QPointF &outlineDocPoint, const Ko
 
     KisConfig cfg;
     KisPaintOpSettings::OutlineMode outlineMode;
-    outlineMode = KisPaintOpSettings::CursorIsNotOutline;
+    outlineMode = KisPaintOpSettings::CursorNoOutline;
 
     if (isOutlineEnabled() &&
         (mode() == KisTool::GESTURE_MODE ||
-         ((cfg.cursorStyle() == CURSOR_STYLE_OUTLINE ||
-           cfg.cursorStyle() == CURSOR_STYLE_OUTLINE_CENTER_DOT ||
-           cfg.cursorStyle() == CURSOR_STYLE_OUTLINE_CENTER_CROSS ||
-           cfg.cursorStyle() == CURSOR_STYLE_OUTLINE_TRIANGLE_RIGHTHANDED ||
-           cfg.cursorStyle() == CURSOR_STYLE_OUTLINE_TRIANGLE_LEFTHANDED)&&
+         ((cfg.newOutlineStyle() == OUTLINE_FULL ||
+           cfg.newOutlineStyle() == OUTLINE_CIRCLE) &&
           ((mode() == HOVER_MODE) ||
            (mode() == PAINT_MODE && cfg.showOutlineWhilePainting()))))) { // lisp forever!
 
-        outlineMode = KisPaintOpSettings::CursorIsOutline;
+        outlineMode = cfg.newOutlineStyle() == OUTLINE_CIRCLE ?
+            KisPaintOpSettings::CursorIsCircleOutline :
+            KisPaintOpSettings::CursorIsOutline;
     }
 
     m_outlineDocPoint = outlineDocPoint;



More information about the kimageshop mailing list