Commit 40386499 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Show tooltip too

parent 17f0ac4d
Pipeline #80875 passed with stage
in 7 minutes and 9 seconds
......@@ -9,10 +9,11 @@
using namespace KPIMTextEdit;
EmoticonTextEditItem::EmoticonTextEditItem(const QString &emoticonText, QListWidget *parent)
EmoticonTextEditItem::EmoticonTextEditItem(const QString &emoticonText, const QString &tooltip, QListWidget *parent)
: QListWidgetItem(emoticonText, parent)
, mText(emoticonText)
{
setToolTip(tooltip);
}
QString EmoticonTextEditItem::text() const
......@@ -48,10 +49,10 @@ void EmoticonListWidgetSelector::slotMouseOverItem(QListWidgetItem *item)
}
}
void EmoticonListWidgetSelector::setEmoticons(const QStringList &lst)
void EmoticonListWidgetSelector::setEmoticons(const QVector<EmoticonUnicodeUtils::EmoticonStruct> &emoticons)
{
for (const QString &emoji : lst) {
new KPIMTextEdit::EmoticonTextEditItem(emoji, this);
for (const auto &emoji : emoticons) {
new KPIMTextEdit::EmoticonTextEditItem(emoji.emoticonCode, emoji.emoticonName, this);
}
}
......
......@@ -6,6 +6,7 @@
#pragma once
#include "emoticonunicodeutils.h"
#include "kpimtextedit_private_export.h"
#include <QListWidget>
......@@ -14,7 +15,7 @@ namespace KPIMTextEdit
class KPIMTEXTEDIT_TESTS_EXPORT EmoticonTextEditItem : public QListWidgetItem
{
public:
explicit EmoticonTextEditItem(const QString &emoticonText, QListWidget *parent);
explicit EmoticonTextEditItem(const QString &emoticonText, const QString &tooltip, QListWidget *parent);
Q_REQUIRED_RESULT QString text() const;
private:
......@@ -28,7 +29,7 @@ public:
explicit EmoticonListWidgetSelector(QWidget *parent = nullptr);
~EmoticonListWidgetSelector() override;
void setEmoticons(const QStringList &lst);
void setEmoticons(const QVector<EmoticonUnicodeUtils::EmoticonStruct> &emoticons);
Q_SIGNALS:
void itemSelected(const QString &);
......
......@@ -72,13 +72,8 @@ void EmoticonUnicodeTab::createPlainTextEmoticonTab(const QString &str, const QV
if (!emoticons.isEmpty()) {
auto selector = new EmoticonListWidgetSelector(this);
connect(selector, &KPIMTextEdit::EmoticonListWidgetSelector::itemSelected, this, &EmoticonUnicodeTab::itemSelected);
QStringList lst;
lst.reserve(emoticons.count());
for (const EmoticonUnicodeUtils::EmoticonStruct &emoji : emoticons) {
lst.append(emoji.emoticonCode);
}
selector->setEmoticons(lst);
const QString strTab = lst.first();
selector->setEmoticons(emoticons);
const QString strTab = emoticons.first().emoticonCode;
const int index = addTab(selector, strTab);
if (!str.isEmpty()) {
setTabToolTip(index, str);
......
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