mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Show unread count on MacOs toolbar
This commit is contained in:
parent
97ca8d0ed1
commit
06cacc13d1
2 changed files with 19 additions and 0 deletions
|
@ -8,6 +8,10 @@ find_package(Qt5Widgets REQUIRED)
|
||||||
find_package(Qt5Network REQUIRED)
|
find_package(Qt5Network REQUIRED)
|
||||||
find_package(Qt5LinguistTools REQUIRED)
|
find_package(Qt5LinguistTools REQUIRED)
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
find_package(Qt5MacExtras REQUIRED)
|
||||||
|
endif(APPLE)
|
||||||
|
|
||||||
if (Qt5Widgets_FOUND)
|
if (Qt5Widgets_FOUND)
|
||||||
if (Qt5Widgets_VERSION VERSION_LESS 5.7.0)
|
if (Qt5Widgets_VERSION VERSION_LESS 5.7.0)
|
||||||
message(STATUS "Qt version ${Qt5Widgets_VERSION}")
|
message(STATUS "Qt version ${Qt5Widgets_VERSION}")
|
||||||
|
@ -244,6 +248,10 @@ else()
|
||||||
add_executable (nheko ${OS_BUNDLE} ${SRC_FILES} ${UI_HEADERS} ${MOC_HEADERS} ${QRC} ${LANG_QRC} ${QM_SRC})
|
add_executable (nheko ${OS_BUNDLE} ${SRC_FILES} ${UI_HEADERS} ${MOC_HEADERS} ${QRC} ${LANG_QRC} ${QM_SRC})
|
||||||
target_link_libraries (nheko matrix_events Qt5::Widgets Qt5::Network)
|
target_link_libraries (nheko matrix_events Qt5::Widgets Qt5::Network)
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
target_link_libraries(nheko Qt5::MacExtras)
|
||||||
|
endif(APPLE)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_link_libraries(nheko Qt5::WinMain)
|
target_link_libraries(nheko Qt5::WinMain)
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
|
@ -20,6 +20,10 @@
|
||||||
|
|
||||||
#include "TrayIcon.h"
|
#include "TrayIcon.h"
|
||||||
|
|
||||||
|
#if defined(Q_OS_MAC)
|
||||||
|
#include <QtMacExtras>
|
||||||
|
#endif
|
||||||
|
|
||||||
MsgCountComposedIcon::MsgCountComposedIcon(const QString &filename)
|
MsgCountComposedIcon::MsgCountComposedIcon(const QString &filename)
|
||||||
: QIconEngine()
|
: QIconEngine()
|
||||||
{
|
{
|
||||||
|
@ -91,10 +95,17 @@ TrayIcon::TrayIcon(const QString &filename, QWidget *parent)
|
||||||
|
|
||||||
void TrayIcon::setUnreadCount(int count)
|
void TrayIcon::setUnreadCount(int count)
|
||||||
{
|
{
|
||||||
|
#if defined(Q_OS_MAC)
|
||||||
|
if (count == 0)
|
||||||
|
QtMac::setBadgeLabelText("");
|
||||||
|
else
|
||||||
|
QtMac::setBadgeLabelText(QString::number(count));
|
||||||
|
#else
|
||||||
MsgCountComposedIcon *tmp = static_cast<MsgCountComposedIcon *>(icon_->clone());
|
MsgCountComposedIcon *tmp = static_cast<MsgCountComposedIcon *>(icon_->clone());
|
||||||
tmp->msgCount = count;
|
tmp->msgCount = count;
|
||||||
|
|
||||||
setIcon(QIcon(tmp));
|
setIcon(QIcon(tmp));
|
||||||
|
|
||||||
icon_ = tmp;
|
icon_ = tmp;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue