* Quasselfied 2010 by Manuel Nickschas <sputnick@quassel-irc.org> *
* *
* This file is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
+ * it under the terms of the GNU Library General Public License (LGPL) *
+ * as published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+#include "mainwin.h"
+#include "qtui.h"
#include "statusnotifieritemdbus.h"
#include "statusnotifieritem.h"
-#include "qtui.h"
#include <QDBusConnection>
#include <QPixmap>
#include "statusnotifierwatcher.h"
#include "statusnotifieritemadaptor.h"
+#ifdef Q_OS_WIN64
+__inline int toInt(WId wid)
+{
+ return (int)((__int64)wid);
+}
+
+#else
+__inline int toInt(WId wid)
+{
+ return (int)wid;
+}
+#endif
+
// Marshall the ImageStruct data into a D-BUS argument
const QDBusArgument &operator<<(QDBusArgument &argument, const DBusImageStruct &icon)
{
m_dbus(QDBusConnection::connectToBus(QDBusConnection::SessionBus, m_service))
{
new StatusNotifierItemAdaptor(this);
- qDebug() << "service is" << m_service;
- m_dbus.registerService(m_service);
- m_dbus.registerObject("/StatusNotifierItem", this);
+ //qDebug() << "service is" << m_service;
+ registerService();
}
StatusNotifierItemDBus::~StatusNotifierItemDBus()
{
- m_dbus.unregisterService(m_service);
+ unregisterService();
+}
+
+QDBusConnection StatusNotifierItemDBus::dbusConnection() const
+{
+ return m_dbus;
+}
+
+// FIXME: prevent double registrations, also test this on platforms != KDE
+//
+void StatusNotifierItemDBus::registerService()
+{
+ //qDebug() << "registering to" << m_service;
+ m_dbus.registerService(m_service);
+ m_dbus.registerObject("/StatusNotifierItem", this);
+}
+
+// FIXME: see above
+void StatusNotifierItemDBus::unregisterService()
+{
+ //qDebug() << "unregistering from" << m_service;
+ if(m_dbus.isConnected()) {
+ m_dbus.unregisterObject("/StatusNotifierItem");
+ m_dbus.unregisterService(m_service);
+ }
}
QString StatusNotifierItemDBus::service() const
}
QString StatusNotifierItemDBus::Status() const
- {
+{
return m_statusNotifierItem->metaObject()->enumerator(m_statusNotifierItem->metaObject()->indexOfEnumerator("State")).valueToKey(m_statusNotifierItem->state());
}
int StatusNotifierItemDBus::WindowId() const
{
- return (int)QtUi::mainWindow()->winId();
+ return toInt(QtUi::mainWindow()->winId());
}
return toolTip;
}
+QString StatusNotifierItemDBus::IconThemePath() const
+{
+ return m_statusNotifierItem->iconThemePath();
+}
+
+//Menu
+
+QDBusObjectPath StatusNotifierItemDBus::Menu() const
+{
+ return QDBusObjectPath(m_statusNotifierItem->menuObjectPath());
+}
+
+
//Interaction
void StatusNotifierItemDBus::ContextMenu(int x, int y)
//TODO: nicer placement, possible?
if (!m_statusNotifierItem->trayMenu()->isVisible()) {
+#ifdef HAVE_KDE
m_statusNotifierItem->trayMenu()->setWindowFlags(Qt::Window|Qt::FramelessWindowHint);
+#endif
m_statusNotifierItem->trayMenu()->popup(QPoint(x,y));
#ifdef HAVE_KDE
KWindowSystem::setState(m_statusNotifierItem->trayMenu()->winId(), NET::SkipTaskbar|NET::SkipPager|NET::KeepAbove);