koffice/krita/ui

Dmitry Kazakov dimula73 at gmail.com
Wed Nov 24 18:08:28 CET 2010


Don't we have the same shortcut set up onto the Backspace key?

On Wed, Nov 24, 2010 at 5:08 PM, Boudewijn Rempt <boud at valdyas.org> wrote:

> SVN commit 1200276 by rempt:
>
> Call the Edit > Clear action when the Del. key is pressed
>
> Patch by "Francisco Fernandes"
> CCMAIL: francisco.fernandes.j at gmail.com
>
>  M  +28 -25    kis_selection_manager.cc
>
>
> --- trunk/koffice/krita/ui/kis_selection_manager.cc #1200275:1200276
> @@ -1,3 +1,4 @@
> +
>  /*
>  *  Copyright (c) 2004 Boudewijn Rempt <boud at valdyas.org>
>  *  Copyright (c) 2007 Sven Langkamp <sven.langkamp at gmail.com>
> @@ -94,7 +95,6 @@
>         m_selectAll(0),
>         m_deselect(0),
>         m_clear(0),
> -        m_delete(0),
>         m_reselect(0),
>         m_invert(0),
>         m_toNewLayer(0),
> @@ -120,8 +120,7 @@
>
>  KisSelectionManager::~KisSelectionManager()
>  {
> -    while (!m_pluginActions.isEmpty())
> -        delete m_pluginActions.takeFirst();
> +    qDeleteAll(m_pluginActions);
>  }
>
>  void KisSelectionManager::setup(KActionCollection * collection)
> @@ -145,12 +144,8 @@
>     m_deselect = collection->addAction(KStandardAction::Deselect,
>  "deselect", this, SLOT(deselect()));
>
>     m_clear = collection->addAction(KStandardAction::Clear,  "clear", this,
> SLOT(clear()));
> +    m_clear->setShortcut(QKeySequence((Qt::Key_Delete)));
>
> -    m_delete = new KAction(KIcon("edit-delete"), i18n("D&elete
> Selection"), this);
> -    collection->addAction("delete", m_delete);
> -    m_delete->setShortcut(QKeySequence(Qt::Key_Delete));
> -    connect(m_delete, SIGNAL(triggered()), this, SLOT(deleteSelection()));
> -
>     m_reselect  = new KAction(i18n("&Reselect"), this);
>     collection->addAction("reselect", m_reselect);
>     m_reselect->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT +
> Qt::Key_D));
> @@ -267,8 +262,8 @@
>  #endif
>                     }
>
> +    m_clear->setEnabled(enable);
>         m_cut->setEnabled(enable);
> -    m_clear->setEnabled(enable);
>     m_fillForegroundColor->setEnabled(enable);
>     m_fillBackgroundColor->setEnabled(enable);
>     m_fillPattern->setEnabled(enable);
> @@ -316,7 +311,6 @@
>
>     l = m_view->activeLayer();
>     KisShapeLayer * shapeLayer = dynamic_cast<KisShapeLayer*>(l.data());
> -
>     bool shapePasteEnable = false;
>     bool shapeCopyEnable = false;
>     if (shapeLayer) {
> @@ -340,16 +334,18 @@
>     m_pasteNew->setEnabled(!image.isNull() && m_clipboard->hasClip());
>     m_toNewLayer->setEnabled(enable);
>
> -    if (shapeLayer || ((m_view->selection()
> -                        && m_view->selection()->hasShapeSelection()
> -                       )
> -                       &&
> m_view->canvasBase()->shapeManager()->selection()->count() > 0
> -                      )
> -       ) {
> -        m_delete->setEnabled(true);
> -    } else
> -        m_delete->setEnabled(false);
> +    //Handle the clear action disponibility
>
> +    if (m_view->canvasBase()->shapeManager()->selection()->count() > 0) {
> +        m_clear->setEnabled(true);
> +    }
> +    else if (shapeLayer &&
> m_view->canvasBase()->shapeManager()->shapes().empty()){
> +        m_clear->setEnabled(false);
> +    }
> +    else {
> +        m_clear->setEnabled(true);
> +    }
> +
>     updateStatusBar();
>
>  }
> @@ -398,7 +394,8 @@
>     KisShapeLayer * shapeLayer =
> dynamic_cast<KisShapeLayer*>(layer.data());
>     if (shapeLayer) {
>         m_view->canvasBase()->toolProxy()->copy();
> -    } else {
> +    }
> +    else {
>
>         KisImageWSP image = m_view->image();
>         if (!image) return;
> @@ -582,28 +579,34 @@
>     if (!image) return;
>
>     KisPaintDeviceSP dev = m_view->activeDevice();
> -    if (!dev) return;
>
> +    if(m_view->canvasBase()->shapeManager()->selection()->count()){
> +        deleteSelection();
> +    }else if(dev){
> +
>     KisSelectionSP sel = m_view->selection();
>
>     KisTransaction transaction(i18n("Clear"), dev);
>
> -    if (sel)
> +        if (sel){
>         dev->clearSelection(sel);
> -    else {
> +        }else{
>         dev->clear();
>         dev->setDirty();
>     }
>
> +        updateGUI();
> +
>     transaction.commit(image->undoAdapter());
> -
>     dev->setDirty(image->bounds());
>  }
> +}
>
>  void KisSelectionManager::deleteSelection()
>  {
> -    if (m_view->canvasBase()->shapeManager()->selection())
> +    if (m_view->canvasBase()->shapeManager()->selection()){
>         m_view->canvasBase()->toolProxy()->deleteSelection();
> +    }
>     updateGUI();
>  }
>
>


-- 
Dmitry Kazakov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/kimageshop/attachments/20101124/32fbdb60/attachment.htm 


More information about the kimageshop mailing list