generic: adjust to KRun changes

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-05-12 03:22:02 +03:00
parent 6058479e6f
commit 957da2bb43
55 changed files with 139 additions and 599 deletions

View file

@ -314,7 +314,6 @@ add_subdirectory(kdeeject)
add_subdirectory(kfile)
add_subdirectory(kiconfinder)
add_subdirectory(kioclient)
add_subdirectory(kioexec)
add_subdirectory(ktraderclient)
add_subdirectory(kreadconfig)
add_subdirectory(kmimetypefinder)

View file

@ -24,7 +24,6 @@
#include <KCmdLineArgs>
#include <KDebug>
#include <KRun>
#include <KUrl>
DolphinApplication::DolphinApplication() :

View file

@ -357,7 +357,7 @@ void DolphinMainWindow::updateFilterBarAction(bool show)
void DolphinMainWindow::openNewMainWindow()
{
KRun::run("dolphin %u", KUrl::List(), this);
KToolInvocation::self()->startServiceByStorageId("dolphin", QStringList(), this);
}
void DolphinMainWindow::openNewTab()
@ -468,7 +468,7 @@ void DolphinMainWindow::openInNewWindow()
}
if (!newWindowUrl.isEmpty()) {
KRun::run("dolphin %u", KUrl::List() << newWindowUrl, this);
KToolInvocation::self()->startServiceByStorageId("dolphin", QStringList() << newWindowUrl.url(), this);
}
}
@ -955,18 +955,15 @@ void DolphinMainWindow::openTabContextMenu(int index, const QPoint& pos)
openNewTab(url);
m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
} else if (selectedAction == detachTabAction) {
const QString separator(QLatin1Char(' '));
QString command = QLatin1String("dolphin");
QStringList dolphinArgs;
const DolphinTabPage* tabPage = m_viewTab.at(index);
command += separator + tabPage->primaryViewContainer()->url().url();
dolphinArgs << tabPage->primaryViewContainer()->url().url();
if (tabPage->splitViewEnabled()) {
command += separator + tabPage->secondaryViewContainer()->url().url();
command += separator + QLatin1String("-split");
dolphinArgs << tabPage->secondaryViewContainer()->url().url();
dolphinArgs << QLatin1String("-split");
}
KRun::runCommand(command, this);
KToolInvocation::self()->startProgram("dolphin", dolphinArgs, this);
closeTab(index);
} else if (selectedAction == closeOtherTabsAction) {
@ -1010,7 +1007,7 @@ void DolphinMainWindow::handleUrl(const KUrl& url)
this, SLOT(slotHandleUrlStatFinished(KJob*)));
} else {
new KRun(url, this); // Automatically deletes itself after being finished
KToolInvocation::self()->startServiceForUrl(url.url(), this);
}
}
@ -1022,7 +1019,7 @@ void DolphinMainWindow::slotHandleUrlStatFinished(KJob* job)
if (entry.isDir()) {
activeViewContainer()->setUrl(url);
} else {
new KRun(url, this); // Automatically deletes itself after being finished
KToolInvocation::self()->startServiceForUrl(url.url(), this);
}
}
@ -1056,7 +1053,7 @@ void DolphinMainWindow::openContextMenu(const QPoint& pos,
switch (command) {
case DolphinContextMenu::OpenParentFolderInNewWindow: {
KRun::run("dolphin %u", KUrl::List() << item.url().upUrl(), this);
KToolInvocation::self()->startServiceByStorageId("dolphin", QStringList() << item.url().upUrl().url(), this);
break;
}

View file

@ -405,7 +405,7 @@ private slots:
/**
* If the URL can be listed, open it in the current view, otherwise
* run it through KRun.
* run it through KToolInvocation.
*/
void handleUrl(const KUrl& url);

View file

@ -43,8 +43,6 @@
#include <KUrl>
#include <KUrlComboBox>
#include <KUrlNavigator>
#include <KRun>
#include "dolphin_generalsettings.h"
#include "filterbar/filterbar.h"

View file

@ -26,7 +26,7 @@
#include <QMenu>
#include <QFileInfo>
#include <QDir>
#include <KRun>
#include <KToolInvocation>
#include <KIcon>
#include <QProcess>
#include <QApplication>
@ -152,19 +152,19 @@ void KateProjectTreeViewContextMenu::exec(const QString& filename, const QPoint&
} else if(openDirectoryWithMenu == action->parentWidget()) {
// handle open directory with
const QString openDirWith = action->data().toString();
if (KService::Ptr app = KService::serviceByDesktopPath(openDirWith)) {
if (!openDirWith.isEmpty()) {
QFileInfo fi(filename);
QList<QUrl> list;
list << QUrl::fromLocalFile (fi.dir().absolutePath());
KRun::run(*app, list, parent);
QStringList list;
list << fi.dir().absolutePath();
KToolInvocation::self()->startServiceByStorageId(openDirWith, list, parent);
}
} else {
// open with
const QString openWith = action->data().toString();
if (KService::Ptr app = KService::serviceByDesktopPath(openWith)) {
QList<QUrl> list;
list << QUrl::fromLocalFile (filename);
KRun::run(*app, list, parent);
if (!openWith.isEmpty()) {
QStringList list;
list << filename;
KToolInvocation::self()->startServiceByStorageId(openWith, list, parent);
}
}
}

View file

@ -202,7 +202,7 @@ void KateSessionApplet::slotOnItemClicked(const QModelIndex &index)
else if ( id > 2 )
args <<"-n"<< "--start"<<m_sessions[ id-3 ];
KToolInvocation::self()->kdeinitExec("kate", args);
KToolInvocation::self()->startProgram("kate", args);
}
void KateSessionApplet::createConfigurationInterface(KConfigDialog *parent)

View file

@ -74,7 +74,7 @@
#include <kmimetypechooser.h>
#include <knuminput.h>
#include <kmenu.h>
#include <krun.h>
#include <ktoolinvocation.h>
#include <kseparator.h>
#include <kstandarddirs.h>
#include <ktemporaryfile.h>
@ -1250,12 +1250,11 @@ void KateModOnHdPrompt::slotPDone()
}
m_diffFile->setAutoRemove(false);
KUrl url = KUrl::fromPath(m_diffFile->fileName());
QString url = m_diffFile->fileName();
delete m_diffFile;
m_diffFile = 0;
// KRun::runUrl should delete the file, once the client exits
KRun::runUrl( url, "text/x-patch", this, true );
KToolInvocation::self()->startServiceForUrl( url, this, true );
}
void KateModOnHdPrompt::slotButtonClicked(int button)

