make mouse scroll wheel zoom configurable

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34955 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Stephan Witt 2010-07-17 22:29:42 +00:00
parent 30bae1710a
commit 0d386d7c25
6 changed files with 191 additions and 3 deletions

View File

@ -173,6 +173,7 @@ LexerKeyword lyxrcTags[] = {
{ "\\screen_font_typewriter_foundry", LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY },
{ "\\screen_zoom", LyXRC::RC_SCREEN_ZOOM },
{ "\\scroll_below_document", LyXRC::RC_SCROLL_BELOW_DOCUMENT },
{ "\\scroll_whell_zoom", LyXRC::RC_SCROLL_WHEEL_ZOOM },
{ "\\serverpipe", LyXRC::RC_SERVERPIPE },
{ "\\set_color", LyXRC::RC_SET_COLOR },
{ "\\show_banner", LyXRC::RC_SHOW_BANNER },
@ -320,6 +321,7 @@ void LyXRC::setDefaults()
date_insert_format = "%x";
cursor_follows_scrollbar = false;
scroll_below_document = false;
scroll_whell_zoom = SCROLL_WHEEL_ZOOM_CTRL;
paragraph_markers = false;
mac_like_word_movement = false;
macro_edit_style = MACRO_EDIT_INLINE_BOX;
@ -1195,6 +1197,23 @@ int LyXRC::read(Lexer & lexrc)
}
}
break;
case RC_SCROLL_WHEEL_ZOOM:
if (lexrc.next()) {
string const tmp = lexrc.getString();
if (tmp == "ctrl")
scroll_whell_zoom = SCROLL_WHEEL_ZOOM_CTRL;
else if (tmp == "shift")
scroll_whell_zoom = SCROLL_WHEEL_ZOOM_SHIFT;
else if (tmp == "option")
scroll_whell_zoom = SCROLL_WHEEL_ZOOM_OPTION;
else {
scroll_whell_zoom = SCROLL_WHEEL_ZOOM_OFF;
if (tmp != "off" && tmp != "false")
LYXERR0("Unrecognized scroll_whell_zoom status \""
<< tmp << '"');
}
}
break;
// Obsoteted in 1.4.0
case RC_USETEMPDIR:
@ -2571,6 +2590,29 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
if (tag != RC_LAST)
break;
case RC_SCROLL_WHEEL_ZOOM:
if (ignore_system_lyxrc ||
scroll_whell_zoom != system_lyxrc.scroll_whell_zoom) {
string status;
switch (scroll_whell_zoom) {
case SCROLL_WHEEL_ZOOM_OFF:
status = "off";
break;
case SCROLL_WHEEL_ZOOM_CTRL:
status = "ctrl";
break;
case SCROLL_WHEEL_ZOOM_SHIFT:
status = "shift";
break;
case SCROLL_WHEEL_ZOOM_OPTION:
status = "option";
break;
}
os << "\\scroll_whell_zoom " << status << '\n';
}
if (tag != RC_LAST)
break;
os << "\n#\n"
<< "# FORMATS SECTION ##########################\n"
<< "#\n\n";
@ -2909,6 +2951,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
case LyXRC::RC_FORWARD_SEARCH_PDF:
case LyXRC::RC_EXPORT_OVERWRITE:
case LyXRC::RC_DEFAULT_DECIMAL_POINT:
case LyXRC::RC_SCROLL_WHEEL_ZOOM:
case LyXRC::RC_LAST:
break;
}

View File

@ -156,6 +156,7 @@ public:
RC_SCREEN_FONT_TYPEWRITER_FOUNDRY,
RC_SCREEN_ZOOM,
RC_SCROLL_BELOW_DOCUMENT,
RC_SCROLL_WHEEL_ZOOM,
RC_SERVERPIPE,
RC_SET_COLOR,
RC_SHOW_BANNER,
@ -502,6 +503,15 @@ public:
int export_overwrite;
/// Default decimal point when aligning table columns on decimal
std::string default_decimal_point;
///
enum ScrollWheelZoom {
SCROLL_WHEEL_ZOOM_OFF,
SCROLL_WHEEL_ZOOM_CTRL,
SCROLL_WHEEL_ZOOM_SHIFT,
SCROLL_WHEEL_ZOOM_OPTION
};
///
ScrollWheelZoom scroll_whell_zoom;
};

View File

@ -460,6 +460,10 @@ PrefInput::PrefInput(GuiPreferences * form)
this, SIGNAL(changed()));
connect(mouseWheelSpeedSB, SIGNAL(valueChanged(double)),
this, SIGNAL(changed()));
connect(scrollzoomEnableCB, SIGNAL(clicked()),
this, SIGNAL(changed()));
connect(scrollzoomValueCO, SIGNAL(activated(int)),
this, SIGNAL(changed()));
}
@ -470,6 +474,21 @@ void PrefInput::apply(LyXRC & rc) const
rc.primary_kbmap = internal_path(fromqstr(firstKeymapED->text()));
rc.secondary_kbmap = internal_path(fromqstr(secondKeymapED->text()));
rc.mouse_wheel_speed = mouseWheelSpeedSB->value();
if (scrollzoomEnableCB->isChecked()) {
switch (scrollzoomValueCO->currentIndex()) {
case 0:
rc.scroll_whell_zoom = LyXRC::SCROLL_WHEEL_ZOOM_CTRL;
break;
case 1:
rc.scroll_whell_zoom = LyXRC::SCROLL_WHEEL_ZOOM_SHIFT;
break;
case 2:
rc.scroll_whell_zoom = LyXRC::SCROLL_WHEEL_ZOOM_OPTION;
break;
}
} else {
rc.scroll_whell_zoom = LyXRC::SCROLL_WHEEL_ZOOM_OFF;
}
}
@ -480,6 +499,23 @@ void PrefInput::update(LyXRC const & rc)
firstKeymapED->setText(toqstr(external_path(rc.primary_kbmap)));
secondKeymapED->setText(toqstr(external_path(rc.secondary_kbmap)));
mouseWheelSpeedSB->setValue(rc.mouse_wheel_speed);
switch (rc.scroll_whell_zoom) {
case LyXRC::SCROLL_WHEEL_ZOOM_OFF:
scrollzoomEnableCB->setChecked(false);
break;
case LyXRC::SCROLL_WHEEL_ZOOM_CTRL:
scrollzoomEnableCB->setChecked(true);
scrollzoomValueCO->setCurrentIndex(0);
break;
case LyXRC::SCROLL_WHEEL_ZOOM_SHIFT:
scrollzoomEnableCB->setChecked(true);
scrollzoomValueCO->setCurrentIndex(1);
break;
case LyXRC::SCROLL_WHEEL_ZOOM_OPTION:
scrollzoomEnableCB->setChecked(true);
scrollzoomValueCO->setCurrentIndex(2);
break;
}
}
@ -516,6 +552,12 @@ void PrefInput::on_keymapCB_toggled(bool keymap)
}
void PrefInput::on_scrollzoomEnableCB_toggled(bool enabled)
{
scrollzoomValueCO->setEnabled(enabled);
}
/////////////////////////////////////////////////////////////////////
//
// PrefCompletion

View File

@ -183,6 +183,7 @@ private Q_SLOTS:
void on_firstKeymapPB_clicked(bool);
void on_secondKeymapPB_clicked(bool);
void on_keymapCB_toggled(bool);
void on_scrollzoomEnableCB_toggled(bool);
private:
QString testKeymap(QString const & keymap);

View File

@ -817,7 +817,24 @@ void GuiWorkArea::wheelEvent(QWheelEvent * ev)
// Wheel rotation by one notch results in a delta() of 120 (see
// documentation of QWheelEvent)
double const delta = ev->delta() / 120.0;
if (ev->modifiers() & Qt::ControlModifier) {
bool zoom = false;
switch (lyxrc.scroll_whell_zoom) {
case LyXRC::SCROLL_WHEEL_ZOOM_CTRL:
zoom = ev->modifiers() & Qt::ControlModifier;
zoom &= !(ev->modifiers() & (Qt::ShiftModifier || Qt::AltModifier));
break;
case LyXRC::SCROLL_WHEEL_ZOOM_SHIFT:
zoom = ev->modifiers() & Qt::ShiftModifier;
zoom &= !(ev->modifiers() & (Qt::ControlModifier || Qt::AltModifier));
break;
case LyXRC::SCROLL_WHEEL_ZOOM_OPTION:
zoom = ev->modifiers() & Qt::AltModifier;
zoom &= !(ev->modifiers() & (Qt::ShiftModifier || Qt::ControlModifier));
break;
case LyXRC::SCROLL_WHEEL_ZOOM_OFF:
break;
}
if (zoom) {
docstring arg = convert<docstring>(int(5 * delta));
lyx::dispatch(FuncRequest(LFUN_BUFFER_ZOOM_IN, arg));
return;

View File

@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>426</width>
<height>227</height>
<width>432</width>
<height>303</height>
</rect>
</property>
<property name="windowTitle">
@ -177,6 +177,81 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="scrollzoomGB">
<property name="minimumSize">
<size>
<width>0</width>
<height>65</height>
</size>
</property>
<property name="title">
<string>Scroll wheel zoom</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>304</width>
<height>27</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>5</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item>
<widget class="QCheckBox" name="scrollzoomEnableCB">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Enable</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="scrollzoomValueCO">
<property name="enabled">
<bool>false</bool>
</property>
<property name="editable">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Ctrl</string>
</property>
</item>
<item>
<property name="text">
<string>Shift</string>
</property>
</item>
<item>
<property name="text">
<string>Option</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<spacer>
<property name="orientation">