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:20 +03:00
parent 9df38fce82
commit a91ec41cc6
16 changed files with 45 additions and 78 deletions

View file

@ -37,7 +37,7 @@
#include <KGlobal>
#include <KLocale>
#include <KMessageBox>
#include <KRun>
#include <KToolInvocation>
#include <KIO/RenameDialog>
#include <kwidgetjobtracker.h>
@ -181,7 +181,7 @@ void BatchExtract::slotResult(KJob *job)
if (openDestinationAfterExtraction()) {
KUrl destination(destinationFolder());
destination.cleanPath();
KRun::runUrl(destination, QLatin1String( "inode/directory" ), 0);
KToolInvocation::self()->startServiceForUrl(destination.url());
}
kDebug() << "Finished, emitting the result";

View file

@ -32,7 +32,7 @@
#include <KMessageBox>
#include <KProgressDialog>
#include <KPushButton>
#include <KRun>
#include <KToolInvocation>
#include <KIO/NetAccess>
#include <KPixmapWidget>
@ -88,22 +88,16 @@ void ArkViewer::dialogClosed()
void ArkViewer::view(const QString& fileName, QWidget *parent)
{
const KUrl fileNameUrl = KUrl(fileName);
KMimeType::Ptr mimeType = KMimeType::findByUrl(fileNameUrl);
KMimeType::Ptr mimeType = KMimeType::findByUrl(KUrl(fileName));
kDebug() << "MIME type" << mimeType->name();
KService::Ptr viewer = ArkViewer::getViewer(mimeType);
const bool needsExternalViewer = (!viewer.isNull() &&
!viewer->hasServiceType(QLatin1String("KParts/ReadOnlyPart")));
if (needsExternalViewer) {
// We have already resolved the MIME type and the service above.
// So there is no point in using KRun::runUrl() which would need
// to do the same again.
const KUrl::List fileUrlList = fileNameUrl;
// The last argument (tempFiles) set to true means that the temporary
// The last argument (temp) set to true means that the temporary
// file will be removed when the viewer application exits.
KRun::run(*viewer, fileUrlList, parent, true);
KToolInvocation::self()->startServiceByStorageId(viewer->entryPath(), QStringList() << fileName, parent, true);
return;
}

View file

@ -49,6 +49,7 @@
#include <KMessageBox>
#include <KPluginFactory>
#include <KRun>
#include <KToolInvocation>
#include <KSelectAction>
#include <KStandardDirs>
#include <KStandardGuiItem>
@ -754,11 +755,7 @@ void Part::slotExtractionDone(KJob* job)
}
if (ArkSettings::openDestinationFolderAfterExtraction()) {
KUrl destinationDirectory(extractJob->destinationDirectory());
destinationDirectory.cleanPath();
KRun::runUrl(destinationDirectory, QLatin1String("inode/directory"), widget());
KToolInvocation::self()->startServiceForUrl(extractJob->destinationDirectory(), widget());
}
if (ArkSettings::closeAfterExtraction()) {

View file

@ -25,26 +25,21 @@
#include "widget.h"
#include <KDebug>
#include <KIconLoader> //::mousePressEvent()
#include <KIconLoader>
#include <KJob>
#include <KIO/Job> //::mousePressEvent()
#include <KIO/Job>
#include <KIO/DeleteJob>
#include <KIO/JobUiDelegate>
#include <KLocale>
#include <KMessageBox> //::mousePressEvent()
#include <KMenu> //::mousePressEvent()
#include <KRun> //::mousePressEvent()
#include <KMessageBox>
#include <KMenu>
#include <KToolInvocation>
#include <KUrl>
#include <QtGui/QApplication> //QApplication::setOverrideCursor()
#include <QtGui/QApplication>
#include <QtGui/QClipboard>
#include <QtGui/QPainter>
#include <QtCore/QTimer> //::resizeEvent()
#include <QtCore/QTimer>
#include <QtGui/qevent.h>
#include <QtGui/QToolTip>
@ -239,7 +234,7 @@ void RadialMap::Widget::mousePressEvent(QMouseEvent *e)
QAction* clicked = popup.exec(e->globalPos(), 0);
if (openFileManager && clicked == openFileManager) {
KRun::runUrl(url.url(),QLatin1String( "inode/directory" ), this);
KToolInvocation::self()->startServiceForUrl(url.url(), this);
} else if (openTerminal && clicked == openTerminal) {
KToolInvocation::self()->invokeTerminal(QString(), url.path());
} else if (centerMap && clicked == centerMap) {
@ -279,7 +274,7 @@ section_two:
if (!isDir || e->button() == Qt::MiddleButton) {
// KIconEffect::visualActivate(this, rect); // TODO: recreate this
new KRun(url, this, true); //FIXME see above
KToolInvocation::self()->startServiceForUrl(url.url(), this); //FIXME see above
}
else if (m_focus->file() != m_tree) { // is left click
// KIconEffect::visualActivate(this, rect); // TODO: recreate this

View file

@ -41,7 +41,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <KMimeTypeTrader>
#include <KOpenWithDialog>
#include <KPropertiesDialog>
#include <KRun>
#include <KToolInvocation>
#include <KService>
#include <KXMLGUIClient>
@ -441,7 +441,7 @@ void FileOpsContextManagerItem::openWith(QAction* action)
if (!service) {
// User entered a custom command
Q_ASSERT(!dlg.text().isEmpty());
KRun::run(dlg.text(), list, d->mGroup);
KToolInvocation::self()->startProgram(dlg.text(), list.toStringList(), d->mGroup);
return;
}
} else {
@ -449,7 +449,7 @@ void FileOpsContextManagerItem::openWith(QAction* action)
}
Q_ASSERT(service);
KRun::run(*service, list, d->mGroup);
KToolInvocation::self()->startServiceByStorageId(service->entryPath(), list.toStringList(), d->mGroup);
}
} // namespace

