Commit 008ea3de authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Show recent tab

parent 22b47f62
Pipeline #81478 passed with stage
in 7 minutes and 6 seconds
......@@ -52,6 +52,7 @@ void EmoticonRecentUsedFilterProxyModel::setUsedIdentifier(const QStringList &us
writeRecentUsed();
invalidateFilter();
}
Q_EMIT usedIdentifierChanged(!mUsedIdentifier.isEmpty());
}
void EmoticonRecentUsedFilterProxyModel::addIdentifier(const QString &identifier)
......@@ -61,6 +62,7 @@ void EmoticonRecentUsedFilterProxyModel::addIdentifier(const QString &identifier
writeRecentUsed();
invalidateFilter();
}
Q_EMIT usedIdentifierChanged(!mUsedIdentifier.isEmpty());
}
bool EmoticonRecentUsedFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
......
......@@ -27,6 +27,9 @@ public:
protected:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
Q_SIGNALS:
void usedIdentifierChanged(bool isNotEmpty);
private:
void writeRecentUsed();
QStringList mUsedIdentifier;
......
......@@ -6,6 +6,7 @@
#include "emoticonunicodetab.h"
#include "emoticonlistview.h"
#include "emoticonrecentlistview.h"
#include "emoticonrecentusedfilterproxymodel.h"
#include "emoticonunicodemodel.h"
#include "emoticonunicodemodelmanager.h"
......@@ -25,6 +26,7 @@ EmoticonUnicodeTab::EmoticonUnicodeTab(QWidget *parent)
f.setPointSize(22);
f.setFamily(QStringLiteral("NotoColorEmoji"));
setFont(f);
connect(mEmoticonUnicodeRecentProxyModel, &EmoticonRecentUsedFilterProxyModel::usedIdentifierChanged, this, &EmoticonUnicodeTab::slotUsedIdentifierChanged);
}
EmoticonUnicodeTab::~EmoticonUnicodeTab()
......@@ -50,19 +52,22 @@ void EmoticonUnicodeTab::createSearchTab()
allEmojisView->setModel(mEmoticonUnicodeSearchProxyModel);
mSearchTabIndex = addTab(allEmojisView, QIcon::fromTheme(QStringLiteral("edit-find")), {});
setTabToolTip(mSearchTabIndex, i18n("Result"));
connect(allEmojisView, &KPIMTextEdit::EmoticonListView::emojiItemSelected, this, &EmoticonUnicodeTab::itemSelected);
connect(allEmojisView, &KPIMTextEdit::EmoticonListView::emojiItemSelected, this, &EmoticonUnicodeTab::slotInsertEmoticons);
}
void EmoticonUnicodeTab::createRecentTab()
{
auto recentEmojisView = new EmoticonListView(this);
auto recentEmojisView = new EmoticonRecentListView(this);
mEmoticonUnicodeRecentProxyModel->setSourceModel(EmoticonUnicodeModelManager::self()->emoticonUnicodeModel());
recentEmojisView->setModel(mEmoticonUnicodeRecentProxyModel);
mRecentTabIndex = addTab(recentEmojisView, QIcon::fromTheme(QStringLiteral("edit-find")), {});
setTabToolTip(mSearchTabIndex, i18n("Recents"));
connect(recentEmojisView, &KPIMTextEdit::EmoticonListView::emojiItemSelected, this, &EmoticonUnicodeTab::itemSelected);
// TODO show or not recent tab
mRecentTabIndex = addTab(recentEmojisView, QIcon::fromTheme(QStringLiteral("deep-history")), {});
setTabToolTip(mRecentTabIndex, i18n("Recents"));
connect(recentEmojisView, &EmoticonRecentListView::clearAll, this, [this]() {
mEmoticonUnicodeRecentProxyModel->setUsedIdentifier(QStringList());
});
// Recent tab => not add in mEmoticonUnicodeRecentProxyModel => use itemSelected directly
connect(recentEmojisView, &EmoticonRecentListView::emojiItemSelected, this, &EmoticonUnicodeTab::itemSelected);
}
void EmoticonUnicodeTab::createEmoticonTab(const QString &str, const QVector<EmoticonUnicodeUtils::EmoticonStruct> &emoticons)
......@@ -80,7 +85,7 @@ void EmoticonUnicodeTab::createEmoticonTab(const QString &str, const QVector<Emo
if (!str.isEmpty()) {
setTabToolTip(index, str);
}
connect(emojisView, &KPIMTextEdit::EmoticonListView::emojiItemSelected, this, &EmoticonUnicodeTab::itemSelected);
connect(emojisView, &KPIMTextEdit::EmoticonListView::emojiItemSelected, this, &EmoticonUnicodeTab::slotInsertEmoticons);
}
}
......@@ -122,5 +127,16 @@ void EmoticonUnicodeTab::loadEmoticons()
createEmoticonTab(i18n("Hotel"), EmoticonUnicodeUtils::unicodeHotelEmoji());
createEmoticonTab(i18n("Award-Medal"), EmoticonUnicodeUtils::unicodeAwardMedalEmoji());
setTabVisible(mSearchTabIndex, false);
setTabVisible(mRecentTabIndex, false);
setTabVisible(mRecentTabIndex, !mEmoticonUnicodeRecentProxyModel->usedIdentifier().isEmpty());
}
void EmoticonUnicodeTab::slotInsertEmoticons(const QString &identifier)
{
mEmoticonUnicodeRecentProxyModel->addIdentifier(identifier);
Q_EMIT itemSelected(identifier);
}
void EmoticonUnicodeTab::slotUsedIdentifierChanged(bool show)
{
setTabVisible(mRecentTabIndex, show);
}
......@@ -36,6 +36,8 @@ private:
void createEmoticonTab(const QString &str, const QVector<EmoticonUnicodeUtils::EmoticonStruct> &emoticons);
void createSearchTab();
void createRecentTab();
void slotInsertEmoticons(const QString &identifier);
void slotUsedIdentifierChanged(bool show);
EmoticonUnicodeProxyModel *const mEmoticonUnicodeSearchProxyModel;
EmoticonRecentUsedFilterProxyModel *const mEmoticonUnicodeRecentProxyModel;
int mSearchTabIndex = -1;
......
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