File indexing completed on 2024-09-29 07:24:47
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(QStringLiteral("org.kde.neochat.tray")); 0014 connect(this, &KStatusNotifierItem::activateRequested, this, [this] { 0015 KWindowSystem::setCurrentXdgActivationToken(providedToken()); 0016 WindowController::instance().toggleWindow(); 0017 }); 0018 0019 connect(&WindowController::instance(), &WindowController::windowChanged, this, [this] { 0020 setAssociatedWindow(WindowController::instance().window()); 0021 }); 0022 } 0023 0024 void TrayIcon::show() 0025 { 0026 setStatus(Active); 0027 } 0028 0029 void TrayIcon::hide() 0030 { 0031 setStatus(Passive); 0032 } 0033 0034 #include "moc_trayicon_sni.cpp"