Remove dependency on KStatusNotifierItem

We had two implementations of the system tray icon for no particularly good reason
This commit is contained in:
Tobias Fella
2026-02-20 14:21:16 +01:00
committed by Tobias Fella
parent 73e6a536db
commit b7688d4373
6 changed files with 3 additions and 73 deletions

View File

@@ -28,7 +28,6 @@ Dependencies:
'frameworks/qqc2-desktop-style': '@latest-kf6'
'frameworks/kio': '@latest-kf6'
'frameworks/kwindowsystem': '@latest-kf6'
'frameworks/kstatusnotifieritem': '@latest-kf6'
- 'on': ['Linux', 'FreeBSD']
'require':
'frameworks/kdbusaddons': '@latest-kf6'

View File

@@ -88,7 +88,7 @@ if(ANDROID)
)
else()
find_package(Qt6 ${QT_MIN_VERSION} COMPONENTS Widgets)
find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS QQC2DesktopStyle KIO WindowSystem StatusNotifierItem)
find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS QQC2DesktopStyle KIO WindowSystem)
find_package(KF6SyntaxHighlighting ${KF_MIN_VERSION} REQUIRED)
set_package_properties(KF6QQC2DesktopStyle PROPERTIES
TYPE RUNTIME

View File

@@ -171,12 +171,7 @@ ecm_add_app_icon(NEOCHAT_ICON ICONS ${CMAKE_SOURCE_DIR}/128-logo.png)
target_sources(neochat-app PRIVATE ${NEOCHAT_ICON})
if(NOT ANDROID)
if (NOT WIN32 AND NOT APPLE)
target_sources(neochat PRIVATE trayicon_sni.cpp trayicon_sni.h)
target_link_libraries(neochat PRIVATE KF6::StatusNotifierItem)
else()
target_sources(neochat PRIVATE trayicon.cpp trayicon.h)
endif()
target_link_libraries(neochat PUBLIC KF6::WindowSystem)
target_compile_definitions(neochat PUBLIC -DHAVE_WINDOWSYSTEM)
endif()

View File

@@ -29,10 +29,8 @@
#include "proxycontroller.h"
#include "roommanager.h"
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
#if !defined(Q_OS_ANDROID)
#include "trayicon.h"
#elif !defined(Q_OS_ANDROID)
#include "trayicon_sni.h"
#endif
#ifdef HAVE_KUNIFIEDPUSH

View File

@@ -1,32 +0,0 @@
// SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@kde.org>
// SPDX-License-Identifier: GPL-3.0-only
#include "trayicon_sni.h"
#include <KWindowSystem>
#include "windowcontroller.h"
using namespace Qt::StringLiterals;
TrayIcon::TrayIcon(QObject *parent)
: KStatusNotifierItem(parent)
{
setCategory(KStatusNotifierItem::ItemCategory::Communications);
setIconByName(u"org.kde.neochat.tray"_s);
connect(&WindowController::instance(), &WindowController::windowChanged, this, [this] {
setAssociatedWindow(WindowController::instance().window());
});
}
void TrayIcon::show()
{
setStatus(Active);
}
void TrayIcon::hide()
{
setStatus(Passive);
}
#include "moc_trayicon_sni.cpp"

View File

@@ -1,30 +0,0 @@
// SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@kde.org>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <KStatusNotifierItem>
/**
* @class TrayIcon
*
* A class inheriting KStatusNotifierItem to provide a tray icon.
*
* @sa KStatusNotifierItem
*/
class TrayIcon : public KStatusNotifierItem
{
Q_OBJECT
public:
explicit TrayIcon(QObject *parent = nullptr);
/**
* @brief Show the tray icon.
*/
void show();
/**
* @brief Hide the tray icon.
*/
void hide();
};