From 6b004a6b4eb4e90fac188907623085da49c065e7 Mon Sep 17 00:00:00 2001
From: Florian Jung <flo@windfisch.org>
Date: Sun, 18 Sep 2011 15:19:53 +0000
Subject: made muse more usable without middle mouse button

---
 muse2/awl/floatentry.cpp               |  5 ++++-
 muse2/muse/conf.cpp                    |  3 +++
 muse2/muse/gconfig.cpp                 |  3 ++-
 muse2/muse/gconfig.h                   |  2 +-
 muse2/muse/widgets/dentry.cpp          |  5 ++++-
 muse2/muse/widgets/genset.cpp          |  3 +++
 muse2/muse/widgets/gensetbase.ui       | 38 +++++++++++++++++++++++++++++++---
 muse2/muse/widgets/musewidgetsplug.cpp |  1 +
 muse2/muse/widgets/nentry.cpp          |  5 ++++-
 muse2/muse/widgets/siglabel.cpp        |  5 ++++-
 10 files changed, 61 insertions(+), 9 deletions(-)

diff --git a/muse2/awl/floatentry.cpp b/muse2/awl/floatentry.cpp
index 44739944..573420df 100644
--- a/muse2/awl/floatentry.cpp
+++ b/muse2/awl/floatentry.cpp
@@ -22,6 +22,7 @@
 
 #include "floatentry.h"
 #include "fastlog.h"
+#include "gconfig.h"
 
 #include <QLineEdit>
 #include <QMouseEvent>
