Commit 417af269 authored by Kurt Hindenburg's avatar Kurt Hindenburg

Add option to disable ctrl+<mouse-wheel> zooming

The built-in behavior of Ctrl+<Mouse Wheel> to zoom in/out the terminal
can not be disabled. This patch adds an option to disable this
behavior. (Default to the original behavior).

Original patch by Yichao Yu yyc1992@gmail.com
I made some changes - bugs are mine as usual
REVIEW: 107281
FIXED-IN: 4.11
GUI:
parent ad5ad927
......@@ -471,6 +471,9 @@ void EditProfileDialog::setupAppearancePage(const Profile::Ptr profile)
_ui->boldIntenseButton->setChecked(profile->boldIntense());
connect(_ui->boldIntenseButton, SIGNAL(toggled(bool)), this,
SLOT(setBoldIntense(bool)));
_ui->enableMouseWheelZoomButton->setChecked(profile->mouseWheelZoomEnabled());
connect(_ui->enableMouseWheelZoomButton, SIGNAL(toggled(bool)), this,
SLOT(toggleMouseWheelZoom(bool)));
}
void EditProfileDialog::setAntialiasText(bool enable)
{
......@@ -486,6 +489,10 @@ void EditProfileDialog::setBoldIntense(bool enable)
preview(Profile::BoldIntense, enable);
updateTempProfileProperty(Profile::BoldIntense, enable);
}
void EditProfileDialog::toggleMouseWheelZoom(bool enable)
{
updateTempProfileProperty(Profile::MouseWheelZoomEnabled, enable);
}
void EditProfileDialog::colorSchemeAnimationUpdate()
{
QAbstractItemModel* model = _ui->colorSchemeList->model();
......@@ -1032,6 +1039,10 @@ void EditProfileDialog::setupMousePage(const Profile::Ptr profile)
SLOT(TripleClickModeChanged(int)));
_ui->openLinksByDirectClickButton->setEnabled(_ui->underlineLinksButton->isChecked());
_ui->enableMouseWheelZoomButton->setChecked(profile->mouseWheelZoomEnabled());
connect(_ui->enableMouseWheelZoomButton, SIGNAL(toggled(bool)), this,
SLOT(toggleMouseWheelZoom(bool)));
}
void EditProfileDialog::setupAdvancedPage(const Profile::Ptr profile)
{
......
......@@ -129,6 +129,7 @@ private slots:
void colorSchemeSelected();
void previewColorScheme(const QModelIndex& index);
void fontSelected(const QFont&);
void toggleMouseWheelZoom(bool enable);
void colorSchemeAnimationUpdate();
......
......@@ -893,6 +893,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="enableMouseWheelZoomButton">
<property name="toolTip">
<string>Pressing Ctrl+&amp;lt;mouse-wheel&amp;gt; will increase/decrease the text size.</string>
</property>
<property name="text">
<string>Allow Ctrl+&amp;lt;mouse-wheel&amp;gt; to zoom text size</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
......@@ -111,6 +111,7 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] = {
, { PasteFromSelectionEnabled , "PasteFromSelectionEnabled" , INTERACTION_GROUP , QVariant::Bool }
, { PasteFromClipboardEnabled , "PasteFromClipboardEnabled" , INTERACTION_GROUP , QVariant::Bool }
, { MiddleClickPasteMode, "MiddleClickPasteMode" , INTERACTION_GROUP , QVariant::Int }
, { MouseWheelZoomEnabled, "MouseWheelZoomEnabled", INTERACTION_GROUP, QVariant::Bool }
// Encoding
, { DefaultEncoding , "DefaultEncoding" , ENCODING_GROUP , QVariant::String }
......@@ -159,6 +160,7 @@ FallbackProfile::FallbackProfile()
setProperty(SilenceSeconds, 10);
setProperty(TerminalColumns, 80);
setProperty(TerminalRows, 40);
setProperty(MouseWheelZoomEnabled, true);
setProperty(KeyBindings, "default");
setProperty(ColorScheme, "Linux"); //use DarkPastels when is start support blue ncurses UI properly
......
......@@ -245,7 +245,11 @@ public:
*
* In future, the format might be #.#.# to account for levels
*/
MenuIndex
MenuIndex,
/** (bool) If true, mouse wheel scroll with Ctrl key pressed
* increases/decreases the terminal font size.
*/
MouseWheelZoomEnabled
};
/**
......@@ -423,6 +427,11 @@ public:
return property<bool>(Profile::BlinkingTextEnabled);
}
/** Convenience method for property<bool>(Profile::MouseWheelZoomEnabled) */
bool mouseWheelZoomEnabled() const {
return property<bool>(Profile::MouseWheelZoomEnabled);
}
/** Convenience method for property<bool>(Profile::BlinkingCursorEnabled) */
bool blinkingCursorEnabled() const {
return property<bool>(Profile::BlinkingCursorEnabled);
......
......@@ -2392,8 +2392,8 @@ void TerminalDisplay::wheelEvent(QWheelEvent* ev)
const int modifiers = ev->modifiers();
const int delta = ev->delta();
// ctrl+<wheel> for zomming, like in konqueror and firefox
if (modifiers & Qt::ControlModifier) {
// ctrl+<wheel> for zooming, like in konqueror and firefox
if ((modifiers & Qt::ControlModifier) && mouseWheelZoom()) {
if (delta > 0) {
// wheel-up for increasing font size
increaseFontSize();
......
......@@ -334,6 +334,22 @@ public:
/** Play a visual bell for prompt or warning. */
void visualBell();
/**
* Specified whether zoom terminal on Ctrl+<mouse wheel> is enabled or not.
* Defaults to enabled.
*/
void setMouseWheelZoom(bool value) {
_mouseWheelZoom = value;
};
/**
* Returns the whether zoom terminal on Ctrl+<mouse wheel> is enabled.
*
* See setMouseWheelZoom()
*/
bool mouseWheelZoom() {
return _mouseWheelZoom;
};
/**
* Reimplemented. Has no effect. Use setVTFont() to change the font
* used to draw characters in the display.
......@@ -856,6 +872,7 @@ private:
SessionController* _sessionController;
bool _trimTrailingSpaces; // trim trailing spaces in selected text
bool _mouseWheelZoom; // enable mouse wheel zooming or not
friend class TerminalDisplayAccessible;
};
......
......@@ -841,6 +841,9 @@ void ViewManager::applyProfileToView(TerminalDisplay* view , const Profile::Ptr
// bell mode
view->setBellMode(profile->property<int>(Profile::BellMode));
// mouse wheel zoom
view->setMouseWheelZoom(profile->mouseWheelZoomEnabled());
}
void ViewManager::updateViewsForSession(Session* session)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment