]> git.lyx.org Git - features.git/commitdiff
Add pref option to disable middle-mouse-button paste
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 8 Feb 2015 16:41:28 +0000 (17:41 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 8 Feb 2015 16:41:28 +0000 (17:41 +0100)
Fixes: #9399
src/LyXRC.cpp
src/LyXRC.h
src/Text3.cpp
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/ui/PrefInputUi.ui
src/mathed/InsetMathNest.cpp

index 7b6a6f51b6cb71af302bf6ac7e260ce213eaea4f..b6462d5d999e4ae81b96461fec85512f1ef60322 100644 (file)
@@ -142,6 +142,7 @@ LexerKeyword lyxrcTags[] = {
        { "\\macro_edit_style", LyXRC::RC_MACRO_EDIT_STYLE },
        { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
        { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
+       { "\\mouse_middlebutton_paste", LyXRC::RC_MOUSE_MIDDLEBUTTON_PASTE },
        { "\\mouse_wheel_speed", LyXRC::RC_MOUSE_WHEEL_SPEED },
        { "\\nomencl_command", LyXRC::RC_NOMENCL_COMMAND },
        { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
@@ -377,6 +378,7 @@ void LyXRC::setDefaults()
        default_length_unit = Length::CM;
        cursor_width = 1;
        close_buffer_with_last_view = "yes";
+       mouse_middlebutton_paste = true;
 }
 
 
@@ -1292,6 +1294,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                        }
                        break;
 
+               case RC_MOUSE_MIDDLEBUTTON_PASTE:
+                       lexrc >> mouse_middlebutton_paste;
+                       break;
+
                case RC_LAST:
                        break; // this is just a dummy
                }
@@ -2243,6 +2249,14 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                }
                if (tag != RC_LAST)
                        break;
+       case RC_MOUSE_MIDDLEBUTTON_PASTE:
+               if (ignore_system_lyxrc ||
+                   mouse_middlebutton_paste != system_lyxrc.mouse_middlebutton_paste) {
+                       os << "\\mouse_middlebutton_paste "
+                          << convert<string>(mouse_middlebutton_paste) << '\n';
+               }
+               if (tag != RC_LAST)
+                       break;
        case RC_COMPLETION_INLINE_DELAY:
                if (ignore_system_lyxrc ||
                    completion_inline_delay != system_lyxrc.completion_inline_delay) {
@@ -2974,6 +2988,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
        case LyXRC::RC_MAKE_BACKUP:
        case LyXRC::RC_MARK_FOREIGN_LANGUAGE:
        case LyXRC::RC_MOUSE_WHEEL_SPEED:
+       case LyXRC::RC_MOUSE_MIDDLEBUTTON_PASTE:
        case LyXRC::RC_NUMLASTFILES:
        case LyXRC::RC_PARAGRAPH_MARKERS:
        case LyXRC::RC_PATH_PREFIX:
index d1326685f05c5e790db980ecd1d36fbe76b26dea..613a9c7f06499857dc863dbfcd62d63510149c59 100644 (file)
@@ -119,6 +119,7 @@ public:
                RC_MAKE_BACKUP,
                RC_MARK_FOREIGN_LANGUAGE,
                RC_MOUSE_WHEEL_SPEED,
+               RC_MOUSE_MIDDLEBUTTON_PASTE,
                RC_NOMENCL_COMMAND,
                RC_NUMLASTFILES,
                RC_OPEN_BUFFERS_IN_TABS,
@@ -305,6 +306,8 @@ public:
        std::string hunspelldir_path;
        ///
        bool auto_region_delete;
+       /// enable middle-mouse-button paste
+       bool mouse_middlebutton_paste;
        /// flag telling whether lastfiles should be checked for existance
        bool auto_reset_options;
        ///
index 4c99c15774707dfe432fed950f1eae836d5185d4..fc8846ea5bb755cfc0d94b72da79aef9d2044c99 100644 (file)
@@ -1549,11 +1549,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                        break;
 
                case mouse_button::button2:
-                       // Middle mouse pasting.
-                       bv->mouseSetCursor(cur);
-                       lyx::dispatch(
-                               FuncRequest(LFUN_COMMAND_ALTERNATIVES,
-                                           "selection-paste ; primary-selection-paste paragraph"));
+                       if (lyxrc.mouse_middlebutton_paste) {
+                               // Middle mouse pasting.
+                               bv->mouseSetCursor(cur);
+                               lyx::dispatch(
+                                       FuncRequest(LFUN_COMMAND_ALTERNATIVES,
+                                                   "selection-paste ; primary-selection-paste paragraph"));
+                       }
                        cur.noScreenUpdate();
                        break;
 
index 01f24321ccc5f54bb975777cd9a08ed45fe144f8..df0675a4a2b635889aa4bf28708a23287cec0dea 100644 (file)
@@ -497,6 +497,8 @@ PrefInput::PrefInput(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(dontswapCB, SIGNAL(toggled(bool)),
                this, SIGNAL(changed()));
+       connect(mmPasteCB, SIGNAL(toggled(bool)),
+               this, SIGNAL(changed()));
 
        // reveal checkbox for switching Ctrl and Meta on Mac:
        bool swapcb = false;
@@ -532,6 +534,7 @@ void PrefInput::applyRC(LyXRC & rc) const
                rc.scroll_wheel_zoom = LyXRC::SCROLL_WHEEL_ZOOM_OFF;
        }
        rc.mac_dontswap_ctrl_meta  = dontswapCB->isChecked();
+       rc.mouse_middlebutton_paste = mmPasteCB->isChecked();
 }
 
 
@@ -560,6 +563,7 @@ void PrefInput::updateRC(LyXRC const & rc)
                break;
        }
        dontswapCB->setChecked(rc.mac_dontswap_ctrl_meta);
