Commit 349d8296 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

allow to configure if double/middle click shall open/close stuff in tabbar

BUG: 426982
parent 606bac41
......@@ -156,6 +156,18 @@ void KateConfigDialog::addBehaviorPage()
connect(m_expandTabs, &QCheckBox::toggled, this, &KateConfigDialog::slotChanged);
vbox->addWidget(m_expandTabs);
m_tabDoubleClickNewDocument = new QCheckBox(i18n("&Double click opens a new document"), buttonGroup);
m_tabDoubleClickNewDocument->setChecked(cgGeneral.readEntry("Tab Double Click New Document", true));
m_tabDoubleClickNewDocument->setToolTip(i18n("When checked double click opens a new document."));
connect(m_tabDoubleClickNewDocument, &QCheckBox::toggled, this, &KateConfigDialog::slotChanged);
vbox->addWidget(m_tabDoubleClickNewDocument);
m_tabMiddleClickCloseDocument = new QCheckBox(i18n("&Middle click closes a document"), buttonGroup);
m_tabMiddleClickCloseDocument->setChecked(cgGeneral.readEntry("Tab Middle Click Close Document", true));
m_tabMiddleClickCloseDocument->setToolTip(i18n("When checked middle click closes a document."));
connect(m_tabMiddleClickCloseDocument, &QCheckBox::toggled, this, &KateConfigDialog::slotChanged);
vbox->addWidget(m_tabMiddleClickCloseDocument);
layout->addWidget(buttonGroup);
layout->addStretch(1); // :-] works correct without autoadd
......@@ -360,6 +372,9 @@ void KateConfigDialog::slotApply()
cg.writeEntry("Expand Tabs", m_expandTabs->isChecked());
cg.writeEntry("Tab Double Click New Document", m_tabDoubleClickNewDocument->isChecked());
cg.writeEntry("Tab Middle Click Close Document", m_tabMiddleClickCloseDocument->isChecked());
// patch document modified warn state
const QList<KTextEditor::Document *> &docs = KateApp::self()->documentManager()->documentList();
for (KTextEditor::Document *doc : docs)
......
......@@ -84,6 +84,8 @@ private:
QSpinBox *m_tabLimit;
QCheckBox *m_showTabCloseButton;
QCheckBox *m_expandTabs;
QCheckBox *m_tabDoubleClickNewDocument;
QCheckBox *m_tabMiddleClickCloseDocument;
Ui::SessionConfigWidget sessionConfigUi;
......
......@@ -78,6 +78,10 @@ void KateTabBar::readConfig()
// handle tab close button and expansion
setExpanding(cgGeneral.readEntry("Expand Tabs", true));
setTabsClosable(cgGeneral.readEntry("Show Tabs Close Button", true));
// get mouse click rules
m_doubleClickNewDocument = cgGeneral.readEntry("Tab Double Click New Document", true);
m_middleClickCloseDocument = cgGeneral.readEntry("Tab Middle Click Close Document", true);
}
void KateTabBar::setActive(bool active)
......@@ -122,7 +126,10 @@ QVariant KateTabBar::ensureValidTabData(int idx)
void KateTabBar::mouseDoubleClickEvent(QMouseEvent *event)
{
event->accept();
emit newTabRequested();
if (m_doubleClickNewDocument) {
emit newTabRequested();
}
}
void KateTabBar::mousePressEvent(QMouseEvent *event)
......@@ -133,7 +140,7 @@ void KateTabBar::mousePressEvent(QMouseEvent *event)
QTabBar::mousePressEvent(event);
// handle close for middle mouse button
if (event->button() == Qt::MiddleButton) {
if (m_middleClickCloseDocument && event->button() == Qt::MiddleButton) {
int id = tabAt(event->pos());
if (id >= 0) {
emit tabCloseRequested(id);
......
......@@ -141,6 +141,16 @@ private:
*/
quint64 m_lruCounter = 0;
/**
* should a double click create a new document?
*/
bool m_doubleClickNewDocument = false;
/*
* should a middle click close a document?
*/
bool m_middleClickCloseDocument = false;
/**
* LRU counter storage, to determine which document has which age
* simple 64-bit counter, worst thing that can happen on 64-bit wraparound
......
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