File indexing completed on 2024-09-29 10:12:48

0001 // SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@kde.org>
0002 // SPDX-License-Identifier: GPL-3.0-only
0003 
0004 #include "trayicon_sni.h"
0005 #include <KWindowSystem>
0006 
0007 #include "windowcontroller.h"
0008 
0009 TrayIcon::TrayIcon(QObject *parent)
0010     : KStatusNotifierItem(parent)
0011 {
0012     setCategory(KStatusNotifierItem::ItemCategory::Communications);
0013     setIconByName("org.kde.neochat.tray");
0014     connect(this, &KStatusNotifierItem::activateRequested, this, [this] {
0015         KWindowSystem::setCurrentXdgActivationToken(providedToken());
0016         Q_EMIT showWindow();
0017     });
0018 
0019     connect(&WindowController::instance(), &WindowController::windowChanged, this, [this] {
0020 #if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
0021         setAssociatedWindow(WindowController::instance().window());
0022 #else
0023         Q_UNUSED(this);
0024 #endif
0025     });
0026 }
0027 
0028 void TrayIcon::show()
0029 {
0030     setStatus(Active);
0031 }
0032 
0033 void TrayIcon::hide()
0034 {
0035     setStatus(Passive);
0036 }
0037 
0038 #include "moc_trayicon_sni.cpp"