File indexing completed on 2024-04-28 05:11:03
0001 /* 0002 This file is part of Akregator. 0003 0004 SPDX-FileCopyrightText: 2004 Stanislav Karchebny <Stanislav.Karchebny@kdemail.net> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0 0007 */ 0008 0009 #include "trayicon.h" 0010 0011 #include <KLocalizedString> 0012 0013 using namespace Akregator; 0014 0015 TrayIcon *TrayIcon::m_instance = nullptr; 0016 0017 TrayIcon *TrayIcon::getInstance() 0018 { 0019 return m_instance; 0020 } 0021 0022 void TrayIcon::setInstance(TrayIcon *trayIcon) 0023 { 0024 m_instance = trayIcon; 0025 } 0026 0027 bool TrayIcon::isEnabled() const 0028 { 0029 return mEnabled; 0030 } 0031 0032 void TrayIcon::setEnabled(bool enabled) 0033 { 0034 mEnabled = enabled; 0035 } 0036 0037 TrayIcon::TrayIcon(QObject *parent) 0038 : KStatusNotifierItem(parent) 0039 { 0040 setToolTipTitle(i18n("Akregator")); 0041 setToolTipIconByName(i18n("Akregator")); 0042 setIconByName(QStringLiteral("akregator")); 0043 } 0044 0045 TrayIcon::~TrayIcon() = default; 0046 0047 void TrayIcon::slotSetUnread(int unread) 0048 { 0049 if (mEnabled && m_unread != unread) { 0050 m_unread = unread; 0051 0052 setToolTip(QStringLiteral("akregator"), 0053 i18n("Akregator"), 0054 unread == 0 ? i18n("There are no unread articles") : i18np("1 unread article", "%1 unread articles", unread)); 0055 setStatus(unread > 0 ? KStatusNotifierItem::Active : KStatusNotifierItem::Passive); 0056 } 0057 } 0058 0059 void TrayIcon::settingsChanged() 0060 { 0061 slotSetUnread(m_unread); 0062 } 0063 0064 #include "moc_trayicon.cpp"