View file

@ -343,7 +343,7 @@ class KatePartPluginConfigPage : public KateConfigPage
* This dialog will prompt the user for what do with a file that is
* modified on disk.
* If the file wasn't deleted, it has a 'diff' button, which will create
* a diff file (uing diff(1)) and launch that using KRun.
* a diff file (uing diff(1)) and launch that using KToolInvocation.
*/
class KateModOnHdPrompt : public KDialog
{

View file

@ -25,7 +25,7 @@
#include <qprocess.h>
#include <qtextstream.h>
#include <kmessagebox.h>
#include <krun.h>
#include <ktoolinvocation.h>
#include <klocale.h>
//BEGIN SwapDiffCreator
@ -149,12 +149,11 @@ void SwapDiffCreator::slotDiffFinished()
return;
}
// close diffFile and avoid removal, KRun will do that later!
// close diffFile and avoid removal
m_diffFile.close ();
m_diffFile.setAutoRemove (false);
// KRun::runUrl should delete the file, once the client exits
KRun::runUrl (KUrl::fromPath(m_diffFile.fileName()), "text/x-patch", m_swapFile->document()->activeView(), true );
KToolInvocation::self()->startServiceForUrl (m_diffFile.fileName(), m_swapFile->document()->activeView(), true );
deleteLater();
}

View file

@ -808,19 +808,11 @@ void KateMainWindow::slotOpenWithMenuAction(QAction* a)
// display "open with" dialog
KOpenWithDialog dlg(list);
if (dlg.exec())
KRun::run(*dlg.service(), list, this);
KToolInvocation::self()->startServiceByStorageId(dlg.service()->entryPath(), list.toStringList(), this);
return;
}
KService::Ptr app = KService::serviceByDesktopPath(openWith);
if (app)
{
KRun::run(*app, list, this);
}
else
{
KMessageBox::error(this, i18n("Application '%1' not found.", openWith), i18n("Application not found"));
}
KToolInvocation::self()->startServiceByStorageId(openWith, list.toStringList(), this);
}
void KateMainWindow::pluginHelp()

View file

@ -25,7 +25,7 @@
#include <KLocale>
#include <KMessageBox>
#include <KRun>
#include <KToolInvocation>
#include <KTemporaryFile>
#include <KPushButton>
#include <KVBox>
@ -301,12 +301,11 @@ void KateMwModOnHdDialog::slotPDone()
}
m_diffFile->setAutoRemove(false);
KUrl url = KUrl::fromPath(m_diffFile->fileName());
QString url = m_diffFile->fileName();
delete m_diffFile;
m_diffFile = 0;
// KRun::runUrl should delete the file, once the client exits
KRun::runUrl( url, "text/x-patch", this, true );
KToolInvocation::self()->startServiceForUrl( url, this, true );
}
void KateMwModOnHdDialog::addDocument(KTextEditor::Document *doc)

View file

@ -31,7 +31,7 @@
#include <KMimeTypeTrader>
#include <KMimeType>
#include <KOpenWithDialog>
#include <KRun>
#include <KToolInvocation>
#include <KMessageBox>
#include <QtGui/QMenu>
@ -261,19 +261,11 @@ void KateFileTree::slotOpenWithMenuAction(QAction* a)
// display "open with" dialog
KOpenWithDialog dlg(list);
if (dlg.exec())
KRun::run(*dlg.service(), list, this);
KToolInvocation::self()->startServiceByStorageId(dlg.service()->entryPath(), list.toStringList(), this);
return;
}
KService::Ptr app = KService::serviceByDesktopPath(openWith);
if (app)
{
KRun::run(*app, list, this);
}
else
{
KMessageBox::error(this, i18n("Application '%1' not found.", openWith), i18n("Application not found"));
}
KToolInvocation::self()->startServiceByStorageId(openWith, list.toStringList(), this);
}

View file

@ -672,7 +672,7 @@ void KAccessConfig::save()
// make kaccess reread the configuration
// turning a11y features off needs to be done by kaccess
// so run it to clear any enabled features and it will exit if it should
KToolInvocation::self()->startServiceByDesktopName("kaccess");
KToolInvocation::self()->startServiceByStorageId("kaccess");
emit changed(false);
}

View file

@ -1162,7 +1162,7 @@ void KColorCm::save()
displayGroup.writeEntry("exportKDEColors", applyToAlien->isChecked());
cfg.sync();
KToolInvocation::self()->startServiceByDesktopName("krdb");
KToolInvocation::self()->startServiceByStorageId("krdb");
emit changed(false);
}

View file

@ -270,7 +270,7 @@ bool FontAASettings::load()
xft.apply(); // Save this setting
KConfigGroup(&kglobals, "General").writeEntry("XftHintStyle", KXftConfig::toStr(hStyle));
kglobals.sync();
KToolInvocation::self()->startServiceByDesktopName("krdb");
KToolInvocation::self()->startServiceByStorageId("krdb");
}
hintingStyle->setCurrentIndex(getIndex(hStyle));
@ -731,7 +731,7 @@ void KFonts::save()
}
#endif
#endif
KToolInvocation::self()->startServiceByDesktopName("krdb");
KToolInvocation::self()->startServiceByStorageId("krdb");
emit changed(false);
}

View file

@ -551,7 +551,7 @@ void MouseConfig::save()
group.writeEntry("MKCurve", mk_curve->value());
// restart kaccess
KToolInvocation::self()->startServiceByDesktopName("kaccess");
KToolInvocation::self()->startServiceByStorageId("kaccess");
emit changed(false);
}

View file

@ -257,7 +257,7 @@ bool ThemePage::applyTheme(const CursorTheme *theme, const int size)
KToolInvocation::self()->setLaunchEnv("XCURSOR_THEME", theme->name());
// Update the Xcursor X resources
KToolInvocation::self()->startServiceByDesktopName("krdb");
KToolInvocation::self()->startServiceByStorageId("krdb");
// Notify all applications that the cursor theme has changed
KGlobalSettings::self()->emitChange(KGlobalSettings::MouseChanged);

View file

@ -162,7 +162,7 @@ void RandrMonitorModule::processX11Event( XEvent* e )
void RandrMonitorModule::showKcm()
{
KToolInvocation::self()->kdeinitExec("kcmshell4", QStringList() << "randr");
KToolInvocation::self()->startProgram("kcmshell4", QStringList() << "randr");
}
void RandrMonitorModule::tryAutoConfig()
@ -244,7 +244,7 @@ void RandrMonitorModule::switchDisplay()
return;
}
// no idea what to do here
KToolInvocation::self()->kdeinitExec( "kcmshell4", QStringList() << "randr" );
KToolInvocation::self()->startProgram( "kcmshell4", QStringList() << "randr" );
}
void RandrMonitorModule::resumedFromSuspend()

View file

@ -389,7 +389,7 @@ void KCMStyle::save()
// export fonts/colors settings.
if (m_bStyleDirty | m_bToolbarDirty) // Export only if necessary
{
KToolInvocation::self()->startServiceByDesktopName("krdb");
KToolInvocation::self()->startServiceByStorageId("krdb");
}
// Clean up

View file

@ -176,7 +176,7 @@ void KCrashModule::slotDirty(const QString &path)
kcrashargs.append(kcrashdisplay);
}
kDebug() << "Restarting" << kcrashfilepath << kcrashapppath << kcrashargs;
KToolInvocation::self()->kdeinitExec(kcrashapppath, kcrashargs);
KToolInvocation::self()->startProgram(kcrashapppath, kcrashargs);
}
}
}

View file

@ -46,7 +46,7 @@
#include <klocale.h>
#include <kstandardaction.h>
#include <kfiledialog.h>
#include <krun.h>
#include <ktoolinvocation.h>
#include <kstandarddirs.h>
#include <kbookmark.h>
#include <kbookmarkmanager.h>
@ -407,7 +407,7 @@ void ActionsImpl::slotOpenLink()
for (it = bookmarks.constBegin(); it != end; ++it) {
if ((*it).isGroup() || (*it).isSeparator())
continue;
(void)new KRun((*it).url(), KEBApp::self());
KToolInvocation::self()->startServiceForUrl((*it).url().url(), KEBApp::self());
}
}

View file

@ -32,7 +32,7 @@
#include <kfiledialog.h>
#include <klocale.h>
#include <kapplication.h>
#include <krun.h>
#include <ktoolinvocation.h>
#include <kmessagebox.h>
#include <kglobal.h>
#include <kdebug.h>
@ -520,7 +520,7 @@ void KFindTreeView::openContainingFolder()
//TODO if >1 add a warn ?
Q_FOREACH( const KUrl & url, folderMaps.keys() )
{
(void) new KRun(url, this);
KToolInvocation::self()->startServiceForUrl(url.url(), this);
}
}

View file