View file

@ -34,8 +34,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include <KLocale>
#include <KMessageBox>
#include <KProtocolInfo>
#include <KRun>
#include <KService>
#include <KToolInvocation>
#include <KStandardGuiItem>
#include <Solid/Device>
@ -143,12 +142,7 @@ public:
void startGwenview()
{
KService::Ptr service = KService::serviceByDesktopName("gwenview");
if (!service) {
kError() << "Could not find gwenview";
} else {
KRun::run(*service, KUrl::List() << mThumbnailPage->destinationUrl(), 0 /* window */);
}
KToolInvocation::self()->startServiceByStorageId("gwenview", QStringList() << mThumbnailPage->destinationUrl().url());
}
void showWhatNext()

View file

@ -25,7 +25,7 @@
// KDE
#include <KBookmarkOwner>
#include <KRun>
#include <KToolInvocation>
class BookmarkOwner : public KBookmarkOwner
@ -47,7 +47,7 @@ inline bool BookmarkOwner::enableOption(BookmarkOption) const
}
inline void BookmarkOwner::openBookmark(const KBookmark& bookmark, Qt::MouseButtons, Qt::KeyboardModifiers)
{
new KRun(bookmark.url(), (QWidget*)0);
KToolInvocation::self()->startServiceForUrl(bookmark.url().url());
}
#endif

View file

@ -37,7 +37,7 @@
#include <KDebug>
#include <KConfigDialog>
#include <KSharedConfig>
#include <KRun>
#include <KToolInvocation>
#include <KUrl>
#include <KFileDialog>
#include <KServiceTypeTrader>
@ -213,7 +213,7 @@ void Frame::slotOpenPicture()
}
if (!url.path().isEmpty()) {
new KRun(url, 0);
KToolInvocation::self()->startServiceForUrl(url.url());
}
}

View file

@ -163,11 +163,7 @@ void KonsoleProfilesWidget::slotProfileClicked()
Q_ASSERT(!profilename.isEmpty());
const QStringList konsoleargs = QStringList()
<< "--profile" << profilename;
QString invocationerror;
const int invocationresult = KToolInvocation::self()->kdeinitExec("konsole", konsoleargs, &invocationerror);
if (invocationresult != 0) {
m_konsoleprofiles->showMessage(KIcon("dialog-error"), invocationerror, Plasma::ButtonOk);
}
KToolInvocation::self()->startProgram("konsole", konsoleargs);
}
KonsoleProfilesApplet::KonsoleProfilesApplet(QObject *parent, const QVariantList &args)

View file

@ -367,7 +367,7 @@ void Timer::slotCountDone()
QStringList args = KShell::splitArgs(m_command);
QString command = args[0];
args.removeFirst();
KToolInvocation::self()->kdeinitExec(command, args);
KToolInvocation::self()->startProgram(command, args);
}
}

View file

@ -133,7 +133,7 @@ void KateSessions::run(const Plasma::QueryMatch &match)
if (!session.isEmpty()) {
QStringList args;
args << QLatin1String("--start") << session << QLatin1String("-n");
KToolInvocation::self()->kdeinitExec(QLatin1String("kate"), args);
KToolInvocation::self()->startProgram(QLatin1String("kate"), args);
}
}

View file

