Commit 49bbc815 authored by Philipp Erhardt's avatar Philipp Erhardt
Browse files

Implement toggle mouse buttons, different cursors

parent ed92a34b
......@@ -123,6 +123,9 @@ KEY BINDINGS
*i* ::
Toggle between normal and inverted color rendering.
*v* ::
Swap the mouse buttons for selection and panning.
VARIABLES
---------
'string' *background_color* ::
......
......@@ -64,3 +64,4 @@ reload=R
open=O
save=S
toggle_toc=F9
swap_selection_and_panning_buttons=V
......@@ -97,6 +97,12 @@ Canvas::Canvas(Viewer *v, QWidget *parent) :
setup_keys(this);
if (drag_view_button == Qt::LeftButton) {
setCursor(Qt::OpenHandCursor);
} else {
setCursor(Qt::IBeamCursor);
}
// prints the string representation of a key
// cerr << QKeySequence(Qt::Key_Equal).toString().toUtf8().constData() << endl;
......@@ -138,6 +144,7 @@ void Canvas::setup_keys(QWidget *base) {
add_action(base, "set_presenter_layout", SLOT(set_presenter_layout()), this);
add_action(base, "toggle_overlay", SLOT(toggle_overlay()), this);
add_action(base, "focus_goto", SLOT(focus_goto()), this);
add_action(base, "swap_selection_and_panning_buttons", SLOT(swap_selection_and_panning_buttons()), this);
}
Layout *Canvas::get_layout() const {
......@@ -181,6 +188,11 @@ void Canvas::mousePressEvent(QMouseEvent *event) {
mx_down = mx;
my_down = my;
}
if (drag_view_button != Qt::NoButton && event->button() == drag_view_button) {
if (cursor().shape() != Qt::PointingHandCursor) { // TODO
setCursor(Qt::ClosedHandCursor);
}
}
if (select_text_button != Qt::NoButton && event->button() == select_text_button) {
if (triple_click_possible) {
cur_layout->select(event->x(), event->y(), Selection::StartLine);
......@@ -188,6 +200,10 @@ void Canvas::mousePressEvent(QMouseEvent *event) {
} else {
cur_layout->select(event->x(), event->y(), Selection::Start);
}
if (cursor().shape() != Qt::PointingHandCursor) { // TODO
setCursor(Qt::IBeamCursor);
}
update();
}
}
......@@ -211,6 +227,13 @@ void Canvas::mouseReleaseEvent(QMouseEvent *event) {
}
}
}
if (drag_view_button == Qt::LeftButton) {
setCursor(Qt::OpenHandCursor);
} else {
setCursor(Qt::IBeamCursor);
}
if (select_text_button != Qt::NoButton && event->button() == select_text_button) {
cur_layout->copy_selection_text();
}
......@@ -361,6 +384,18 @@ void Canvas::disable_triple_click() {
triple_click_possible = false;
}
void Canvas::swap_selection_and_panning_buttons() {
Qt::MouseButton tmp = drag_view_button;
drag_view_button = select_text_button;
select_text_button = tmp;
if (drag_view_button == Qt::LeftButton) {
setCursor(Qt::OpenHandCursor);
} else {
setCursor(Qt::IBeamCursor);
}
}
void Canvas::set_search_visible(bool visible) {
cur_layout->set_search_visible(visible);
......
......@@ -64,6 +64,8 @@ private slots:
void disable_triple_click();
void swap_selection_and_panning_buttons();
private:
void setup_keys(QWidget *base);
......
......@@ -79,6 +79,7 @@ CFG::CFG() :
keys["jump_forward"] = QStringList() << "Ctrl+I" << "Alt+Right";
keys["mark_jump"] = QStringList() << "M";
keys["toggle_invert_colors"] = QStringList() << "I";
keys["swap_selection_and_panning_buttons"] = QStringList() << "V";
// viewer keys
keys["toggle_fullscreen"] = QStringList() << "F";
keys["close_search"] = QStringList() << "Esc";
......
Supports Markdown
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