Commit 016a61ec authored by Dominik Haumann's avatar Dominik Haumann

allow to close a document via context menu

parent 1876076d
......@@ -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();
}
}
......
......@@ -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();
......
......@@ -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()<<")";
......
......@@ -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;
......
Markdown is supported
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