mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-10-30 09:30:47 +03:00
Remove custom badge counter from mac and windows (#42)
- Add icon set on mac for future packaging
This commit is contained in:
parent
f5ba63946b
commit
b382dfbee6
6 changed files with 102 additions and 9 deletions
26
.gitignore
vendored
26
.gitignore
vendored
|
@ -45,3 +45,29 @@ CMakeCache.txt
|
||||||
CMakeFiles
|
CMakeFiles
|
||||||
cmake_install.cmake
|
cmake_install.cmake
|
||||||
install_manifest.txt
|
install_manifest.txt
|
||||||
|
|
||||||
|
#####=== OSX ===#####
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
|
@ -4,6 +4,9 @@ project(nheko CXX)
|
||||||
|
|
||||||
option(BUILD_TESTS "Build all tests" OFF)
|
option(BUILD_TESTS "Build all tests" OFF)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Discover Qt dependencies.
|
||||||
|
#
|
||||||
find_package(Qt5Widgets REQUIRED)
|
find_package(Qt5Widgets REQUIRED)
|
||||||
find_package(Qt5Network REQUIRED)
|
find_package(Qt5Network REQUIRED)
|
||||||
find_package(Qt5LinguistTools REQUIRED)
|
find_package(Qt5LinguistTools REQUIRED)
|
||||||
|
@ -19,6 +22,9 @@ if (Qt5Widgets_FOUND)
|
||||||
endif()
|
endif()
|
||||||
endif(Qt5Widgets_FOUND)
|
endif(Qt5Widgets_FOUND)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Set up compiler flags.
|
||||||
|
#
|
||||||
set(CMAKE_C_COMPILER gcc)
|
set(CMAKE_C_COMPILER gcc)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
@ -81,6 +87,9 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Declare source and header files.
|
||||||
|
#
|
||||||
set(SRC_FILES
|
set(SRC_FILES
|
||||||
src/AvatarProvider.cc
|
src/AvatarProvider.cc
|
||||||
src/ChatPage.cc
|
src/ChatPage.cc
|
||||||
|
@ -205,6 +214,9 @@ qt5_wrap_cpp(MOC_HEADERS
|
||||||
include/ui/ThemeManager.h
|
include/ui/ThemeManager.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bundle translations.
|
||||||
|
#
|
||||||
FILE(GLOB LANG_TS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/resources/langs/*.ts")
|
FILE(GLOB LANG_TS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/resources/langs/*.ts")
|
||||||
|
|
||||||
qt5_add_translation(QM_SRC ${LANG_TS_SRC})
|
qt5_add_translation(QM_SRC ${LANG_TS_SRC})
|
||||||
|
@ -222,10 +234,24 @@ file(APPEND ${_qrc} "</qresource> </RCC>")
|
||||||
qt5_add_resources(LANG_QRC ${_qrc})
|
qt5_add_resources(LANG_QRC ${_qrc})
|
||||||
qt5_add_resources(QRC resources/res.qrc)
|
qt5_add_resources(QRC resources/res.qrc)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Matrix events library.
|
||||||
|
#
|
||||||
add_library(matrix_events ${MATRIX_EVENTS} src/Deserializable.cc)
|
add_library(matrix_events ${MATRIX_EVENTS} src/Deserializable.cc)
|
||||||
target_link_libraries(matrix_events Qt5::Core)
|
target_link_libraries(matrix_events Qt5::Core)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bundle icons.
|
||||||
|
#
|
||||||
|
if (APPLE)
|
||||||
|
set(ICON_FILE resources/nheko.icns)
|
||||||
|
set_source_files_properties(${ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (BUILD_TESTS)
|
if (BUILD_TESTS)
|
||||||
|
#
|
||||||
|
# Build tests.
|
||||||
|
#
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
find_package(GTest REQUIRED)
|
find_package(GTest REQUIRED)
|
||||||
|
@ -244,14 +270,20 @@ if (BUILD_TESTS)
|
||||||
add_test(MatrixEventCollection event_collection_test)
|
add_test(MatrixEventCollection event_collection_test)
|
||||||
add_test(MatrixMessageEvents message_events)
|
add_test(MatrixMessageEvents message_events)
|
||||||
else()
|
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)
|
# Build the executable.
|
||||||
|
#
|
||||||
|
SET (NHEKO_LIBS matrix_events Qt5::Widgets Qt5::Network)
|
||||||
|
set (NHEKO_DEPS ${OS_BUNDLE} ${SRC_FILES} ${UI_HEADERS} ${MOC_HEADERS} ${QRC} ${LANG_QRC} ${QM_SRC})
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
target_link_libraries(nheko Qt5::MacExtras)
|
add_executable (nheko ${NHEKO_DEPS})
|
||||||
endif(APPLE)
|
target_link_libraries (nheko ${NHEKO_LIBS} Qt5::MacExtras)
|
||||||
|
elseif(WIN32)
|
||||||
if(WIN32)
|
add_executable (nheko ${ICON_FILE} ${NHEKO_DEPS})
|
||||||
target_link_libraries(nheko Qt5::WinMain)
|
target_link_libraries (nheko ${NHEKO_LIBS} Qt5::WinMain)
|
||||||
endif(WIN32)
|
else()
|
||||||
|
add_executable (nheko ${NHEKO_DEPS})
|
||||||
|
target_link_libraries (nheko ${NHEKO_LIBS})
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
BIN
resources/nheko-1024.png
Normal file
BIN
resources/nheko-1024.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
BIN
resources/nheko.icns
Normal file
BIN
resources/nheko.icns
Normal file
Binary file not shown.
26
scripts/generate_icns.sh
Executable file
26
scripts/generate_icns.sh
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# Manually generate icon set for MacOS.
|
||||||
|
#
|
||||||
|
|
||||||
|
INPUT=$1
|
||||||
|
OUTPUT=nheko
|
||||||
|
|
||||||
|
mkdir ${OUTPUT}.iconset
|
||||||
|
|
||||||
|
sips -z 16 16 ${INPUT} --out ${OUTPUT}.iconset/icon_16x16.png
|
||||||
|
sips -z 32 32 ${INPUT} --out ${OUTPUT}.iconset/icon_16x16@2x.png
|
||||||
|
sips -z 32 32 ${INPUT} --out ${OUTPUT}.iconset/icon_32x32.png
|
||||||
|
sips -z 64 64 ${INPUT} --out ${OUTPUT}.iconset/icon_32x32@2x.png
|
||||||
|
sips -z 128 128 ${INPUT} --out ${OUTPUT}.iconset/icon_128x128.png
|
||||||
|
sips -z 256 256 ${INPUT} --out ${OUTPUT}.iconset/icon_128x128@2x.png
|
||||||
|
sips -z 256 256 ${INPUT} --out ${OUTPUT}.iconset/icon_256x256.png
|
||||||
|
sips -z 512 512 ${INPUT} --out ${OUTPUT}.iconset/icon_256x256@2x.png
|
||||||
|
sips -z 512 512 ${INPUT} --out ${OUTPUT}.iconset/icon_512x512.png
|
||||||
|
|
||||||
|
cp ${INPUT} ${OUTPUT}.iconset/icon_512x512@2x.png
|
||||||
|
|
||||||
|
iconutil -c icns ${OUTPUT}.iconset
|
||||||
|
|
||||||
|
rm -R ${OUTPUT}.iconset
|
|
@ -70,8 +70,12 @@ QIconEngine *MsgCountComposedIcon::clone() const
|
||||||
TrayIcon::TrayIcon(const QString &filename, QWidget *parent)
|
TrayIcon::TrayIcon(const QString &filename, QWidget *parent)
|
||||||
: QSystemTrayIcon(parent)
|
: QSystemTrayIcon(parent)
|
||||||
{
|
{
|
||||||
|
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||||
|
setIcon(QIcon(filename));
|
||||||
|
#else
|
||||||
icon_ = new MsgCountComposedIcon(filename);
|
icon_ = new MsgCountComposedIcon(filename);
|
||||||
setIcon(QIcon(icon_));
|
setIcon(QIcon(icon_));
|
||||||
|
#endif
|
||||||
|
|
||||||
QMenu *menu = new QMenu(parent);
|
QMenu *menu = new QMenu(parent);
|
||||||
viewAction_ = new QAction(tr("Show"), parent);
|
viewAction_ = new QAction(tr("Show"), parent);
|
||||||
|
@ -95,12 +99,17 @@ TrayIcon::TrayIcon(const QString &filename, QWidget *parent)
|
||||||
|
|
||||||
void TrayIcon::setUnreadCount(int count)
|
void TrayIcon::setUnreadCount(int count)
|
||||||
{
|
{
|
||||||
|
// Use the native badge counter in MacOS.
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
QtMac::setBadgeLabelText("");
|
QtMac::setBadgeLabelText("");
|
||||||
else
|
else
|
||||||
QtMac::setBadgeLabelText(QString::number(count));
|
QtMac::setBadgeLabelText(QString::number(count));
|
||||||
|
#elif defined(Q_OS_WIN)
|
||||||
|
// FIXME: Find a way to use Windows apis for the badge counter (if any).
|
||||||
#else
|
#else
|
||||||
|
// Custom drawing on Linux.
|
||||||
|
// FIXME: It doesn't seem to work on KDE.
|
||||||
MsgCountComposedIcon *tmp = static_cast<MsgCountComposedIcon *>(icon_->clone());
|
MsgCountComposedIcon *tmp = static_cast<MsgCountComposedIcon *>(icon_->clone());
|
||||||
tmp->msgCount = count;
|
tmp->msgCount = count;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue