summary refs log tree commit diff
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-07-01 16:34:36 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-07-01 16:34:36 +0300
commit06cacc13d1ddcc4fb7f9dcd21debe826107fac5a (patch)
treea81199319d787b8aa9d761b60edc7d5ca12d5cd9
parentRemove hardcoded font sizes on the top bars and text input (diff)
downloadnheko-06cacc13d1ddcc4fb7f9dcd21debe826107fac5a.tar.xz
Show unread count on MacOs toolbar
-rw-r--r--CMakeLists.txt8
-rw-r--r--src/TrayIcon.cc11
2 files changed, 19 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt

index 51e1993b..26aaf1ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -8,6 +8,10 @@ find_package(Qt5Widgets REQUIRED) find_package(Qt5Network REQUIRED) find_package(Qt5LinguistTools REQUIRED) +if (APPLE) + find_package(Qt5MacExtras REQUIRED) +endif(APPLE) + if (Qt5Widgets_FOUND) if (Qt5Widgets_VERSION VERSION_LESS 5.7.0) 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}) target_link_libraries (nheko matrix_events Qt5::Widgets Qt5::Network) + if (APPLE) + target_link_libraries(nheko Qt5::MacExtras) + endif(APPLE) + if(WIN32) target_link_libraries(nheko Qt5::WinMain) endif(WIN32) diff --git a/src/TrayIcon.cc b/src/TrayIcon.cc
index beaf00df..7e649077 100644 --- a/src/TrayIcon.cc +++ b/src/TrayIcon.cc
@@ -20,6 +20,10 @@ #include "TrayIcon.h" +#if defined(Q_OS_MAC) +#include <QtMacExtras> +#endif + MsgCountComposedIcon::MsgCountComposedIcon(const QString &filename) : QIconEngine() { @@ -91,10 +95,17 @@ TrayIcon::TrayIcon(const QString &filename, QWidget *parent) 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()); tmp->msgCount = count; setIcon(QIcon(tmp)); icon_ = tmp; +#endif }