@ -130,7 +130,7 @@ void KonsoleSessions::run(const Plasma::QueryMatch &match)
args << QLatin1String( "--profile" );
args << session;
kDebug() << "=== START: konsole" << args;
KToolInvocation::self()->kdeinitExec(QLatin1String("konsole"), args);
KToolInvocation::self()->startProgram(QLatin1String("konsole"), args);
}
}

View file

@ -50,7 +50,7 @@
#include <kmenu.h>
#include <kmimetypetrader.h>
#include <kopenwithdialog.h>
#include <krun.h>
#include <ktoolinvocation.h>
#include <kstandarddirs.h>
#include <kstartupinfo.h>
#include <kvbox.h>
@ -421,9 +421,7 @@ void KSnapshot::slotOpen(const QString& application)
return;
}
KUrl::List list;
list.append(url);
KRun::run(application, list, this);
KToolInvocation::self()->startServiceByStorageId(application, QStringList() << url.url(), this);
}
void KSnapshot::slotOpen(QAction* action)
@ -460,15 +458,18 @@ void KSnapshot::slotOpen(QAction* action)
if (!service && !dlg->text().isEmpty())
{
KRun::run(dlg->text(), list, this);
KToolInvocation::self()->startProgram(dlg->text(), list.toStringList(), this, true);
delete dlg;
return;
}
delete dlg;
}
if (!service) {
return;
}
// we have an action with a service, run it!
KRun::run(*service, list, this, isTempfile);
KToolInvocation::self()->startServiceByStorageId(service->entryPath(), list.toStringList(), this, true);
}
void KSnapshot::slotPopulateOpenMenu()

View file

@ -3424,9 +3424,7 @@ void Document::processAction( const Action * action )
KService::Ptr ptr = KMimeTypeTrader::self()->preferredService( mime->name(), "Application" );
if ( ptr )
{
KUrl::List lst;
lst.append( fileName );
KRun::run( *ptr, lst, 0 );
KToolInvocation::self()->startServiceByStorageId( ptr->entryPath(), QStringList() << fileName );
}
else
{
@ -3512,8 +3510,7 @@ void Document::processAction( const Action * action )
realUrl = KUrl( d->m_url.upUrl(), url );
}
// Albert: this is not a leak!
new KRun( realUrl, d->m_widget );
KToolInvocation::self()->startServiceForUrl( realUrl.url(), d->m_widget );
}
break;
}

View file

@ -51,7 +51,6 @@
#include <kurifilter.h>
#include <kstringhandler.h>
#include <ktoolinvocation.h>
#include <krun.h>
#include <kimageio.h>
// system includes
@ -2731,7 +2730,7 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
if ( choice == textToClipboard )
copyTextSelection();
else if ( choice == httpLink )
new KRun( url, this );
KToolInvocation::self()->startServiceForUrl( url.url(), this );
}
}
}
@ -4385,7 +4384,7 @@ void PageView::slotHandleWebShortcutAction()
void PageView::slotConfigureWebShortcuts()
{
KToolInvocation::self()->kdeinitExec( "kcmshell4", QStringList() << "ebrowsing" );
KToolInvocation::self()->startProgram( "kcmshell4", QStringList() << "ebrowsing" );
}
void PageView::slotZoom()

View file

@ -42,7 +42,7 @@
#include <kdebug.h>
#include <kmessagebox.h>
#include <kfiledialog.h>
#include <krun.h>
#include <ktoolinvocation.h>
#include <ktemporaryfile.h>
#include <kaboutdata.h>
#include <ktextedit.h>
@ -417,8 +417,6 @@ void ApplyProgressDialog::browserReport()
{
KTemporaryFile file;
// Make sure the temp file is created somewhere another user can read it: KRun::runUrl() will open
// the file as the logged in user, not as the user running our application.
file.setFileTemplate("/tmp/" + KGlobal::mainComponent().aboutData()->appName() + "-XXXXXX.html");
file.setAutoRemove(false);
@ -432,11 +430,7 @@ void ApplyProgressDialog::browserReport()
<< report().toHtml()
<< html.footer();
// set the temp file's permission for everyone to read it.
file.setPermissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ReadGroup | QFile::ReadOther);
if (!KRun::runUrl(file.fileName(), "text/html", this, true))
KMessageBox::sorry(this, i18nc("@info", "The configured external browser could not be run. Please check your settings."), i18nc("@title:window", "Could Not Launch Browser."));
KToolInvocation::self()->startServiceForUrl(file.fileName(), this, true);
}
else
KMessageBox::sorry(this, i18nc("@info", "Could not create temporary file <filename>%1</filename> for writing.", file.fileName()), i18nc("@title:window", "Could Not Launch Browser."));