10#include <QCoreApplication>
11#include <QDBusArgument>
12#include <QDBusInterface>
13#include <QDBusConnection>
14#include <QDBusConnectionInterface>
15#include <QDBusMetaType>
27 const auto&
img =
px.toImage ().convertToFormat (QImage::Format_ARGB32);
34 return { .Width_ =
img.width (), .Height_ =
img.height (), .Data_ = data };
52 out.beginStructure ();
68 out.beginStructure ();
100 auto sb = QDBusConnection::sessionBus ();
102 const auto&
watchers =
sb.interface ()->registeredServiceNames ().value ().filter (
"StatusNotifierWatcher");
104 throw std::runtime_error {
"no SNI watchers available" };
108 throw std::runtime_error {
"interface to the SNI watcher " +
watcherService.toStdString () +
"is invalid" };
112 .arg (QByteArray::number (QCoreApplication::applicationPid ()), QByteArray::number (++
uniqueId));
114 throw std::runtime_error {
"unable to register SNI service" };
115 if (!
sb.registerObject (
"/StatusNotifierItem",
this))
116 throw std::runtime_error {
"unable to register SNI object" };
119 reply.type () == QDBusMessage::ErrorMessage)
120 throw std::runtime_error {
"unable to register the SNI with the watcher: " +
reply.errorMessage ().toStdString () };
146 : QDBusAbstractAdaptor { &
impl }
175 QString SNIAdaptor::GetId ()
const
180 QString SNIAdaptor::GetTitle ()
const
185 QString SNIAdaptor::GetStatus ()
const
194 return "NeedsAttention";
202 QString SNIAdaptor::GetIconName ()
const
206 [] (
const QIcon&) { return QString {}; });
212 [] (
const QString&) { return QList<IconFrame> {}; },
216 DBusTooltip SNIAdaptor::GetTooltip ()
const
220 .Title_ = Impl_.FTI_.GetInfo ().Title_,
221 .Subtitle_ = Impl_.FTI_.GetTooltip ().HTML_
void UpdateTooltip() override
void UpdateStatus() override
FancyTrayIconFreedesktop(FancyTrayIcon &icon)
void UpdateIcon() override
void UpdateMenu() override
const IconInfo & GetInfo() const
const Icon & GetIcon() const
void scrolled(int, Qt::Orientation)
QMenu * GetContextMenu() const
void secondaryActivated()
void ContextMenu(int x, int y)
void SecondaryActivate(int, int)
void Scroll(int, const QString &)
SNIAdaptor(FancyTrayIconFreedesktop &)
QList< IconFrame > IconToFrames(const QIcon &icon)
const QDBusArgument & operator>>(const QDBusArgument &in, IconFrame &frame)
QDBusArgument & operator<<(QDBusArgument &out, const IconFrame &frame)
Container< T > Filter(const Container< T > &c, F f)
auto Visit(const Either< Left, Right > &either, Args &&... args)
auto Map(Container &&c, F &&f) noexcept(noexcept(std::is_nothrow_invocable_v< F, decltype(*c.begin())>))
static IconFrame FromPixmap(const QPixmap &)