Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 590cd3a8 authored by Laurent Montel's avatar Laurent Montel 😁

Avoid duplicate code

parent d5b863e2
......@@ -248,20 +248,9 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList &)
connect(m_mainWidget.data(), &MainWidget::signalUnreadCountChanged, UnityServiceManager::instance(), &UnityServiceManager::slotSetUnread);
if (Settings::showTrayIcon() && !TrayIcon::getInstance()) {
TrayIcon *trayIcon = new TrayIcon(m_mainWidget->window());
TrayIcon::setInstance(trayIcon);
m_actionManager->setTrayIcon(trayIcon);
if (isTrayIconEnabled()) {
trayIcon->setStatus(KStatusNotifierItem::Active);
}
initializeTrayIcon();
QWidget *const notificationParent = isTrayIconEnabled() ? m_mainWidget->window() : nullptr;
NotificationManager::self()->setWidget(notificationParent, componentData().componentName());
connect(m_mainWidget.data(), &MainWidget::signalUnreadCountChanged, trayIcon, &TrayIcon::slotSetUnread);
connect(m_mainWidget.data(), &MainWidget::signalArticlesSelected,
this, &Part::signalArticlesSelected);
}
connect(qApp, &QCoreApplication::aboutToQuit, this, &Part::slotOnShutdown);
......@@ -340,26 +329,33 @@ void Part::slotOnShutdown()
//delete m_actionManager;
}
void Part::slotSettingsChanged()
void Part::initializeTrayIcon()
{
NotificationManager::self()->setWidget(isTrayIconEnabled() ? m_mainWidget->window() : nullptr, componentData().componentName());
TrayIcon *trayIcon = new TrayIcon(m_mainWidget->window());
TrayIcon::setInstance(trayIcon);
m_actionManager->setTrayIcon(trayIcon);
if (Settings::showTrayIcon() && !TrayIcon::getInstance()) {
TrayIcon *trayIcon = new TrayIcon(m_mainWidget->window());
TrayIcon::setInstance(trayIcon);
m_actionManager->setTrayIcon(trayIcon);
if (isTrayIconEnabled()) {
trayIcon->setStatus(KStatusNotifierItem::Active);
}
if (isTrayIconEnabled()) {
trayIcon->setStatus(KStatusNotifierItem::Active);
}
connect(m_mainWidget.data(), &MainWidget::signalUnreadCountChanged, trayIcon, &TrayIcon::slotSetUnread);
connect(m_mainWidget.data(), &MainWidget::signalArticlesSelected,
this, &Part::signalArticlesSelected);
connect(m_mainWidget.data(), &MainWidget::signalUnreadCountChanged, trayIcon, &TrayIcon::slotSetUnread);
connect(m_mainWidget.data(), &MainWidget::signalArticlesSelected,
this, &Part::signalArticlesSelected);
m_mainWidget->slotSetTotalUnread();
}
m_mainWidget->slotSetTotalUnread();
}
if (!Settings::showTrayIcon()) {
void Part::slotSettingsChanged()
{
NotificationManager::self()->setWidget(isTrayIconEnabled() ? m_mainWidget->window() : nullptr, componentData().componentName());
if (Settings::showTrayIcon()) {
if (!TrayIcon::getInstance()) {
initializeTrayIcon();
m_mainWidget->slotSetTotalUnread();
}
} else {
TrayIcon::getInstance()->disconnect();
delete TrayIcon::getInstance();
TrayIcon::setInstance(nullptr);
......
......@@ -206,6 +206,7 @@ private: // methods
void clearCrashProperties();
private: // attributes
void initializeTrayIcon();
class ApplyFiltersInterceptor;
ApplyFiltersInterceptor *m_applyFiltersInterceptor = nullptr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment