commit d48e5330bee3218336fb443d726b625c84eacf10 Author: Juergen Spitzmueller <sp...@lyx.org> Date: Sun Feb 8 17:41:28 2015 +0100
Add pref option to disable middle-mouse-button paste Fixes: #9399 diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 7b6a6f5..b6462d5 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -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: diff --git a/src/LyXRC.h b/src/LyXRC.h index d132668..613a9c7 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -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; /// diff --git a/src/Text3.cpp b/src/Text3.cpp index 4c99c15..fc8846e 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -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; diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 01f2432..df0675a 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -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); } diff --git a/src/frontends/qt4/ui/PrefInputUi.ui b/src/frontends/qt4/ui/PrefInputUi.ui index 92cc547..9964e3f 100644 --- a/src/frontends/qt4/ui/PrefInputUi.ui +++ b/src/frontends/qt4/ui/PrefInputUi.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>350</width> - <height>303</height> + <height>316</height> </rect> </property> <property name="windowTitle"> @@ -142,8 +142,21 @@ <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>&Wheel scrolling speed:</string> @@ -153,7 +166,7 @@ </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> @@ -175,18 +188,15 @@ </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>&Middle mouse button pasting</string> </property> - </spacer> + </widget> </item> </layout> </widget> @@ -214,7 +224,7 @@ <x>10</x> <y>30</y> <width>304</width> - <height>27</height> + <height>29</height> </rect> </property> <layout class="QHBoxLayout" name="horizontalLayout_2"> diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index 74ee70d..179d777 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -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();