summaryrefslogtreecommitdiffstats
path: root/parts/openwith
diff options
context:
space:
mode:
Diffstat (limited to 'parts/openwith')
-rw-r--r--parts/openwith/Makefile.am15
-rw-r--r--parts/openwith/README.dox52
-rw-r--r--parts/openwith/kdevopenwith.desktop82
-rw-r--r--parts/openwith/openwithpart.cpp138
-rw-r--r--parts/openwith/openwithpart.h36
5 files changed, 323 insertions, 0 deletions
diff --git a/parts/openwith/Makefile.am b/parts/openwith/Makefile.am
new file mode 100644
index 00000000..59bf6185
--- /dev/null
+++ b/parts/openwith/Makefile.am
@@ -0,0 +1,15 @@
+# Here resides the openwith part.
+
+INCLUDES = -I$(top_srcdir)/lib/interfaces -I$(top_srcdir)/lib/util $(all_includes)
+
+kde_module_LTLIBRARIES = libkdevopenwith.la
+libkdevopenwith_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
+libkdevopenwith_la_LIBADD = $(top_builddir)/lib/libkdevelop.la
+
+libkdevopenwith_la_SOURCES = openwithpart.cpp
+
+METASOURCES = AUTO
+
+servicedir = $(kde_servicesdir)
+service_DATA = kdevopenwith.desktop
+
diff --git a/parts/openwith/README.dox b/parts/openwith/README.dox
new file mode 100644
index 00000000..c729ad92
--- /dev/null
+++ b/parts/openwith/README.dox
@@ -0,0 +1,52 @@
+/** \class OpenWithPart
+Put a brief description here, the brief description ends at the first dot.
+Put a more detailed description of your part in these lines. It can span
+over several lines. You can even use some html commands in these lines like:
+<code>This is code</code>, html links <a href="http://somelocation">link text</a>,
+and images.
+
+\authors <a href="mailto:$EMAIL$">$AUTHOR$</a>
+\authors <a href="mailto:2nd author AT provider.com">2nd author full name</a>
+...
+\authors <a href="mailto:nth author AT provider.com">nth author full name</a>
+
+\maintainer <a href="mailto:$EMAIL$">$AUTHOR$</a>
+\maintainer <a href="mailto:2nd maintainer AT provider.com">2nd maintainer full name</a>
+...
+\maintainer <a href="mailto:nth maintainer AT provider.com">nth maintainer full name</a>
+
+\feature Describe the first feature
+\feature Describe the second feature
+...
+\feature Describe the last feature
+
+\bug Describe a the 1st bug that you know of, but probably hasn't been reported yet.
+..
+\bug Describe a the nth bug that you know of, but probably hasn't been reported yet.
+
+\requirement Describe a the 1st requirement of your part.
+\requirement Describe a the 2nd requirement of your part.
+...
+\requirement Describe a the nth requirement of your part.
+
+\todo Describe a the 1st TODO of your part.
+\todo Describe a the 2nd TODO of your part.
+...
+\todo Describe a the nth TODO of your part.
+
+\faq <b>First frequenly asked question about your part ?</b> Answer.
+\faq <b>Second frequenly asked question about your part ?</b> Answer.
+...
+\faq <b>Last frequenly asked question about your part ?</b> Answer.
+
+\note First note text.
+\note Second note text.
+...
+\note Last note text.
+
+\warning First warning text.
+\warning Second warning text.
+...
+\warning Last warning text.
+
+*/
diff --git a/parts/openwith/kdevopenwith.desktop b/parts/openwith/kdevopenwith.desktop
new file mode 100644
index 00000000..fcc7134c
--- /dev/null
+++ b/parts/openwith/kdevopenwith.desktop
@@ -0,0 +1,82 @@
+[Desktop Entry]
+Type=Service
+Exec=blubb
+Comment=This plugin provides additional "open" alternatives for various context menus in KDevelop.
+Comment[ca]=Aquest connector proporciona alternatives "open" addicionals per a diversos menús de context a KDevelop.
+Comment[da]=Dette plugin sørger for yderligere "åbne" alternativer for forskellige sammenhængsmenuer i KDevelop.
+Comment[de]=Dieses Modul stellt in vielen Kontextmenüs Alternativen für den Menüpunkt "Öffnen" zur Verfügung.
+Comment[el]=Αυτό το πρόσθετο προσφέρει εναλλακτικές επιλογές "ανοίγματος" για διάφορα σχετικά μενού στο KDevelop.
+Comment[es]=Este complemento proporciona alternativas de «abrir» adicionales en varios menús contextuales de KDevelop.
+Comment[et]=See plugin lisab KDevelopi erinevatele kontekstimenüüdele täiendavaid faili avamise võimalusi.
+Comment[eu]=Plugin honek KDevelop-eko testuinguru menu hainbatentzat beste "ireki" aukera eskeintzen dizkie.
+Comment[fa]=این وصله، انتخابهای »باز کردن« اضافی را برای گزینگان متن مختلف در KDevelop فراهم می‌کند.
+Comment[fr]=Ce module externe fournit des alternatives « ouvertes » supplémentaires pour divers menus contextuels dans KDevelop.
+Comment[gl]=Esta extensión proporciona alternativas "abrir" adicionais a varios menús de contexto de KDevelop.
+Comment[hu]=Ez a bővítőmodul további megnyitási lehetőségeket hoz létre a KDevelop felbukkanó menüiben.
+Comment[it]=Questo plugin offre alternative aggiuntive per "Apri" per i vari menu contestuali di KDevelop.
+Comment[ja]=このプラグインは、KDevelop の中のさまざまなコンテキストメニューに追加の「開く」選択肢を供給します。
+Comment[ms]=Plugin ini menyediakan alternatif "buka" tambahan untuk pelbagai menu konteks dalam KDevelop.
+Comment[nds]=Dit Moduul stellt för en Reeg Rechtsklickmenüs in KDevelop mehr Mööglichkeiten för "Opmaken" praat.
+Comment[ne]=यो प्लगइनले केडीई विकासमा विविध प्रसङ्ग मेनुका लागि अतिरिक्त "खोल्नुहोस्" विकल्प प्रदान गर्दछ ।
+Comment[nl]=Deze plugin biedt extra "open"-alternatieven in verschillende contextmenus in KDevelop.
+Comment[pl]=Ta wtyczka umożliwia dodanie dodatkowych możliwości otwierania plików w menu kontekstowych KDevelopa.
+Comment[pt]=Este 'plugin' oferece várias alternativas adicionais e "abertas" para vários menus de contexto no KDevelop.
+Comment[pt_BR]=Este plug-in fornece alternativas adicionais de "abrir" para vários menus de contetxo do KDevelop.
+Comment[ru]=Этот модуль предоставляет различные возможности открытия файлов, используя контекстные меню KDevelop.
+Comment[sk]=Modul poskytuje dodatočné "Otvoriť pomocou" alternatívy pre rôzne kontextové menu v KDevelop.
+Comment[sr]=Овај прикључак обезбеђује додатне алтернативе за „отвори“ за различите контекстне меније у kdevelop-у.
+Comment[sr@Latn]=Ovaj priključak obezbeđuje dodatne alternative za „otvori“ za različite kontekstne menije u kdevelop-u.
+Comment[sv]=Insticksprogrammet tillhandahåller ytterligare "öppna" alternativ i diverse sammanhangsberoende menyer i KDevelop.
+Comment[ta]=இந்த சொருகி Kஉருவாக்கியில் உள்ள வெவ்வேறு சூழுல் பட்டியலிற்கு பதில் "open" என்ற கூடுதல் வசதி தரும்.
+Comment[tg]=Ин модул як чанд хел кушодани файлҳоро имкон медиҳад, ҳангоми истифода намудани KDevelop.
+Comment[tr]=Bu eklenti, KDevelop'taki bir çok bağlam menüleri için fazladan "aç" alternatifleri sunar.
+Comment[zh_CN]=这个插件在 KDevelop 多个上下文菜单中提供“打开”菜单项。
+Comment[zh_TW]=此外掛程式提供 KDevelop 額外的「開啟方式」選單。
+Name=KDevOpenWith
+Name[da]=KDevelop Åbn med
+Name[de]="Öffnen mit"-Menüerweiterung (KDevelop)
+Name[hi]=के-डेव-ओपन-विथ
+Name[nds]=KDevelop-"Opmaken mit"-Menüverwiedern
+Name[pl]=KDevOtwórzW
+Name[sk]=KDev otvoriť pomocou
+Name[sv]=KDevelop öppna med
+Name[ta]=KDev வைத்து திற
+Name[tg]=Кушодани аз рӯи KDev
+Name[zh_TW]=KDevelop 開啟方式
+GenericName="Open with" Menu Addon
+GenericName[ca]=Afegit de menú "Obre amb"
+GenericName[da]="Åbn med" menu-tilføjelse
+GenericName[de]=Menüerweiterung "Öffnen mit"
+GenericName[el]=Πρόσθετο μενού "Άνοιγμα με"
+GenericName[es]=Extensión de menú «Abrir con»
+GenericName[et]=Menüü "Ava kasutades" lisamine
+GenericName[eu]="Ireki honekin" menu gehigarria
+GenericName[fa]=»باز کردن با« افزودن گزینگان
+GenericName[fr]=Extension de menu « Ouvrir avec... »
+GenericName[gl]=Engadido "Abrir con" para menús
+GenericName[hu]="Megnyitás ezzel" menübővítés
+GenericName[it]=Aggiunta al menu della voce "Apri con"
+GenericName[ja]=「アプリケーションで開く」メニューアドオン
+GenericName[nds]=Menüverwiedern "Opmaken mit"
+GenericName[ne]="यससँग खोल्नुहोस्" मेनु एडअन
+GenericName[nl]="Openen met" menutoevoeging
+GenericName[pl]=Dodatek do menu "Otwórz za pomocą"
+GenericName[pt]=Extra do Menu "Abrir com"
+GenericName[pt_BR]=Addon de Menu "Abrir com"
+GenericName[ru]=Дополнение меню "Открыть с помощью"
+GenericName[sk]="Otvoriť pomocou" prídavok k menu
+GenericName[sl]=Menijski dodatek »Odpri z«
+GenericName[sr]=Додатак за мени „Отвори помоћу“
+GenericName[sr@Latn]=Dodatak za meni „Otvori pomoću“
+GenericName[sv]=Menytillägg till "Öppna med"
+GenericName[ta]="Open with" பட்டியல் அடான்
+GenericName[tg]=Менюи иловагӣ "Кушодан бо фармони Ёрӣ"
+GenericName[tr]="Birlikte Aç" Menü Eki
+GenericName[zh_CN]=“打开方式”菜单项
+GenericName[zh_TW]="開啟方式"選單
+Icon=kdevelop
+ServiceTypes=KDevelop/Plugin
+X-KDE-Library=libkdevopenwith
+X-KDevelop-Version=5
+X-KDevelop-Scope=Global
+X-KDevelop-Properties=GlobalFileManagement,FileOpenWith
diff --git a/parts/openwith/openwithpart.cpp b/parts/openwith/openwithpart.cpp
new file mode 100644
index 00000000..4ff33ffb
--- /dev/null
+++ b/parts/openwith/openwithpart.cpp
@@ -0,0 +1,138 @@
+#include "openwithpart.h"
+
+#include <qfile.h>
+
+#include <kpopupmenu.h>
+#include <kdevgenericfactory.h>
+#include <kdebug.h>
+#include <kmimetype.h>
+#include <ktrader.h>
+#include <krun.h>
+#include <kaction.h>
+#include <kcharsets.h>
+
+#include "kdevpartcontroller.h"
+#include "kdevcore.h"
+#include "kdevplugininfo.h"
+#include "urlutil.h"
+
+typedef KDevGenericFactory<OpenWithPart> OpenWithFactory;
+
+static const KDevPluginInfo data("kdevopenwith");
+K_EXPORT_COMPONENT_FACTORY(libkdevopenwith, OpenWithFactory(data))
+
+OpenWithPart::OpenWithPart(QObject *parent, const char *name, const QStringList &)
+ : KDevPlugin(&data, parent, name ? name : "OpenWithPart")
+{
+ setInstance( OpenWithFactory::instance() );
+
+ connect(core(), SIGNAL(contextMenu(QPopupMenu*,const Context *)),
+ this, SLOT(fillContextMenu(QPopupMenu*,const Context *)));
+}
+
+
+OpenWithPart::~OpenWithPart()
+{
+}
+
+
+void OpenWithPart::fillContextMenu(QPopupMenu *popup, const Context *context)
+{
+ if ( !context->hasType( Context::FileContext ) ) return;
+
+ const FileContext *ctx = static_cast<const FileContext*>(context);
+ m_urls = ctx->urls();
+
+ popup->insertSeparator();
+
+ popup->insertItem( i18n("Open as UTF-8"), this, SLOT(openAsUtf8()) );
+
+ KPopupMenu * openAsPopup = new KPopupMenu( popup );
+
+ int id = popup->insertItem( i18n("Open As"), openAsPopup );
+ popup->setWhatsThis(id, i18n("<b>Open As</b><p>Lists all encodings that can be used to open the selected file."));
+
+ QStringList encodings = KGlobal::charsets()->descriptiveEncodingNames();
+
+ int i = 0;
+ QStringList::const_iterator it = encodings.constBegin();
+ while ( it != encodings.constEnd() )
+ {
+ openAsPopup->insertItem( *it, this, SLOT(openAsEncoding(int)), 0, i );
+ ++it;
+ i++;
+ }
+
+ KPopupMenu * openWithPopup = new KPopupMenu( popup );
+
+ // hmmm.. what to do here? open every different mimetype seperately? Just go with the first for now..
+ QString mimeType = KMimeType::findByURL(m_urls.first(), 0, true, true)->name();
+ KTrader::OfferList offers = KTrader::self()->query(mimeType, "Type == 'Application'");
+ if (offers.count() > 0)
+ {
+ KTrader::OfferList::Iterator it;
+ for (it = offers.begin(); it != offers.end(); ++it)
+ {
+ KAction *action = new KAction((*it)->name(), (*it)->icon(), 0, 0, QFile::encodeName( (*it)->desktopEntryPath() ).data());
+ connect(action, SIGNAL(activated()), this, SLOT(openWithService()));
+ action->plug( openWithPopup );
+ }
+ }
+
+ id = popup->insertItem( i18n("Open With"), openWithPopup );
+ popup->setWhatsThis(id, i18n("<b>Open With</b><p>Lists all applications that can be used to open the selected file."));
+
+ openWithPopup->insertSeparator();
+
+ // make sure the generic "Open with ..." entry gets appended to the submenu
+ id = openWithPopup->insertItem(i18n("Open With..."), this, SLOT(openWithDialog()));
+ openWithPopup->setWhatsThis(id, i18n("<b>Open With...</b><p>Provides a dialog to choose the application to open the selected file."));
+}
+
+
+void OpenWithPart::openWithService()
+{
+ KService::Ptr ptr = KService::serviceByDesktopPath(sender()->name());
+ if (ptr)
+ {
+ KRun::run(*ptr, m_urls);
+ }
+}
+
+
+void OpenWithPart::openWithDialog()
+{
+ KRun::displayOpenWithDialog( m_urls );
+}
+
+
+void OpenWithPart::openAsEncoding( int id )
+{
+ QStringList encodings = KGlobal::charsets()->descriptiveEncodingNames();
+ QString encoding;
+ if ( id <= encodings.count() && id >= 0 )
+ {
+ encoding = KGlobal::charsets()->encodingForName( encodings[ id ] );
+ }
+
+ KURL::List::iterator it = m_urls.begin();
+ while ( it != m_urls.end() )
+ {
+ partController()->setEncoding( encoding );
+ partController()->editDocument( *it );
+ ++it;
+ }
+}
+
+void OpenWithPart::openAsUtf8( )
+{
+ KURL::List::iterator it = m_urls.begin();
+ while ( it != m_urls.end() )
+ {
+ partController()->setEncoding( "utf8" );
+ partController()->editDocument( *it );
+ ++it;
+ }
+}
+
+#include "openwithpart.moc"
diff --git a/parts/openwith/openwithpart.h b/parts/openwith/openwithpart.h
new file mode 100644
index 00000000..c79ad164
--- /dev/null
+++ b/parts/openwith/openwithpart.h
@@ -0,0 +1,36 @@
+#ifndef __OPENWITHPART_H__
+#define __OPENWITHPART_H__
+
+#include <kurl.h>
+
+#include "kdevplugin.h"
+
+class QPopupMenu;
+class Context;
+
+
+class OpenWithPart : public KDevPlugin
+{
+ Q_OBJECT
+
+public:
+
+ OpenWithPart(QObject *parent, const char *name, const QStringList &);
+ ~OpenWithPart();
+
+
+private slots:
+
+ void fillContextMenu(QPopupMenu *popup, const Context *context);
+
+ void openWithService();
+ void openWithDialog();
+ void openAsEncoding(int id);
+ void openAsUtf8();
+
+private:
+
+ KURL::List m_urls;
+};
+
+#endif