[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdesdk/kate/plugins/externaltools [POSSIBLY UNSAFE]
From: Dominik Haumann <dhdev () gmx ! de>
Date: 2008-03-31 22:39:01
Message-ID: 1207003141.663496.8749.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 792379 by dhaumann:
external tools shows up again. google selection even works.
still lots of polishing needed.
M +22 -20 kateexternaltools.cpp [POSSIBLY UNSAFE: KRun::runCommand]
M +1 -1 kateexternaltools.h
M +18 -10 kateexternaltoolsplugin.cpp
M +4 -0 kateexternaltoolsplugin.h
M +5 -2 ui.rc
--- trunk/KDE/kdesdk/kate/plugins/externaltools/kateexternaltools.cpp #792378:792379
@@ -250,18 +250,21 @@
bool KateExternalToolAction::expandMacro( const QString &str, QStringList &ret )
{
-#if 0
- KateMainWindow *mw = (KateMainWindow*)parent()->parent();
+ Kate::MainWindow *mw = qobject_cast<Kate::MainWindow*>(parent()->parent());
+ Q_ASSERT(mw);
- KTextEditor::View *view = mw->viewManager()->activeView();
+ KTextEditor::View *view = mw->activeView();
if ( ! view ) return false;
+ KTextEditor::Document *doc = view->document();
+ KUrl url = doc->url();
+
if ( str == "URL" )
- ret += mw->activeDocumentUrl().url();
+ ret += url.url();
else if ( str == "directory" ) // directory of current doc
- ret += mw->activeDocumentUrl().directory();
+ ret += url.directory();
else if ( str == "filename" )
- ret += mw->activeDocumentUrl().fileName();
+ ret += url.fileName();
else if ( str == "line" ) // cursor line of current doc
ret += QString::number( view->cursorPosition().line() );
else if ( str == "col" ) // cursor col of current doc
@@ -269,17 +272,16 @@
else if ( str == "selection" ) // selection of current doc if any
ret += view->selectionText();
else if ( str == "text" ) // text of current doc
- ret += view->document()->text();
+ ret += doc->text();
else if ( str == "URLs" )
{
- foreach( KTextEditor::Document *doc, KateDocManager::self()->documentList())
- if ( ! doc->url().isEmpty() )
- ret += doc->url().url();
+ foreach( KTextEditor::Document *it, Kate::documentManager()->documents())
+ if ( ! it->url().isEmpty() )
+ ret += it->url().url();
}
else
return false;
-#endif
return true;
}
@@ -290,14 +292,14 @@
void KateExternalToolAction::slotRun()
{
-#if 0
// expand the macros in command if any,
// and construct a command with an absolute path
QString cmd = tool->command;
+ Kate::MainWindow *mw = qobject_cast<Kate::MainWindow*>(parent()->parent());
if ( ! expandMacrosShellQuote( cmd ) )
{
- KMessageBox::sorry( (KateMainWindow*)parent()->parent(),
+ KMessageBox::sorry( 0,
i18n("Failed to expand the command '%1'.", cmd ),
i18n( "Kate External Tools") );
return;
@@ -305,26 +307,26 @@
kDebug(13001) << "externaltools: Running command: " << cmd;
// save documents if requested
- KateMainWindow *mw = (KateMainWindow*)parent()->parent();
if ( tool->save == 1 )
- mw->viewManager()->activeView()->document()->save();
- else if ( tool->save == 2 )
- mw->actionCollection()->action("file_save_all")->trigger();
+ mw->activeView()->document()->save();
+// FIXME
+// else if ( tool->save == 2 )
+// mw->actionCollection()->action("file_save_all")->trigger();
- KRun::runCommand( cmd, tool->tryexec, tool->icon );
-#endif
+ KRun::runCommand( cmd, tool->tryexec, tool->icon, 0 );
}
//END KateExternalToolAction
//BEGIN KateExternalToolsMenuAction
KateExternalToolsMenuAction::KateExternalToolsMenuAction( const QString &text,
+ KActionCollection *collection,
QObject *parent,
Kate::MainWindow *mw )
: KActionMenu( text, parent ),
mainwindow( mw )
{
- m_actionCollection = new KActionCollection( (QWidget*) mainwindow );
+ m_actionCollection = collection;
// connect to view changed...
connect(mw, SIGNAL(viewChanged()), this, SLOT(slotDocumentChanged()));
--- trunk/KDE/kdesdk/kate/plugins/externaltools/kateexternaltools.h #792378:792379
@@ -66,7 +66,7 @@
Q_OBJECT
public:
- KateExternalToolsMenuAction( const QString &text, QObject *parent, class \
Kate::MainWindow *mw = 0 ); + KateExternalToolsMenuAction( const QString &text, \
class KActionCollection *collection, QObject *parent, class Kate::MainWindow *mw = 0 \
); ~KateExternalToolsMenuAction()
{}
--- trunk/KDE/kdesdk/kate/plugins/externaltools/kateexternaltoolsplugin.cpp \
#792378:792379 @@ -2,16 +2,16 @@
Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
Copyright (C) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
-
+
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
@@ -51,13 +51,21 @@
}
KateExternalToolsPluginView::KateExternalToolsPluginView (Kate::MainWindow \
*mainWindow)
- : Kate::PluginView (mainWindow)
+ : Kate::PluginView (mainWindow), KXMLGUIClient()
{
- /* actionCollection()->addAction( KStandardAction::Mail, this, SLOT(slotMail()) \
)
- ->setWhatsThis(i18n("Send one or more of the open documents as email \
attachments."));
- setInstance (new KInstance("kate"));
- setXMLFile("plugins/kateexternaltools/ui.rc");
- mainWindow->guiFactory()->addClient (this);*/
+ externalTools = 0;
+
+ if (KAuthorized::authorizeKAction("shell_access"))
+ {
+ externalTools = new KateExternalToolsMenuAction( i18n("External Tools"), \
actionCollection(), mainWindow, mainWindow ); + \
actionCollection()->addAction("tools_external", externalTools); + \
externalTools->setWhatsThis( i18n("Launch external helper applications") ); +
+ setComponentData(KComponentData("kate"));
+ setXMLFile("plugins/kateexternaltools/ui.rc");
+ }
+
+ mainWindow->guiFactory()->addClient (this);
}
KateExternalToolsPluginView::~KateExternalToolsPluginView ()
@@ -71,7 +79,7 @@
if( cmdIface )
cmdIface->registerCommand( KateExternalToolsCommand::self() );
}
-
+
if ( KAuthorized::authorize("shell_access") )
{
externalTools = new KateExternalToolsMenuAction( i18n("External Tools"), this, \
this );
--- trunk/KDE/kdesdk/kate/plugins/externaltools/kateexternaltoolsplugin.h \
#792378:792379 @@ -26,7 +26,9 @@
#include <kxmlguiclient.h>
+#include "kateexternaltools.h"
+
namespace KParts
{
}
@@ -57,6 +59,8 @@
* Virtual destructor.
*/
~KateExternalToolsPluginView ();
+
+ KateExternalToolsMenuAction *externalTools;
};
#endif
--- trunk/KDE/kdesdk/kate/plugins/externaltools/ui.rc #792378:792379
@@ -1,8 +1,11 @@
<!DOCTYPE kpartgui>
-<kpartplugin name="katemailfiles" library="katemailfilesplugin" version="2">
+<kpartplugin name="kateexternaltools" library="kateexternaltoolsplugin" version="2">
<MenuBar>
<Menu name="file"><text>&File</text>
<Action name="file_mail" group="export_merge"/>
</Menu>
+ <Menu name="tools"><text>&Tools</text>
+ <Action name="tools_external" />
+ </Menu>
</MenuBar>
-</kpartplugin>
+</kpartplugin>
\ No newline at end of file
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic