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) | |
Create a KRun object to run the preferred application for a file/URL. | |
virtual | ~KRun () |
Destructor. | |
void | abort () |
Abort this KRun. | |
bool | hasError () const |
bool | hasFinished () const |
bool | autoDelete () const |
By default auto deletion is on. | |
void | setAutoDelete (bool b) |
void | setPreferredService (const QString &desktopEntryName) |
Set the preferred service for opening this URL, after its mimetype will have been found by KRun. | |
Static Public Member Functions | |
pid_t | run (const KService &_service, const KURL::List &_urls, bool tempFiles) |
Open a list of URLs with a certain service (application). | |
pid_t | run (const KService &_service, const KURL::List &_urls) |
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) |
Open a list of URLs with. | |
pid_t | runURL (const KURL &_url, const QString &_mimetype, bool tempFile) |
Open the given URL. | |
pid_t | runURL (const KURL &_url, const QString &_mimetype) |
pid_t | runCommand (QString cmd) |
Run the given shell command and notifies kicker of the starting of the application. | |
pid_t | runCommand (const QString &cmd, const QString &execName, const QString &icon) |
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. | |
bool | displayOpenWithDialog (const KURL::List &lst, bool tempFiles) |
Display the Open-With dialog for those URLs, and run the chosen application. | |
bool | displayOpenWithDialog (const KURL::List &lst) |
void | shellQuote (QString &_str) |
Quotes a string for the shell. | |
QStringList | processDesktopExec (const KService &_service, const KURL::List &_urls, bool has_shell, bool tempFiles) |
Processes a Exec= line as found in .desktop files. | |
QStringList | processDesktopExec (const KService &_service, const KURL::List &_urls, bool has_shell) |
QString | binaryName (const QString &execLine, bool removePath) |
Given a full command line (e.g. | |
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) |
Called if the mimetype has been detected. | |
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 |
Used to indicate that the next action is to scan the file. | |
bool | m_bIsDirectory |
bool | m_bInit |
USed to indicate that the next action is to initialize. | |
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.
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.
Definition at line 52 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.
Definition at line 737 of file krun.cpp. References QObject::connect(), m_bInit, m_bScanFile, and QTimer::start(). |
|
Destructor. Don't call it yourself, since a KRun object auto-deletes itself. Definition at line 857 of file krun.cpp. References QTimer::stop(). |
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 1119 of file krun.cpp. References QTimer::start(). |
|
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.
|
|
Open a list of URLs with a certain service (application).
Definition at line 664 of file krun.cpp. References KRecentDocument::add(), QValueList< KURL >::begin(), QValueList< KURL >::ConstIterator(), KService::desktopEntryName(), KService::desktopEntryPath(), QValueList< KURL >::end(), QValueList< KURL >::first(), KDesktopFile::isAuthorizedDesktopFile(), QValueList< KURL >::isEmpty(), QString::isEmpty(), 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 713 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 68 of file krun.cpp. References QValueList< KURL >::append(), displayOpenWithDialog(), KMessageBox::error(), KURL::htmlURL(), KURL::isLocalFile(), KURL::path(), KServiceTypeProfile::preferredService(), run(), KDEDesktopMimeType::run(), runCommand(), shellQuote(), 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.
Definition at line 721 of file krun.cpp. Referenced by 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 726 of file krun.cpp. References binaryName(), KSharedPtr< T >::data(), KService::serviceByDesktopName(), and KProcess::setUseShell(). |
|
Display the Open-With dialog for those URLs, and run the chosen application.
Definition at line 123 of file krun.cpp. References QDialog::exec(), run(), KOpenWithDlg::service(), and KOpenWithDlg::text(). Referenced by runURL(). |
|
Quotes a string for the shell.
Definition at line 138 of file krun.cpp. References QString::isEmpty(), and QString::replace(). Referenced by processDesktopExec(), and runURL(). |
|
Processes a Exec= line as found in .desktop files.
Definition at line 417 of file krun.cpp. References QString::arg(), QValueList< KURL >::begin(), KGlobal::config(), QValueList< KURL >::ConstIterator(), QValueList< KURL >::end(), KService::exec(), QString::find(), QString::isEmpty(), QStringList::join(), KConfigBase::readPathEntry(), shellQuote(), KService::substituteUid(), KService::terminal(), KService::terminalOptions(), 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 535 of file krun.cpp. References QString::contains(), QString::findRev(), and QString::mid(). Referenced by runCommand(). |
|
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 1016 of file krun.cpp. References QValueList< KURL >::append(), QObject::inherits(), KIO::Scheduler::publishSlaveOnHold(), KIO::SimpleJob::putOnHold(), run(), runURL(), KService::serviceByDesktopName(), and QTimer::start(). |
Member Data Documentation
|
Used to indicate that the next action is to scan the file. This action is invoked from slotTimeout. Definition at line 264 of file krun.h. Referenced by KRun(). |
|
USed to indicate that the next action is to initialize. This action is invoked from slotTimeout Definition at line 271 of file krun.h. Referenced by KRun(). |
The documentation for this class was generated from the following files: