[calligra] krita: Set the default projection color to the selected color

Wolthera griffinvalley at gmail.com
Sat Nov 8 15:03:44 UTC 2014


Okay, so I tested this.

In principle this works just fine. If you want transparent, just set the
background colour to transparent instead of opaque in the new file menu.

However, changing projection color is still buggy: Going from white to
another colour is no problem, but going from white to transparent, accept,
and then trying to go from transparent to white doesn't work. It seems to
apply this colour to the LAYER instead of the background, and only to tiles
that carry no information(leading to alpha-channel artefacts.

On Tue, Nov 4, 2014 at 2:02 PM, Boudewijn Rempt <boud at valdyas.org> wrote:

> Git commit d925d5ac2b49c1aa6bccb90ad1edff3ef8fad641 by Boudewijn Rempt.
> Committed on 04/11/2014 at 12:58.
> Pushed by rempt into branch 'master'.
>
> Set the default projection color to the selected color
>
> CCMAIL:kimageshop at kde.org
> BUG:340216
>
> We used to set the default pixel color of the first layer to the color
> selected in the custom image widget. We also have a default projection
> color. This change sets the color and transparency set in the custom
> image widget as the default projection color.
>
> This has two consequences:
>
> * erase will now no longer show up the transparency checkers if you
> use an opaque background color (which is the default)
> * in order to have transparent areas in the image, you need to use
> the image properties or the new image background color menu option.
>
> Please test and give feedback whether this is what we want, or whether
> we need refining.
>
> Two possible issues:
>
> * erase still doesn't erase to the bg color selected in the toolbar;
> it will erase to the bg color selected for the image
> * loading, say, a jpg and using the eraser will still by default erase
> to transparency checkers. We could consider making the default background
> color for an image solid white...
>
> M  +2    -1    krita/krita.rc
> M  +61   -16   krita/ui/forms/wdgnewimage.ui
> M  +1    -1    krita/ui/kis_doc2.cc
> M  +28   -1    krita/ui/kis_image_manager.cc
> M  +1    -0    krita/ui/kis_image_manager.h
>
> http://commits.kde.org/calligra/d925d5ac2b49c1aa6bccb90ad1edff3ef8fad641
>
> diff --git a/krita/krita.rc b/krita/krita.rc
> index 804ecdc..edd76fd 100644
> --- a/krita/krita.rc
> +++ b/krita/krita.rc
> @@ -1,6 +1,6 @@
>  <?xml version="1.0"?>
>  <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
> -<kpartgui name="Krita" version="53">
> +<kpartgui name="Krita" version="55">
>
>  <MenuBar>
>   <Menu name="file"><text>&File</text>
> @@ -80,6 +80,7 @@
>
>  <Menu name="Image"><text>&Image</text>
>    <Action name="image_properties"/>
> +  <Action name="image_color"/>
>    <Action name="duplicate_image"/>
>    <Separator/>
>    <DefineGroup name="canvas_resize_merge" append="canvas_resize_merge"/>
> diff --git a/krita/ui/forms/wdgnewimage.ui b/krita/ui/forms/wdgnewimage.ui
> index 2fc9d3b..814bc1a 100644
> --- a/krita/ui/forms/wdgnewimage.ui
> +++ b/krita/ui/forms/wdgnewimage.ui
> @@ -63,7 +63,16 @@
>           <layout class="QHBoxLayout">
>            <item>
>             <layout class="QVBoxLayout">
> -            <property name="margin">
> +            <property name="leftMargin">
> +             <number>0</number>
> +            </property>
> +            <property name="topMargin">
> +             <number>0</number>
> +            </property>
> +            <property name="rightMargin">
> +             <number>0</number>
> +            </property>
> +            <property name="bottomMargin">
>               <number>0</number>
>              </property>
>              <item>
> @@ -96,7 +105,16 @@
>            </item>
>            <item>
>             <layout class="QVBoxLayout">
> -            <property name="margin">
> +            <property name="leftMargin">
> +             <number>0</number>
> +            </property>
> +            <property name="topMargin">
> +             <number>0</number>
> +            </property>
> +            <property name="rightMargin">
> +             <number>0</number>
> +            </property>
> +            <property name="bottomMargin">
>               <number>0</number>
>              </property>
>              <item>
> @@ -138,7 +156,16 @@
>            </item>
>            <item>
>             <layout class="QVBoxLayout">
> -            <property name="margin">
> +            <property name="leftMargin">
> +             <number>0</number>
> +            </property>
> +            <property name="topMargin">
> +             <number>0</number>
> +            </property>
> +            <property name="rightMargin">
> +             <number>0</number>
> +            </property>
> +            <property name="bottomMargin">
>               <number>0</number>
>              </property>
>              <item>
> @@ -376,7 +403,7 @@
>        <item row="0" column="0">
>         <widget class="QLabel" name="lblColor">
>          <property name="text">
> -         <string>C&anvas color:</string>
> +         <string>&Image Background Color:</string>
>          </property>
>          <property name="alignment">
>           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
> @@ -388,14 +415,17 @@
>        </item>
>        <item row="0" column="1">
>         <widget class="KColorButton" name="cmbColor">
> -        <property name="color">
> +        <property name="toolTip">
> +         <string>Reset the image background color in the Image Properties
> dialog</string>
> +        </property>
> +        <property name="color" stdset="0">
>           <color>
>            <red>255</red>
>            <green>255</green>
>            <blue>255</blue>
>           </color>
>          </property>
> -        <property name="defaultColor">
> +        <property name="defaultColor" stdset="0">
>           <color>
>            <red>255</red>
>            <green>255</green>
> @@ -412,14 +442,14 @@
>         </widget>
>        </item>
>        <item row="0" column="3">
> -       <widget class="KIntNumInput" name="intNumLayers">
> -        <property name="value">
> +       <widget class="KIntNumInput" name="intNumLayers" native="true">
> +        <property name="value" stdset="0">
>           <number>2</number>
>          </property>
> -        <property name="minimum">
> +        <property name="minimum" stdset="0">
>           <number>1</number>
>          </property>
> -        <property name="maximum">
> +        <property name="maximum" stdset="0">
>           <number>200</number>
>          </property>
>         </widget>
> @@ -427,7 +457,7 @@
>        <item row="1" column="0">
>         <widget class="QLabel" name="lblOpacity">
>          <property name="text">
> -         <string>&Opacity:</string>
> +         <string>Image Background &Opacity:</string>
>          </property>
>          <property name="alignment">
>           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
> @@ -446,7 +476,16 @@
>           <enum>QFrame::Plain</enum>
>          </property>
>          <layout class="QHBoxLayout">
> -         <property name="margin">
> +         <property name="leftMargin">
> +          <number>0</number>
> +         </property>
> +         <property name="topMargin">
> +          <number>0</number>
> +         </property>
> +         <property name="rightMargin">
> +          <number>0</number>
> +         </property>
> +         <property name="bottomMargin">
>            <number>0</number>
>           </property>
>           <item>
> @@ -517,16 +556,22 @@
>       <zorder>lblDescription</zorder>
>       <zorder>txtDescription</zorder>
>       <zorder>cmbColor</zorder>
> -     <zorder>textLabel2</zorder>
> -     <zorder>sliderOpacity</zorder>
> -     <zorder>textLabel1</zorder>
>       <zorder>intNumLayers</zorder>
>       <zorder>label_4</zorder>
>      </widget>
>     </item>
>     <item>
>      <layout class="QHBoxLayout">
> -     <property name="margin">
> +     <property name="leftMargin">
> +      <number>0</number>
> +     </property>
> +     <property name="topMargin">
> +      <number>0</number>
> +     </property>
> +     <property name="rightMargin">
> +      <number>0</number>
> +     </property>
> +     <property name="bottomMargin">
>        <number>0</number>
>       </property>
>       <item>
> diff --git a/krita/ui/kis_doc2.cc b/krita/ui/kis_doc2.cc
> index b4949e1..b352c25 100644
> --- a/krita/ui/kis_doc2.cc
> +++ b/krita/ui/kis_doc2.cc
> @@ -422,6 +422,7 @@ bool KisDoc2::newImage(const QString& name,
>      QApplication::setOverrideCursor(Qt::BusyCursor);
>
>      image = new KisImage(createUndoStore(), width, height, cs, name);
> +    image->setDefaultProjectionColor(bgColor);
>      Q_CHECK_PTR(image);
>
>      connect(image.data(), SIGNAL(sigImageModified()), this,
> SLOT(setImageModified()));
> @@ -437,7 +438,6 @@ bool KisDoc2::newImage(const QString& name,
>      layer = new KisPaintLayer(image.data(), image->nextLayerName(),
> bgColor.opacityU8(), cs);
>      Q_CHECK_PTR(layer);
>
> -    layer->paintDevice()->setDefaultPixel(bgColor.data());
>      image->addNode(layer.data(), image->rootLayer().data());
>      setCurrentImage(image);
>
> diff --git a/krita/ui/kis_image_manager.cc b/krita/ui/kis_image_manager.cc
> index 4741cb3..107228b 100644
> --- a/krita/ui/kis_image_manager.cc
> +++ b/krita/ui/kis_image_manager.cc
> @@ -25,7 +25,9 @@
>  #include <klocale.h>
>  #include <kurl.h>
>  #include <kactioncollection.h>
> +#include <kcolordialog.h>
>
> +#include <KoColor.h>
>  #include <KoIcon.h>
>  #include <KoFilterManager.h>
>  #include <KoFileDialog.h>
> @@ -53,6 +55,12 @@ void KisImageManager::setup(KActionCollection *
> actionCollection)
>      action  = new KAction(koIcon("document-properties"),
> i18n("Properties..."), this);
>      actionCollection->addAction("image_properties", action);
>      connect(action, SIGNAL(triggered()), this,
> SLOT(slotImageProperties()));
> +
> +    action = new KAction(koIcon("format-stroke-color"), i18n("Image
> Background Colorc and Transparency..."), this);
> +    action->setToolTip(i18n("Change the background color of the image"));
> +    actionCollection->addAction("image_color", action);
> +    connect(action, SIGNAL(triggered()), this, SLOT(slotImageColor()));
> +
>  }
>
>  void KisImageManager::slotImportLayerFromFile()
> @@ -126,7 +134,6 @@ void KisImageManager::shearCurrentImage(double angleX,
> double angleY)
>  void KisImageManager::slotImageProperties()
>  {
>      KisImageWSP image = m_view->image();
> -
>      if (!image) return;
>
>      QPointer<KisDlgImageProperties> dlg = new
> KisDlgImageProperties(image, m_view);
> @@ -136,5 +143,25 @@ void KisImageManager::slotImageProperties()
>      delete dlg;
>  }
>
> +void KisImageManager::slotImageColor()
> +{
> +    KisImageWSP image = m_view->image();
> +    if (!image) return;
> +
> +    KColorDialog dlg;
> +    dlg.setAlphaChannelEnabled(true);
> +
> +    KoColor bg = image->defaultProjectionColor();
> +
> +    dlg.setColor(bg.toQColor());
> +    dlg.setButtons(KColorDialog::Ok | KColorDialog::Cancel);
> +    if (dlg.exec() == KColorDialog::Accepted) {
> +        QColor c = dlg.color();
> +        bg.fromQColor(c);
> +        image->setDefaultProjectionColor(bg);
> +        image->refreshGraphAsync();
> +    }
> +}
> +
>
>  #include "kis_image_manager.moc"
> diff --git a/krita/ui/kis_image_manager.h b/krita/ui/kis_image_manager.h
> index eaedb61..bafe9f3 100644
> --- a/krita/ui/kis_image_manager.h
> +++ b/krita/ui/kis_image_manager.h
> @@ -60,6 +60,7 @@ public slots:
>      void rotateCurrentImage(double radians);
>      void shearCurrentImage(double angleX, double angleY);
>      void slotImageProperties();
> +    void slotImageColor();
>
>  private:
>      KisView2 * m_view;
> _______________________________________________
> Krita mailing list
> kimageshop at kde.org
> https://mail.kde.org/mailman/listinfo/kimageshop
>



-- 
Wolthera
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kimageshop/attachments/20141108/178dbdfa/attachment-0001.html>


More information about the kimageshop mailing list