diff options
author | Kevin Krammer <kevin.krammer@gmx.at> | 2007-01-29 00:28:44 +0000 |
---|---|---|
committer | Kevin Krammer <kevin.krammer@gmx.at> | 2007-01-29 00:28:44 +0000 |
commit | da124397a4baf16a7659cf202a292926c0b25678 (patch) | |
tree | 00d78302770897d399b0eed23c5fae1e6a1077ae | |
parent | 861573367193417ec3db96ff15f915cb4c4adbe8 (diff) |
Adding support for windowInfo
-rw-r--r-- | kde3/src/dapiimpl.cpp | 74 | ||||
-rw-r--r-- | kde3/src/dapiimpl.h | 11 |
2 files changed, 81 insertions, 4 deletions
diff --git a/kde3/src/dapiimpl.cpp b/kde3/src/dapiimpl.cpp index ee21b65..9db6842 100644 --- a/kde3/src/dapiimpl.cpp +++ b/kde3/src/dapiimpl.cpp @@ -25,6 +25,7 @@ // Qt D-Bus includes #include <dbus/qdbusdata.h> #include <dbus/qdbuserror.h> +#include <dbus/qdbusvariant.h> // DAPI common includes #include "dapi-common.h" @@ -33,6 +34,43 @@ #include "dapiimpl.h" #include "kabchandler.h" +static WId dapiWindowID(const QDBusVariant& windowInfo) +{ +#if defined(Q_WS_X11) + WId window = 0; + if (windowInfo.signature == "u") + { + window = windowInfo.value.toUInt32(); + } + else if (windowInfo.signature == "t") + { + window = windowInfo.value.toUInt64(); + } + + return window; +#endif +} + +static QCString dapiMakeStartupInfo( const QDBusVariant& windowInfo ) +{ +#if defined(Q_WS_X11) + WId window = dapiWindowID(windowInfo); + + if( window != 0 ) + { + // TODO for the window !=0 case KStartupInfo API needs to be + // extended to accept external timestamp for creating new startup info + KApplication::kApplication()->updateUserTimestamp(); + } + else + { + KApplication::kApplication()->updateUserTimestamp(); + } +#endif + + return KStartupInfo::createNewStartupId(); +} + /////////////////////////////////////////////////////////////////////////////// DAPIImpl::DAPIImpl() : org::freedesktop::dapi(), @@ -85,7 +123,9 @@ bool DAPIImpl::OpenUrl(const QString& url, const QDBusVariant& windowinfo, if (url.isEmpty()) return false; - KApplication::kApplication()->invokeBrowser(url); // TODO use windowinfo + QCString startupInfo = dapiMakeStartupInfo(windowinfo); + + KApplication::kApplication()->invokeBrowser(url, startupInfo); return true; } @@ -101,7 +141,15 @@ bool DAPIImpl::ExecuteUrl(const QString& url, const QDBusVariant& windowinfo, if (url.isEmpty()) return false; - KRun* run = new KRun(url); // TODO use windowinfo + KRun* run = new KRun(url); + + WId windowID = dapiWindowID(windowinfo); + if (windowID != 0) + { + KDapiFakeWidget* widget = new KDapiFakeWidget(windowID); + + QObject::connect(run, SIGNAL(destroyed()), widget, SLOT(deleteLater())); + } return !run->hasError(); } @@ -163,9 +211,11 @@ bool DAPIImpl::MailTo(const QString& subject, const QString& body, Q_UNUSED(error); Q_UNUSED(windowinfo); - // TODO use windowinfo + QCString startupInfo = dapiMakeStartupInfo(windowinfo); + KApplication::kApplication()->invokeMailer(to, cc, bcc, subject, body, - QString::null, attachments); + QString::null, attachments, + startupInfo); return true; } @@ -311,4 +361,20 @@ KABCHandler* DAPIImpl::addressBook() return m_addressBook; } +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +// some KDE APIs accept only QWidget* instead of WId + +KDapiFakeWidget::KDapiFakeWidget(WId window) +{ + create(window, false); // don't init +} + +/////////////////////////////////////////////////////////////////////////////// + +KDapiFakeWidget::~KDapiFakeWidget() +{ + destroy(false); // no cleanup +} + // End of File diff --git a/kde3/src/dapiimpl.h b/kde3/src/dapiimpl.h index 87f3a22..bf574c4 100644 --- a/kde3/src/dapiimpl.h +++ b/kde3/src/dapiimpl.h @@ -19,6 +19,9 @@ #if !defined(DAPIIMPL_H_INCLUDED) #define DAPIIMPL_H_INCLUDED +// Qt includes +#include <qwidget.h> + // Qt D-Bus includes #include <dbus/qdbusconnection.h> @@ -84,6 +87,14 @@ protected: KABCHandler* addressBook(); }; +class KDapiFakeWidget : public QWidget +{ + Q_OBJECT +public: + KDapiFakeWidget( WId window ); + virtual ~KDapiFakeWidget(); +}; + #endif // End of File |