Changeset 14580


Ignore:
Timestamp:
Oct 18, 2015, 11:48:10 AM (6 years ago)
Author:
mikedld
Message:

Display notifications via tray icon if dbus is not available

Location:
trunk/qt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/Application.cc

    r14563 r14580  
    2020#include <QProcess>
    2121#include <QRect>
     22#include <QSystemTrayIcon>
    2223
    2324#include <libtransmission/transmission.h>
     
    546547Application::notifyApp (const QString& title, const QString& body) const
    547548{
     549  QDBusConnection bus = QDBusConnection::sessionBus ();
     550  if (!bus.isConnected ())
     551    {
     552      myWindow->trayIcon ().showMessage (title, body);
     553      return true;
     554    }
     555
    548556  const QString dbusServiceName   = QString::fromUtf8 ("org.freedesktop.Notifications");
    549557  const QString dbusInterfaceName = QString::fromUtf8 ("org.freedesktop.Notifications");
     
    561569  args.append (static_cast<int32_t> (-1));            // use the default timeout period
    562570  m.setArguments (args);
    563   QDBusMessage replyMsg = QDBusConnection::sessionBus ().call (m);
     571  QDBusMessage replyMsg = bus.call (m);
    564572  //std::cerr << qPrintable (replyMsg.errorName ()) << std::endl;
    565573  //std::cerr << qPrintable (replyMsg.errorMessage ()) << std::endl;
  • trunk/qt/MainWindow.h

    r14566 r14580  
    5353    MainWindow (Session&, Prefs&, TorrentModel&, bool minized);
    5454    virtual ~MainWindow ();
     55
     56    QSystemTrayIcon& trayIcon () { return myTrayIcon; }
    5557
    5658  public slots:
Note: See TracChangeset for help on using the changeset viewer.