setFocusPolicy(Qt::StrongFocus);
- viewport()->setCursor(Qt::IBeamCursor);
+ setCursorShape(Qt::IBeamCursor);
synthetic_mouse_event_.timeout.timeout.connect(
bind(&GuiWorkArea::generateSyntheticMouseEvent,
}
+Qt::CursorShape GuiWorkArea::cursorShape() const
+{
+ return viewport()->cursor().shape();
+}
+
+
+void GuiWorkArea::setCursorShape(Qt::CursorShape shape)
+{
+ viewport()->setCursor(shape);
+}
+
+
+void GuiWorkArea::updateCursorShape()
+{
+ setCursorShape(buffer_view_->clickableInset()
+ ? Qt::PointingHandCursor : Qt::IBeamCursor);
+}
+
+
void GuiWorkArea::setGuiView(GuiView & gv)
{
lyx_view_ = &gv;
if (update_metrics || lyx_view_ != guiApp->currentView()
|| lyx_view_->currentWorkArea() != this) {
// FIXME: it would be nice to optimize for the off-screen case.
+ buffer_view_->cursor().fixIfBroken();
buffer_view_->updateMetrics();
buffer_view_->cursor().fixIfBroken();
}
buffer_view_->coordCache().dump();
setReadOnly(buffer_view_->buffer().isReadonly());
+
+ updateCursorShape();
}
// Show the cursor immediately after any operation
startBlinkingCursor();
}
+
+ updateCursorShape();
}
// which are otherwise reserved to focus switching between controls
// within a dialog.
QKeyEvent * ke = static_cast<QKeyEvent*>(e);
- if ((ke->key() != Qt::Key_Tab && ke->key() != Qt::Key_Backtab)
- || ke->modifiers() & Qt::ControlModifier)
- return QAbstractScrollArea::event(e);
- keyPressEvent(ke);
- return true;
+ if ((ke->key() == Qt::Key_Tab && ke->modifiers() == Qt::NoModifier)
+ || (ke->key() == Qt::Key_Backtab && (
+ ke->modifiers() == Qt::ShiftModifier
+ || ke->modifiers() == Qt::NoModifier))) {
+ keyPressEvent(ke);
+ return true;
+ }
+ return QAbstractScrollArea::event(e);
}
default:
// 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_wheel_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_ALT:
+ 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;
EmbeddedWorkArea::~EmbeddedWorkArea()
{
// No need to destroy buffer and bufferview here, because it is done
- // in theBuffeerList() destruction loop at application exit
+ // in theBufferList() destruction loop at application exit
}
void TabWorkArea::setFullScreen(bool full_screen)
{
for (int i = 0; i != count(); ++i) {
- if (GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(widget(i)))
+ if (GuiWorkArea * wa = workArea(i))
wa->setFullScreen(full_screen);
}
}
+GuiWorkArea * TabWorkArea::workArea(int index)
+{
+ return dynamic_cast<GuiWorkArea *>(widget(index));
+}
+
+
GuiWorkArea * TabWorkArea::workArea(Buffer & buffer)
{
// FIXME: this method doesn't work if we have more than work area
// showing the same buffer.
for (int i = 0; i != count(); ++i) {
- GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(widget(i));
+ GuiWorkArea * wa = workArea(i);
LASSERT(wa, return 0);
if (&wa->bufferView().buffer() == &buffer)
return wa;
void TabWorkArea::closeAll()
{
while (count()) {
- GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(widget(0));
+ GuiWorkArea * wa = workArea(0);
LASSERT(wa, /**/);
removeTab(0);
delete wa;
// returns e.g. on application destruction
if (i == -1)
return;
- GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(widget(i));
+ GuiWorkArea * wa = workArea(i);
LASSERT(wa, return);
wa->setUpdatesEnabled(true);
wa->redraw(true);
if (clicked_tab_ == -1)
wa = currentWorkArea();
else {
- wa = dynamic_cast<GuiWorkArea *>(widget(clicked_tab_));
+ wa = workArea(clicked_tab_);
LASSERT(wa, /**/);
}
wa->view().closeWorkArea(wa);
if (clicked_tab_ == -1)
wa = currentWorkArea();
else {
- wa = dynamic_cast<GuiWorkArea *>(widget(clicked_tab_));
+ wa = workArea(clicked_tab_);
LASSERT(wa, /**/);
}
wa->view().hideWorkArea(wa);
if (index == -1)
wa = currentWorkArea();
else {
- wa = dynamic_cast<GuiWorkArea *>(widget(index));
+ wa = workArea(index);
LASSERT(wa, /**/);
}
wa->view().closeWorkArea(wa);
// collect full names first: path into postfix, empty prefix and
// filename without extension
for (size_t i = 0; i < n; ++i) {
- GuiWorkArea * i_wa = dynamic_cast<GuiWorkArea *>(widget(i));
+ GuiWorkArea * i_wa = workArea(i);
FileName const fn = i_wa->bufferView().buffer().fileName();
paths.push_back(DisplayPath(i, fn));
}
// set new tab titles
for (It it = paths.begin(); it != paths.end(); ++it) {
- GuiWorkArea * i_wa = dynamic_cast<GuiWorkArea *>(widget(it->tab()));
+ GuiWorkArea * i_wa = workArea(it->tab());
Buffer & buf = i_wa->bufferView().buffer();
if (!buf.fileName().empty() && !buf.isClean())
setTabText(it->tab(), it->displayString() + "*");