+       mmPasteCB->setChecked(rc.mouse_middlebutton_paste);
 }
 
 
index 92cc5473c84d313d6fee70a8b612c239a344a654..9964e3f6647947a83d20be82a3b5b7cdc296895f 100644 (file)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>350</width>
-    <height>303</height>
+    <height>316</height>
    </rect>
   </property>
   <property name="windowTitle">
      <property name="flat">
       <bool>true</bool>
      </property>
-     <layout class="QHBoxLayout" name="horizontalLayout">
-      <item>
+     <layout class="QGridLayout" name="gridLayout_2">
+      <item row="0" column="3">
+       <spacer>
+        <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="0" column="1">
        <widget class="QLabel" name="scrollingSpeedLA">
         <property name="text">
          <string>&amp;Wheel scrolling speed:</string>
         </property>
        </widget>
       </item>
-      <item>
+      <item row="0" column="2">
        <widget class="QDoubleSpinBox" name="mouseWheelSpeedSB">
         <property name="toolTip">
          <string>1.0 is the standard scrolling speed with the mouse wheel. Higher values will speed it up, low values slow it down.</string>
         </property>
        </widget>
       </item>
-      <item>
-       <spacer>
-        <property name="orientation">
-         <enum>Qt::Horizontal</enum>
+      <item row="1" column="1">
+       <widget class="QCheckBox" name="mmPasteCB">
+        <property name="toolTip">
+         <string>If this is checked, the middle mouse button will paste the recent selection</string>
         </property>
-        <property name="sizeHint" stdset="0">
-         <size>
-          <width>40</width>
-          <height>20</height>
-         </size>
+        <property name="text">
+         <string>&amp;Middle mouse button pasting</string>
         </property>
-       </spacer>
+       </widget>
       </item>
      </layout>
     </widget>
         <x>10</x>
         <y>30</y>
         <width>304</width>
-        <height>27</height>
+        <height>29</height>
        </rect>
       </property>
       <layout class="QHBoxLayout" name="horizontalLayout_2">
index 74ee70d141097a11dafded8494dfcb77e0090733..179d7775f32015e04c08f234a806957d10fb669b 100644 (file)
@@ -1551,7 +1551,7 @@ void InsetMathNest::lfunMousePress(Cursor & cur, FuncRequest & cmd)
                // cur.result().update(): don't overwrite previously set flags.
                cur.screenUpdateFlags(Update::Decoration | Update::FitCursor
                                | cur.result().screenUpdate());
-       } else if (cmd.button() == mouse_button::button2) {
+       } else if (cmd.button() == mouse_button::button2 && lyxrc.mouse_middlebutton_paste) {
                if (cap::selection()) {
                        // See comment in Text::dispatch why we do this
                        cap::copySelectionToStack();