aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Haumann <dhaumann@kde.org>2014-01-24 14:28:06 (GMT)
committerDominik Haumann <dhaumann@kde.org>2014-01-24 14:28:06 (GMT)
commit016a61ecc4d83014506e356b77278a734bc20ee9 (patch)
tree171c35f2302bc1391fa799d6ff41da237ec67a39
parent1876076d6f37d82258317556ae0352fb83c5451d (diff)
allow to close a document via context menu
-rw-r--r--kate/src/katetabbutton.cpp8
-rw-r--r--kate/src/katetabbutton.h12
-rw-r--r--kate/src/kateviewspace.cpp8
-rw-r--r--kate/src/kateviewspace.h6
4 files changed, 15 insertions, 19 deletions
diff --git a/kate/src/katetabbutton.cpp b/kate/src/katetabbutton.cpp
index 50c947e..0f6e47d 100644
--- a/kate/src/katetabbutton.cpp
+++ b/kate/src/katetabbutton.cpp
@@ -129,9 +129,7 @@ void KateTabButton::contextMenuEvent(QContextMenuEvent *ev)
QIcon::fromTheme(QStringLiteral("colors")), i18n("C&ustom Color..."));
menu.addSeparator();
- QAction *aCloseTab = menu.addAction(i18n("&Close Tab"));
- QAction *aCloseOtherTabs = menu.addAction(i18n("Close &Other Tabs"));
- QAction *aCloseAllTabs = menu.addAction(i18n("Close &All Tabs"));
+ QAction *aCloseTab = menu.addAction(i18n("&Close Document"));
QAction *choice = menu.exec(ev->globalPos());
@@ -167,10 +165,6 @@ void KateTabButton::contextMenuEvent(QContextMenuEvent *ev)
}
} else if (choice == aCloseTab) {
emit closeRequest(this);
- } else if (choice == aCloseOtherTabs) {
- emit closeOtherTabsRequest(this);
- } else if (choice == aCloseAllTabs) {
- emit closeAllTabsRequest();
}
}
diff --git a/kate/src/katetabbutton.h b/kate/src/katetabbutton.h
index ba27f77..8ee64bf 100644
--- a/kate/src/katetabbutton.h
+++ b/kate/src/katetabbutton.h
@@ -95,18 +95,6 @@ Q_SIGNALS:
*/
void closeRequest(KateTabButton *tabbutton);
- /**
- * Emitted whenever the user wants to close all the tab button except the
- * selected one.
- * @param tabbutton the button that emitted this signal
- */
- void closeOtherTabsRequest(KateTabButton *tabbutton);
-
- /**
- * Emitted whenever the user wants to close all the tabs.
- */
- void closeAllTabsRequest();
-
protected Q_SLOTS:
void buttonClicked();
diff --git a/kate/src/kateviewspace.cpp b/kate/src/kateviewspace.cpp
index f9edc18..3407cdc 100644
--- a/kate/src/kateviewspace.cpp
+++ b/kate/src/kateviewspace.cpp
@@ -60,6 +60,7 @@ KateViewSpace::KateViewSpace(KateViewManager *viewManager,
connect(m_tabBar, &KateTabBar::currentChanged, this, &KateViewSpace::changeView);
connect(m_tabBar, &KateTabBar::moreTabsRequested, this, &KateViewSpace::addTabs);
connect(m_tabBar, &KateTabBar::lessTabsRequested, this, &KateViewSpace::removeTabs);
+ connect(m_tabBar, &KateTabBar::closeTabRequested, this, &KateViewSpace::closeTabRequest, Qt::QueuedConnection);
hLayout->addWidget(m_tabBar);
// add vertical split view space
@@ -393,6 +394,13 @@ void KateViewSpace::updateDocumentName(KTextEditor::Document *doc)
m_tabBar->setTabToolTip(buttonId, doc->url().toDisplayString());
}
+void KateViewSpace::closeTabRequest(int id)
+{
+ KTextEditor::Document *doc = m_docToTabId.key(id);
+ Q_ASSERT(doc);
+ KateApp::self()->documentManager()->closeDocument(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 32e09f1..ccadd7b 100644
--- a/kate/src/kateviewspace.h
+++ b/kate/src/kateviewspace.h
@@ -104,6 +104,12 @@ private Q_SLOTS:
*/
void addTabs(int count);
+ /**
+ * This slot is called by the tabbar, if tab @p id was closed through the
+ * context menu.
+ */
+ void closeTabRequest(int id);
+
private:
// Kate's view manager
KateViewManager *m_viewManager;