[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdevplatform/plugins/openwith
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2009-08-09 22:41:48
Message-ID: 1249857708.903558.26878.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1009418 by apaku:

Implement support for opening urls in external applications.

 M  +19 -5     openwithplugin.cpp  
 M  +3 -1      openwithplugin.h  


--- trunk/KDE/kdevplatform/plugins/openwith/openwithplugin.cpp #1009417:1009418
@@ -35,6 +35,12 @@
 #include <kmimetypetrader.h>
 #include <QSignalMapper>
 #include <kmenu.h>
+#include <krun.h>
+#include <interfaces/icore.h>
+#include <interfaces/iuicontroller.h>
+#include <interfaces/iruncontroller.h>
+#include <interfaces/idocumentcontroller.h>
+#include <kparts/mainwindow.h>
 
 using namespace KDevelop;
 
@@ -59,7 +65,7 @@
     {
         delete actionMap;
     }
-    KUrl url;
+    url = KUrl();
     FileContext* filectx = dynamic_cast<FileContext*>( context );
     ProjectItemContext* projctx = dynamic_cast<ProjectItemContext*>( context );
     if( filectx && filectx->urls().count() == 1 )
@@ -88,8 +94,8 @@
         // Now setup a menu with actions for each part and app
         KMenu* menu = new KMenu( i18n("Open With" ) );
         
-        menu->addActions( actionsForServices( parts, preferredpart, "|__PART__" ) );
-        menu->addActions( actionsForServices( apps, preferredapp, "|__APP__" ) );
+        menu->addActions( actionsForServices( parts, preferredpart ) );
+        menu->addActions( actionsForServices( apps, preferredapp ) );
         
         KDevelop::ContextMenuExtension ext;
         ext.addAction( KDevelop::ContextMenuExtension::FileGroup, menu->menuAction() \
); @@ -99,7 +105,7 @@
 }
 
 
-QList< QAction* > OpenWithPlugin::actionsForServices ( const KService::List& list, \
KService::Ptr pref, const QString& prefix ) +QList< QAction* > \
OpenWithPlugin::actionsForServices ( const KService::List& list, KService::Ptr pref ) \
{  QList<QAction*> openactions;
     foreach( KService::Ptr svc, list )
@@ -107,7 +113,7 @@
         KAction* act = new KAction( svc->name(), this );
         act->setIcon( KIcon( svc->icon() ) );
         connect(act, SIGNAL(triggered()), actionMap, SLOT(map()));
-        actionMap->setMapping( act, svc->storageId()+prefix );
+        actionMap->setMapping( act, svc->storageId() );
         if( svc->storageId() == pref->storageId() )
         {
             openactions.prepend( act );
@@ -122,4 +128,12 @@
 void OpenWithPlugin::open ( const QString& storageid )
 {
     kDebug() << "opening:" << storageid;
+    KService::Ptr svc = KService::serviceByStorageId( storageid );
+    if( svc->isApplication() )
+    {
+        KRun::run( *svc, QList<KUrl>() << url, \
ICore::self()->uiController()->activeMainWindow() ); +    } else 
+    {
+        ICore::self()->documentController()->openDocument( url );
+    }
 }
--- trunk/KDE/kdevplatform/plugins/openwith/openwithplugin.h #1009417:1009418
@@ -24,6 +24,7 @@
 #include <interfaces/iplugin.h>
 #include <QVariantList>
 #include <kservice.h>
+#include <kurl.h>
 
 class QSignalMapper;
 namespace KDevelop
@@ -42,8 +43,9 @@
 private slots:
     void open( const QString& );
 private:
-    QList<QAction*> actionsForServices( const KService::List& list, KService::Ptr \
pref, const QString& prefix ); +    QList<QAction*> actionsForServices( const \
KService::List& list, KService::Ptr pref );  QSignalMapper* actionMap;
+    KUrl url;
 };
 
 #endif // OPENWITHPLUGIN_H


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic