[krita] libs/ui: Add a GUI settings for useRightMiddleTabletButtonWorkaround

Dmitry Kazakov null at kde.org
Thu Apr 18 15:52:43 BST 2019


Git commit 4e602f7aaa64256051f4057b3aa81f5108ee0fc7 by Dmitry Kazakov.
Committed on 18/04/2019 at 14:50.
Pushed by dkazakov into branch 'master'.

Add a GUI settings for useRightMiddleTabletButtonWorkaround

Some tablet devices don't pass barrel-button clicks via tablet API.
If you have such a device, you can try activate this workaround.
Krita will try to read right- and middle-button clicks from the
mouse events stream. It may or may not work on your device
(depends on the tablet driver implementation).

BUG:399585
CC:kimageshop at kde.org

M  +9    -0    libs/ui/dialogs/kis_dlg_preferences.cc
M  +43   -33   libs/ui/forms/wdgtabletsettings.ui
M  +1    -1    libs/ui/input/kis_input_manager_p.cpp
M  +10   -0    libs/ui/kis_config.cc
M  +3    -0    libs/ui/kis_config.h

https://commits.kde.org/krita/4e602f7aaa64256051f4057b3aa81f5108ee0fc7

diff --git a/libs/ui/dialogs/kis_dlg_preferences.cc b/libs/ui/dialogs/kis_dlg_preferences.cc
index 388c9951368..d3e1e81fa53 100644
--- a/libs/ui/dialogs/kis_dlg_preferences.cc
+++ b/libs/ui/dialogs/kis_dlg_preferences.cc
@@ -706,6 +706,9 @@ void TabletSettingsTab::setDefault()
     curve.fromString(DEFAULT_CURVE_STRING);
     m_page->pressureCurve->setCurve(curve);
 
+    m_page->chkUseRightMiddleClickWorkaround->setChecked(
+        KisConfig(true).useRightMiddleTabletButtonWorkaround(true));
+
 #if defined Q_OS_WIN && (!defined USE_QT_TABLET_WINDOWS || defined QT_HAS_WINTAB_SWITCH)
 
 #ifdef USE_QT_TABLET_WINDOWS
@@ -743,6 +746,9 @@ TabletSettingsTab::TabletSettingsTab(QWidget* parent, const char* name): QWidget
     m_page->pressureCurve->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
     m_page->pressureCurve->setCurve(curve);
 
+    m_page->chkUseRightMiddleClickWorkaround->setChecked(
+         cfg.useRightMiddleTabletButtonWorkaround());
+
 #if defined Q_OS_WIN && (!defined USE_QT_TABLET_WINDOWS || defined QT_HAS_WINTAB_SWITCH)
 #ifdef USE_QT_TABLET_WINDOWS
     // ask Qt if WinInk is actually available
@@ -1617,6 +1623,9 @@ bool KisDlgPreferences::editPreferences()
 
         // Tablet settings
         cfg.setPressureTabletCurve( dialog->m_tabletSettings->m_page->pressureCurve->curve().toString() );
+        cfg.setUseRightMiddleTabletButtonWorkaround(
+            dialog->m_tabletSettings->m_page->chkUseRightMiddleClickWorkaround->isChecked());
+
 #if defined Q_OS_WIN && (!defined USE_QT_TABLET_WINDOWS || defined QT_HAS_WINTAB_SWITCH)
 #ifdef USE_QT_TABLET_WINDOWS
         // ask Qt if WinInk is actually available
diff --git a/libs/ui/forms/wdgtabletsettings.ui b/libs/ui/forms/wdgtabletsettings.ui
index 786fd7bd003..805b4c7452e 100644
--- a/libs/ui/forms/wdgtabletsettings.ui
+++ b/libs/ui/forms/wdgtabletsettings.ui
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>569</width>
-    <height>453</height>
+    <height>461</height>
    </rect>
   </property>
   <property name="sizePolicy">
@@ -20,6 +20,32 @@
    <string>Color Settings</string>
   </property>
   <layout class="QGridLayout" name="gridLayout_2">
+   <item row="5" column="0">
+    <spacer name="verticalSpacer_2">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>40</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="1" column="1">
+    <spacer name="horizontalSpacer_2">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>40</width>
+       <height>20</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
    <item row="1" column="0">
     <layout class="QGridLayout" name="gridLayout">
      <property name="leftMargin">
@@ -132,43 +158,17 @@
      </item>
     </layout>
    </item>
