• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KIO

  • kio
  • kio
krun.h
Go to the documentation of this file.
1// -*- mode: c++; c-basic-offset: 2 -*-
2/* This file is part of the KDE project
3 Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
4 Copyright (C) 2006 David Faure <faure@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22#ifndef KRUN_H
23#define KRUN_H
24
25#include <kio/kio_export.h>
26
27#include <QtCore/QObject>
28#include <QtCore/QTimer>
29#include <QtCore/QString>
30#include <sys/types.h>
31#include <kurl.h>
32
33class KService;
34class KStartupInfo;
35class KJob;
36namespace KIO
37{
38class Job;
39}
40
59class KIO_EXPORT KRun : public QObject
60{
61 Q_OBJECT
62public:
89 KRun(const KUrl& url, QWidget* window, mode_t mode = 0,
90 bool isLocalFile = false, bool showProgressInfo = true,
91 const QByteArray& asn = QByteArray());
92
97 virtual ~KRun();
98
105 void abort();
106
112 bool hasError() const;
113
119 bool hasFinished() const;
120
128 bool autoDelete() const;
129
138 void setAutoDelete(bool b);
139
149 void setPreferredService(const QString& desktopEntryName);
150
157 void setRunExecutables(bool b);
158
165 void setEnableExternalBrowser(bool b);
166
174 void setSuggestedFileName(const QString& fileName);
175
179 QString suggestedFileName() const;
180
185 QWidget* window() const;
186
187
201 static bool run(const KService& service, const KUrl::List& urls, QWidget* window,
202 bool tempFiles = false, const QString& suggestedFileName = QString(),
203 const QByteArray& asn = QByteArray());
204
221 static bool run(const QString& exec, const KUrl::List& urls, QWidget* window,
222 const QString& name = QString(),
223 const QString& icon = QString(),
224 const QByteArray& asn = QByteArray());
225
244 static bool runUrl(const KUrl& url, const QString& mimetype, QWidget* window,
245 bool tempFile = false , bool runExecutables = true,
246 const QString& suggestedFileName = QString(), const QByteArray& asn = QByteArray());
247
262 static bool runCommand(const QString &cmd, QWidget* window);
263
269 static bool runCommand(const QString &cmd, QWidget* window, const QString& workingDirectory);
270 // TODO KDE5: merge the above with 2-args runCommand, using QString()
271
284 static bool runCommand(const QString& cmd, const QString & execName,
285 const QString & icon, QWidget* window, const QByteArray& asn = QByteArray());
286
294 static bool runCommand(const QString& cmd, const QString & execName,
295 const QString & icon, QWidget* window,
296 const QByteArray& asn, const QString& workingDirectory);
297 // TODO KDE5: merge the above with 5-args runCommand, using QString()
298
309 static bool displayOpenWithDialog(const KUrl::List& lst, QWidget* window,
310 bool tempFiles = false, const QString& suggestedFileName = QString(),
311 const QByteArray& asn = QByteArray());
312
323#ifndef KDE_NO_DEPRECATED
324 static KDE_DEPRECATED void shellQuote(QString &str);
325#endif
326
337 static QStringList processDesktopExec(const KService &_service, const KUrl::List &_urls,
338 bool tempFiles = false,
339 const QString& suggestedFileName = QString());
340
348 static QString binaryName(const QString & execLine, bool removePath);
349
354 static bool isExecutable(const QString& serviceType);
355
368 static bool isExecutableFile(const KUrl& url, const QString &mimetype);
369
373 static bool checkStartupNotify(const QString& binName, const KService* service, bool* silent_arg,
374 QByteArray* wmclass_arg);
375
376Q_SIGNALS:
382 void finished();
387 void error();
388
389protected Q_SLOTS:
393
398 void slotTimeout(); // KDE5: rename to slotNextStep() or something like that
399
403 void slotScanFinished(KJob *);
404
409 void slotScanMimeType(KIO::Job *, const QString &type);
410
416 void mimeTypeDetermined(const QString& mimeType);
417
421 virtual void slotStatResult(KJob *);
422
423protected:
427
431 virtual void init();
432
436 virtual void scanFile();
437
449 virtual void foundMimeType(const QString& type);
450
454 virtual void killJob();
455
459 void setUrl(const KUrl &url);
460
464 KUrl url() const;
465
469 void setError(bool error);
470
474 void setProgressInfo(bool progressInfo);
475
479 bool progressInfo() const;
480
484 void setFinished(bool finished);
485
489 void setJob(KIO::Job *job);
490
494 KIO::Job* job();
495
501#ifndef KDE_NO_DEPRECATED
502 KDE_DEPRECATED QTimer& timer();
503#endif
504
509#ifndef KDE_NO_DEPRECATED
510 KDE_DEPRECATED void setDoScanFile(bool scanFile);
511#endif
512
517#ifndef KDE_NO_DEPRECATED
518 KDE_DEPRECATED bool doScanFile() const;
519#endif
520
525#ifndef KDE_NO_DEPRECATED
526 KDE_DEPRECATED void setIsDirecory(bool isDirectory);
527#endif
528
532 bool isDirectory() const;
533
537#ifndef KDE_NO_DEPRECATED
538 KDE_DEPRECATED void setInitializeNextAction(bool initialize);
539#endif
540
544#ifndef KDE_NO_DEPRECATED
545 KDE_DEPRECATED bool initializeNextAction() const;
546#endif
547
551 void setIsLocalFile(bool isLocalFile);
552
556 bool isLocalFile() const;
557
561 void setMode(mode_t mode);
562
566 mode_t mode() const;
567
568private:
569 class KRunPrivate;
570 KRunPrivate* const d;
571};
572
573#endif
KIO::Job
The base class for all jobs.
Definition jobclasses.h:94
KJob
KRun::KRunPrivate
Definition krun_p.h:78
KRun::isDirectory
bool isDirectory() const
Returns whether it is a directory.
Definition krun.cpp:1685
KRun::finished
void finished()
Emitted when the operation finished.
KRun::checkStartupNotify
static bool checkStartupNotify(const QString &binName, const KService *service, bool *silent_arg, QByteArray *wmclass_arg)
Definition krun.cpp:651
KRun::slotStatResult
virtual void slotStatResult(KJob *)
This slot is called when the 'stat' job has finished.
Definition krun.cpp:1364
KRun::setJob
void setJob(KIO::Job *job)
Sets the job.
Definition krun.cpp:1647
KRun::init
virtual void init()
All following protected methods are used by subclasses of KRun!
Definition krun.cpp:1139
KRun::autoDelete
bool autoDelete() const
Checks whether auto delete is activated.
Definition krun.cpp:1567
KRun::timer
QTimer & timer()
Returns the timer object.
Definition krun.cpp:1658
KRun::progressInfo
bool progressInfo() const
Returns whether progress information are shown.
Definition krun.cpp:1635
KRun::hasError
bool hasError() const
Returns true if the KRun instance has an error.
Definition krun.cpp:1557
KRun::suggestedFileName
QString suggestedFileName() const
Suggested file name given by the server (e.g.
Definition krun.cpp:1602
KRun::slotTimeout
void slotTimeout()
All following protected slots are used by subclasses of KRun!
Definition krun.cpp:1330
KRun::setIsDirecory
void setIsDirecory(bool isDirectory)
Sets whether it is a directory.
Definition krun.cpp:1679
KRun::slotScanFinished
void slotScanFinished(KJob *)
This slot is called when the scan job is finished.
Definition krun.cpp:1434
KRun::processDesktopExec
static QStringList processDesktopExec(const KService &_service, const KUrl::List &_urls, bool tempFiles=false, const QString &suggestedFileName=QString())
Processes a Exec= line as found in .desktop files.
Definition krun.cpp:407
KRun::isExecutableFile
static bool isExecutableFile(const KUrl &url, const QString &mimetype)
Returns whether the url of mimetype is executable.
Definition krun.cpp:100
KRun::initializeNextAction
bool initializeNextAction() const
Definition krun.cpp:1698
KRun::setInitializeNextAction
void setInitializeNextAction(bool initialize)
Definition krun.cpp:1691
KRun::runCommand
static bool runCommand(const QString &cmd, QWidget *window)
Run the given shell command and notifies KDE of the starting of the application.
Definition krun.cpp:1057
KRun::url
KUrl url() const
Returns the url.
Definition krun.cpp:1620
KRun::slotScanMimeType
void slotScanMimeType(KIO::Job *, const QString &type)
This slot is called when the scan job has found out the mime type.
Definition krun.cpp:1425
KRun::scanFile
virtual void scanFile()
Start scanning a file.
Definition krun.cpp:1289
KRun::setRunExecutables
void setRunExecutables(bool b)
Sets whether executables, .desktop files or shell scripts should be run by KRun.
Definition krun.cpp:1592
KRun::displayOpenWithDialog
static bool displayOpenWithDialog(const KUrl::List &lst, QWidget *window, bool tempFiles=false, const QString &suggestedFileName=QString(), const QByteArray &asn=QByteArray())
Display the Open-With dialog for those URLs, and run the chosen application.
Definition krun.cpp:193
KRun::setEnableExternalBrowser
void setEnableExternalBrowser(bool b)
Sets whether the external webbrowser setting should be honoured.
Definition krun.cpp:1577
KRun::setMode
void setMode(mode_t mode)
Sets the file mode.
Definition krun.cpp:1714
KRun::setSuggestedFileName
void setSuggestedFileName(const QString &fileName)
Sets the file name to use in the case of downloading the file to a tempfile in order to give to a non...
Definition krun.cpp:1597
KRun::KRun
KRun(const KUrl &url, QWidget *window, mode_t mode=0, bool isLocalFile=false, bool showProgressInfo=true, const QByteArray &asn=QByteArray())
Definition krun.cpp:1101
KRun::mode
mode_t mode() const
Returns the file mode.
Definition krun.cpp:1719
KRun::shellQuote
static void shellQuote(QString &str)
Quotes a string for the shell.
Definition krun.cpp:223
KRun::setPreferredService
void setPreferredService(const QString &desktopEntryName)
Set the preferred service for opening this URL, after its mimetype will have been found by KRun.
Definition krun.cpp:1587
KRun::error
void error()
Emitted when the operation had an error.
KRun::isLocalFile
bool isLocalFile() const
Returns whether it is a local file.
Definition krun.cpp:1709
KRun::job
KIO::Job * job()
Returns the job.
Definition krun.cpp:1652
KRun::hasFinished
bool hasFinished() const
Returns true if the KRun instance has finished.
Definition krun.cpp:1562
KRun::foundMimeType
virtual void foundMimeType(const QString &type)
Called if the mimetype has been detected.
Definition krun.cpp:1472
KRun::doScanFile
bool doScanFile() const
Returns whether the file shall be scanned.
Definition krun.cpp:1672
KRun::abort
void abort()
Abort this KRun.
Definition krun.cpp:1531
KRun::runUrl
static bool runUrl(const KUrl &url, const QString &mimetype, QWidget *window, bool tempFile=false, bool runExecutables=true, const QString &suggestedFileName=QString(), const QByteArray &asn=QByteArray())
Open the given URL.
Definition krun.cpp:122
KRun::setAutoDelete
void setAutoDelete(bool b)
Enables or disabled auto deletion.
Definition krun.cpp:1572
KRun::setDoScanFile
void setDoScanFile(bool scanFile)
Indicate that the next action is to scan the file.
Definition krun.cpp:1665
KRun::killJob
virtual void killJob()
Kills the file scanning job.
Definition krun.cpp:1522
KRun::window
QWidget * window() const
Associated window, as passed to the constructor.
Definition krun.cpp:1552
KRun::isExecutable
static bool isExecutable(const QString &serviceType)
Returns whether serviceType refers to an executable program instead of a data file.
Definition krun.cpp:1607
KRun::setUrl
void setUrl(const KUrl &url)
Sets the url.
Definition krun.cpp:1615
KRun::setIsLocalFile
void setIsLocalFile(bool isLocalFile)
Sets whether it is a local file.
Definition krun.cpp:1704
KRun::setError
void setError(bool error)
Sets whether an error has occurred.
Definition krun.cpp:1625
KRun::binaryName
static QString binaryName(const QString &execLine, bool removePath)
Given a full command line (e.g.
Definition krun.cpp:568
KRun::setProgressInfo
void setProgressInfo(bool progressInfo)
Sets whether progress information shall be shown.
Definition krun.cpp:1630
KRun::run
static bool run(const KService &service, const KUrl::List &urls, QWidget *window, bool tempFiles=false, const QString &suggestedFileName=QString(), const QByteArray &asn=QByteArray())
Open a list of URLs with a certain service (application).
Definition krun.cpp:984
KRun::setFinished
void setFinished(bool finished)
Marks this 'KRun' instance as finished.
Definition krun.cpp:1640
KRun::mimeTypeDetermined
void mimeTypeDetermined(const QString &mimeType)
Call this from subclasses when you have determined the mimetype.
Definition krun.cpp:1457
KService
KStartupInfo
KUrl::List
KUrl
QObject
QWidget
kio_export.h
kurl.h
KIO
A namespace for KIO globals.
Definition kbookmarkmenu.h:55
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Tue Mar 25 2025 00:00:00 by doxygen 1.14.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal