Commit bbfa7ee9 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

Revert "Make modified doc's tab's text italic"

This reverts commit 7d5ff41a.
parent af2285fb
......@@ -165,7 +165,6 @@ void KateTabBar::mousePressEvent(QMouseEvent *event)
if (!isActive()) {
Q_EMIT activateViewSpaceRequested();
}
m_dragInProgress = false;
if (event->button() == Qt::LeftButton && tabAt(event->pos()) != -1) {
dragStartPos = event->pos();
......@@ -184,12 +183,6 @@ void KateTabBar::mousePressEvent(QMouseEvent *event)
}
}
void KateTabBar::mouseReleaseEvent(QMouseEvent *e)
{
m_dragInProgress = false;
QTabBar::mouseReleaseEvent(e);
}
void KateTabBar::mouseMoveEvent(QMouseEvent *event)
{
if (dragStartPos.isNull()) {
......@@ -203,7 +196,6 @@ void KateTabBar::mouseMoveEvent(QMouseEvent *event)
}
if (rect().contains(event->pos())) {
m_dragInProgress = true;
return QTabBar::mouseMoveEvent(event);
}
......@@ -286,51 +278,6 @@ void KateTabBar::wheelEvent(QWheelEvent *event)
setCurrentIndex(idx);
}
void KateTabBar::paintEvent(QPaintEvent *e)
{
if (m_dragInProgress) {
QTabBar::paintEvent(e);
return;
}
QStylePainter painter(this);
if (drawBase()) {
QStyleOptionTabBarBase opt;
opt.initFrom(this);
opt.documentMode = true;
opt.shape = shape();
for (int i = 0; i < count(); ++i) {
opt.tabBarRect |= tabRect(i);
}
QStyleOptionTab tabOverlap;
tabOverlap.shape = shape();
int overlap = style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, &tabOverlap, this);
opt.rect.setRect(0, size().height() - overlap, size().width(), overlap);
painter.drawPrimitive(QStyle::PE_FrameTabBarBase, opt);
}
const int closeBtnWidth = style()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, nullptr, this);
for (int i = 0; i < count(); i++) {
QStyleOptionTab opt;
initStyleOption(&opt, i);
opt.palette.setColor(QPalette::Button, Qt::red);
painter.drawControl(QStyle::CE_TabBarTabShape, opt);
QFont original = painter.font();
QRect r = tabRect(i);
r.adjust(-closeBtnWidth, 0, 0, 0);
if (tabDocument(i) && tabDocument(i)->isModified()) {
// move it back slightly so the text doesn't jump
auto original = painter.font();
auto copy = original;
copy.setItalic(true);
painter.setFont(copy);
}
painter.drawText(r, Qt::AlignCenter, tabText(i));
painter.setFont(original);
}
}
void KateTabBar::setTabDocument(int idx, KTextEditor::Document *doc)
{
QVariant data = ensureValidTabData(idx);
......
......@@ -129,10 +129,6 @@ protected:
//! Cycle through tabs
void wheelEvent(QWheelEvent *event) override;
void paintEvent(QPaintEvent *) override;
void mouseReleaseEvent(QMouseEvent *e) override;
private:
using QTabBar::addTab;
using QTabBar::insertTab;
......@@ -174,8 +170,6 @@ private:
std::unordered_map<KTextEditor::Document *, std::pair<quint64, bool>> m_docToLruCounterAndHasTab;
QPoint dragStartPos;
bool m_dragInProgress = false;
};
#endif // KATE_TAB_BAR_H
......@@ -516,12 +516,7 @@ void KateViewSpace::registerDocument(KTextEditor::Document *doc)
*/
connect(doc, &KTextEditor::Document::documentNameChanged, this, &KateViewSpace::updateDocumentName);
connect(doc, &KTextEditor::Document::documentUrlChanged, this, &KateViewSpace::updateDocumentUrl);
connect(doc, &KTextEditor::Document::modifiedChanged, this, [this](KTextEditor::Document *doc) {
int tab = m_tabBar->documentIdx(doc);
if (tab >= 0) {
m_tabBar->update(m_tabBar->tabRect(tab));
}
});
connect(doc, &KTextEditor::Document::modifiedChanged, this, &KateViewSpace::updateDocumentName);
/**
* allow signals again, now that the tab is there
......@@ -687,6 +682,9 @@ void KateViewSpace::updateDocumentName(KTextEditor::Document *doc)
// 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("&&"));
if (doc->isModified()) {
tabName.append(QStringLiteral(" *"));
}
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