Commit c857e08f authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

TabBar: Allow to configure tab scrollability and text eliding

With a large limit the UI might break, thus having an option to allow
scrolling is necessary.
parent 50d07aa4
Pipeline #135305 passed with stage
in 3 minutes and 26 seconds
......@@ -120,6 +120,8 @@ void KateConfigDialog::addBehaviorPage()
m_tabLimit->setValue(cgGeneral.readEntry("Tabbar Tab Limit", 0));
connect(m_tabLimit, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &KateConfigDialog::slotChanged);
vbox->addLayout(hlayout);
vbox->addWidget(
new QLabel(i18n("A high limit can increase the window size, please enable 'Allow tab scrolling' to prevent it. Unlimited tabs are always scrollable.")));
m_showTabCloseButton = new QCheckBox(i18n("&Show close button"), buttonGroup);
m_showTabCloseButton->setChecked(cgGeneral.readEntry("Show Tabs Close Button", true));
......@@ -145,6 +147,18 @@ void KateConfigDialog::addBehaviorPage()
connect(m_tabMiddleClickCloseDocument, &QCheckBox::toggled, this, &KateConfigDialog::slotChanged);
vbox->addWidget(m_tabMiddleClickCloseDocument);
m_tabsScrollable = new QCheckBox(i18n("Allow tab scrolling"), this);
m_tabsScrollable->setChecked(cgGeneral.readEntry("Allow Tab Scrolling", false));
m_tabsScrollable->setToolTip(i18n("When checked this will allow scrolling in tab bar when number of tabs are large."));
connect(m_tabsScrollable, &QCheckBox::toggled, this, &KateConfigDialog::slotChanged);
vbox->addWidget(m_tabsScrollable);
m_tabsElided = new QCheckBox(i18n("Elide tab text"), this);
m_tabsElided->setChecked(cgGeneral.readEntry("Elide Tab Text", false));
m_tabsElided->setToolTip(i18n("When checked tab text might be elided if its too long."));
connect(m_tabsElided, &QCheckBox::toggled, this, &KateConfigDialog::slotChanged);
vbox->addWidget(m_tabsElided);
layout->addWidget(buttonGroup);
layout->addStretch(1); // :-] works correct without autoadd
......@@ -351,6 +365,9 @@ void KateConfigDialog::slotApply()
cg.writeEntry("Tab Double Click New Document", m_tabDoubleClickNewDocument->isChecked());
cg.writeEntry("Tab Middle Click Close Document", m_tabMiddleClickCloseDocument->isChecked());
cg.writeEntry("Allow Tab Scrolling", m_tabsScrollable->isChecked());
cg.writeEntry("Elide Tab Text", m_tabsElided->isChecked());
// patch document modified warn state
const QList<KTextEditor::Document *> &docs = KateApp::self()->documentManager()->documentList();
for (KTextEditor::Document *doc : docs) {
......
......@@ -85,6 +85,8 @@ private:
QCheckBox *m_expandTabs;
QCheckBox *m_tabDoubleClickNewDocument;
QCheckBox *m_tabMiddleClickCloseDocument;
QCheckBox *m_tabsScrollable = nullptr;
QCheckBox *m_tabsElided = nullptr;
Ui::SessionConfigWidget sessionConfigUi;
......
......@@ -71,10 +71,10 @@ void KateTabBar::readConfig()
m_tabCountLimit = (tabCountLimit <= 0) ? 0 : tabCountLimit;
// use scroll buttons if we have no limit
setUsesScrollButtons(m_tabCountLimit == 0);
setUsesScrollButtons(m_tabCountLimit == 0 || cgGeneral.readEntry("Allow Tab Scrolling", false));
// elide if we have some limit
setElideMode((m_tabCountLimit == 0) ? Qt::ElideNone : Qt::ElideMiddle);
setElideMode((m_tabCountLimit == 0 || !cgGeneral.readEntry("Elide Tab Text", false)) ? Qt::ElideNone : Qt::ElideMiddle);
const std::vector<int> documentTabIndexes = this->documentTabIndexes();
......
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