@@ -219,7 +220,9 @@ void FloatEntry::repeat()
 
       switch (button) {
             case Qt::LeftButton:
-                  return;
+                  if (!MusEConfig::config.leftMouseButtonCanDecrease)
+                    return;
+                  // else fall through
             case Qt::MidButton:
                   decValue(evx);
                   break;
diff --git a/muse2/muse/conf.cpp b/muse2/muse/conf.cpp
index 2e7fa84e..2a3acc67 100644
--- a/muse2/muse/conf.cpp
+++ b/muse2/muse/conf.cpp
@@ -944,6 +944,8 @@ void readConfiguration(Xml& xml, bool readOnlySequencer, bool doReadGlobalConfig
                               MusEConfig::config.useProjectSaveDialog = xml.parseInt();
                         else if (tag == "popupsDefaultStayOpen")
                               MusEConfig::config.popupsDefaultStayOpen = xml.parseInt();
+                        else if (tag == "leftMouseButtonCanDecrease")
+                              MusEConfig::config.leftMouseButtonCanDecrease = xml.parseInt();
 
                         // ---- the following only skips obsolete entries ----
                         else if ((tag == "arranger") || (tag == "geometryPianoroll") || (tag == "geometryDrumedit"))
@@ -1275,6 +1277,7 @@ void MusE::writeGlobalConfiguration(int level, Xml& xml) const
       xml.intTag(level, "useOldStyleStopShortCut", MusEConfig::config.useOldStyleStopShortCut);
       xml.intTag(level, "moveArmedCheckBox", MusEConfig::config.moveArmedCheckBox);
       xml.intTag(level, "popupsDefaultStayOpen", MusEConfig::config.popupsDefaultStayOpen);
+      xml.intTag(level, "leftMouseButtonCanDecrease", MusEConfig::config.leftMouseButtonCanDecrease);
       
       //for (int i = 0; i < 6; ++i) {
       for (int i = 0; i < NUM_FONTS; ++i) {
diff --git a/muse2/muse/gconfig.cpp b/muse2/muse/gconfig.cpp
index 354e4cbc..ab3a0d4e 100644
--- a/muse2/muse/gconfig.cpp
+++ b/muse2/muse/gconfig.cpp
@@ -185,7 +185,8 @@ GlobalConfigValues config = {
       true,                         // projectStoreInFolder
       true,                         // useProjectSaveDialog
       64,                           // minControlProcessPeriod
-      false                         // popupsDefaultStayOpen
+      false,                        // popupsDefaultStayOpen
+      false                         // leftMouseButtonCanDecrease
     };
 
 } // namespace MusEConfig
diff --git a/muse2/muse/gconfig.h b/muse2/muse/gconfig.h
index f50984f8..96abc4ac 100644
--- a/muse2/muse/gconfig.h
+++ b/muse2/muse/gconfig.h
@@ -160,10 +160,10 @@ struct GlobalConfigValues {
       bool useProjectSaveDialog;
       unsigned long minControlProcessPeriod;
       bool popupsDefaultStayOpen;
+      bool leftMouseButtonCanDecrease;
       };
 
 extern GlobalConfigValues config;
-
 } // namespace MusEConfig
 
 #endif
diff --git a/muse2/muse/widgets/dentry.cpp b/muse2/muse/widgets/dentry.cpp
index 000dec50..7c7237f7 100644
--- a/muse2/muse/widgets/dentry.cpp
+++ b/muse2/muse/widgets/dentry.cpp
@@ -27,6 +27,7 @@
 
 #include "dentry.h"
 #include "globals.h"
+#include "gconfig.h"
 
 #define TIMER1    400
 #define TIMER2    200
@@ -172,7 +173,9 @@ void Dentry::repeat()
 
       switch (button) {
             case Qt::LeftButton:
-                  return;
+                  if (!MusEConfig::config.leftMouseButtonCanDecrease)
+                    return;
+                  // else fall through
             case Qt::MidButton:
                   if(_slider)
                     _slider->stepPages(-1);
diff --git a/muse2/muse/widgets/genset.cpp b/muse2/muse/widgets/genset.cpp
index c6761a07..16750385 100644
--- a/muse2/muse/widgets/genset.cpp
+++ b/muse2/muse/widgets/genset.cpp
@@ -169,6 +169,7 @@ Shorter periods are desirable.</string>
       moveArmedCheckBox->setChecked(MusEConfig::config.moveArmedCheckBox);
       projectSaveCheckBox->setChecked(MusEConfig::config.useProjectSaveDialog);
       popsDefStayOpenCheckBox->setChecked(MusEConfig::config.popupsDefaultStayOpen);
+      lmbDecreasesCheckBox->setChecked(MusEConfig::config.leftMouseButtonCanDecrease);
       
       //updateSettings();    // TESTING
       
@@ -305,6 +306,7 @@ void GlobalSettingsConfig::updateSettings()
       moveArmedCheckBox->setChecked(MusEConfig::config.moveArmedCheckBox);
       projectSaveCheckBox->setChecked(MusEConfig::config.useProjectSaveDialog);
       popsDefStayOpenCheckBox->setChecked(MusEConfig::config.popupsDefaultStayOpen);
+      lmbDecreasesCheckBox->setChecked(MusEConfig::config.leftMouseButtonCanDecrease);
       
       updateMdiSettings();
 }
@@ -401,6 +403,7 @@ void GlobalSettingsConfig::apply()
       MusEConfig::config.moveArmedCheckBox = moveArmedCheckBox->isChecked();
       MusEConfig::config.useProjectSaveDialog = projectSaveCheckBox->isChecked();
       MusEConfig::config.popupsDefaultStayOpen = popsDefStayOpenCheckBox->isChecked();
+      MusEConfig::config.leftMouseButtonCanDecrease = lmbDecreasesCheckBox->isChecked();
 
       //MusEGlobal::muse->showMixer(MusEConfig::config.mixerVisible);
       MusEGlobal::muse->showMixer1(MusEConfig::config.mixer1Visible);
diff --git a/muse2/muse/widgets/gensetbase.ui b/muse2/muse/widgets/gensetbase.ui
index b5fb56b6..d5be9869 100644
--- a/muse2/muse/widgets/gensetbase.ui
+++ b/muse2/muse/widgets/gensetbase.ui
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>556</width>
-    <height>506</height>
+    <height>527</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -1345,12 +1345,44 @@ Adjusts responsiveness of audio controls and
           </item>
           <item row="4" column="1">
            <widget class="QCheckBox" name="popsDefStayOpenCheckBox">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
             <property name="toolTip">
              <string>Allows some popup menus to stay open.
 Otherwise, hold Ctrl to keep them open.</string>
             </property>
             <property name="text">
-             <string/>
+             <string notr="true"/>
+            </property>
+           </widget>
+          </item>
+          <item row="5" column="0">
+           <widget class="QLabel" name="label_2">
+            <property name="toolTip">
+             <string>In some areas, the middle mouse button decreases
+values, while the right button increases. Users without a
+middle mouse button can select this option to make the
+left button behave like the middle button in such areas.</string>
+            </property>
+            <property name="text">
+             <string>Use left mouse button for decreasing values</string>
+            </property>
+           </widget>
+          </item>
+          <item row="5" column="1">
+           <widget class="QCheckBox" name="lmbDecreasesCheckBox">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="text">
+             <string notr="true"/>
             </property>
            </widget>
           </item>
@@ -1409,7 +1441,7 @@ Otherwise, hold Ctrl to keep them open.</string>
                <x>0</x>
                <y>0</y>
                <width>482</width>
-               <height>168</height>
+               <height>166</height>
               </rect>
              </property>
              <layout class="QHBoxLayout" name="horizontalLayout_3">
diff --git a/muse2/muse/widgets/musewidgetsplug.cpp b/muse2/muse/widgets/musewidgetsplug.cpp
index 7141fe4e..95cc6b94 100644
--- a/muse2/muse/widgets/musewidgetsplug.cpp
+++ b/muse2/muse/widgets/musewidgetsplug.cpp
@@ -213,6 +213,7 @@ GlobalConfigValues config = {
       true,                         // useProjectSaveDialog
       64,                           // minControlProcessPeriod
       false                         // popupsDefaultStayOpen
+      true                         // leftMouseButtonCanDecrease
       };
 
 //---------------------------------------------------------
diff --git a/muse2/muse/widgets/nentry.cpp b/muse2/muse/widgets/nentry.cpp
index 13569b0d..a70b1a54 100644
--- a/muse2/muse/widgets/nentry.cpp
+++ b/muse2/muse/widgets/nentry.cpp
@@ -28,6 +28,7 @@
 #include <QTimer>
 
 #include "nentry.h"
+#include "gconfig.h"
 
 #define TIMER1    400
 #define TIMER2    200
@@ -254,7 +255,9 @@ void Nentry::repeat()
 
       switch (button) {
             case Qt::LeftButton:
-                  return;
+                  if (!MusEConfig::config.leftMouseButtonCanDecrease)
+                    return;
+                  // else fall through
             case Qt::MidButton:
                   decValue(evx);
                   break;
diff --git a/muse2/muse/widgets/siglabel.cpp b/muse2/muse/widgets/siglabel.cpp
index 1a1c9164..9916bd0a 100644
--- a/muse2/muse/widgets/siglabel.cpp
+++ b/muse2/muse/widgets/siglabel.cpp
@@ -31,6 +31,7 @@
 #define TIMER4    50
 
 #include "globals.h"
+#include "gconfig.h"
 #include <QMouseEvent>
 #include <QWheelEvent>
 #include <QLabel>
@@ -70,7 +71,9 @@ void SigLabel::mousePressEvent(QMouseEvent* event)
       int zz = z, nn = n;
       switch (button) {
             case Qt::LeftButton:
-                  return;
+                  if (!MusEConfig::config.leftMouseButtonCanDecrease)
+                    return;
+                  // else fall through
             case Qt::MidButton:
                   incValue(zaehler, false, zz, nn);
                   break;
-- 
cgit v1.2.3