@ -18,6 +18,8 @@
#include "kioclient.h"
#include <QTimer>
#include <QDBusConnection>
#include <kio/job.h>
#include <kio/copyjob.h>
#include <kio/deletejob.h>
@ -32,9 +34,7 @@
#include <kfiledialog.h>
#include <kdebug.h>
#include <kservice.h>
#include <QTimer>
#include <krun.h>
#include <QtDBus/QtDBus>
#include <ktoolinvocation.h>
#include <kcomponentdata.h>
#include <iostream>
@ -145,18 +145,6 @@ int main( int argc, char **argv )
return ClientApp::doIt() ? 0 /*no error*/ : 1 /*error*/;
}
bool krun_has_error = false;
void ClientApp::delayedQuit()
{
// Quit in 2 seconds. This leaves time for KRun to pop up
// "app not found" in KProcessRunner, if that was the case.
QTimer::singleShot( 2000, this, SLOT(quit()) );
// don't access the KRun instance later, it will be deleted after calling slots
if( static_cast< const KRun* >( sender())->hasError())
krun_has_error = true;
}
static void checkArgumentCount(int count, int min, int max)
{
if (count < min)
@ -171,23 +159,22 @@ static void checkArgumentCount(int count, int min, int max)
}
}
bool ClientApp::kde_open(const KUrl& url, const QString& mimeType, bool allowExec)
bool ClientApp::kde_open(const KUrl& url, const QString& mimeType)
{
if ( mimeType.isEmpty() ) {
kDebug() << url;
KRun * run = new KRun( url, 0 );
run->setRunExecutables(allowExec);
QObject::connect( run, SIGNAL( finished() ), this, SLOT( delayedQuit() ));
QObject::connect( run, SIGNAL( error() ), this, SLOT( delayedQuit() ));
bool ok = KToolInvocation::self()->startServiceForUrl( url.url() );
// Quit in 2 seconds. This leaves time for KToolInvocation to pop up
// "app not found", if that was the case.
QTimer::singleShot( 2000, this, SLOT(quit()) );
this->exec();
return !krun_has_error;
return ok;
} else {
const KUrl::List urls( url );
const KService::List offers = KMimeTypeTrader::self()->query(
mimeType, QLatin1String( "Application" ) );
if (offers.isEmpty()) return 1;
KService::Ptr serv = offers.first();
return KRun::run( *serv, urls, 0 );
return KToolInvocation::self()->startServiceByStorageId( serv->entryPath(), QStringList() << url.url() );
}
}
@ -286,7 +273,7 @@ bool ClientApp::doIt()
kFatal() << "Session bus not found" ;
#ifdef KIOCLIENT_AS_KDEOPEN
return app.kde_open(args->url(0), QByteArray(), false);
return app.kde_open(args->url(0), QByteArray());
#elif defined(KIOCLIENT_AS_KDECP)
checkArgumentCount(argc, 2, 0);
return app.doCopy(0);
@ -321,8 +308,7 @@ bool ClientApp::doIt()
{
checkArgumentCount(argc, 2, 3);
return app.kde_open( args->url( 1 ),
argc == 3 ? args->arg( 2 ) : QString(),
true );
argc == 3 ? args->arg( 2 ) : QString());
}
else if ( command == "download" )
{

View file

@ -35,11 +35,10 @@ private Q_SLOTS:
void slotPrintData(KIO::Job *job, const QByteArray &data);
void slotEntries(KIO::Job* job, const KIO::UDSEntryList& );
void slotResult( KJob * );
void delayedQuit();
void slotDialogCanceled();
private:
bool kde_open( const KUrl& url, const QString& mimeType, bool allowExec );
bool kde_open( const KUrl& url, const QString& mimeType );
bool doCopy( int firstArg );
bool doMove( int firstArg );
bool doList( int firstArg );

View file

@ -1,10 +0,0 @@
set(kioexec_SRCS main.cpp )
add_executable(kioexec ${kioexec_SRCS})
target_link_libraries(kioexec KDE4::kio)
install(
TARGETS kioexec
DESTINATION ${KDE4_LIBEXEC_INSTALL_DIR}
)

View file

@ -1,2 +0,0 @@
#!/bin/bash
$XGETTEXT *.cpp -o $podir/kioexec.pot

View file

@ -1,26 +0,0 @@
kioexec is launched when the user wants to open a remote file with
an application that only supports local files.
For this it does the following:
- downloads a remote file to a temp location
- starts a 'local' application with that temp file as argument
- wait fors application to be exited
- if the modification time of the file is different from the original one,
(because the file was modified) then it offers re-uploading the modified version.
This is how you offer network transparency to apps that don't have it.
BUT: with KUniqueApplication, this breaks, because the app returns at once,
so we have no way to know when the user finished editing the file...
Conclusion: if the application has network transparency built-in, it should
put "%u" in its desktop file - and kioexec isn't used -. If it doesn't, either
it's a KApplication and kiiooexec does its job, or it's a KUniqueApplication
and... kioexec can't see modifications to the file. Be warned.
From Waldo: "The program doesn't return _at once_. It returns
after "newInstance()" returns. So if you open the file there it will still work.
(Or rename it)"
David Faure <faure@kde.org>
20-May-2000

View file

@ -1,283 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
Copyright (C) 2000-2005 David Faure <faure@kde.org>
Copyright (C) 2001 Waldo Bastian <bastian@kde.org>
This program 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.
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "main.h"
#include <QtCore/QFile>
#include <QtCore/qprocess.h>
#include <kapplication.h>
#include <kdeversion.h>
#include <kstandarddirs.h>
#include <kdebug.h>
#include <kmessagebox.h>
#include <kio/job.h>
#include <krun.h>
#include <kio/netaccess.h>
#include <kservice.h>
#include <klocale.h>
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <kstartupinfo.h>
#include <kshell.h>
#include <kde_file.h>
static const char description[] =
I18N_NOOP("KIO Exec - Opens remote files, watches modifications, asks for upload");
KIOExec::KIOExec()
: mExited(false)
{
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (args->count() < 1)
KCmdLineArgs::usageError(i18n("'command' expected.\n"));
tempfiles = args->isSet("tempfiles");
if ( args->isSet( "suggestedfilename" ) )
suggestedFileName = args->getOption( "suggestedfilename" );
expectedCounter = 0;
jobCounter = 0;
command = args->arg(0);
kDebug() << "command=" << command;
for ( int i = 1; i < args->count(); i++ )
{
KUrl url = args->url(i);
url = KIO::NetAccess::mostLocalUrl( url, 0 );
//kDebug() << "url=" << url.url() << " filename=" << url.fileName();
// A local file, not an URL ?
// => It is not encoded and not shell escaped, too.
if ( url.isLocalFile() )
{
FileInfo file;
file.path = url.toLocalFile();
file.url = url;
fileList.append(file);
}
// It is an URL
else
{
if ( !url.isValid() )
KMessageBox::error( 0L, i18n( "The URL %1\nis malformed" , url.url() ) );
else if ( tempfiles )
KMessageBox::error( 0L, i18n( "Remote URL %1\nnot allowed with --tempfiles switch" , url.url() ) );
else
// We must fetch the file
{
QString fileName = KIO::encodeFileName( url.fileName() );
if ( !suggestedFileName.isEmpty() )
fileName = suggestedFileName;
// Build the destination filename, in ~/.kde/cache-*/krun/
// Unlike KDE-1.1, we put the filename at the end so that the extension is kept
// (Some programs rely on it)
QString tmp = KGlobal::dirs()->saveLocation( "cache", "krun/" ) +
QString("%1_%2_%3").arg(getpid()).arg(jobCounter++).arg(fileName);
FileInfo file;
file.path = tmp;
file.url = url;
fileList.append(file);
expectedCounter++;
KUrl dest;
dest.setPath( tmp );
kDebug() << "Copying " << url.prettyUrl() << " to " << dest;
KIO::Job *job = KIO::file_copy( url, dest );
jobList.append( job );
connect( job, SIGNAL( result( KJob * ) ), SLOT( slotResult( KJob * ) ) );
}
}
}
args->clear();
if ( tempfiles )
{
slotRunApp();
return;
}
counter = 0;
if ( counter == expectedCounter )
slotResult( 0L );
}
void KIOExec::slotResult( KJob * job )
{
if (job && job->error())
{
// That error dialog would be queued, i.e. not immediate...
//job->showErrorDialog();
if ( (job->error() != KIO::ERR_USER_CANCELED) )
KMessageBox::error( 0L, job->errorString() );
QString path = static_cast<KIO::FileCopyJob*>(job)->destUrl().path();
QList<FileInfo>::Iterator it = fileList.begin();
for(;it != fileList.end(); ++it)
{
if ((*it).path == path)
break;
}
if ( it != fileList.end() )
fileList.erase( it );
else
kDebug() << path << " not found in list";
}
counter++;
if ( counter < expectedCounter )
return;
kDebug() << "All files downloaded, will call slotRunApp shortly";
// We know we can run the app now - but let's finish the job properly first.
QTimer::singleShot( 0, this, SLOT( slotRunApp() ) );
jobList.clear();
}
void KIOExec::slotRunApp()
{
if ( fileList.isEmpty() ) {
kDebug() << "No files downloaded -> exiting";
mExited = true;
QApplication::exit(1);
return;
}
KService service("dummy", command, QString());
KUrl::List list;
// Store modification times
QList<FileInfo>::Iterator it = fileList.begin();
for ( ; it != fileList.end() ; ++it )
{
KDE_struct_stat buff;
(*it).time = KDE_stat( QFile::encodeName((*it).path), &buff ) ? 0 : buff.st_mtime;
KUrl url;
url.setPath((*it).path);
list << url;
}
QStringList params = KRun::processDesktopExec(service, list);
kDebug() << "EXEC " << KShell::joinArgs( params );
#ifdef Q_WS_X11
// propagate the startup identification to the started process
KStartupInfoId id;
id.initId( kapp->startupId());
id.setupStartupEnv();
#endif
QString exe( params.takeFirst() );
const int exit_code = QProcess::execute( exe, params );
#ifdef Q_WS_X11
KStartupInfo::resetStartupEnv();
#endif
kDebug() << "EXEC done";
// Test whether one of the files changed
it = fileList.begin();
for( ;it != fileList.end(); ++it )
{
KDE_struct_stat buff;
QString src = (*it).path;
KUrl dest = (*it).url;
if ( (KDE::stat( src, &buff ) == 0) &&
((*it).time != buff.st_mtime) )
{
if ( tempfiles )
{
if ( KMessageBox::questionYesNo( 0L,
i18n( "The supposedly temporary file\n%1\nhas been modified.\nDo you still want to delete it?" , dest.pathOrUrl()),
i18n( "File Changed" ), KStandardGuiItem::del(), KGuiItem(i18n("Do Not Delete")) ) != KMessageBox::Yes )
continue; // don't delete the temp file
}
else if ( ! dest.isLocalFile() ) // no upload when it's already a local file
{
if ( KMessageBox::questionYesNo( 0L,
i18n( "The file\n%1\nhas been modified.\nDo you want to upload the changes?" , dest.prettyUrl()),
i18n( "File Changed" ), KGuiItem(i18n("Upload")), KGuiItem(i18n("Do Not Upload")) ) == KMessageBox::Yes )
{
kDebug() << "src='" << src << "' dest='" << dest << "'";
// Do it the synchronous way.
if ( !KIO::NetAccess::upload( src, dest, 0 ) )
{
KMessageBox::error( 0L, KIO::NetAccess::lastErrorString() );
continue; // don't delete the temp file
}
}
}
}
if ((!dest.isLocalFile() || tempfiles) && exit_code == 0) {
// Wait for a reasonable time so that even if the application forks on startup (like OOo or amarok)
// it will have time to start up and read the file before it gets deleted. #130709.
kDebug() << "sleeping...";
sleep(180); // 3 mn
kDebug() << "about to delete " << src;
unlink( QFile::encodeName(src) );
}
}
mExited = true;
QApplication::exit(exit_code);
}
int main( int argc, char **argv )
{
KAboutData aboutData( "kioexec", "kioexec", ki18n("KIOExec"),
KDE_VERSION_STRING, ki18n(description), KAboutData::License_GPL,
ki18n("(c) 1998-2000,2003 The KFM/Konqueror Developers"));
aboutData.addAuthor(ki18n("David Faure"),KLocalizedString(), "faure@kde.org");
aboutData.addAuthor(ki18n("Stephan Kulow"),KLocalizedString(), "coolo@kde.org");
aboutData.addAuthor(ki18n("Bernhard Rosenkraenzer"),KLocalizedString(), "bero@arklinux.org");
aboutData.addAuthor(ki18n("Waldo Bastian"),KLocalizedString(), "bastian@kde.org");
aboutData.addAuthor(ki18n("Oswald Buddenhagen"),KLocalizedString(), "ossi@kde.org");
aboutData.setProgramIconName("kde");
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineOptions options;
options.add("tempfiles", ki18n("Treat URLs as local files and delete them afterwards"));
options.add("suggestedfilename <file name>", ki18n("Suggested file name for the downloaded file"));
options.add("+command", ki18n("Command to execute"));
options.add("+[URLs]", ki18n("URL(s) or local file(s) used for 'command'"));
KCmdLineArgs::addCmdLineOptions( options );
KApplication app;
app.setQuitOnLastWindowClosed(false);
KIOExec exec;
// Don't go into the event loop if we already want to exit (#172197)
if (exec.exited())
return 0;
return app.exec();
}
#include "moc_main.cpp"

View file

@ -1,66 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
Copyright (C) 2000-2005 David Faure <faure@kde.org>
Copyright (C) 2001 Waldo Bastian <bastian@kde.org>
This program 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.
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KIOEXEC_MAIN_H
#define KIOEXEC_MAIN_H
#include <QtCore/QObject>
#include <QtCore/QString>
#include <QList>
#include <QtCore/QTimer>
#include <KUrl>
namespace KIO { class Job; }
class KJob;
class KIOExec : public QObject
{
Q_OBJECT
public:
KIOExec();
bool exited() const { return mExited; }
public Q_SLOTS:
void slotResult( KJob * );
void slotRunApp();
protected:
bool mExited;
bool tempfiles;
QString suggestedFileName;
int counter;
int expectedCounter;
QString command;
struct FileInfo {
QString path;
KUrl url;
int time;
};
QList<FileInfo> fileList;
int jobCounter;
QList<KIO::Job *> jobList;
};
#endif

View file

@ -33,7 +33,6 @@
#include <KDirNotify>
#include <KCharsets>
#include <KDebug>
#include <KRun>
#include <KToolInvocation>
#include <KProtocolInfo>
@ -198,7 +197,7 @@ bool KNetAttach::validateCurrentPage()
return false;
}
KRun::runUrl(url, "inode/directory", this);
KToolInvocation::self()->startServiceForUrl(url.url(), this);
QString name = _connectionName->text().trimmed();

