Author: switt
Date: Fri Mar 11 07:11:55 2011
New Revision: 37901
URL: http://www.lyx.org/trac/changeset/37901
Log:
now the user has control over the width of the text cursor
Modified:
lyx-devel/trunk/src/LyXRC.cpp
lyx-devel/trunk/src/LyXRC.h
lyx-devel/trunk/src/frontends/qt4/GuiPrefs.cpp
lyx-devel/trunk/src/frontends/qt4/GuiWorkArea.cpp
lyx-devel/trunk/src/frontends/qt4/ui/PrefEditUi.ui
Modified: lyx-devel/trunk/src/LyXRC.cpp
==============================================================================
--- lyx-devel/trunk/src/LyXRC.cpp Thu Mar 10 23:11:34 2011 (r37900)
+++ lyx-devel/trunk/src/LyXRC.cpp Fri Mar 11 07:11:55 2011 (r37901)
@@ -85,6 +85,7 @@
{ "\\converter_cache_maxage", LyXRC::RC_CONVERTER_CACHE_MAXAGE },
{ "\\copier", LyXRC::RC_COPIER },
{ "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
+ { "\\cursor_width", LyXRC::RC_CURSOR_WIDTH },
{ "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
{ "\\def_file", LyXRC::RC_DEFFILE },
{ "\\default_decimal_point", LyXRC::RC_DEFAULT_DECIMAL_POINT },
@@ -360,6 +361,7 @@
completion_inline_dots = -1;
completion_inline_delay = 0.2;
default_decimal_point = ".";
+ cursor_width = 1;
}
@@ -903,6 +905,10 @@
lexrc >> cursor_follows_scrollbar;
break;
+ case RC_CURSOR_WIDTH:
+ lexrc >> cursor_width;
+ break;
+
case RC_SCROLL_BELOW_DOCUMENT:
lexrc >> scroll_below_document;
break;
@@ -1754,6 +1760,15 @@
}
if (tag != RC_LAST)
break;
+ case RC_CURSOR_WIDTH:
+ if (ignore_system_lyxrc ||
+ cursor_width
+ != system_lyxrc.cursor_width) {
+ os << "\\cursor_width "
+ << cursor_width << '\n';
+ }
+ if (tag != RC_LAST)
+ break;
case RC_SCROLL_BELOW_DOCUMENT:
if (ignore_system_lyxrc ||
scroll_below_document
@@ -3005,6 +3020,7 @@
case LyXRC::RC_EXPORT_OVERWRITE:
case LyXRC::RC_DEFAULT_DECIMAL_POINT:
case LyXRC::RC_SCROLL_WHEEL_ZOOM:
+ case LyXRC::RC_CURSOR_WIDTH:
case LyXRC::RC_LAST:
break;
}
@@ -3078,6 +3094,10 @@
str = _("LyX normally doesn't update the cursor position if you
move the scrollbar. Set to true if you'd prefer to always have the cursor on
screen.");
break;
+ case RC_CURSOR_WIDTH:
+ str = _("Configure the width of the text cursor. Automatic zoom
controled cursor width used when set to 0.");
+ break;
+
case RC_SCROLL_BELOW_DOCUMENT:
str = _("LyX normally doesn't allow the user to scroll further
than the bottom of the document. Set to true if you prefer to scroll the bottom
of the document to the top of the screen");
break;
Modified: lyx-devel/trunk/src/LyXRC.h
==============================================================================
--- lyx-devel/trunk/src/LyXRC.h Thu Mar 10 23:11:34 2011 (r37900)
+++ lyx-devel/trunk/src/LyXRC.h Fri Mar 11 07:11:55 2011 (r37901)
@@ -65,6 +65,7 @@
RC_CONVERTER_CACHE_MAXAGE,
RC_COPIER,
RC_CURSOR_FOLLOWS_SCROLLBAR,
+ RC_CURSOR_WIDTH,
RC_DATE_INSERT_FORMAT,
RC_DEFAULT_DECIMAL_POINT,
RC_DEFAULT_LANGUAGE,
@@ -530,6 +531,8 @@
ScrollWheelZoom scroll_wheel_zoom;
///
bool force_paint_single_char;
+ ///
+ int cursor_width;
};
Modified: lyx-devel/trunk/src/frontends/qt4/GuiPrefs.cpp
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiPrefs.cpp Thu Mar 10 23:11:34
2011 (r37900)
+++ lyx-devel/trunk/src/frontends/qt4/GuiPrefs.cpp Fri Mar 11 07:11:55
2011 (r37901)
@@ -2528,6 +2528,8 @@
this, SIGNAL(changed()));
connect(macroEditStyleCO, SIGNAL(activated(int)),
this, SIGNAL(changed()));
+ connect(cursorWidthSB, SIGNAL(valueChanged(int)),
+ this, SIGNAL(changed()));
connect(fullscreenLimitGB, SIGNAL(clicked()),
this, SIGNAL(changed()));
connect(fullscreenWidthSB, SIGNAL(valueChanged(int)),
@@ -2555,6 +2557,7 @@
case 1: rc.macro_edit_style = LyXRC::MACRO_EDIT_INLINE; break;
case 2: rc.macro_edit_style = LyXRC::MACRO_EDIT_LIST; break;
}
+ rc.cursor_width = cursorWidthSB->value();
rc.full_screen_toolbars = toggleToolbarsCB->isChecked();
rc.full_screen_scrollbar = toggleScrollbarCB->isChecked();
rc.full_screen_tabbar = toggleTabbarCB->isChecked();
@@ -2572,6 +2575,7 @@
sortEnvironmentsCB->setChecked(rc.sort_layouts);
groupEnvironmentsCB->setChecked(rc.group_layouts);
macroEditStyleCO->setCurrentIndex(rc.macro_edit_style);
+ cursorWidthSB->setValue(rc.cursor_width);
toggleScrollbarCB->setChecked(rc.full_screen_scrollbar);
toggleToolbarsCB->setChecked(rc.full_screen_toolbars);
toggleTabbarCB->setChecked(rc.full_screen_tabbar);
Modified: lyx-devel/trunk/src/frontends/qt4/GuiWorkArea.cpp
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiWorkArea.cpp Thu Mar 10 23:11:34
2011 (r37900)
+++ lyx-devel/trunk/src/frontends/qt4/GuiWorkArea.cpp Fri Mar 11 07:11:55
2011 (r37901)
@@ -73,11 +73,6 @@
#include <cmath>
-#ifdef Q_WS_WIN
-int const CursorWidth = 2;
-#else
-int const CursorWidth = 1;
-#endif
int const TabIndicatorWidth = 3;
#undef KeyPress
@@ -128,7 +123,9 @@
class CursorWidget {
public:
- CursorWidget() {}
+ CursorWidget() {
+ recomputeWidth();
+ }
void draw(QPainter & painter)
{
@@ -141,7 +138,7 @@
int bot = rect_.bottom();
// draw vertical line
- painter.fillRect(x_, y, CursorWidth, rect_.height(), color_);
+ painter.fillRect(x_, y, cursor_width_, rect_.height(), color_);
// draw RTL/LTR indication
painter.setPen(color_);
@@ -149,7 +146,7 @@
if (rtl_)
painter.drawLine(x_, bot, x_ - l, bot);
else
- painter.drawLine(x_, bot, x_ + CursorWidth + r,
bot);
+ painter.drawLine(x_, bot, x_ + cursor_width_ +
r, bot);
}
// draw completion triangle
@@ -160,8 +157,8 @@
painter.drawLine(x_ - 1, m - d, x_ - 1 - d, m);
painter.drawLine(x_ - 1, m + d, x_ - 1 - d, m);
} else {
- painter.drawLine(x_ + CursorWidth, m - d, x_ +
CursorWidth + d, m);
- painter.drawLine(x_ + CursorWidth, m + d, x_ +
CursorWidth + d, m);
+ painter.drawLine(x_ + cursor_width_, m - d, x_
+ cursor_width_ + d, m);
+ painter.drawLine(x_ + cursor_width_, m + d, x_
+ cursor_width_ + d, m);
}
}
}
@@ -196,11 +193,17 @@
}
// compute overall rectangle
- rect_ = QRect(x - l, y, CursorWidth + r + l, h);
+ rect_ = QRect(x - l, y, cursor_width_ + r + l, h);
}
void show(bool set_show = true) { show_ = set_show; }
void hide() { show_ = false; }
+ int cursorWidth() const { return cursor_width_; }
+ void recomputeWidth() {
+ cursor_width_ = lyxrc.cursor_width
+ ? lyxrc.cursor_width
+ : 1 + int((lyxrc.zoom + 50) / 200.0);
+ }
QRect const & rect() { return rect_; }
@@ -219,6 +222,8 @@
QRect rect_;
/// x position (were the vertical line is drawn)
int x_;
+
+ int cursor_width_;
};
@@ -600,6 +605,7 @@
&& !completer_->popupVisible()
&& !completer_->inlineVisible();
cursor_visible_ = true;
+ cursor_->recomputeWidth();
showCursor(p.x_, p.y_, h, l_shape, isrtl, completable);
}
Modified: lyx-devel/trunk/src/frontends/qt4/ui/PrefEditUi.ui
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/ui/PrefEditUi.ui Thu Mar 10 23:11:34
2011 (r37900)
+++ lyx-devel/trunk/src/frontends/qt4/ui/PrefEditUi.ui Fri Mar 11 07:11:55
2011 (r37901)
@@ -38,6 +38,36 @@
</property>
</widget>
</item>
+ <item row="1" column="0" >
+ <layout class="QGridLayout" name="gridLayout_4" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label_3" >
+ <property name="text" >
+ <string>Cursor width (&pixels):</string>
+ </property>
+ <property name="buddy" >
+ <cstring>cursorWidthSB</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QSpinBox" name="cursorWidthSB" >
+ <property name="minimum" >
+ <number>0</number>
+ </property>
+ <property name="maximum" >
+ <number>10</number>
+ </property>
+ <property name="singleStep" >
+ <number>1</number>
+ </property>
+ <property name="value" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
<item row="2" column="0" >
<widget class="QCheckBox" name="scrollBelowCB" >
<property name="text" >