LeechCraft  0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
fancytrayiconfreedesktop.h
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #pragma once
10 
11 #include <QObject>
12 #include <QDBusAbstractAdaptor>
13 #include "fancytrayiconimpl.h"
14 
15 namespace LC::Util
16 {
17  class FancyTrayIconFreedesktop;
18 }
19 
20 namespace LC::Util::detail
21 {
22  struct IconFrame
23  {
24  int Width_;
25  int Height_;
26  QByteArray Data_;
27 
28  static IconFrame FromPixmap (const QPixmap&);
29  };
30 
31  struct DBusTooltip
32  {
33  QString Title_;
34  QString Subtitle_;
35  };
36 }
37 
41 
42 namespace LC::Util::detail
43 {
44  class SNIAdaptor : public QDBusAbstractAdaptor
45  {
46  Q_OBJECT
47 
48  // KDE seems to expect `org.kde.StatusNotifierItem` contrary to the spec
49  Q_CLASSINFO ("D-Bus Interface", "org.kde.StatusNotifierItem")
50 
51  Q_PROPERTY (QString Category MEMBER Category_ CONSTANT)
52  Q_PROPERTY (quint32 WindowId MEMBER WindowId_ CONSTANT)
53 
54  Q_PROPERTY (QString Id READ GetId CONSTANT)
55  Q_PROPERTY (QString Title READ GetTitle)
56  Q_PROPERTY (QString Status READ GetStatus NOTIFY NewStatus)
57 
58  Q_PROPERTY (QString IconName READ GetIconName)
59  Q_PROPERTY (QList<LC::Util::detail::IconFrame> IconPixmap READ GetIconPixmap NOTIFY NewIcon)
60 
61  Q_PROPERTY (LC::Util::detail::DBusTooltip ToolTip READ GetTooltip NOTIFY NewTooltip)
62 
64 
65  const QString Category_ = QStringLiteral ("ApplicationStatus");
66  const QString Status_ = QStringLiteral ("Active");
67  const quint32 WindowId_ = 0;
68  public:
70  public slots:
71  void ContextMenu (int x, int y);
72  void Activate (int, int);
73  void SecondaryActivate (int, int);
74  void Scroll (int, const QString&);
75  private:
76  QString GetId () const;
77  QString GetTitle () const;
78  QString GetStatus () const;
79  QString GetIconName () const;
80  QList<IconFrame> GetIconPixmap () const;
81  DBusTooltip GetTooltip () const;
82  signals:
83  void NewIcon ();
84  void NewTooltip ();
85  void NewStatus ();
86  };
87 }
88 
89 namespace LC::Util
90 {
92  {
93  friend class detail::SNIAdaptor;
94 
95  FancyTrayIcon& FTI_;
96 
97  detail::SNIAdaptor Adaptor_;
98  public:
99  explicit FancyTrayIconFreedesktop (FancyTrayIcon& icon);
100 
101  void UpdateIcon () override;
102  void UpdateTooltip () override;
103  void UpdateMenu () override;
104  void UpdateStatus () override;
105  };
106 }
static IconFrame FromPixmap(const QPixmap &)
QList< LC::Util::detail::IconFrame > IconPixmap
LC::Util::detail::DBusTooltip ToolTip
Q_DECLARE_METATYPE(QVariantList *)