View file

@ -20,7 +20,7 @@
// Own
#include "Filter.h"
// Qt
// Katie
#include <QAction>
#include <QApplication>
#include <QtGui/QClipboard>
@ -29,7 +29,7 @@
// KDE
#include <KLocalizedString>
#include <KRun>
#include <KToolInvocation>
// Konsole
#include "TerminalCharacterDecoder.h"
@ -419,7 +419,7 @@ void UrlFilter::HotSpot::activate(QObject* object)
url.prepend("mailto:");
}
new KRun(url, QApplication::activeWindow());
KToolInvocation::self()->startServiceForUrl(url, QApplication::activeWindow());
}
}

View file

@ -37,7 +37,6 @@
#include <KLocalizedString>
#include <KMenu>
#include <KMessageBox>
#include <KRun>
#include <KShell>
#include <KToolInvocation>
#include <KStandardDirs>
@ -443,7 +442,7 @@ void SessionController::handleWebShortcutAction()
if (KUriFilter::self()->filterUri(filterData, QStringList() << "kurisearchfilter")) {
const KUrl& url = filterData.uri();
new KRun(url, QApplication::activeWindow());
KToolInvocation::self()->startServiceForUrl(url.url(), QApplication::activeWindow());
}
}
@ -488,14 +487,14 @@ void SessionController::handleOpenWithAction()
const QStringList actionData = action->data().toStringList();
Q_ASSERT(actionData.count() == 2);
KUrl::List actionUrls;
QStringList actionUrls;
actionUrls << actionData.at(1);
KRun::run(actionData.at(0), actionUrls, QApplication::activeWindow());
KToolInvocation::self()->startServiceByStorageId(actionData.at(0), actionUrls, QApplication::activeWindow());
}
void SessionController::configureWebShortcuts()
{
KToolInvocation::self()->kdeinitExec("kcmshell4", QStringList() << "ebrowsing");
KToolInvocation::self()->startProgram("kcmshell4", QStringList() << "ebrowsing");
}
void SessionController::sendSignal(QAction* action)
@ -973,9 +972,9 @@ void SessionController::openBrowser()
KUrl currentUrl = url();
if (currentUrl.isLocalFile())
new KRun(currentUrl, QApplication::activeWindow(), 0, true, true);
KToolInvocation::self()->startServiceForUrl(currentUrl.url(), QApplication::activeWindow());
else
new KRun(KUrl(QDir::homePath()), QApplication::activeWindow(), 0, true, true);
KToolInvocation::self()->startServiceForUrl(QDir::homePath(), QApplication::activeWindow());
}
void SessionController::copy()

View file

@ -97,10 +97,7 @@ KStart::KStart()
KStartupInfo::sendFinish(id); // failed to start
}
} else {
QString error;
if (KToolInvocation::self()->startServiceByDesktopPath(exe, url, &error) != 0) {
kError() << error;
}
KToolInvocation::self()->startServiceByStorageId(exe, QStringList() << url);
}
QTimer::singleShot(useRule ? 0 : 120 * 1000, qApp, SLOT(quit()));

View file

@ -968,7 +968,7 @@ void RuleBook::edit(Client* c, bool whole_app)
args << "--wid" << QString::number(c->window());
if (whole_app)
args << "--whole-app";
KToolInvocation::self()->kdeinitExec("kwin_rules_dialog", args);
KToolInvocation::self()->startProgram("kwin_rules_dialog", args);
}
void RuleBook::load()

View file

@ -223,7 +223,7 @@ void UserActionsMenu::configureWM()
{
QStringList args;
args << "--icon" << "preferences-system-windows" << configModules();
KToolInvocation::self()->kdeinitExec("kcmshell4", args);
KToolInvocation::self()->startProgram("kcmshell4", args);
}
void UserActionsMenu::init()

View file

@ -89,11 +89,10 @@ KonqOperations::~KonqOperations()
void KonqOperations::editMimeType( const QString & mimeType, QWidget* parent )
{
QString keditfiletype = QLatin1String("keditfiletype");
KRun::runCommand( keditfiletype
+ " --parent " + QString::number( (qptrdiff)parent->winId())
+ ' ' + KShell::quoteArg(mimeType),
keditfiletype, keditfiletype /*unused*/, parent );
QStringList args;
args << "--parent" << QString::number( (qptrdiff)parent->winId());
args << mimeType;
KToolInvocation::self()->startProgram( QLatin1String("keditfiletype"), args, parent );
}
void KonqOperations::del( QWidget * parent, Operation method, const KUrl::List & selectedUrls )
@ -381,10 +380,9 @@ void KonqOperations::asyncDrop( const KFileItem & destItem )
KConfigGroup desktopGroup = desktopFile.desktopGroup();
if ( desktopFile.hasApplicationType() )
{
QString error;
const QStringList urlStrList = m_info->urls.toStringList();
if ( KToolInvocation::self()->startServiceByDesktopPath( m_destUrl.path(), urlStrList, &error ) > 0 )
KMessageBox::error( parentWidget(), error );
KToolInvocation::self()->startServiceByStorageId(
m_destUrl.path(), m_info->urls.toStringList(), parentWidget()
);
}
else
{

View file

@ -30,8 +30,7 @@
#include <klocale.h>
#include <kbookmarkmanager.h>
#include <kbookmarkdialog.h>
#include <kdebug.h>
#include <krun.h>
#include <ktoolinvocation.h>
#include <kprotocolmanager.h>
#include <kicon.h>
#include <kiconloader.h>
@ -44,6 +43,7 @@
#include <kdesktopfile.h>
#include <kglobal.h>
#include <kacceleratormanager.h>
#include <kdebug.h>
#include <QFileInfo>
@ -479,7 +479,7 @@ KFileItemActions* KonqPopupMenu::fileItemActions() const
void KonqPopupMenuPrivate::slotPopupNewView()
{
Q_FOREACH(const KUrl& url, m_popupItemProperties.urlList()) {
(void) new KRun(url, m_parentWidget);
KToolInvocation::self()->startServiceForUrl(url.url(), m_parentWidget);
}
}
@ -498,7 +498,7 @@ void KonqPopupMenuPrivate::slotPopupEmptyTrashBin()
void KonqPopupMenuPrivate::slotConfigTrashBin()
{
KRun::run("kcmshell4 kcmtrash", KUrl::List(), m_parentWidget);
KToolInvocation::self()->startProgram("kcmshell4", QStringList() << "kcmtrash", m_parentWidget);
}
void KonqPopupMenuPrivate::slotPopupRestoreTrashedItems()
@ -580,7 +580,7 @@ void KonqPopupMenuPrivate::slotShowOriginalFile()
}
// Now destUrl points to the target file, let's go up to parent dir
destUrl.setPath(destUrl.directory());
KRun::runUrl(destUrl, "inode/directory", m_parentWidget);
KToolInvocation::self()->startServiceForUrl(destUrl.url(), m_parentWidget);
}
#include "moc_konq_popupmenu.cpp"

View file

@ -40,7 +40,7 @@
#include <Solid/OpticalDrive>
#include <Solid/PowerManagement>
#include <KIcon>
#include <KRun>
#include <KToolInvocation>
#include <KDiskFreeSpaceInfo>
#include <KDebug>
@ -308,7 +308,7 @@ void DeviceNotifierWidget::slotIconActivated()
mountpoint = solidstorageacces->filePath();
}
if (!mountpoint.isEmpty()) {
KRun::runUrl(KUrl(mountpoint), "inode/directory", nullptr);
KToolInvocation::self()->startServiceForUrl(mountpoint);
}
}

View file

@ -32,7 +32,7 @@
#include <KLocale>
#include <KMenu>
#include <KPropertiesDialog>
#include <KRun>
#include <KToolInvocation>
#include <KSharedConfig>
#include <KShell>
#include <KSycoca>
@ -258,11 +258,10 @@ void IconApplet::openUrl()
{
if (m_service) {
emit releaseVisualFocus();
KUrl::List urls;
KRun::run(*m_service, urls, 0);
KToolInvocation::self()->startServiceByStorageId(m_service->entryPath());
} else if (m_url.isValid()) {
emit releaseVisualFocus();
new KRun(m_url, 0);
KToolInvocation::self()->startServiceForUrl(m_url.url());
}
}
@ -421,7 +420,7 @@ void IconApplet::dropEvent(QGraphicsSceneDragDropEvent *event)
constraintsEvent(Plasma::FormFactorConstraint);
return;
} else if (m_service) {
KRun::run(*m_service, urls, 0);
KToolInvocation::self()->startServiceByStorageId(m_service->entryPath(), urls.toStringList());
return;
}
@ -433,24 +432,21 @@ void IconApplet::dropEvent(QGraphicsSceneDragDropEvent *event)
KDesktopFile::isDesktopFile(m_url.toLocalFile()))) {
if (KDesktopFile::isDesktopFile(m_url.toLocalFile())) {
//Extract the command from the Desktop file
KService service(m_url.toLocalFile());
KRun::run(service, urls, 0);
KToolInvocation::self()->startServiceByStorageId(m_url.toLocalFile(), urls.toStringList());
return;
}
// Just exec the local executable
QString params;
QStringList params;
foreach (const KUrl &url, urls) {
if (url.isLocalFile()) {
params += ' ' + KShell::quoteArg(url.toLocalFile());
params << url.toLocalFile();
} else {
params += ' ' + KShell::quoteArg(url.prettyUrl());
params << url.prettyUrl();
}
}
QString commandStr = KShell::quoteArg(m_url.path());
KRun::runCommand(commandStr + ' ' + params, 0);
KToolInvocation::self()->startProgram(m_url.path(), params);
} else if (mimetype && mimetype->is("inode/directory")) {
dropUrls(urls, m_url, event->modifiers());
}

