示例#1
0
StatusNotifierButton::StatusNotifierButton(QString service, QString objectPath, ILXQtPanelPlugin* plugin, QWidget *parent)
    : QToolButton(parent),
    mMenu(nullptr),
    mStatus(Passive),
    mFallbackIcon(QIcon::fromTheme("application-x-executable")),
    mPlugin(plugin)
{
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    setAutoRaise(true);
    interface = new SniAsync(service, objectPath, QDBusConnection::sessionBus(), this);

    connect(interface, &SniAsync::NewIcon, this, &StatusNotifierButton::newIcon);
    connect(interface, &SniAsync::NewOverlayIcon, this, &StatusNotifierButton::newOverlayIcon);
    connect(interface, &SniAsync::NewAttentionIcon, this, &StatusNotifierButton::newAttentionIcon);
    connect(interface, &SniAsync::NewToolTip, this, &StatusNotifierButton::newToolTip);
    connect(interface, &SniAsync::NewStatus, this, &StatusNotifierButton::newStatus);

    interface->propertyGetAsync(QLatin1String("Menu"), [this] (QDBusObjectPath path) {
        if (!path.path().isEmpty())
        {
            mMenu = (new MenuImporter{interface->service(), path.path(), this})->menu();
            mMenu->setObjectName(QLatin1String("StatusNotifierMenu"));
        }
    });

    interface->propertyGetAsync(QLatin1String("Status"), [this] (QString status) {
        newStatus(status);
    });

    interface->propertyGetAsync(QLatin1String("IconThemePath"), [this] (QString value) {
        //do the logic of icons after we've got the theme path
        refetchIcon(Active, value);
        refetchIcon(Passive, value);
        refetchIcon(NeedsAttention, value);
    });

    newToolTip();
}
示例#2
0
StatusNotifierButton::StatusNotifierButton(QString service, QString objectPath, ILXQtPanelPlugin* plugin, QWidget *parent)
    : QToolButton(parent),
    mMenu(NULL),
    mStatus(Passive),
    mValid(true),
    mFallbackIcon(QIcon::fromTheme("application-x-executable")),
    mPlugin(plugin)
{
    interface = new org::kde::StatusNotifierItem(service, objectPath, QDBusConnection::sessionBus(), this);

    QString menuPath = interface->menu().path();
    if (!menuPath.isEmpty())
    {
        mMenu = (new DBusMenuImporter(service, interface->menu().path(), this))->menu();
        dynamic_cast<QObject &>(*mMenu).setParent(this);
        mMenu->setObjectName(QStringLiteral("StatusNotifierMenu"));
    }

    // HACK: sni-qt creates some invalid items (like one for konversarion 1.5)
    if (interface->title().isEmpty() && interface->id().isEmpty())
        mValid = false;

    if (mValid)
    {
        newToolTip();
        refetchIcon(Active);
        refetchIcon(Passive);
        refetchIcon(NeedsAttention);
        newStatus(interface->status());
        resetIcon();

        connect(interface, SIGNAL(NewIcon()), this, SLOT(newIcon()));
        connect(interface, SIGNAL(NewOverlayIcon()), this, SLOT(newOverlayIcon()));
        connect(interface, SIGNAL(NewAttentionIcon()), this, SLOT(newAttentionIcon()));
        connect(interface, SIGNAL(NewToolTip()), this, SLOT(newToolTip()));
        connect(interface, SIGNAL(NewStatus(QString)), this, SLOT(newStatus(QString)));
    }
}
示例#3
0
void StatusNotifierButton::newIcon()
{
    interface->propertyGetAsync(QLatin1String("IconThemePath"), [this] (QString value) {
        refetchIcon(Passive, value);
    });
}
示例#4
0
void StatusNotifierButton::newAttentionIcon()
{
    interface->propertyGetAsync(QLatin1String("IconThemePath"), [this] (QString value) {
        refetchIcon(NeedsAttention, value);
    });
}
示例#5
0
void StatusNotifierButton::newAttentionIcon()
{
    refetchIcon(NeedsAttention);
    resetIcon();
}
示例#6
0
void StatusNotifierButton::newOverlayIcon()
{
    refetchIcon(Active);
    resetIcon();
}
示例#7
0
void StatusNotifierButton::newIcon()
{
    refetchIcon(Passive);
    resetIcon();
}