Commit 7a6e8f3b authored by Yunhe Guo's avatar Yunhe Guo

Use breeze icons for categories

Summary:
Before:
{F8163716}
After:
{F8163717}

Reviewers: #plasma, apol

Reviewed By: apol

Subscribers: ngraham, davidre, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D27915
parent 8aa96ac7
......@@ -58,42 +58,6 @@ struct Emoji {
QStringList annotations;
};
class TextImageProvider : public QQuickImageProvider
{
public:
TextImageProvider()
: QQuickImageProvider(QQuickImageProvider::Pixmap)
{
}
QPixmap requestPixmap(const QString &id, QSize *_size, const QSize &requestedSize) override
{
const QString renderString = id.mid(1); //drop initial /
QSize size = requestedSize;
QFont font;
if (!size.isValid()) {
QPixmap dummy;
QFontMetrics fm(font, &dummy);
size = { fm.horizontalAdvance(renderString), fm.height() };
} else {
font.setPointSize((requestedSize.height() * 3) / 4);
}
if (_size) {
*_size = size;
}
QPixmap pixmap(size.width(), size.height());
pixmap.fill(Qt::transparent);
QPainter p;
p.begin(&pixmap);
p.setFont(font);
p.drawText(QRect(0, 0, size.width(), size.height()), Qt::AlignCenter, renderString);
p.end();
return pixmap;
}
};
class AbstractEmojiModel : public QAbstractListModel
{
Q_OBJECT
......@@ -405,7 +369,6 @@ int main(int argc, char** argv)
QQmlApplicationEngine engine;
new EngineWatcher(&engine);
engine.addImageProvider(QLatin1String("text"), new TextImageProvider);
engine.load(QUrl(QStringLiteral("qrc:/ui/emojier.qml")));
QObject::connect(service, &KDBusService::activateRequested, &engine, [&engine](const QStringList &/*arguments*/, const QString &/*workingDirectory*/) {
......
......@@ -21,11 +21,25 @@
import org.kde.kirigami 2.6 as Kirigami
Kirigami.Action {
function getIcon(category) {
switch (category.trim()) {
case 'Activities': return 'games-highscores'
case 'Animals & Nature': return 'animal'
case 'Flags': return 'flag'
case 'Food & Drink': return 'food'
case 'Objects': return 'object'
case 'Smileys & People': return 'smiley'
case 'Symbols': return 'love'
case 'Travel & Places': return 'globe'
default: return 'folder'
}
}
property string category
checked: window.pageStack.get(0).title === text
text: i18nd("ibus10", category) //Get the translation of emoji categories from ibus10.mo installed by ibus
icon.name: "image://text/" + emoji.findFirstEmojiForCategory(category)
icon.name: getIcon(category)
onTriggered: {
window.pageStack.replace("qrc:/ui/CategoryPage.qml", {title: text, category: category, model: emoji })
}
......
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