aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Haumann <dhaumann@kde.org>2014-01-25 16:55:17 (GMT)
committerDominik Haumann <dhaumann@kde.org>2014-01-25 16:55:17 (GMT)
commit06168866c65fa65267dd00a8cd8321230371968c (patch)
tree4da29efb53bc8f25341c311289f9cb4206fa65ae
parent6d70b7b4300c99ea3719cfc9378d3230b9ad38ec (diff)
double click in empty space of tab bar crates new empty document
-rw-r--r--kate/src/katetabbar.cpp9
-rw-r--r--kate/src/katetabbar.h10
-rw-r--r--kate/src/katetabbutton.cpp5
-rw-r--r--kate/src/katetabbutton.h8
-rw-r--r--kate/src/kateviewspace.cpp15
-rw-r--r--kate/src/kateviewspace.h5
6 files changed, 48 insertions, 4 deletions
diff --git a/kate/src/katetabbar.cpp b/kate/src/katetabbar.cpp
index 4d29d77..5d385e3 100644
--- a/kate/src/katetabbar.cpp
+++ b/kate/src/katetabbar.cpp
@@ -434,3 +434,12 @@ int KateTabBar::maxTabCount() const
{
return qMax(1, width() / m_minimumTabWidth);
}
+
+/**
+ * Override to request a new tab.
+ */
+void KateTabBar::mouseDoubleClickEvent(QMouseEvent *event)
+{
+ event->accept();
+ emit newTabRequested();
+}
diff --git a/kate/src/katetabbar.h b/kate/src/katetabbar.h
index 12b52bc..b3b7acb 100644
--- a/kate/src/katetabbar.h
+++ b/kate/src/katetabbar.h
@@ -127,13 +127,21 @@ Q_SIGNALS:
*/
void lessTabsRequested(int count);
+ /**
+ * This signal is emitted whenever the users double clicks on the free
+ * space next to the tab bar. Typically, a new document should be
+ * created.
+ */
+ void newTabRequested();
+
protected Q_SLOTS:
void tabButtonActivated(KateTabButton *tabButton);
void tabButtonHighlightChanged(KateTabButton *tabButton);
void tabButtonCloseRequest(KateTabButton *tabButton);
protected:
- virtual void resizeEvent(QResizeEvent *event);
+ void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
+ void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
protected:
void updateButtonPositions();
diff --git a/kate/src/katetabbutton.cpp b/kate/src/katetabbutton.cpp
index f30e474..3c7a3dc 100644
--- a/kate/src/katetabbutton.cpp
+++ b/kate/src/katetabbutton.cpp
@@ -266,6 +266,11 @@ void KateTabButton::mousePressEvent(QMouseEvent *ev)
}
}
+void KateTabButton::mouseDoubleClickEvent(QMouseEvent *event)
+{
+ event->accept();
+}
+
void KateTabButton::setHighlightColor(const QColor &color)
{
if (color.isValid()) {
diff --git a/kate/src/katetabbutton.h b/kate/src/katetabbutton.h
index 3dddb33..343954c 100644
--- a/kate/src/katetabbutton.h
+++ b/kate/src/katetabbutton.h
@@ -118,11 +118,13 @@ protected Q_SLOTS:
protected:
/** paint eyecandy rectangles around the button */
- virtual void paintEvent(QPaintEvent *ev);
+ void paintEvent(QPaintEvent *ev) Q_DECL_OVERRIDE;
/** support for context menu */
- virtual void contextMenuEvent(QContextMenuEvent *ev);
+ void contextMenuEvent(QContextMenuEvent *ev) Q_DECL_OVERRIDE;
/** middle mouse button changes color */
- virtual void mousePressEvent(QMouseEvent *ev);
+ void mousePressEvent(QMouseEvent *ev) Q_DECL_OVERRIDE;
+ /** eat double click events */
+ void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
private:
TabCloseButton * m_closeButton;
diff --git a/kate/src/kateviewspace.cpp b/kate/src/kateviewspace.cpp
index d6740ab..230bb13 100644
--- a/kate/src/kateviewspace.cpp
+++ b/kate/src/kateviewspace.cpp
@@ -62,6 +62,7 @@ KateViewSpace::KateViewSpace(KateViewManager *viewManager,
connect(m_tabBar, &KateTabBar::moreTabsRequested, this, &KateViewSpace::addTabs);
connect(m_tabBar, &KateTabBar::lessTabsRequested, this, &KateViewSpace::removeTabs);
connect(m_tabBar, &KateTabBar::closeTabRequested, this, &KateViewSpace::closeTabRequest);
+ connect(m_tabBar, &KateTabBar::newTabRequested, this, &KateViewSpace::createNewDocument);
hLayout->addWidget(m_tabBar);
// add vertical split view space
@@ -435,6 +436,20 @@ void KateViewSpace::closeTabRequest(int id)
KateApp::self()->documentManager()->closeDocument(doc);
}
+void KateViewSpace::createNewDocument()
+{
+ // make sure we open the view in this view space
+ if (! isActiveSpace()) {
+ m_viewManager->setActiveSpace(this);
+ }
+
+ // create document
+ KTextEditor::Document *doc = KateApp::self()->documentManager()->createDoc();
+
+ // tell the view manager to show the document
+ m_viewManager->activateView(doc);
+}
+
void KateViewSpace::saveConfig(KConfigBase *config, int myIndex , const QString &viewConfGrp)
{
// qCDebug(LOG_KATE)<<"KateViewSpace::saveConfig("<<myIndex<<", "<<viewConfGrp<<") - currentView: "<<currentView()<<")";
diff --git a/kate/src/kateviewspace.h b/kate/src/kateviewspace.h
index 779eabf..94c2906 100644
--- a/kate/src/kateviewspace.h
+++ b/kate/src/kateviewspace.h
@@ -124,6 +124,11 @@ private Q_SLOTS:
*/
void closeTabRequest(int id);
+ /**
+ * Called to create a new empty document.
+ */
+ void createNewDocument();
+
private:
// Kate's view manager
KateViewManager *m_viewManager;