Commit 3893e288 authored by Ghislain MARY's avatar Ghislain MARY

Implement display of unread messages count on the application icon in the dock on Mac OS X.

parent 5a296211
......@@ -203,6 +203,9 @@ set(HEADERS
src/utils/Utils.hpp
)
if(APPLE)
list(APPEND SOURCES src/components/core/MessagesCountNotifierMacOS.m)
endif()
if(ENABLE_DBUS)
list(APPEND SOURCES src/app/single-application/SingleApplicationDBus.cpp)
list(APPEND HEADERS src/app/single-application/SingleApplicationDBusPrivate.hpp)
......@@ -348,6 +351,9 @@ foreach (package ${QT5_PACKAGES_OPTIONAL})
endforeach ()
target_link_libraries(${TARGET_NAME} ${BCTOOLBOX_CORE_LIBRARIES} ${BELCARD_LIBRARIES} ${LINPHONE_LIBRARIES} ${LINPHONECXX_LIBRARIES})
if(APPLE)
target_link_libraries(${TARGET_NAME} "-framework Cocoa")
endif()
install(TARGETS ${TARGET_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
......
......@@ -24,6 +24,14 @@
#include "MessagesCountNotifier.hpp"
#if defined(Q_OS_LINUX)
// TODO.
#elif defined(Q_OS_MACOS)
#include "MessagesCountNotifierMacOS.h"
#elif defined(Q_OS_WIN)
// TODO.
#endif
using namespace std;
// =============================================================================
......@@ -58,10 +66,10 @@ void MessagesCountNotifier::notifyUnreadMessagesCount () {
#if defined(Q_OS_LINUX)
// TODO.
#elif defined(Q_OS_MACOS)
// TODO.
::notifyUnreadMessagesCountMacOS(mUnreadMessagesCount);
#elif defined(Q_OS_WIN)
// TODO.
#endif // ifdef Q_OS_LINUX
#endif
}
// -----------------------------------------------------------------------------
......
/*
* MessagesCountNotifierMacOS.h
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: June 30, 2017
* Author: Ghislain MARY
*/
// =============================================================================
extern "C" void notifyUnreadMessagesCountMacOS(int count);
/*
* MessagesCountNotifierMacOS.m
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: June 30, 2017
* Author: Ghislain MARY
*/
#import <Cocoa/Cocoa.h>
// =============================================================================
void notifyUnreadMessagesCountMacOS(int count) {
NSString *badgeStr = (count > 0) ? [NSString stringWithFormat:@"%d", count] : @"";
[[NSApp dockTile] setBadgeLabel:badgeStr];
}
Markdown is supported
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