Skip to content

Commit

Permalink
Merge pull request #1825 from Integral-Tech/fix-tooltip
Browse files Browse the repository at this point in the history
Add profile name to tooltip & fix message count
  • Loading branch information
deepbluev7 authored Oct 13, 2024
2 parents 27683be + 3b0df06 commit 2f96797
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/TrayIcon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <QWindow>

#include "TrayIcon.h"
#include "UserSettingsPage.h"

MsgCountComposedIcon::MsgCountComposedIcon(const QIcon &icon)
: QIconEngine()
Expand Down Expand Up @@ -114,12 +115,30 @@ TrayIcon::TrayIcon(const QString &filename, QWindow *parent)

menu->addAction(viewAction_);
menu->addAction(quitAction_);

QString toolTip = QLatin1String("nheko");
QString profile = UserSettings::instance()->profile();
if (!profile.isEmpty())
toolTip.append(QStringLiteral(" | %1").arg(profile));

setToolTip(toolTip);
}

void
TrayIcon::setUnreadCount(int count)
{
qGuiApp->setBadgeNumber(count);
if (count != previousCount) {
QString toolTip = QLatin1String("nheko");
QString profile = UserSettings::instance()->profile();
if (!profile.isEmpty())
toolTip.append(QStringLiteral(" | %1").arg(profile));

if (count != 0)
toolTip.append(tr("\n%n unread message(s)", "", count));

setToolTip(toolTip);
}

#if !defined(Q_OS_MACOS) && !defined(Q_OS_WIN)
if (count != previousCount) {
Expand All @@ -131,13 +150,6 @@ TrayIcon::setUnreadCount(int count)
#else
(void)previousCount;
#endif

QString toolTip = QLatin1String("nheko");
if (count > 0) {
toolTip.append(tr("\n%n unread message(s)", "", count));
}

setToolTip(toolTip);
}

#include "moc_TrayIcon.cpp"

0 comments on commit 2f96797

Please sign in to comment.