Commit 05914458 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer

Made it possible to turn off scroll wheel zooming

It activates too easily for some people.

Task-number: QTCREATORBUG-406
parent 0be80466
...@@ -34,9 +34,7 @@ ...@@ -34,9 +34,7 @@
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QHash> #include <QtCore/QHash>
#include <QtCore/QSet> #include <QtCore/QSet>
#include <QtGui/QStandardItem> #include <QtCore/QAbstractItemModel>
#include <QtGui/QStandardItemModel>
#include <QtGui/QTreeView>
#include <QtScript/QScriptValue> #include <QtScript/QScriptValue>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
......
...@@ -1504,12 +1504,22 @@ bool BaseTextEditor::codeFoldingSupported() const ...@@ -1504,12 +1504,22 @@ bool BaseTextEditor::codeFoldingSupported() const
void BaseTextEditor::setMouseNavigationEnabled(bool b) void BaseTextEditor::setMouseNavigationEnabled(bool b)
{ {
d->m_mouseNavigationEnabled = b; d->m_behaviorSettings.m_mouseNavigation = b;
} }
bool BaseTextEditor::mouseNavigationEnabled() const bool BaseTextEditor::mouseNavigationEnabled() const
{ {
return d->m_mouseNavigationEnabled; return d->m_behaviorSettings.m_mouseNavigation;
}
void BaseTextEditor::setScrollWheelZoomingEnabled(bool b)
{
d->m_behaviorSettings.m_scrollWheelZooming = b;
}
bool BaseTextEditor::scrollWheelZoomingEnabled() const
{
return d->m_behaviorSettings.m_scrollWheelZooming;
} }
void BaseTextEditor::setRevisionsVisible(bool b) void BaseTextEditor::setRevisionsVisible(bool b)
...@@ -1547,7 +1557,6 @@ BaseTextEditorPrivate::BaseTextEditorPrivate() ...@@ -1547,7 +1557,6 @@ BaseTextEditorPrivate::BaseTextEditorPrivate()
m_marksVisible(false), m_marksVisible(false),
m_codeFoldingVisible(false), m_codeFoldingVisible(false),
m_codeFoldingSupported(false), m_codeFoldingSupported(false),
m_mouseNavigationEnabled(true),
m_revisionsVisible(false), m_revisionsVisible(false),
m_lineNumbersVisible(true), m_lineNumbersVisible(true),
m_highlightCurrentLine(true), m_highlightCurrentLine(true),
...@@ -3110,7 +3119,7 @@ void BaseTextEditor::mousePressEvent(QMouseEvent *e) ...@@ -3110,7 +3119,7 @@ void BaseTextEditor::mousePressEvent(QMouseEvent *e)
void BaseTextEditor::mouseReleaseEvent(QMouseEvent *e) void BaseTextEditor::mouseReleaseEvent(QMouseEvent *e)
{ {
if (d->m_mouseNavigationEnabled if (mouseNavigationEnabled()
&& d->m_linkPressed && d->m_linkPressed
&& e->modifiers() & Qt::ControlModifier && e->modifiers() & Qt::ControlModifier
&& !(e->modifiers() & Qt::ShiftModifier) && !(e->modifiers() & Qt::ShiftModifier)
...@@ -3516,8 +3525,8 @@ void BaseTextEditor::handleBackspaceKey() ...@@ -3516,8 +3525,8 @@ void BaseTextEditor::handleBackspaceKey()
void BaseTextEditor::wheelEvent(QWheelEvent *e) void BaseTextEditor::wheelEvent(QWheelEvent *e)
{ {
d->clearVisibleCollapsedBlock(); d->clearVisibleCollapsedBlock();
if (e->modifiers() & Qt::ControlModifier) { if (scrollWheelZoomingEnabled() && e->modifiers() & Qt::ControlModifier) {
const int delta = e->delta(); const int delta = e->delta();
if (delta < 0) if (delta < 0)
zoomOut(); zoomOut();
...@@ -3644,7 +3653,7 @@ void BaseTextEditor::updateLink(QMouseEvent *e) ...@@ -3644,7 +3653,7 @@ void BaseTextEditor::updateLink(QMouseEvent *e)
{ {
bool linkFound = false; bool linkFound = false;
if (d->m_mouseNavigationEnabled && e->modifiers() & Qt::ControlModifier) { if (mouseNavigationEnabled() && e->modifiers() & Qt::ControlModifier) {
// Link emulation behaviour for 'go to definition' // Link emulation behaviour for 'go to definition'
const QTextCursor cursor = cursorForPosition(e->pos()); const QTextCursor cursor = cursorForPosition(e->pos());
...@@ -4688,6 +4697,7 @@ void BaseTextEditor::setDisplaySettings(const DisplaySettings &ds) ...@@ -4688,6 +4697,7 @@ void BaseTextEditor::setDisplaySettings(const DisplaySettings &ds)
void BaseTextEditor::setBehaviorSettings(const TextEditor::BehaviorSettings &bs) void BaseTextEditor::setBehaviorSettings(const TextEditor::BehaviorSettings &bs)
{ {
setMouseNavigationEnabled(bs.m_mouseNavigation); setMouseNavigationEnabled(bs.m_mouseNavigation);
setScrollWheelZoomingEnabled(bs.m_scrollWheelZooming);
} }
void BaseTextEditor::setStorageSettings(const StorageSettings &storageSettings) void BaseTextEditor::setStorageSettings(const StorageSettings &storageSettings)
......
...@@ -360,6 +360,9 @@ public: ...@@ -360,6 +360,9 @@ public:
void setMouseNavigationEnabled(bool b); void setMouseNavigationEnabled(bool b);
bool mouseNavigationEnabled() const; bool mouseNavigationEnabled() const;
void setScrollWheelZoomingEnabled(bool b);
bool scrollWheelZoomingEnabled() const;
void setRevisionsVisible(bool b); void setRevisionsVisible(bool b);
bool revisionsVisible() const; bool revisionsVisible() const;
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#define BASETEXTEDITOR_P_H #define BASETEXTEDITOR_P_H
#include "basetexteditor.h" #include "basetexteditor.h"
#include "behaviorsettings.h"
#include "displaysettings.h" #include "displaysettings.h"
#include "texteditoroverlay.h" #include "texteditoroverlay.h"
#include "fontsettings.h" #include "fontsettings.h"
...@@ -181,8 +182,10 @@ public: ...@@ -181,8 +182,10 @@ public:
// end parentheses matcher // end parentheses matcher
QWidget *m_extraArea; QWidget *m_extraArea;
DisplaySettings m_displaySettings; DisplaySettings m_displaySettings;
TextEditor::FontSettings m_fontSettings; FontSettings m_fontSettings;
BehaviorSettings m_behaviorSettings;
int extraAreaSelectionAnchorBlockNumber; int extraAreaSelectionAnchorBlockNumber;
int extraAreaToggleMarkBlockNumber; int extraAreaToggleMarkBlockNumber;
...@@ -205,7 +208,6 @@ public: ...@@ -205,7 +208,6 @@ public:
uint m_marksVisible : 1; uint m_marksVisible : 1;
uint m_codeFoldingVisible : 1; uint m_codeFoldingVisible : 1;
uint m_codeFoldingSupported : 1; uint m_codeFoldingSupported : 1;
uint m_mouseNavigationEnabled : 1;
uint m_revisionsVisible : 1; uint m_revisionsVisible : 1;
uint m_lineNumbersVisible : 1; uint m_lineNumbersVisible : 1;
uint m_highlightCurrentLine : 1; uint m_highlightCurrentLine : 1;
......
...@@ -33,12 +33,14 @@ ...@@ -33,12 +33,14 @@
#include <QtCore/QString> #include <QtCore/QString>
static const char * const mouseNavigationKey = "MouseNavigation"; static const char * const mouseNavigationKey = "MouseNavigation";
static const char * const scrollWheelZoomingKey = "ScrollWheelZooming";
static const char * const groupPostfix = "BehaviorSettings"; static const char * const groupPostfix = "BehaviorSettings";
namespace TextEditor { namespace TextEditor {
BehaviorSettings::BehaviorSettings() : BehaviorSettings::BehaviorSettings() :
m_mouseNavigation(true) m_mouseNavigation(true),
m_scrollWheelZooming(true)
{ {
} }
...@@ -49,6 +51,7 @@ void BehaviorSettings::toSettings(const QString &category, QSettings *s) const ...@@ -49,6 +51,7 @@ void BehaviorSettings::toSettings(const QString &category, QSettings *s) const
group.insert(0, category); group.insert(0, category);
s->beginGroup(group); s->beginGroup(group);
s->setValue(QLatin1String(mouseNavigationKey), m_mouseNavigation); s->setValue(QLatin1String(mouseNavigationKey), m_mouseNavigation);
s->setValue(QLatin1String(scrollWheelZoomingKey), m_scrollWheelZooming);
s->endGroup(); s->endGroup();
} }
...@@ -62,11 +65,13 @@ void BehaviorSettings::fromSettings(const QString &category, const QSettings *s) ...@@ -62,11 +65,13 @@ void BehaviorSettings::fromSettings(const QString &category, const QSettings *s)
*this = BehaviorSettings(); // Assign defaults *this = BehaviorSettings(); // Assign defaults
m_mouseNavigation = s->value(group + QLatin1String(mouseNavigationKey), m_mouseNavigation).toBool(); m_mouseNavigation = s->value(group + QLatin1String(mouseNavigationKey), m_mouseNavigation).toBool();
m_scrollWheelZooming = s->value(group + QLatin1String(scrollWheelZoomingKey), m_scrollWheelZooming).toBool();
} }
bool BehaviorSettings::equals(const BehaviorSettings &ds) const bool BehaviorSettings::equals(const BehaviorSettings &ds) const
{ {
return m_mouseNavigation == ds.m_mouseNavigation return m_mouseNavigation == ds.m_mouseNavigation
&& m_scrollWheelZooming == ds.m_scrollWheelZooming
; ;
} }
......
...@@ -52,6 +52,7 @@ struct TEXTEDITOR_EXPORT BehaviorSettings ...@@ -52,6 +52,7 @@ struct TEXTEDITOR_EXPORT BehaviorSettings
bool equals(const BehaviorSettings &bs) const; bool equals(const BehaviorSettings &bs) const;
bool m_mouseNavigation; bool m_mouseNavigation;
bool m_scrollWheelZooming;
}; };
inline bool operator==(const BehaviorSettings &t1, const BehaviorSettings &t2) { return t1.equals(t2); } inline bool operator==(const BehaviorSettings &t1, const BehaviorSettings &t2) { return t1.equals(t2); }
......
...@@ -109,9 +109,10 @@ QWidget *BehaviorSettingsPage::createPage(QWidget *parent) ...@@ -109,9 +109,10 @@ QWidget *BehaviorSettingsPage::createPage(QWidget *parent)
<< ' ' << m_d->m_page.cleanWhitespace->text() << ' ' << m_d->m_page.cleanWhitespace->text()
<< ' ' << m_d->m_page.addFinalNewLine->text() << ' ' << m_d->m_page.addFinalNewLine->text()
<< ' ' << m_d->m_page.mouseNavigation->text() << ' ' << m_d->m_page.mouseNavigation->text()
<< ' ' << m_d->m_page.scrollWheelZooming->text()
<< ' ' << m_d->m_page.groupBoxTabAndIndentSettings->title() << ' ' << m_d->m_page.groupBoxTabAndIndentSettings->title()
<< ' ' << m_d->m_page.groupBoxStorageSettings->title() << ' ' << m_d->m_page.groupBoxStorageSettings->title()
<< ' ' << m_d->m_page.groupBoxNavigation->title(); << ' ' << m_d->m_page.groupBoxMouse->title();
m_d->m_searchKeywords.remove(QLatin1Char('&')); m_d->m_searchKeywords.remove(QLatin1Char('&'));
} }
return w; return w;
...@@ -170,6 +171,7 @@ void BehaviorSettingsPage::settingsFromUI(TabSettings &tabSettings, ...@@ -170,6 +171,7 @@ void BehaviorSettingsPage::settingsFromUI(TabSettings &tabSettings,
storageSettings.m_addFinalNewLine = m_d->m_page.addFinalNewLine->isChecked(); storageSettings.m_addFinalNewLine = m_d->m_page.addFinalNewLine->isChecked();
behaviorSettings.m_mouseNavigation = m_d->m_page.mouseNavigation->isChecked(); behaviorSettings.m_mouseNavigation = m_d->m_page.mouseNavigation->isChecked();
behaviorSettings.m_scrollWheelZooming = m_d->m_page.scrollWheelZooming->isChecked();
} }
void BehaviorSettingsPage::settingsToUI() void BehaviorSettingsPage::settingsToUI()
...@@ -190,6 +192,7 @@ void BehaviorSettingsPage::settingsToUI() ...@@ -190,6 +192,7 @@ void BehaviorSettingsPage::settingsToUI()
const BehaviorSettings &behaviorSettings = m_d->m_behaviorSettings; const BehaviorSettings &behaviorSettings = m_d->m_behaviorSettings;
m_d->m_page.mouseNavigation->setChecked(behaviorSettings.m_mouseNavigation); m_d->m_page.mouseNavigation->setChecked(behaviorSettings.m_mouseNavigation);
m_d->m_page.scrollWheelZooming->setChecked(behaviorSettings.m_scrollWheelZooming);
} }
TabSettings BehaviorSettingsPage::tabSettings() const TabSettings BehaviorSettingsPage::tabSettings() const
......
...@@ -277,9 +277,9 @@ ...@@ -277,9 +277,9 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBoxNavigation"> <widget class="QGroupBox" name="groupBoxMouse">
<property name="title"> <property name="title">
<string>Navigation</string> <string>Mouse</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
...@@ -289,6 +289,13 @@ ...@@ -289,6 +289,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="scrollWheelZooming">
<property name="text">
<string>Enable scroll &amp;wheel zooming</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
......
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