Use newly introduced setBadgeNumber api on Qt >= 6.6
This commit is contained in:
@@ -10,11 +10,13 @@
|
|||||||
#include "user.h"
|
#include "user.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
|
||||||
#ifndef Q_OS_ANDROID
|
#ifndef Q_OS_ANDROID
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QDBusInterface>
|
#include <QDBusInterface>
|
||||||
#include <QDBusMessage>
|
#include <QDBusMessage>
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
@@ -29,15 +31,6 @@ using namespace Quotient;
|
|||||||
|
|
||||||
Q_DECLARE_METATYPE(Quotient::JoinState)
|
Q_DECLARE_METATYPE(Quotient::JoinState)
|
||||||
|
|
||||||
#ifndef Q_OS_ANDROID
|
|
||||||
bool useUnityCounter()
|
|
||||||
{
|
|
||||||
static const auto Result = QDBusInterface("com.canonical.Unity", "/").isValid();
|
|
||||||
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
RoomListModel::RoomListModel(QObject *parent)
|
RoomListModel::RoomListModel(QObject *parent)
|
||||||
: QAbstractListModel(parent)
|
: QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
@@ -46,9 +39,9 @@ RoomListModel::RoomListModel(QObject *parent)
|
|||||||
m_categoryVisibility[collapsedSection] = false;
|
m_categoryVisibility[collapsedSection] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef Q_OS_ANDROID
|
|
||||||
connect(this, &RoomListModel::notificationCountChanged, this, [this]() {
|
connect(this, &RoomListModel::notificationCountChanged, this, [this]() {
|
||||||
if (useUnityCounter()) {
|
#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
|
||||||
|
#ifndef Q_OS_ANDROID
|
||||||
// copied from Telegram desktop
|
// copied from Telegram desktop
|
||||||
const auto launcherUrl = "application://org.kde.neochat.desktop";
|
const auto launcherUrl = "application://org.kde.neochat.desktop";
|
||||||
// Gnome requires that count is a 64bit integer
|
// Gnome requires that count is a 64bit integer
|
||||||
@@ -67,9 +60,11 @@ RoomListModel::RoomListModel(QObject *parent)
|
|||||||
signal.setArguments({launcherUrl, dbusUnityProperties});
|
signal.setArguments({launcherUrl, dbusUnityProperties});
|
||||||
|
|
||||||
QDBusConnection::sessionBus().send(signal);
|
QDBusConnection::sessionBus().send(signal);
|
||||||
}
|
#endif // Q_OS_ANDROID
|
||||||
|
#else
|
||||||
|
qGuiApp->setBadgeNumber(m_notificationCount);
|
||||||
|
#endif // QT_VERSION_CHECK(6, 6, 0)
|
||||||
});
|
});
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomListModel::~RoomListModel() = default;
|
RoomListModel::~RoomListModel() = default;
|
||||||
|
|||||||
Reference in New Issue
Block a user