# class KRun

###

Module | kio
Namespace |
Class | KRun
Inherits | QObject

### methods

- KRun (url, window, mode, isLocalFile, showProgressInfo, asn)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  url | KUrl |
  window | QWidget |
  mode | mode_t | 0
  isLocalFile | bool | 0
  showProgressInfo | bool | 1
  asn | QByteArray | ""

  url - the URL of the file or directory to 'run'

  window - The top-level widget of the app that invoked this object. It is used to make sure private information like passwords are properly handled per application.

  mode - The st_mode field of `struct stat`. If you don't know this set it to 0.

  isLocalFile - If this parameter is set to false then url is examined to find out whether it is a local URL or not. This flag is just used to improve speed, since the function KUrl.isLocalFile is a bit slow.

  showProgressInfo - Whether to show progress information when determining the type of the file (i.e. when using KIO.stat and KIO.mimetype) Before you set this to false to avoid a dialog box, think about a very slow FTP server... It is always better to provide progress info in such cases.

  asn - Application startup notification id, if available (otherwise "").

- abort ( )

  returns Nothing

  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)

- autoDelete ( )

  returns bool

  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. Returns true if auto deletion is on, false otherwise

- binaryName (execLine, removePath)

  returns QString
  static

  Argument | Type | Default
  --- | --- | ---
  execLine | QString |
  removePath | bool |

  Given a full command line (e.g. the Exec= line from a .desktop file), extract the name of the binary being run.

  execLine - the full command line

  removePath - if true, remove a (relative or absolute) path. E.g. /usr/bin/ls becomes ls. Returns the name of the binary to run

- checkStartupNotify (binName, service, silent_arg, wmclass_arg)

  returns bool
  Not implemented

  Argument | Type | Default
  --- | --- | ---
  binName | QString |
  service | KService |
  silent_arg | bool |
  wmclass_arg | QByteArray |

  Internal

- displayOpenWithDialog (lst, window, tempFiles, suggestedFileName, asn)

  returns bool
  static

  Argument | Type | Default
  --- | --- | ---
  lst | KUrl.List |
  window | QWidget |
  tempFiles | bool | 0
  suggestedFileName | QString | QString()
  asn | QByteArray | ""

  Display the Open-With dialog for those URLs, and run the chosen application.

  lst - the list of applications to run

  window - The top-level widget of the app that invoked this object.

  tempFiles - if true and lst are local files, they will be deleted when the application exits.

  suggestedFileName - see setSuggestedFileName

  asn - Application startup notification id, if any (otherwise ""). Returns false if the dialog was canceled

- doScanFile ( )

  returns bool

  Returns whether the file shall be scanned. Deprecated not useful in public API

- error ( )

  returns Nothing
  SIGNAL ("error ()")

  Emitted when the operation had an error.

  See also hasError()

- finished ( )

  returns Nothing
  SIGNAL ("finished ()")

  Emitted when the operation finished.

  See also hasFinished()

- foundMimeType (type)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  type | QString |

  Called if the mimetype has been detected. The function runs the application associated with this mimetype. Reimplement this method to implement a different behavior, like opening the component for displaying the URL embedded.

- hasError ( )

  returns bool

  Returns true if the KRun instance has an error. Returns true when an error occurred

  See also error()

- hasFinished ( )

  returns bool

  Returns true if the KRun instance has finished. Returns true if the KRun instance has finished

  See also finished()

- init ( )

  returns Nothing

  Initializes the krun object.

- initializeNextAction ( )

  returns bool

  Deprecated not useful in public API

- isDirectory ( )

  returns bool

  Returns whether it is a directory.

- isExecutable (serviceType)

  returns bool
  static

  Argument | Type | Default
  --- | --- | ---
  serviceType | QString |

  Returns whether serviceType refers to an executable program instead of a data file.

- isExecutableFile (url, mimetype)

  returns bool
  static

  Argument | Type | Default
  --- | --- | ---
  url | KUrl |
  mimetype | QString |

  Returns whether the url of mimetype is executable. To be executable the file must pass the following rules: -# Must reside on the local filesystem. -# Must be marked as executable for the user by the filesystem. -# The mime type must inherit application/x-executable or application/x-executable-script. To allow a script to run when the above rules are satisfied add the entry

      X-KDE-IsAlso=application/x-executable-script

  to the mimetype's desktop file.

- isLocalFile ( )

  returns bool

  Returns whether it is a local file.

- job ( )

  returns KIO.Job

  Returns the job.

- killJob ( )

  returns Nothing

  Kills the file scanning job.

- mimeTypeDetermined (mimeType)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  mimeType | QString |

  Call this from subclasses when you have determined the mimetype. It will call foundMimeType, but also sets up protection against deletion during message boxes. @since 4.0.2

- mode ( )

  returns mode_t

  Returns the file mode.

- processDesktopExec (_service, _urls, tempFiles, suggestedFileName)

  returns QStringList
  static

  Argument | Type | Default
  --- | --- | ---
  _service | KService |
  _urls | KUrl.List |
  tempFiles | bool | 0
  suggestedFileName | QString | QString()

  Processes a Exec= line as found in .desktop files.

  _service - the service to extract information from.

  _urls - The urls the service should open.

  tempFiles - if true and urls are local files, they will be deleted when the application exits.

  suggestedFileName - see setSuggestedFileName

  Returns a list of arguments suitable for KProcess.setProgram().

- progressInfo ( )

  returns bool

  Returns whether progress information are shown.

- run (service, urls, window, tempFiles, suggestedFileName, asn)

  returns bool
  static

  Argument | Type | Default
  --- | --- | ---
  service | KService |
  urls | KUrl.List |
  window | QWidget |
  tempFiles | bool | 0
  suggestedFileName | QString | QString()
  asn | QByteArray | ""

  Open a list of URLs with a certain service (application).

  service - the service to run

  urls - the list of URLs, can be empty (app launched without argument)

  window - The top-level widget of the app that invoked this object.

  tempFiles - if true and urls are local files, they will be deleted when the application exits.

  suggestedFileName - see setSuggestedFileName

  asn - Application startup notification id, if any (otherwise ""). Returns true on success, false on error

- run (exec, urls, window, name, icon, asn)

  returns bool
  static

  Argument | Type | Default
  --- | --- | ---
  exec | QString |
  urls | KUrl.List |
  window | QWidget |
  name | QString | QString()
  icon | QString | QString()
  asn | QByteArray | ""

  Open a list of URLs with.

  exec - the name of the executable, for example "/usr/bin/netscape".

  urls - the list of URLs to open, can be empty (app launched without argument)

  window - The top-level widget of the app that invoked this object.

  name - the logical name of the application, for example "Netscape 4.06".

  icon - the icon which should be used by the application.

  asn - Application startup notification id, if any (otherwise ""). Returns true on success, false on error

- runCommand (cmd, window)

  returns bool
  static

  Argument | Type | Default
  --- | --- | ---
  cmd | QString |
  window | QWidget |

  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.

  cmd must be a shell command. You must not append "&" to it, since the function will do that for you.

  window - The top-level widget of the app that invoked this object.

  Returns true on success, false on error

- runCommand (cmd, execName, icon, window, asn)

  returns bool
  static

  Argument | Type | Default
  --- | --- | ---
  cmd | QString |
  execName | QString |
  icon | QString |
  window | QWidget |
  asn | QByteArray | ""

  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.

  cmd - must be a shell command. You must not append "&" to it, since the function will do that for you.

  execName - the name of the executable

  icon - icon for app starting notification

  window - The top-level widget of the app that invoked this object.

  asn - Application startup notification id, if any (otherwise ""). Returns true on success, false on error

- runUrl (url, mimetype, window, tempFile, runExecutables, suggestedFileName, asn)

  returns bool
  static

  Argument | Type | Default
  --- | --- | ---
  url | KUrl |
  mimetype | QString |
  window | QWidget |
  tempFile | bool | 0
  runExecutables | bool | 1
  suggestedFileName | QString | QString()
  asn | QByteArray | ""

  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.

  url - the URL to open

  mimetype - the mime type of the resource

  window - The top-level widget of the app that invoked this object.

  tempFile - if true and url is a local file, it will be deleted when the launched application exits.

  runExecutables - if false then local .desktop files, executables and shell scripts will not be run. See also isExecutable().

  suggestedFileName - see setSuggestedFileName

  asn - Application startup notification id, if any (otherwise ""). Returns true on success, false on error

- scanFile ( )

  returns Nothing

  Start scanning a file.

- setAutoDelete (b)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  b | bool |

  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.

  b - true to enable auto deletion, false to disable

- setDoScanFile (scanFile)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  scanFile | bool |

  Indicate that the next action is to scan the file. Deprecated not useful in public API

- setEnableExternalBrowser (b)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  b | bool |

  Sets whether the external webbrowser setting should be honoured. This is enabled by default. This should only be disabled in webbrowser applications.

  b - whether to enable the external browser or not.

- setError (error)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  error | bool |

  Sets whether an error has occured.

- setFinished (finished)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  finished | bool |

  Marks this 'KRun' instance as finished.

- setInitializeNextAction (initialize)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  initialize | bool |

  Deprecated not useful in public API

- setIsDirecory (isDirectory)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  isDirectory | bool |

  Sets whether it is a directory. Deprecated typo in the name, and not useful as a public method

- setIsLocalFile (isLocalFile)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  isLocalFile | bool |

  Sets whether it is a local file.

- setJob (job)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  job | KIO.Job |

  Sets the job.

- setMode (mode)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  mode | mode_t |

  Sets the file mode.

- setPreferredService (desktopEntryName)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  desktopEntryName | QString |

  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.

  desktopEntryName - the desktopEntryName of the service, e.g. "kate".

- setProgressInfo (progressInfo)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  progressInfo | bool |

  Sets whether progress information shall be shown.

- setRunExecutables (b)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  b | bool |

  Sets whether executables, .desktop files or shell scripts should be run by KRun. This is enabled by default.

  b - whether to run executable files or not.

  See also isExecutable()

- setSuggestedFileName (fileName)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  fileName | QString |

  Sets the file name to use in the case of downloading the file to a tempfile in order to give to a non-url-aware application. Some apps rely on the extension to determine the mimetype of the file. Usually the file name comes from the URL, but in the case of the HTTP Content-Disposition header, we need to override the file name.

- setUrl (url)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  url | KUrl |

  Sets the url.

- shellQuote (str)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  str | QString |

  Quotes a string for the shell. An empty string will not be quoted.

  Deprecated Use KShell.quoteArg() instead. Note that this function behaves differently for empty arguments and returns the result differently.

  str - the string to quote. The quoted string will be written here

- slotScanFinished (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | KJob |

  This slot is called when the scan job is finished.

- slotScanMimeType (a0, type)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | KIO.Job |
  type | QString |

  This slot is called when the scan job has found out the mime type.

- slotStatResult (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | KJob |

  This slot is called when the 'stat' job has finished.

- slotTimeout ( )

  returns Nothing

  This slot is called whenever the internal time has a timeout.

- suggestedFileName ( )

  returns QString

  Suggested file name given by the server (e.g. HTTP content-disposition)

- timer ( )

  returns QTimer

  Returns the timer object.

- url ( )

  returns KUrl

  Returns the url.