summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Mi <codeminister@publicstatic.de>2014-01-24 14:29:28 (GMT)
committerGregor Mi <codeminister@publicstatic.de>2014-01-24 14:29:28 (GMT)
commit37e61d64087158fee24855b0b58cd0b01da44483 (patch)
tree8efec31408438dec423fada4ec539c57ee136489
parented0db93ee61ab838735ac33966bcfa564c973f21 (diff)
Statusbar: doubleclick on insert mode label toggles between INSERT and OVERWRITE.
In VI mode: do nothing
-rw-r--r--src/view/katestatusbar.cpp18
-rw-r--r--src/view/katestatusbar.h3
-rw-r--r--src/view/kateview.cpp5
-rw-r--r--src/view/kateview.h2
4 files changed, 28 insertions, 0 deletions
diff --git a/src/view/katestatusbar.cpp b/src/view/katestatusbar.cpp
index 3a581ff..90b6566 100644
--- a/src/view/katestatusbar.cpp
+++ b/src/view/katestatusbar.cpp
@@ -178,6 +178,7 @@ KateStatusBar::KateStatusBar(KTextEditor::ViewPrivate *view)
topLayout->addSpacing(style()->pixelMetric(QStyle::PM_ScrollBarExtent, &option, this));
// signals for the statusbar
+ m_insertModeLabel->installEventFilter(this); // register for doubleclick
connect(m_view, SIGNAL(cursorPositionChanged(KTextEditor::View*,KTextEditor::Cursor)), this, SLOT(cursorPositionChanged()));
connect(m_view, SIGNAL(viewModeChanged(KTextEditor::View*)), this, SLOT(viewModeChanged()));
connect(m_view, SIGNAL(selectionChanged(KTextEditor::View*)), this, SLOT(selectionChanged()));
@@ -192,6 +193,23 @@ KateStatusBar::KateStatusBar(KTextEditor::ViewPrivate *view)
updateStatus ();
}
+bool KateStatusBar::eventFilter(QObject *obj, QEvent *event)
+{
+ if (obj == m_insertModeLabel) {
+ if (event->type() == QEvent::MouseButtonDblClick) {
+ if (m_view->isViInputMode()) {
+ // m_view->toggleViInputMode(); // in VI Input mode: do nothing
+ }
+ else {
+ m_view->toggleInsert();
+ }
+ return true;
+ }
+ }
+
+ return KateViewBarWidget::eventFilter(obj, event);
+}
+
void KateStatusBar::updateStatus ()
{
selectionChanged ();
diff --git a/src/view/katestatusbar.h b/src/view/katestatusbar.h
index 4c209c6..187ef69 100644
--- a/src/view/katestatusbar.h
+++ b/src/view/katestatusbar.h
@@ -62,6 +62,9 @@ public Q_SLOTS:
void modeChanged ();
+protected:
+ bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE;
+
private:
KTextEditor::ViewPrivate *const m_view;
QLabel* m_lineColLabel;
diff --git a/src/view/kateview.cpp b/src/view/kateview.cpp
index bc3d74c..199f6c9 100644
--- a/src/view/kateview.cpp
+++ b/src/view/kateview.cpp
@@ -1153,6 +1153,11 @@ QString KTextEditor::ViewPrivate::viewMode() const
return currentMode;
}
+bool KTextEditor::ViewPrivate::isViInputMode() const
+{
+ return viInputMode();
+}
+
void KTextEditor::ViewPrivate::slotGotFocus()
{
//qCDebug(LOG_PART) << "KTextEditor::ViewPrivate::slotGotFocus";
diff --git a/src/view/kateview.h b/src/view/kateview.h
index 7dc8521..de0bcfb 100644
--- a/src/view/kateview.h
+++ b/src/view/kateview.h
@@ -119,6 +119,8 @@ public:
QString viewMode() const;
+ bool isViInputMode() const;
+
//
// KTextEditor::ClipboardInterface
//