Commit 03de44d0 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

try to set mime type icons

parent 7ef4699b
......@@ -14,6 +14,7 @@
#include <QDrag>
#include <QIcon>
#include <QMimeData>
#include <QMimeDatabase>
#include <QPainter>
#include <QPixmap>
#include <QResizeEvent>
......@@ -289,22 +290,19 @@ void KateTabBar::setTabDocument(int idx, KTextEditor::Document *doc)
tabName.replace(QLatin1Char('&'), QLatin1String("&&"));
setTabText(idx, tabName);
setTabToolTip(idx, doc->url().toDisplayString());
setModifiedStateIcon(idx, doc->isModified());
setModifiedStateIcon(idx, doc);
}
void KateTabBar::setModifiedStateIcon(int idx, bool modified)
void KateTabBar::setModifiedStateIcon(int idx, KTextEditor::Document *doc)
{
// empty icon as place holder
if (!modified) {
QImage x(100, 100, QImage::Format_ARGB32_Premultiplied);
x.fill(0);
QIcon i(QPixmap::fromImage(x));
setTabIcon(idx, i);
// simple modified indicator if modified
if (doc->isModified()) {
setTabIcon(idx, QIcon::fromTheme(QStringLiteral("choice-round")));
return;
}
// modified indicator
setTabIcon(idx, QIcon::fromTheme(QStringLiteral("choice-round")));
// else mime-type icon
setTabIcon(idx, QIcon(QMimeDatabase().mimeTypeForName(doc->mimeType()).iconName()));
}
void KateTabBar::setCurrentDocument(KTextEditor::Document *doc)
......
......@@ -64,7 +64,7 @@ public:
void setTabDocument(int idx, KTextEditor::Document *doc);
KTextEditor::Document *tabDocument(int idx);
void removeDocument(KTextEditor::Document *doc);
void setModifiedStateIcon(int idx, bool modified);
void setModifiedStateIcon(int idx, KTextEditor::Document *doc);
/**
* Marks this tabbar as active. That is, current-tab indicators are
......
......@@ -519,7 +519,7 @@ void KateViewSpace::registerDocument(KTextEditor::Document *doc)
connect(doc, &KTextEditor::Document::modifiedChanged, this, [this](KTextEditor::Document *doc) {
int tab = m_tabBar->documentIdx(doc);
if (tab >= 0) {
m_tabBar->setModifiedStateIcon(tab, doc->isModified());
m_tabBar->setModifiedStateIcon(tab, doc);
}
});
......@@ -697,6 +697,7 @@ void KateViewSpace::updateDocumentUrl(KTextEditor::Document *doc)
const int buttonId = m_tabBar->documentIdx(doc);
if (buttonId >= 0) {
m_tabBar->setTabToolTip(buttonId, doc->url().toDisplayString());
m_tabBar->setModifiedStateIcon(buttonId, doc);
}
}
......
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