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
|
||||
cmake_install.cmake
|
||||
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)
|
||||
|
||||
#
|
||||
# Discover Qt dependencies.
|
||||
#
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
find_package(Qt5Network REQUIRED)
|
||||
find_package(Qt5LinguistTools REQUIRED)
|
||||
|
@ -19,6 +22,9 @@ if (Qt5Widgets_FOUND)
|
|||
endif()
|
||||
endif(Qt5Widgets_FOUND)
|
||||
|
||||
#
|
||||
# Set up compiler flags.
|
||||
#
|
||||
set(CMAKE_C_COMPILER gcc)
|
||||
|
||||
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()
|
||||
|
||||
#
|
||||
# Declare source and header files.
|
||||
#
|
||||
set(SRC_FILES
|
||||
src/AvatarProvider.cc
|
||||
src/ChatPage.cc
|
||||
|
@ -205,6 +214,9 @@ qt5_wrap_cpp(MOC_HEADERS
|
|||
include/ui/ThemeManager.h
|
||||
)
|
||||
|
||||
#
|
||||
# Bundle translations.
|
||||
#
|
||||
FILE(GLOB LANG_TS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/resources/langs/*.ts")
|
||||
|
||||
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(QRC resources/res.qrc)
|
||||
|
||||
#
|
||||
# Matrix events library.
|
||||
#
|
||||
add_library(matrix_events ${MATRIX_EVENTS} src/Deserializable.cc)
|
||||
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)
|
||||
#
|
||||
# Build tests.
|
||||
#
|
||||
enable_testing()
|
||||
|
||||
find_package(GTest REQUIRED)
|
||||
|
@ -244,14 +270,20 @@ if (BUILD_TESTS)
|
|||
add_test(MatrixEventCollection event_collection_test)
|
||||
add_test(MatrixMessageEvents message_events)
|
||||
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)
|
||||
target_link_libraries(nheko Qt5::MacExtras)
|
||||
endif(APPLE)
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(nheko Qt5::WinMain)
|
||||
endif(WIN32)
|
||||
if(APPLE)
|
||||
add_executable (nheko ${NHEKO_DEPS})
|
||||
target_link_libraries (nheko ${NHEKO_LIBS} Qt5::MacExtras)
|
||||
elseif(WIN32)
|
||||
add_executable (nheko ${ICON_FILE} ${NHEKO_DEPS})
|
||||
target_link_libraries (nheko ${NHEKO_LIBS} Qt5::WinMain)
|
||||
else()
|
||||
add_executable (nheko ${NHEKO_DEPS})
|
||||
target_link_libraries (nheko ${NHEKO_LIBS})
|
||||
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)
|
||||
: QSystemTrayIcon(parent)
|
||||
{
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||
setIcon(QIcon(filename));
|
||||
#else
|
||||
icon_ = new MsgCountComposedIcon(filename);
|
||||
setIcon(QIcon(icon_));
|
||||
#endif
|
||||
|
||||
QMenu *menu = new QMenu(parent);
|
||||
viewAction_ = new QAction(tr("Show"), parent);
|
||||
|
@ -95,12 +99,17 @@ TrayIcon::TrayIcon(const QString &filename, QWidget *parent)
|
|||
|
||||
void TrayIcon::setUnreadCount(int count)
|
||||
{
|
||||
// Use the native badge counter in MacOS.
|
||||
#if defined(Q_OS_MAC)
|
||||
if (count == 0)
|
||||
QtMac::setBadgeLabelText("");
|
||||
else
|
||||
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
|
||||
// Custom drawing on Linux.
|
||||
// FIXME: It doesn't seem to work on KDE.
|
||||
MsgCountComposedIcon *tmp = static_cast<MsgCountComposedIcon *>(icon_->clone());
|
||||
tmp->msgCount = count;
|
||||
|
||||
|
|
Loading…
Reference in a new issue