KRun Class Reference
To open files with their associated applications in KDE, use KRun.Opens files with their associated applications in KDE. More...
#include <krun.h>
Inheritance diagram for KRun:

Signals | |
void | finished () |
void | error () |
Public Member Functions | |
KRun (const KURL &url, mode_t mode=0, bool isLocalFile=false, bool showProgressInfo=true) | |
KRun (const KURL &url, QWidget *window, mode_t mode=0, bool isLocalFile=false, bool showProgressInfo=true) | |
virtual | ~KRun () |
void | abort () |
bool | hasError () const |
bool | hasFinished () const |
bool | autoDelete () const |
void | setAutoDelete (bool b) |
void | setPreferredService (const QString &desktopEntryName) |
void | setRunExecutables (bool b) |
void | setEnableExternalBrowser (bool b) |
Static Public Member Functions | |
static pid_t | run (const KService &_service, const KURL::List &_urls, bool tempFiles) |
static pid_t | run (const KService &_service, const KURL::List &_urls) |
static pid_t | run (const QString &_exec, const KURL::List &_urls, const QString &_name=QString::null, const QString &_icon=QString::null, const QString &_obsolete1=QString::null, const QString &_obsolete2=QString::null) |
static pid_t | runURL (const KURL &_url, const QString &_mimetype, bool tempFile, bool runExecutables) |
static pid_t | runURL (const KURL &_url, const QString &_mimetype, bool tempFile) |
static pid_t | runURL (const KURL &_url, const QString &_mimetype) |
static pid_t | runCommand (QString cmd) |
static pid_t | runCommand (const QString &cmd, const QString &execName, const QString &icon) |
static bool | displayOpenWithDialog (const KURL::List &lst, bool tempFiles) |
static bool | displayOpenWithDialog (const KURL::List &lst) |
static void | shellQuote (QString &_str) |
static QStringList | processDesktopExec (const KService &_service, const KURL::List &_urls, bool has_shell, bool tempFiles) |
static QStringList | processDesktopExec (const KService &_service, const KURL::List &_urls, bool has_shell) |
static QString | binaryName (const QString &execLine, bool removePath) |
static bool | isExecutable (const QString &serviceType) |
static bool | isExecutableFile (const KURL &url, const QString &mimetype) |
static bool | checkStartupNotify (const QString &binName, const KService *service, bool *silent_arg, QCString *wmclass_arg) |
Protected Slots | |
void | slotTimeout () |
void | slotScanFinished (KIO::Job *) |
void | slotScanMimeType (KIO::Job *, const QString &type) |
virtual void | slotStatResult (KIO::Job *) |
Protected Member Functions | |
virtual void | init () |
virtual void | scanFile () |
virtual void | foundMimeType (const QString &_type) |
virtual void | killJob () |
virtual void | virtual_hook (int id, void *data) |
Protected Attributes | |
KURL | m_strURL |
bool | m_bFault |
bool | m_bAutoDelete |
bool | m_bProgressInfo |
bool | m_bFinished |
KIO::Job * | m_job |
QTimer | m_timer |
bool | m_bScanFile |
bool | m_bIsDirectory |
bool | m_bInit |
bool | m_bIsLocalFile |
mode_t | m_mode |
Detailed Description
To open files with their associated applications in KDE, use KRun.Opens files with their associated applications in KDE.It can execute any desktop entry, as well as any file, using the default application or another application "bound" to the file type (or URL protocol).
In that example, the mimetype of the file is not known by the application, so a KRun instance must be created. It will determine the mimetype by itself. If the mimetype is known, or if you even know the service (application) to use for this file, use one of the static methods.
By default KRun uses auto deletion. It causes the KRun instance to delete itself when the it finished its task. If you allocate the KRun object on the stack you must disable auto deletion, otherwise it will crash.
Definition at line 57 of file krun.h.
Constructor & Destructor Documentation
|
Create a KRun object to run the preferred application for a file/URL. KRun will first determine the type of the file, and will then run the associated application.
|
|
BIC: Combine with the above ctor for KDE 4.0.
|
|
Destructor. Don't call it yourself, since a KRun object auto-deletes itself. Definition at line 900 of file krun.cpp. References kdDebug(). |
Member Function Documentation
|
Abort this KRun. This kills any jobs launched by it, and leads to deletion if auto-deletion is on. This is much safer than deleting the KRun (in case it's currently showing an error dialog box, for instance) Definition at line 1169 of file krun.cpp. References kdDebug(), m_bInit, and m_bScanFile. |
|
Returns true if the KRun instance has an error.
|
|
Returns true if the KRun instance has finished.
|
|
Checks whether auto delete is activated. Auto-deletion causes the KRun instance to delete itself when it finished its task. By default auto deletion is on.
|
|
Enables or disabled auto deletion. Auto deletion causes the KRun instance to delete itself when it finished its task. If you allocate the KRun object on the stack you must disable auto deletion. By default auto deletion is on.
|
|
Set the preferred service for opening this URL, after its mimetype will have been found by KRun. IMPORTANT: the service is only used if its configuration says it can handle this mimetype. This is used for instance for the X-KDE-LastOpenedWith key, for the recent documents list.
|
|
Sets whether executables, .desktop files or shell scripts should be run by KRun. This is enabled by default.
|
|
Sets whether the external webbrowser setting should be honoured. This is enabled by default. This should only be disabled in webbrowser applications.
Definition at line 1186 of file krun.cpp. References KGlobal::config(). |
|
Open a list of URLs with a certain service (application).
Definition at line 656 of file krun.cpp. References KRecentDocument::add(), KService::desktopEntryName(), KService::desktopEntryPath(), error(), KDesktopFile::isAuthorizedDesktopFile(), kdDebug(), kdWarning(), KMessageBox::sorry(), KApplication::startServiceByDesktopPath(), and KURL::List::toStringList(). Referenced by displayOpenWithDialog(), KFileOpenWithHandler::displayOpenWithDialog(), KDEDesktopMimeType::executeService(), foundMimeType(), run(), and runURL(). |
|
Open a list of URLs with.
Definition at line 706 of file krun.cpp. References run(). |
|
Open the given URL. This function is used after the mime type is found out. It will search for all services which can handle the mime type and call run() afterwards.
Definition at line 104 of file krun.cpp. References displayOpenWithDialog(), KURL::htmlURL(), isExecutable(), isExecutableFile(), KURL::isLocalFile(), KURL::path(), KServiceTypeProfile::preferredService(), run(), KDEDesktopMimeType::run(), runCommand(), shellQuote(), KMessageBox::sorry(), and KGlobal::staticQString(). Referenced by foundMimeType(). |
|
Run the given shell command and notifies kicker of the starting of the application. If the program to be called doesn't exist, an error box will be displayed. Use only when you know the full command line. Otherwise use the other static methods, or KRun's constructor.
Definition at line 714 of file krun.cpp. Referenced by KMimeTypeChooser::editMimeType(), and runURL(). |
|
Same as the other runCommand(), but it also takes the name of the binary, to display an error message in case it couldn't find it.
Definition at line 719 of file krun.cpp. References binaryName(), KSharedPtr< T >::data(), kdDebug(), KService::serviceByDesktopName(), and KProcess::setUseShell(). |
|
Display the Open-With dialog for those URLs, and run the chosen application.
Definition at line 184 of file krun.cpp. References endl(), kdDebug(), run(), KOpenWithDlg::service(), KMessageBox::sorry(), and KOpenWithDlg::text(). Referenced by runURL(). |
|
Quotes a string for the shell.
Definition at line 206 of file krun.cpp. Referenced by processDesktopExec(), and runURL(). |
|
Processes a Exec= line as found in .desktop files.
Definition at line 344 of file krun.cpp. References KShell::AbortOnMeta, KGlobal::config(), KService::exec(), KShell::FoundMeta, KProtocolInfo::isHelperProtocol(), KShell::joinArgs(), kdWarning(), KService::name(), KShell::NoError, KService::property(), shellQuote(), KShell::splitArgs(), KService::substituteUid(), KService::terminal(), KService::terminalOptions(), KShell::TildeExpand, KURL::List::toStringList(), and KService::username(). |
|
Given a full command line (e.g. the Exec= line from a .desktop file), extract the name of the binary being run.
Definition at line 504 of file krun.cpp. References KShell::splitArgs(). Referenced by runCommand(). |
|
Returns whether
Definition at line 1204 of file krun.cpp. Referenced by runURL(). |
|
Returns wether the To be executable the file must pass the following rules:
Definition at line 88 of file krun.cpp. References KURL::isLocalFile(), KMimeType::mimeType(), and KURL::path(). Referenced by runURL(). |
|
Emitted when the operation finished.
|
|
Emitted when the operation had an error.
Referenced by run(). |
|
Called if the mimetype has been detected. The function checks whether the document and appends the gzip protocol to the URL. Otherwise runURL is called to finish the job. Definition at line 1066 of file krun.cpp. References kdDebug(), KIO::Scheduler::publishSlaveOnHold(), KIO::SimpleJob::putOnHold(), run(), runURL(), and KService::serviceByDesktopName(). |
Member Data Documentation
|
Used to indicate that the next action is to scan the file. This action is invoked from slotTimeout. Definition at line 389 of file krun.h. Referenced by abort(). |
|
USed to indicate that the next action is to initialize. This action is invoked from slotTimeout Definition at line 396 of file krun.h. Referenced by abort(). |
The documentation for this class was generated from the following files: