KIO

krun.h
1 /*
2  This file is part of the KDE project
3  SPDX-FileCopyrightText: 1998, 1999 Torben Weis <[email protected]>
4  SPDX-FileCopyrightText: 2006 David Faure <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #ifndef KRUN_H
10 #define KRUN_H
11 
12 #include "kiowidgets_export.h"
13 
14 #include <QObject>
15 #include <QString>
16 #include <QUrl>
17 
18 class KService;
19 class KJob;
20 class QTimer;
21 class KRunPrivate;
22 
23 namespace KIO
24 {
25 class Job;
26 }
27 
28 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
29 
52 class KIOWIDGETS_EXPORT KRun : public QObject
53 {
54  Q_OBJECT
55 public:
84  KRun(const QUrl &url, QWidget *window,
85  bool showProgressInfo = true,
86  const QByteArray &asn = QByteArray());
87 
92  virtual ~KRun();
93 
100  void abort();
101 
107  bool hasError() const;
108 
114  bool hasFinished() const;
115 
123  bool autoDelete() const;
124 
133  void setAutoDelete(bool b);
134 
144  void setPreferredService(const QString &desktopEntryName);
145 
152  void setRunExecutables(bool b);
153 
160  void setFollowRedirections(bool b);
161 
168  void setEnableExternalBrowser(bool b);
169 
177  void setSuggestedFileName(const QString &fileName);
178 
185  void setShowScriptExecutionPrompt(bool showPrompt);
186 
190  QString suggestedFileName() const;
191 
196  QWidget *window() const;
197 
198 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 6)
199 
225  KIOWIDGETS_DEPRECATED_VERSION(5, 6, "Use KIO::ApplicationLauncherJob, see API docs for a code sample")
226  static bool run(const KService &service, const QList<QUrl> &urls, QWidget *window,
227  bool tempFiles = false, const QString &suggestedFileName = QString(),
228  const QByteArray &asn = QByteArray());
229 #endif
230 
231 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
232 
262  KIOWIDGETS_DEPRECATED_VERSION(5, 71, "Use KIO::ApplicationLauncherJob, see API docs for a code sample")
263  static qint64 runService(const KService &service, const QList<QUrl> &urls, QWidget *window,
264  bool tempFiles = false, const QString &suggestedFileName = QString(),
265  const QByteArray &asn = QByteArray());
266 #endif
267 
268 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
269 
272  enum RunFlag {
273  DeleteTemporaryFiles = 0x1,
274  RunExecutables = 0x2,
275  };
280  Q_DECLARE_FLAGS(RunFlags, RunFlag)
281 #endif
282 
283 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
284 
313  KIOWIDGETS_DEPRECATED_VERSION(5, 71, "Use KIO::ApplicationLauncherJob, see API docs for a code sample")
314  static qint64 runApplication(const KService &service, const QList<QUrl> &urls, QWidget *window,
315  RunFlags flags = RunFlags(), const QString &suggestedFileName = QString(),
316  const QByteArray &asn = QByteArray());
317 #endif
318 
319 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
320 
346  KIOWIDGETS_DEPRECATED_VERSION(5, 71, "Use KIO::ApplicationLauncherJob with a temporary KService, see API docs for a code sample")
347  static bool run(const QString &exec, const QList<QUrl> &urls, QWidget *window,
348  const QString &name = QString(),
349  const QString &icon = QString(),
350  const QByteArray &asn = QByteArray());
351 #endif
352 
353 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 31)
354 
382  KIOWIDGETS_DEPRECATED_VERSION(5, 31, "Use KIO::OpenUrlJob, see API docs for a code sample")
383  static bool runUrl(const QUrl &url, const QString &mimetype, QWidget *window,
384  bool tempFile = false, bool runExecutables = true,
385  const QString &suggestedFileName = QString(), const QByteArray &asn = QByteArray());
386 #endif
387 
388 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
389 
414  KIOWIDGETS_DEPRECATED_VERSION(5, 71, "Use KIO::OpenUrlJob, see API docs for a code sample")
415  static bool runUrl(const QUrl &url, const QString &mimetype, QWidget *window, RunFlags flags,
416  const QString &suggestedFileName = QString(), const QByteArray &asn = QByteArray());
417 #endif
418 
419 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
420 
443  KIOWIDGETS_DEPRECATED_VERSION(5, 71, "Use KIO::CommandLauncherJob, see API docs for a code sample")
444  static bool runCommand(const QString &cmd, QWidget *window, const QString &workingDirectory = QString());
445 #endif
446 
447 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
448 
470  KIOWIDGETS_DEPRECATED_VERSION(5, 71, "Use KIO::CommandLauncherJob, see API docs for a code sample")
471  static bool runCommand(const QString &cmd, const QString &execName,
472  const QString &icon, QWidget *window, const QByteArray &asn = QByteArray());
473 #endif
474 
475 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
476 
493  KIOWIDGETS_DEPRECATED_VERSION(5, 71, "Use KIO::CommandLauncherJob, see API docs for a code sample")
494  static bool runCommand(const QString &cmd, const QString &execName,
495  const QString &icon, QWidget *window,
496  const QByteArray &asn, const QString &workingDirectory);
497 #endif
498 
499 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
500 
522  KIOWIDGETS_DEPRECATED_VERSION(5, 71, "Use KIO::ApplicationLauncherJob, see API docs for a code sample")
523  static bool displayOpenWithDialog(const QList<QUrl> &lst, QWidget *window,
524  bool tempFiles = false, const QString &suggestedFileName = QString(),
525  const QByteArray &asn = QByteArray());
526 #endif
527 
528 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(4, 0)
529 
539  KIOWIDGETS_DEPRECATED_VERSION(4, 0, "Use KShell::quoteArg(...)")
540  static void shellQuote(QString &str);
541 #endif
542 
543 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 0)
544 
555  KIOWIDGETS_DEPRECATED_VERSION(5, 0, "Use KIO::DesktopExecParser")
556  static QStringList processDesktopExec(const KService &_service, const QList<QUrl> &_urls,
557  bool tempFiles = false,
558  const QString &suggestedFileName = QString());
559 #endif
560 
561 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 0)
562 
571  KIOWIDGETS_DEPRECATED_VERSION(5, 0, "See API docs")
572  static QString binaryName(const QString &execLine, bool removePath);
573 #endif
574 
579  static bool isExecutable(const QString &mimeType);
580 
593  static bool isExecutableFile(const QUrl &url, const QString &mimetype);
594 
598  static bool checkStartupNotify(const QString &binName, const KService *service, bool *silent_arg,
599  QByteArray *wmclass_arg);
600 
601 Q_SIGNALS:
607  void finished();
612  void error();
613 
614 protected Q_SLOTS:
623  void slotTimeout();
624 
628  void slotScanFinished(KJob *);
629 
634  void slotScanMimeType(KIO::Job *, const QString &type);
635 
641  void mimeTypeDetermined(const QString &mimeType);
642 
646  virtual void slotStatResult(KJob *);
647 
648 protected:
656  virtual void init();
657 
661  virtual void scanFile();
662 
674  virtual void foundMimeType(const QString &type);
675 
679  virtual void killJob();
680 
687  virtual void handleInitError(int kioErrorCode, const QString &errorMsg);
688 
694  virtual void handleError(KJob *job);
695 
699  void setUrl(const QUrl &url);
700 
704  QUrl url() const;
705 
709  void setError(bool error);
710 
714  void setProgressInfo(bool progressInfo);
715 
719  bool progressInfo() const;
720 
724  void setFinished(bool finished);
725 
729  void setJob(KIO::Job *job);
730 
734  KIO::Job *job();
735 
736 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(4, 4)
737 
742  KIOWIDGETS_DEPRECATED_VERSION(4, 4, "See API docs")
743  QTimer &timer();
744 #endif
745 
746 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(4, 1)
747 
751  KIOWIDGETS_DEPRECATED_VERSION(4, 1, "Do not use")
752  void setDoScanFile(bool scanFile);
753 #endif
754 
755 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(4, 1)
756 
760  KIOWIDGETS_DEPRECATED_VERSION(4, 1, "Do not use")
761  bool doScanFile() const;
762 #endif
763 
764 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(4, 1)
765 
769  KIOWIDGETS_DEPRECATED_VERSION(4, 1, "Do not use")
770  void setIsDirecory(bool isDirectory);
771 #endif
772 
776  bool isDirectory() const;
777 
778 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(4, 1)
779 
782  KIOWIDGETS_DEPRECATED_VERSION(4, 1, "Do not use")
783  void setInitializeNextAction(bool initialize);
784 #endif
785 
786 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(4, 1)
787 
790  KIOWIDGETS_DEPRECATED_VERSION(4, 1, "Do not use")
791  bool initializeNextAction() const;
792 #endif
793 
797  bool isLocalFile() const;
798 
799 private:
800  friend class KRunPrivate;
801  KRunPrivate *const d;
802 };
803 #endif
804 
805 #endif
A namespace for KIO globals.
To open files with their associated applications in KDE, use KRun.
Definition: krun.h:52
RunFlag
Definition: krun.h:272
KIOCORE_EXPORT MimetypeJob * mimetype(const QUrl &url, JobFlags flags=DefaultFlags)
Find MIME type for one file or directory.
Definition: mimetypejob.cpp:84
QCA_EXPORT void init()
The base class for all jobs.
Definition: job_base.h:45
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Jan 20 2021 23:05:18 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.