forked from blue/squawk
unread messages count now is displayed on the launcher icon
This commit is contained in:
parent
721d3a1a89
commit
3916aec358
7 changed files with 35 additions and 2 deletions
|
@ -21,7 +21,7 @@ Application::Application(Core::Squawk* p_core):
|
|||
availability(Shared::Availability::offline),
|
||||
core(p_core),
|
||||
squawk(nullptr),
|
||||
notifications("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus()),
|
||||
notifications("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications"),
|
||||
roster(),
|
||||
conversations(),
|
||||
dialogueQueue(roster),
|
||||
|
@ -29,6 +29,7 @@ Application::Application(Core::Squawk* p_core):
|
|||
destroyingSquawk(false)
|
||||
{
|
||||
connect(&roster, &Models::Roster::unnoticedMessage, this, &Application::notify);
|
||||
connect(&roster, &Models::Roster::unreadMessagesCountChanged, this, &Application::unreadMessagesCountChanged);
|
||||
|
||||
|
||||
//connecting myself to the backed
|
||||
|
@ -100,6 +101,7 @@ void Application::quit()
|
|||
emit quitting();
|
||||
|
||||
writeSettings();
|
||||
unreadMessagesCountChanged(0); //this notification persist in the desktop, for now I'll zero it on quit not to confuse people
|
||||
for (Conversations::const_iterator itr = conversations.begin(), end = conversations.end(); itr != end; ++itr) {
|
||||
disconnect(itr->second, &Conversation::destroyed, this, &Application::onConversationClosed);
|
||||
itr->second->close();
|
||||
|
@ -212,7 +214,7 @@ void Application::notify(const QString& account, const Shared::Message& msg)
|
|||
args << body;
|
||||
args << QStringList();
|
||||
args << QVariantMap({
|
||||
{"desktop-entry", QString(QCoreApplication::applicationName())},
|
||||
{"desktop-entry", qApp->desktopFileName()},
|
||||
{"category", QString("message")},
|
||||
// {"sound-file", "/path/to/macaw/squawk"},
|
||||
{"sound-name", QString("message-new-instant")}
|
||||
|
@ -225,6 +227,18 @@ void Application::notify(const QString& account, const Shared::Message& msg)
|
|||
}
|
||||
}
|
||||
|
||||
void Application::unreadMessagesCountChanged(int count)
|
||||
{
|
||||
QDBusMessage signal = QDBusMessage::createSignal("/", "com.canonical.Unity.LauncherEntry", "Update");
|
||||
signal << qApp->desktopFileName() + QLatin1String(".desktop");
|
||||
signal << QVariantMap ({
|
||||
{"count-visible", count != 0},
|
||||
{"count", count}
|
||||
});
|
||||
QDBusConnection::sessionBus().send(signal);
|
||||
}
|
||||
|
||||
|
||||
void Application::setState(Shared::Availability p_availability)
|
||||
{
|
||||
if (availability != p_availability) {
|
||||
|
|
|
@ -65,6 +65,7 @@ public slots:
|
|||
|
||||
protected slots:
|
||||
void notify(const QString& account, const Shared::Message& msg);
|
||||
void unreadMessagesCountChanged(int count);
|
||||
void setState(Shared::Availability availability);
|
||||
|
||||
void changeAccount(const QString& account, const QMap<QString, QVariant>& data);
|
||||
|
|
|
@ -50,6 +50,7 @@ int main(int argc, char *argv[])
|
|||
QApplication::setOrganizationName("macaw.me");
|
||||
QApplication::setApplicationDisplayName("Squawk");
|
||||
QApplication::setApplicationVersion("0.2.2");
|
||||
app.setDesktopFileName("squawk");
|
||||
|
||||
QTranslator qtTranslator;
|
||||
qtTranslator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue