[krita] libs/ui: Tells you which preset you have chosen via shortcut

Nikita Vertikov null at kde.org
Wed Aug 23 19:20:38 UTC 2017


Git commit 14400fe9b48fae272e4772196405877fa0edfb59 by Nikita Vertikov.
Committed on 23/08/2017 at 19:20.
Pushed by nikitav into branch 'master'.

Tells you which preset you have chosen via shortcut

After changing brush using shortcuts "Next Favorite Preset", "Previous Favorite Preset" and "Switch to Previous Preset" (by default binded to keys: " , ", " . " and " / ") it might be not obvious, which preset just have been selected.

This patch makes so, that after selecting another preset using one of theese shortcuts, selected preset's name and thumbnail will be shown in floating message.

Differential Revision: https://phabricator.kde.org/D7454
GUI:

M  +24   -9    libs/ui/kis_paintop_box.cc

https://commits.kde.org/krita/14400fe9b48fae272e4772196405877fa0edfb59

diff --git a/libs/ui/kis_paintop_box.cc b/libs/ui/kis_paintop_box.cc
index 79a7c8a2bef..059098a9a5d 100644
--- a/libs/ui/kis_paintop_box.cc
+++ b/libs/ui/kis_paintop_box.cc
@@ -1063,36 +1063,47 @@ void KisPaintopBox::slotPreviousFavoritePreset()
 {
     if (!m_favoriteResourceManager) return;
 
-    int i = 0;
-    Q_FOREACH (KisPaintOpPresetSP preset, m_favoriteResourceManager->favoritePresetList()) {
-        if (m_resourceProvider->currentPreset() && m_resourceProvider->currentPreset()->name() == preset->name()) {
+    QVector<KisPaintOpPresetSP> presets = m_favoriteResourceManager->favoritePresetList();
+    for (int i=0; i < presets.size(); ++i) {
+        if (m_resourceProvider->currentPreset() &&
+                m_resourceProvider->currentPreset()->name() == presets[i]->name()) {
             if (i > 0) {
                 m_favoriteResourceManager->slotChangeActivePaintop(i - 1);
             } else {
                 m_favoriteResourceManager->slotChangeActivePaintop(m_favoriteResourceManager->numFavoritePresets() - 1);
             }
+            //floating message should have least 2 lines, otherwise
+            //preset thumbnail will be too small to distinguish
+            //(because size of image on floating message depends on amount of lines in msg)
+            m_viewManager->showFloatingMessage(
+                i18n("%1\nselected",
+                        m_resourceProvider->currentPreset()->name()),
+                QIcon(QPixmap::fromImage(m_resourceProvider->currentPreset()->image())));
+
             return;
         }
-        i++;
     }
-
 }
 
 void KisPaintopBox::slotNextFavoritePreset()
 {
     if (!m_favoriteResourceManager) return;
 
-    int i = 0;
-    Q_FOREACH (KisPaintOpPresetSP preset, m_favoriteResourceManager->favoritePresetList()) {
-        if (m_resourceProvider->currentPreset()->name() == preset->name()) {
+    QVector<KisPaintOpPresetSP> presets = m_favoriteResourceManager->favoritePresetList();
+    for(int i = 0; i < presets.size(); ++i) {
+        if (m_resourceProvider->currentPreset()->name() == presets[i]->name()) {
             if (i < m_favoriteResourceManager->numFavoritePresets() - 1) {
                 m_favoriteResourceManager->slotChangeActivePaintop(i + 1);
             } else {
                 m_favoriteResourceManager->slotChangeActivePaintop(0);
             }
+            m_viewManager->showFloatingMessage(
+                i18n("%1\nselected",
+                        m_resourceProvider->currentPreset()->name()),
+                QIcon(QPixmap::fromImage(m_resourceProvider->currentPreset()->image())));
+
             return;
         }
-        i++;
     }
 }
 
@@ -1101,6 +1112,10 @@ void KisPaintopBox::slotSwitchToPreviousPreset()
     if (m_resourceProvider->previousPreset()) {
         //qDebug() << "slotSwitchToPreviousPreset();" << m_resourceProvider->previousPreset();
         setCurrentPaintop(m_resourceProvider->previousPreset());
+        m_viewManager->showFloatingMessage(
+                i18n("%1\nselected",
+                        m_resourceProvider->currentPreset()->name()),
+            QIcon(QPixmap::fromImage(m_resourceProvider->currentPreset()->image())));
     }
 }
 


More information about the kde-doc-english mailing list