Commit e01219cc authored by Jan Paul Batrina's avatar Jan Paul Batrina
Browse files

Escape shortcut mnemonic markers (&) in tab texts

By default, automatic accelerators are enabled
(at least in KDE), and thus '&' characters
in tab names are erroneously treated as requests
for accelerators.

BUG: 441340
parent 0dbfebcb
......@@ -1031,7 +1031,10 @@ void KatePluginSearchView::startSearch()
clearMarksAndRanges();
m_curResults->matches = 0;
m_ui.resultTabWidget->setTabText(m_ui.resultTabWidget->currentIndex(), m_ui.searchCombo->currentText());
// BUG: 441340 We need to escape the & because it is used for accelerators/shortcut mnemonic by default
QString tabName = m_ui.searchCombo->currentText();
tabName.replace(QLatin1Char('&'), QLatin1String("&&"));
m_ui.resultTabWidget->setTabText(m_ui.resultTabWidget->currentIndex(), tabName);
m_toolView->setCursor(Qt::WaitCursor);
......@@ -2003,7 +2006,10 @@ void KatePluginSearchView::resultTabChanged(int index)
m_ui.matchCase->blockSignals(true);
m_ui.useRegExp->blockSignals(true);
m_ui.searchPlaceCombo->blockSignals(true);
m_ui.searchCombo->lineEdit()->setText(m_ui.resultTabWidget->tabText(index));
// BUG: 441340 & Characters were escaped so that accelerators are not created, so we need to "unescape" them
QString tabName = m_ui.resultTabWidget->tabText(index);
tabName.replace(QLatin1String("&&"), QLatin1String("&"));
m_ui.searchCombo->lineEdit()->setText(tabName);
m_ui.useRegExp->setChecked(res->useRegExp);
m_ui.matchCase->setChecked(res->matchCase);
m_ui.searchPlaceCombo->setCurrentIndex(res->searchPlaceIndex);
......
......@@ -182,7 +182,10 @@ void KateTabBar::setTabDocument(int idx, KTextEditor::Document *doc)
KateTabButtonData buttonData = data.value<KateTabButtonData>();
buttonData.doc = doc;
setTabData(idx, QVariant::fromValue(buttonData));
setTabText(idx, doc->documentName());
// BUG: 441340 We need to escape the & because it is used for accelerators/shortcut mnemonic by default
QString tabName = doc->documentName();
tabName.replace(QLatin1Char('&'), QLatin1String("&&"));
setTabText(idx, tabName);
setTabToolTip(idx, doc->url().toDisplayString());
setTabIcon(idx, icon);
}
......
......@@ -416,7 +416,10 @@ void KateViewSpace::updateDocumentName(KTextEditor::Document *doc)
// update tab button if available, might not be the case for tab limit set!
const int buttonId = m_tabBar->documentIdx(doc);
if (buttonId >= 0) {
m_tabBar->setTabText(buttonId, doc->documentName());
// BUG: 441278 We need to escape the & because it is used for accelerators/shortcut mnemonic by default
QString tabName = doc->documentName();
tabName.replace(QLatin1Char('&'), QLatin1String("&&"));
m_tabBar->setTabText(buttonId, tabName);
}
}
......
Supports Markdown
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