-   <item row="0" column="0">
-    <widget class="QLabel" name="label">
+   <item row="4" column="0" colspan="2">
+    <widget class="QPushButton" name="btnTabletTest">
      <property name="text">
-      <string>Input Pressure Global Curve</string>
+      <string>Open Tablet Tester...</string>
      </property>
     </widget>
    </item>
-   <item row="1" column="1">
-    <spacer name="horizontalSpacer_2">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>40</width>
-       <height>20</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-   <item row="4" column="0">
-    <spacer name="verticalSpacer_2">
-     <property name="orientation">
-      <enum>Qt::Vertical</enum>
-     </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>20</width>
-       <height>40</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-   <item row="3" column="0" colspan="2">
-    <widget class="QPushButton" name="btnTabletTest">
+   <item row="0" column="0">
+    <widget class="QLabel" name="label">
      <property name="text">
-      <string>Open Tablet Tester...</string>
+      <string>Input Pressure Global Curve</string>
      </property>
     </widget>
    </item>
@@ -219,6 +219,16 @@
      </layout>
     </widget>
    </item>
+   <item row="3" column="0">
+    <widget class="QCheckBox" name="chkUseRightMiddleClickWorkaround">
+     <property name="toolTip">
+      <string><html><head/><body><p>Some tablet devices don't pass barrel-button clicks via tablet API. If you have such a device, you can try activate this workaround. Krita will try to read right- and middle-button clicks from the mouse events stream. It may or may not work on your device (depends on the tablet driver implementation).</p><p><br/></p><p>After changing this option Krita should be restarted.</p></body></html></string>
+     </property>
+     <property name="text">
+      <string>Use mouse events for right- and middle-clicks (workaround for convertible devices, needs restart)</string>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <customwidgets>
diff --git a/libs/ui/input/kis_input_manager_p.cpp b/libs/ui/input/kis_input_manager_p.cpp
index 509dc11b0b5..61d8dc35aef 100644
--- a/libs/ui/input/kis_input_manager_p.cpp
+++ b/libs/ui/input/kis_input_manager_p.cpp
@@ -73,7 +73,7 @@ static bool isMouseEventType(QEvent::Type t)
 KisInputManager::Private::EventEater::EventEater()
 {
     KisConfig cfg(true);
-    activateSecondaryButtonsWorkaround = cfg.readEntry("rightMiddleTabletButtonWorkaround", false);
+    activateSecondaryButtonsWorkaround = cfg.useRightMiddleTabletButtonWorkaround();
 }
 
 bool KisInputManager::Private::EventEater::eventFilter(QObject* target, QEvent* event )
diff --git a/libs/ui/kis_config.cc b/libs/ui/kis_config.cc
index fde02edcba6..a8dcccb8f94 100644
--- a/libs/ui/kis_config.cc
+++ b/libs/ui/kis_config.cc
@@ -1169,6 +1169,16 @@ void KisConfig::setUseWin8PointerInputNoApp(QSettings *settings, bool value)
     settings->setValue("useWin8PointerInput", value);
 }
 
+bool KisConfig::useRightMiddleTabletButtonWorkaround(bool defaultValue) const
+{
+    return (defaultValue ? false : m_cfg.readEntry("useRightMiddleTabletButtonWorkaround", false));
+}
+
+void KisConfig::setUseRightMiddleTabletButtonWorkaround(bool value)
+{
+    m_cfg.writeEntry("useRightMiddleTabletButtonWorkaround", value);
+}
+
 qreal KisConfig::vastScrolling(bool defaultValue) const
 {
     return (defaultValue ? 0.9 : m_cfg.readEntry("vastScrolling", 0.9));
diff --git a/libs/ui/kis_config.h b/libs/ui/kis_config.h
index 7002be8a27a..3e124bb2a3b 100644
--- a/libs/ui/kis_config.h
+++ b/libs/ui/kis_config.h
@@ -310,6 +310,9 @@ public:
     static bool useWin8PointerInputNoApp(QSettings *settings, bool defaultValue = false);
     static void setUseWin8PointerInputNoApp(QSettings *settings, bool value);
 
+    bool useRightMiddleTabletButtonWorkaround(bool defaultValue = false) const;
+    void setUseRightMiddleTabletButtonWorkaround(bool value);
+
     qreal vastScrolling(bool defaultValue = false) const;
     void setVastScrolling(const qreal factor) const;
 


More information about the kimageshop mailing list