KIO::OpenUrlJob

#include <KIO/OpenUrlJob>

Inheritance diagram for KIO::OpenUrlJob:

Signals

void mimeTypeFound (const QString &mimeType)
 
- Signals inherited from KJob
void description (KJob *job, const QString &title, const QPair< QString, QString > &field1=QPair< QString, QString >(), const QPair< QString, QString > &field2=QPair< QString, QString >())
 
void finished (KJob *job)
 
void infoMessage (KJob *job, const QString &plain, const QString &rich=QString())
 
void percent (KJob *job, unsigned long percent)
 
void processedAmount (KJob *job, KJob::Unit unit, qulonglong amount)
 
void processedSize (KJob *job, qulonglong size)
 
void result (KJob *job)
 
void resumed (KJob *job)
 
void speed (KJob *job, unsigned long speed)
 
void suspended (KJob *job)
 
void totalAmount (KJob *job, KJob::Unit unit, qulonglong amount)
 
void totalSize (KJob *job, qulonglong size)
 
void warning (KJob *job, const QString &plain, const QString &rich=QString())
 

Public Member Functions

 OpenUrlJob (const QUrl &url, QObject *parent=nullptr)
 
 OpenUrlJob (const QUrl &url, const QString &mimeType, QObject *parent=nullptr)
 
 ~OpenUrlJob () override
 
void setDeleteTemporaryFile (bool b)
 
void setEnableExternalBrowser (bool b)
 
void setFollowRedirections (bool b)
 
void setRunExecutables (bool allow)
 
void setShowOpenOrExecuteDialog (bool b)
 
void setStartupId (const QByteArray &startupId)
 
void setSuggestedFileName (const QString &suggestedFileName)
 
void start () override
 
- Public Member Functions inherited from KCompositeJob
 KCompositeJob (QObject *parent=nullptr)
 
- Public Member Functions inherited from KJob
 KJob (QObject *parent=nullptr)
 
Capabilities capabilities () const
 
int error () const
 
virtual QString errorString () const
 
QString errorText () const
 
bool exec ()
 
bool isAutoDelete () const
 
bool isSuspended () const
 
unsigned long percent () const
 
Q_SCRIPTABLE qulonglong processedAmount (Unit unit) const
 
void setAutoDelete (bool autodelete)
 
void setUiDelegate (KJobUiDelegate *delegate)
 
Q_SCRIPTABLE qulonglong totalAmount (Unit unit) const
 
KJobUiDelegateuiDelegate () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Protected Member Functions

bool doKill () override
 
- Protected Member Functions inherited from KCompositeJob
virtual bool addSubjob (KJob *job)
 
void clearSubjobs ()
 
bool hasSubjobs () const
 
virtual bool removeSubjob (KJob *job)
 
const QList< KJob * > & subjobs () const
 
- Protected Member Functions inherited from KJob
virtual bool doResume ()
 
virtual bool doSuspend ()
 
void emitPercent (qulonglong processedAmount, qulonglong totalAmount)
 
void emitResult ()
 
void emitSpeed (unsigned long speed)
 
bool isFinished () const
 
void setCapabilities (Capabilities capabilities)
 
void setError (int errorCode)
 
void setErrorText (const QString &errorText)
 
void setPercent (unsigned long percentage)
 
void setProcessedAmount (Unit unit, qulonglong amount)
 
void setProgressUnit (Unit unit)
 
void setTotalAmount (Unit unit, qulonglong amount)
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Public Types inherited from KJob
typedef QFlags< CapabilityCapabilities
 
enum  Capability
 
enum  Unit
 
- Properties inherited from QObject
 objectName
 
- Public Slots inherited from KJob
bool kill (KillVerbosity verbosity=Quietly)
 
bool resume ()
 
bool suspend ()
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from KJob
 Bytes
 
 Directories
 
 Files
 
 Items
 
 Killable
 
 NoCapabilities
 
 Suspendable
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Slots inherited from KCompositeJob
virtual void slotInfoMessage (KJob *job, const QString &plain, const QString &rich)
 

Detailed Description

OpenUrlJob finds out the right way to "open" a URL.

This includes finding out its mimetype, and then the associated application, or running desktop files, executables, etc. It also honours the "use this webbrowser for all http(s) URLs" setting.

For the "Open With" dialog functionality to work, make sure to set KIO::JobUiDelegate as the delegate for this job (in widgets applications).

Since
5.71

Definition at line 38 of file openurljob.h.

Constructor & Destructor Documentation

KIO::OpenUrlJob::OpenUrlJob ( const QUrl url,
QObject parent = nullptr 
)
explicit

Creates an OpenUrlJob in order to open a URL.

Parameters
urlthe URL of the file/directory to open

Definition at line 94 of file openurljob.cpp.

KIO::OpenUrlJob::OpenUrlJob ( const QUrl url,
const QString mimeType,
QObject parent = nullptr 
)
explicit

Creates an OpenUrlJob for the case where the mimeType is already known.

Parameters
urlthe URL of the file/directory to open
mimeTypethe type of file/directory. See QMimeType.

Definition at line 99 of file openurljob.cpp.

KIO::OpenUrlJob::~OpenUrlJob ( )
override

Destructor.

Note that by default jobs auto-delete themselves after emitting result.

Definition at line 105 of file openurljob.cpp.

Member Function Documentation

void KIO::OpenUrlJob::mimeTypeFound ( const QString mimeType)
signal

Emitted when the mimeType is determined.

This can be used for special cases like webbrowsers who want to embed the URL in some cases, rather than starting a different application. In that case they can kill the job.

void KIO::OpenUrlJob::setDeleteTemporaryFile ( bool  b)

Specifies that the URL passed to the application will be deleted when it exits (if the URL is a local file)

Definition at line 109 of file openurljob.cpp.

void KIO::OpenUrlJob::setEnableExternalBrowser ( bool  b)

Sets whether the external webbrowser setting should be honoured.

This is enabled by default. This should only be disabled in webbrowser applications.

Parameters
bwhether to let the external browser handle the URL or not

Definition at line 134 of file openurljob.cpp.

void KIO::OpenUrlJob::setFollowRedirections ( bool  b)

Sets whether the job should follow URL redirections.

This is enabled by default.

Parameters
bwhether to follow redirections or not.

Definition at line 139 of file openurljob.cpp.

void KIO::OpenUrlJob::setRunExecutables ( bool  allow)

Set this to true if this class should allow the user to run executables.

Unlike KF5's KRun, this setting is OFF by default here for security reasons. File managers can enable this, but e.g. web browsers, mail clients etc. shouldn't.

Definition at line 124 of file openurljob.cpp.

void KIO::OpenUrlJob::setShowOpenOrExecuteDialog ( bool  b)

Set this to true if this class should show a dialog to ask the user about how to handle various types of executable files; note that executing/running remote files is disallowed as that is not secure (in the case of remote shell scripts and .desktop files, they are always opened as text in the default application):

  • For native binaries: whether to execute or cancel
  • For .exe files: whether to execute or cancel, ("execute" on Linux in this context means running the file with the default application (e.g. WINE))
  • For executable shell scripts: whether to execute the file or open it as text in the default application; note that if the file doesn't have the execute bit, it'll always be opened as text
  • For .desktop files: whether to run the file or open it as text in the default application; note that if the .desktop file is located in a non-standard location (on Linux standard locations are /usr/share/applications or ~/.local/share/applications) and does not have the execute bit, another dialog (see UntrustedProgramHandlerInterface) will be launched to ask the user whether they trust running the application (the one the .desktop file launches based on the Exec line)

Note that the dialog, ExecutableFileOpenDialog (from KIOWidgets), provides an option to remember the last value used and not ask again, if that is set, then the dialog will not be shown.

When set to true this will take precedence over setRunExecutables (the latter can be used to allow running executables without first asking the user for confirmation).

Since
5.73

Definition at line 129 of file openurljob.cpp.

void KIO::OpenUrlJob::setStartupId ( const QByteArray startupId)

Sets the startup notification id of the application launch.

Parameters
startupIdstartup notification id, if any (otherwise "").

Definition at line 119 of file openurljob.cpp.

void KIO::OpenUrlJob::setSuggestedFileName ( const QString suggestedFileName)

Sets the file name to use in the case of downloading the file to a tempfile, in order to give it 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.

Parameters
suggestedFileNamethe file name

Definition at line 114 of file openurljob.cpp.

void KIO::OpenUrlJob::start ( )
overridevirtual

Starts the job.

You must call this, after having called all the needed setters. This is a GUI job, never use exec(), it would block user interaction.

Implements KJob.

Definition at line 150 of file openurljob.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Dec 3 2020 23:02:00 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.