Commit 38d419eb authored by Carl Schwan's avatar Carl Schwan 🚴
Browse files

Add unread count



Signed-off-by: Carl Schwan's avatarCarl Schwan <carl@carlschwan.eu>
parent cc644cc0
Pipeline #226837 passed with stage
in 2 minutes and 56 seconds
......@@ -10,6 +10,8 @@ target_sources(kalendar_mail_plugin PUBLIC
mailmanager.h
mailmodel.cpp
mailmodel.h
helper.h
helper.cpp
messagestatus.h
messagestatus.cpp
......
// SPDX-FileCopyrightText: 2022 Carl Schwan <carlschwan@kde.org>
// SPDX-License-Identifier: LGPL-2.0-or-later
#include "helper.h"
#include <Akonadi/CollectionStatistics>
qint64 MailCollectionHelper::unreadCount(const Akonadi::Collection &collection)
{
return collection.statistics().unreadCount();
}
// SPDX-FileCopyrightText: 2022 Carl Schwan <carlschwan@kde.org>
// SPDX-License-Identifier: LGPL-2.0-or-later
#include <Akonadi/Collection>
#include <QObject>
class MailCollectionHelper : public QObject
{
Q_OBJECT
public:
Q_INVOKABLE qint64 unreadCount(const Akonadi::Collection &collection);
};
......@@ -7,6 +7,7 @@
#include <QQmlEngine>
#include <QtQml>
#include "helper.h"
#include "mailmanager.h"
#include "mailmodel.h"
#include "mime/htmlutils.h"
......@@ -28,6 +29,12 @@ void CalendarPlugin::registerTypes(const char *uri)
return new HtmlUtils::HtmlUtils;
});
qmlRegisterSingletonType<MailCollectionHelper>("org.kde.kalendar.mail", 1, 0, "MailCollectionHelper", [](QQmlEngine *engine, QJSEngine *scriptEngine) {
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
return new MailCollectionHelper;
});
qmlRegisterType<MessageParser>(uri, 1, 0, "MessageParser");
qRegisterMetaType<MailModel *>("MailModel*");
......
......@@ -152,6 +152,23 @@ ListView {
Layout.alignment: Qt.AlignLeft
Layout.fillWidth: true
}
QQC2.Label {
property int unreadCount: MailCollectionHelper.unreadCount(model.collection)
text: unreadCount
visible: unreadCount > 0
padding: Kirigami.Units.smallSpacing
color: Kirigami.Theme.textColor
Layout.minimumWidth: height
horizontalAlignment: Text.AlignHCenter
background: Rectangle {
visible: unreadCount > 0
Kirigami.Theme.colorSet: Kirigami.Theme.Button
color: Kirigami.Theme.disabledTextColor
opacity: 0.3
radius: height / 2
}
}
}
onClicked: {
......
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