View file

@ -102,20 +102,14 @@ static void kRunService(const QString &entrypath, LauncherApplet* launcherapplet
{
Q_ASSERT(launcherapplet != nullptr);
launcherapplet->resetState();
KService::Ptr service = KService::serviceByDesktopPath(entrypath);
Q_ASSERT(!service.isNull());
if (!KRun::run(*service.data(), KUrl::List(), nullptr)) {
kWarning() << "could not run" << entrypath;
}
KToolInvocation::self()->startServiceByStorageId(entrypath);
}
static void kRunUrl(const QString &urlpath, LauncherApplet* launcherapplet)
{
Q_ASSERT(launcherapplet != nullptr);
launcherapplet->resetState();
(void)new KRun(KUrl(urlpath), nullptr);
KToolInvocation::self()->startServiceForUrl(urlpath);
}
static KIcon kGenericIcon(const QString &name)
@ -1827,11 +1821,8 @@ KBookmarkManager* LauncherApplet::bookmarkManager() const
void LauncherApplet::slotEditMenu()
{
if (KToolInvocation::self()->kdeinitExec("kmenuedit") == 0) {
hidePopup();
} else {
showMessage(KIcon("dialog-error"), i18n("Failed to launch menu editor"), Plasma::MessageButton::ButtonOk);
}
hidePopup();
KToolInvocation::self()->startServiceByStorageId("kmenuedit");
}
void LauncherApplet::slotConfigAccepted()

View file

@ -21,7 +21,7 @@
#include <QGraphicsGridLayout>
#include <Plasma/Animation>
#include <KLocale>
#include <KRun>
#include <KToolInvocation>
#include <KIconLoader>
#include <KIcon>
#include <KMimeType>
@ -224,9 +224,7 @@ void JobFrame::slotIcon0Activated()
void JobFrame::slotIcon1Activated()
{
const KUrl desturl = KUrl(m_iconwidget1->property("_k_desturl").toString());
const KMimeType::Ptr kmimetype = KMimeType::findByUrl(desturl);
Q_ASSERT(kmimetype);
KRun::runUrl(desturl, kmimetype->name(), nullptr);
KToolInvocation::self()->startServiceForUrl(desturl.url());
}

View file

@ -19,16 +19,13 @@
***************************************************************************/
#include "launcher.h"
// Qt
// Katie
#include <QtCore/qnamespace.h>
#include <QtGlobal>
#include <QtGui/qgraphicssceneevent.h>
#include <QtGui/qgraphicssceneevent.h>
// KDE
#include <KRun>
// Plasma
#include <KToolInvocation>
#include <Plasma/ToolTipContent>
#include <Plasma/ToolTipManager>
@ -97,7 +94,7 @@ KUrl Launcher::url() const
void Launcher::execute()
{
new KRun(m_data.url(), 0);
KToolInvocation::self()->startServiceForUrl(m_data.url().url());
}
void Launcher::toolTipAboutToShow()

View file

@ -34,7 +34,7 @@
#include <KLocale>
#include <KNotification>
#include <QProcess>
#include <KRun>
#include <KToolInvocation>
#include <KSharedConfig>
#include <KStandardDirs>
#include <KUrl>
@ -187,7 +187,7 @@ void Trash::constraintsEvent(Plasma::Constraints constraints)
void Trash::open()
{
emit releaseVisualFocus();
KRun::runUrl(KUrl("trash:/"), "inode/directory", 0);
KToolInvocation::self()->startServiceForUrl(QString::fromLatin1("trash:/"));
}
void Trash::empty()

View file

@ -21,7 +21,7 @@
#include <KDebug>
#include <KIcon>
#include <KRun>
#include <KToolInvocation>
#include <Plasma/Containment>
AppLauncher::AppLauncher(QObject *parent, const QVariantList &args)
@ -101,7 +101,7 @@ void AppLauncher::switchTo(QAction *action)
{
const QString entrypath = action->data().toString();
kDebug() << "running" << entrypath;
new KRun(KUrl(entrypath), nullptr);
KToolInvocation::self()->startServiceByStorageId(entrypath);
}
#include "moc_launch.cpp"

View file

@ -21,7 +21,7 @@
#include <QMimeData>
#include <KDebug>
#include <KRun>
#include <KToolInvocation>
#include <KLocale>
#include <KMimeType>
#include <KShell>
@ -30,8 +30,6 @@
#include <KProtocolInfo>
#include <KUriFilter>
#include <kservicetypetrader.h>
LocationsRunner::LocationsRunner(QObject *parent, const QVariantList& args)
: Plasma::AbstractRunner(parent, args)
@ -123,9 +121,8 @@ void LocationsRunner::run(const Plasma::QueryMatch &match)
// kDebug() << "url: " << location << data;
KUrl urlToRun(KUriFilter::self()->filteredUri(location, QStringList() << QLatin1String("kshorturifilter")));
new KRun(urlToRun, nullptr);
KUrl urlToRun = KUriFilter::self()->filteredUri(location, QStringList() << QLatin1String("kshorturifilter"));
KToolInvocation::self()->startServiceForUrl(urlToRun.url());
}
QMimeData* LocationsRunner::mimeDataForMatch(const Plasma::QueryMatch &match)

View file

@ -25,7 +25,7 @@
#include <KDebug>
#include <KIcon>
#include <KRun>
#include <KToolInvocation>
#include <KUrl>
//Q_DECLARE_METATYPE(Plasma::RunnerContext)
@ -127,7 +127,7 @@ void PlacesRunner::run(const Plasma::QueryMatch &action)
{
//I don't just pass the model index because the list could change before the user clicks on it, which would make everything go wrong. Ideally we don't want things to go wrong.
if (action.data().canConvert<KUrl>()) {
new KRun(action.data().value<KUrl>().url(), 0);
KToolInvocation::self()->startServiceForUrl(action.data().value<KUrl>().url());
} else if (action.data().canConvert<QString>()) {
//search our list for the device with the same udi, then set it up (mount it).
QString deviceUdi = action.data().toString();
@ -158,7 +158,7 @@ void PlacesRunner::setupComplete(QModelIndex index, bool success)
KFilePlacesModel *places = qobject_cast<KFilePlacesModel*>(sender());
//kDebug() << "setup complete" << places << sender();
if (success && places) {
new KRun(places->url(index), 0);
KToolInvocation::self()->startServiceForUrl(places->url(index).url());
places->deleteLater();
}
}

View file

@ -26,7 +26,7 @@
#include <KDebug>
#include <KDirWatch>
#include <KIcon>
#include <KRun>
#include <KToolInvocation>
#include <KRecentDocument>
RecentDocuments::RecentDocuments(QObject *parent, const QVariantList &args)
@ -95,7 +95,7 @@ void RecentDocuments::run(const Plasma::QueryMatch &match)
{
const QString url = match.data().toString();
kDebug() << "Opening Recent Document" << url;
new KRun(url, 0);
KToolInvocation::self()->startServiceForUrl(url);
}
QMimeData* RecentDocuments::mimeDataForMatch(const Plasma::QueryMatch &match)

View file

@ -23,7 +23,7 @@
#include <KIcon>
#include <KDebug>
#include <KLocale>
#include <KRun>
#include <KToolInvocation>
#include <KService>
#include <KServiceTypeTrader>
#include <KUrl>
@ -191,10 +191,7 @@ void ServiceRunner::match(Plasma::RunnerContext &context)
void ServiceRunner::run(const Plasma::QueryMatch &match)
{
KService::Ptr service = KService::serviceByStorageId(match.data().toString());
if (service) {
KRun::run(*service, KUrl::List(), nullptr);
}
KToolInvocation::self()->startServiceByStorageId(match.data().toString());
}
QMimeData * ServiceRunner::mimeDataForMatch(const Plasma::QueryMatch &match)

View file

@ -23,7 +23,6 @@
#include <KDebug>
#include <KIcon>
#include <KLocale>
#include <KRun>
#include <KShell>
#include <KStandardDirs>
#include <KToolInvocation>
@ -66,7 +65,7 @@ void ShellRunner::run(const Plasma::QueryMatch &match)
if (interminal) {
KToolInvocation::self()->invokeTerminal(command);
} else {
KRun::runCommand(command, nullptr);
KToolInvocation::self()->startProgram(command);
}
}

View file

@ -233,7 +233,7 @@ void SolidRunner::run(const Plasma::QueryMatch &match)
return;
}
const QString actionexe = actioncommand.takeFirst();
const int actionresult = KToolInvocation::self()->kdeinitExec(actionexe, actioncommand);
const int actionresult = KToolInvocation::self()->startProgram(actionexe, actioncommand);
if (actionresult != 0) {
kWarning() << "could not execute action for" << actionname << "in" << actionfilepath << actionresult;
}

View file

@ -1018,7 +1018,7 @@ void PlasmaApp::restoreClients()
}
QString program = restartcommand.takeFirst();
kDebug() << "restoring client" << program << restartcommand;
KToolInvocation::self()->kdeinitExec(program, restartcommand);
KToolInvocation::self()->startProgram(program, restartcommand);
}
sessiongroup.deleteGroup();
sessiongroup.sync();
@ -1159,12 +1159,12 @@ void PlasmaApp::logout(int confirm, int sdtype)
void PlasmaApp::captureDesktop()
{
KToolInvocation::self()->kdeinitExec("ksnapshot", QStringList() << "--fullscreen");
KToolInvocation::self()->startProgram("ksnapshot", QStringList() << "--fullscreen");
}
void PlasmaApp::captureCurrentWindow()
{
KToolInvocation::self()->kdeinitExec("ksnapshot", QStringList() << "--current");
KToolInvocation::self()->startProgram("ksnapshot", QStringList() << "--current");
}
void PlasmaApp::cleanup()

View file

@ -26,9 +26,9 @@
#include <KStandardDirs>
#include <KImageIO>
#include <KIO/Job>
#include <krun.h>
#include <KToolInvocation>
#include <Plasma/Theme>
#include "backgroundlistmodel.h"
#include "backgrounddelegate.h"
#include "removebuttonmanager.h"
@ -751,9 +751,8 @@ void Image::openSlide()
}
// open in image viewer
KUrl filepath(m_wallpaperPackage->filePath("preferred"));
//kDebug() << "opening file " << filepath.path();
new KRun(filepath, NULL);
//kDebug() << "opening file " << m_wallpaperPackage->filePath("preferred");
KToolInvocation::self()->startServiceForUrl(m_wallpaperPackage->filePath("preferred"));
}
void Image::renderWallpaper(const QString& image)

View file

@ -111,9 +111,9 @@ static void kExecuteAction(const KServiceAction &kserviceaction, const Solid::De
return;
}
const QString actionexe = actioncommand.takeFirst();
const int actionresult = KToolInvocation::self()->kdeinitExec(actionexe, actioncommand);
if (actionresult != 0) {
kWarning() << "could not execute action for" << kserviceaction.name() << actionresult;
const bool actionresult = KToolInvocation::self()->startProgram(actionexe, actioncommand);
if (!actionresult) {
kWarning() << "could not execute action for" << kserviceaction.name();
}
}

View file

@ -19,10 +19,9 @@
#include "ExternalAppModule.h"
#include <QtGui/QApplication>
#include <QApplication>
#include <KCModuleInfo>
#include <KRun>
#include <KToolInvocation>
ExternalAppModule::ExternalAppModule(QWidget * parent, KCModuleInfo * module)
{
@ -51,7 +50,9 @@ void ExternalAppModule::showEvent(QShowEvent * event)
void ExternalAppModule::runExternal()
{
KRun::run( *(moduleInfo->service()), KUrl::List(), qApp->activeWindow() ); // Launch it!
KToolInvocation::self()->startServiceByStorageId(
moduleInfo->service()->entryPath(), QStringList(), qApp->activeWindow()
);
}
#include "moc_ExternalAppModule.cpp"