Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

[android] Add setting for OnePlus workaround

Carsten Hartenfels568e7e523eb6
diff --git a/libs/global/kis_config_notifier.cpp b/libs/global/kis_config_notifier.cpp
index 4c970e4058..ab38561815 100644
--- a/libs/global/kis_config_notifier.cpp
+++ b/libs/global/kis_config_notifier.cpp
@@ -81,6 +81,11 @@ void KisConfigNotifier::notifyUsePageUpDownMouseButtonEmulationWorkaroundChanged
Q_EMIT sigUsePageUpDownMouseButtonEmulationWorkaroundChanged(enabled);
}
+void KisConfigNotifier::notifyUseHighFunctionKeyMouseButtonEmulationWorkaroundChanged(bool enabled)
+{
+ Q_EMIT sigUseHighFunctionKeyMouseButtonEmulationWorkaroundChanged(enabled);
+}
+
void KisConfigNotifier::notifyUseIgnoreHistoricTabletEventsWorkaroundChanged(bool enabled)
{
Q_EMIT sigUseIgnoreHistoricTabletEventsWorkaroundChanged(enabled);
diff --git a/libs/global/kis_config_notifier.h b/libs/global/kis_config_notifier.h
index a7caa7b6f8..0bc55c1256 100644
--- a/libs/global/kis_config_notifier.h
+++ b/libs/global/kis_config_notifier.h
@@ -44,6 +44,7 @@ public:
#ifdef Q_OS_ANDROID
void notifyUsePageUpDownMouseButtonEmulationWorkaroundChanged(bool enabled);
+ void notifyUseHighFunctionKeyMouseButtonEmulationWorkaroundChanged(bool enabled);
void notifyUseIgnoreHistoricTabletEventsWorkaroundChanged(bool enabled);
#endif
@@ -61,6 +62,7 @@ Q_SIGNALS:
void sigLongPressChanged(bool enabled);
#ifdef Q_OS_ANDROID
void sigUsePageUpDownMouseButtonEmulationWorkaroundChanged(bool enabled);
+ void sigUseHighFunctionKeyMouseButtonEmulationWorkaroundChanged(bool enabled);
void sigUseIgnoreHistoricTabletEventsWorkaroundChanged(bool enabled);
#endif
diff --git a/libs/ui/KisApplication.cpp b/libs/ui/KisApplication.cpp
index c5743c64e7..b42e80f00f 100644
--- a/libs/ui/KisApplication.cpp
+++ b/libs/ui/KisApplication.cpp
@@ -670,6 +670,14 @@ bool KisApplication::start(const KisApplicationArguments &args)
// workarounds above.
#if KRITA_QT_HAS_ANDROID_EMULATE_MOUSE_BUTTONS_FOR_HIGH_FUNCTION_KEYS
QCoreApplication::setKritaAttribute(KRITA_QATTRIBUTE_ANDROID_EMULATE_MOUSE_BUTTONS_FOR_HIGH_FUNCTION_KEYS, true);
+ auto setHighFunctionKeyMouseButtonEmulationWorkaround = [](bool enabled) {
+ // QCoreApplication::setKritaAttribute(KRITA_QATTRIBUTE_ANDROID_EMULATE_MOUSE_BUTTONS_FOR_HIGH_FUNCTION_KEYS, enabled);
+ };
+ connect(cfgNotifier,
+ &KisConfigNotifier::sigUseHighFunctionKeyMouseButtonEmulationWorkaroundChanged,
+ this,
+ setHighFunctionKeyMouseButtonEmulationWorkaround);
+ setHighFunctionKeyMouseButtonEmulationWorkaround(cfg.useHighFunctionKeyMouseButtonEmulationWorkaround());
#endif
// Xiaomi workaround: historic tablet motion events are garbage, they just
diff --git a/libs/ui/dialogs/kis_dlg_preferences.cc b/libs/ui/dialogs/kis_dlg_preferences.cc
index 7169f035c1..ff6291e109 100644
--- a/libs/ui/dialogs/kis_dlg_preferences.cc
+++ b/libs/ui/dialogs/kis_dlg_preferences.cc
@@ -1622,6 +1622,11 @@ void TabletSettingsTab::setDefault()
cfg.usePageUpDownMouseButtonEmulationWorkaround(true));
#endif
+#if KRITA_QT_HAS_ANDROID_EMULATE_MOUSE_BUTTONS_FOR_HIGH_FUNCTION_KEYS
+ m_page->chkUseHighFunctionKeyMouseButtonEmulationWorkaround->setChecked(
+ cfg.useHighFunctionKeyMouseButtonEmulationWorkaround(true));
+#endif
+
#if KRITA_QT_HAS_ANDROID_IGNORE_HISTORIC_TABLET_EVENTS
m_page->chkUseIgnoreHistoricTabletEventsWorkaround->setChecked(cfg.useIgnoreHistoricTabletEventsWorkaround(true));
#endif
@@ -1683,6 +1688,13 @@ TabletSettingsTab::TabletSettingsTab(QWidget* parent, const char* name): QWidget
m_page->chkUsePageUpDownMouseButtonEmulationWorkaround->hide();
#endif
+#if KRITA_QT_HAS_ANDROID_EMULATE_MOUSE_BUTTONS_FOR_HIGH_FUNCTION_KEYS
+ m_page->chkUseHighFunctionKeyMouseButtonEmulationWorkaround->setChecked(
+ cfg.useHighFunctionKeyMouseButtonEmulationWorkaround());
+#else
+ m_page->chkUseHighFunctionKeyMouseButtonEmulationWorkaround->hide();
+#endif
+
#if KRITA_QT_HAS_ANDROID_IGNORE_HISTORIC_TABLET_EVENTS
m_page->chkUseIgnoreHistoricTabletEventsWorkaround->setChecked(cfg.useIgnoreHistoricTabletEventsWorkaround());
#else
@@ -2916,6 +2928,11 @@ bool KisDlgPreferences::editPreferences()
m_tabletSettings->m_page->chkUsePageUpDownMouseButtonEmulationWorkaround->isChecked());
#endif
+#if KRITA_QT_HAS_ANDROID_EMULATE_MOUSE_BUTTONS_FOR_HIGH_FUNCTION_KEYS
+ cfg.setUseHighFunctionKeyMouseButtonEmulationWorkaround(
+ m_tabletSettings->m_page->chkUseHighFunctionKeyMouseButtonEmulationWorkaround->isChecked());
+#endif
+
#if KRITA_QT_HAS_ANDROID_IGNORE_HISTORIC_TABLET_EVENTS
cfg.setUseIgnoreHistoricTabletEventsWorkaround(
m_tabletSettings->m_page->chkUseIgnoreHistoricTabletEventsWorkaround->isChecked());
diff --git a/libs/ui/forms/wdgtabletsettings.ui b/libs/ui/forms/wdgtabletsettings.ui
index 750bdb1462..eff5ff58ae 100644
--- a/libs/ui/forms/wdgtabletsettings.ui
+++ b/libs/ui/forms/wdgtabletsettings.ui
@@ -195,6 +195,13 @@
</property>
</widget>
</item>
+ <item>
+ <widget class="QCheckBox" name="chkUseHighFunctionKeyMouseButtonEmulationWorkaround">
+ <property name="text">
+ <string>Treate F13 key as middle mouse button (workaround for OnePlus styluses)</string>
+ </property>
+ </widget>
+ </item>
<item>
<widget class="QCheckBox" name="chkUseIgnoreHistoricTabletEventsWorkaround">
<property name="text">
diff --git a/libs/ui/kis_config.cc b/libs/ui/kis_config.cc
index 3a1c2b8cf2..affa10ca65 100644
--- a/libs/ui/kis_config.cc
+++ b/libs/ui/kis_config.cc
@@ -1689,6 +1689,25 @@ void KisConfig::setUsePageUpDownMouseButtonEmulationWorkaround(bool value)
KisConfigNotifier::instance()->notifyUsePageUpDownMouseButtonEmulationWorkaroundChanged(value);
}
+bool KisConfig::useHighFunctionKeyMouseButtonEmulationWorkaround(bool defaultValue) const
+{
+ // This hack is only relevant for OnePlus devices (as far as we know), but
+ // it only affects the F21 key, which isn't something a creature of flesh
+ // and blood would regularly input. So it'll be fine to just enable this b
+ // default rather than bothering to detect the tablet brand or something.
+ if (defaultValue) {
+ return true;
+ } else {
+ return m_cfg.readEntry("useHighFunctionKeyMouseButtonEmulationWorkaround", true);
+ }
+}
+
+void KisConfig::setUseHighFunctionKeyMouseButtonEmulationWorkaround(bool value)
+{
+ m_cfg.writeEntry("useHighFunctionKeyMouseButtonEmulationWorkaround", value);
+ KisConfigNotifier::instance()->notifyUseHighFunctionKeyMouseButtonEmulationWorkaroundChanged(value);
+}
+
bool KisConfig::useIgnoreHistoricTabletEventsWorkaround(bool defaultValue) const
{
bool fallback = KisAndroidUtils::looksLikeXiaomiDevice();
diff --git a/libs/ui/kis_config.h b/libs/ui/kis_config.h
index 250f2d512c..31bab27584 100644
--- a/libs/ui/kis_config.h
+++ b/libs/ui/kis_config.h
@@ -424,6 +424,9 @@ public:
bool usePageUpDownMouseButtonEmulationWorkaround(bool defaultValue = false) const;
void setUsePageUpDownMouseButtonEmulationWorkaround(bool value);
+ bool useHighFunctionKeyMouseButtonEmulationWorkaround(bool defaultValue = false) const;
+ void setUseHighFunctionKeyMouseButtonEmulationWorkaround(bool value);
+
bool useIgnoreHistoricTabletEventsWorkaround(bool defaultValue = false) const;
void setUseIgnoreHistoricTabletEventsWorkaround(bool value);
#endif