Commit 33f534a5 authored by Bernhard Liebl's avatar Bernhard Liebl

nicer brush tool tips

parent bcceb784
......@@ -60,11 +60,16 @@ QTextDocument *KisNodeToolTip::createDocument(const QModelIndex &index)
const QString image = QString("<table border=\"1\"><tr><td><img src=\"data:thumbnail\"></td></tr></table>");
const QString body = QString("<h3 align=\"center\">%1</h3>").arg(name)
+ QString("<table><tr><td>%1</td><td>%2</td></tr></table>").arg(image).arg(rows);
+ QString("<p><table><tr><td>%1</td><td>%2</td></tr></table></p>").arg(image).arg(rows);
const QString html = QString("<html><body>%1</body></html>").arg(body);
doc->setHtml(html);
doc->setTextWidth(qMin(doc->size().width(), qreal(500.0)));
const int margin = 16;
doc->setTextWidth(qMin(doc->size().width() + 2 * margin, qreal(500.0)));
doc->setDocumentMargin(margin);
doc->setUseDesignMetrics(true);
return doc;
}
......@@ -25,6 +25,7 @@
#include <QUrl>
#include <KoResourceModel.h>
#include <klocalizedstring.h>
// #include <WidgetsDebug.h>
......@@ -45,12 +46,23 @@ QTextDocument *KoIconToolTip::createDocument( const QModelIndex &index )
QString name = index.data( Qt::DisplayRole ).toString();
const QString image = QString( "<table align=\"center\"><tr><td><img src=\"data:thumbnail\"></td></tr></table>" );
const QString body = QString( "<h3 align=\"center\">%1</h3>%2" ).arg( name ).arg(image);
QString tags;
QString tagsData = index.data( KoResourceModel::TagsRole ).toString();
if (tagsData.length() > 0) {
const QString list = QString( "<ul style=\"list-style-type: none; margin: 0px;\">%1</ul> ").arg(tagsData);
tags = QString("<p><table><tr><td>%1:</td><td>%2</td></tr></table></p>").arg(i18n("Tags"), list);
}
const QString image = QString( "<center><img src=\"data:thumbnail\"></center>");
const QString body = QString( "<h3 align=\"center\">%1</h3>%2%3" ).arg( name, image, tags );
const QString html = QString( "<html><body>%1</body></html>" ).arg( body );
doc->setHtml( html );
doc->setTextWidth( qMin( doc->size().width(), qreal(500.0) ) );
const int margin = 16;
doc->setTextWidth( qMin( doc->size().width() + 2 * margin, qreal(500.0) ) );
doc->setDocumentMargin( margin );
doc->setUseDesignMetrics( true );
return doc;
}
......@@ -85,12 +85,19 @@ QVariant KoResourceModel::data( const QModelIndex &index, int role ) const
return QVariant();
QString resName = i18n( resource->name().toUtf8().data());
return QVariant( resName );
}
case KoResourceModel::TagsRole:
{
KoResource * resource = static_cast<KoResource*>(index.internalPointer());
if( ! resource )
return QVariant();
if (m_resourceAdapter->assignedTagsList(resource).count()) {
QString taglist = m_resourceAdapter->assignedTagsList(resource).join("] , [");
QString tagListToolTip = QString(" - %1: [%2]").arg(i18n("Tags"), taglist);
return QVariant( resName + tagListToolTip );
QString taglist = m_resourceAdapter->assignedTagsList(resource).join("</li><li>");
return QString("<li>%2</li>").arg(taglist);
} else {
return QString();
}
return QVariant( resName );
}
case Qt::DecorationRole:
{
......
......@@ -52,7 +52,8 @@ public:
enum ItemDataRole
{
/// A larger thumbnail for displaying in a tooltip. 200x200 or so.
LargeThumbnailRole = 33
LargeThumbnailRole = Qt::UserRole + 1,
TagsRole
};
QModelIndex indexFromResource(KoResource* resource) const override;
......
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