File indexing completed on 2024-07-14 04:51:45

0001 /*
0002     SPDX-FileCopyrightText: 2008 Urs Wolfer <uwolfer@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "systemtrayicon.h"
0008 #include "mainwindow.h"
0009 
0010 #include <KActionCollection>
0011 #include <KLocalizedString>
0012 
0013 #include <QMenu>
0014 
0015 SystemTrayIcon::SystemTrayIcon(MainWindow *parent)
0016     : KStatusNotifierItem(parent)
0017     , m_mainWindow(parent)
0018 {
0019     setIconByName(QLatin1String("krdc"));
0020     setStatus(KStatusNotifierItem::Active);
0021     setCategory(KStatusNotifierItem::ApplicationStatus);
0022 
0023     setToolTipIconByName(QLatin1String("krdc"));
0024     setToolTipTitle(i18n("KDE Remote Desktop Client"));
0025 
0026     contextMenu()->addSeparator();
0027     contextMenu()->addAction(parent->actionCollection()->action(QLatin1String("bookmark")));
0028     contextMenu()->addSeparator();
0029 
0030     connect(this, SIGNAL(activateRequested(bool, QPoint)), this, SLOT(checkActivatedWindow(bool)));
0031 }
0032 
0033 void SystemTrayIcon::checkActivatedWindow(bool active)
0034 {
0035     // make sure the fullscreen window stays fullscreen by restoring the FullScreen state upon restore.
0036 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0037     if (active && associatedWidget() != m_mainWindow) {
0038         associatedWidget()->setWindowState(Qt::WindowFullScreen);
0039     }
0040 #else
0041     if (active && associatedWindow() != m_mainWindow->windowHandle()) {
0042         associatedWindow()->setWindowState(Qt::WindowFullScreen);
0043     }
0044 #endif
0045 }
0046 
0047 SystemTrayIcon::~SystemTrayIcon()
0048 {
0049 }