Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
KDE CLI tools
Commits
8dfe577f
Commit
8dfe577f
authored
Apr 10, 2021
by
David Faure
Browse files
Port kde-open5 from KRun to OpenUrlJob
parent
74dfa26a
Changes
2
Hide whitespace changes
Inline
Side-by-side
kioclient/kioclient.cpp
View file @
8dfe577f
...
...
@@ -15,8 +15,8 @@
#ifndef KIOCORE_ONLY
#include
<KIO/ApplicationLauncherJob>
#include
<KIO/JobUiDelegate>
#include
<KIO/OpenUrlJob>
#include
<KPropertiesDialog>
#include
<KRun>
#include
<KService>
#endif
#include
<KAboutData>
...
...
@@ -195,18 +195,6 @@ int main(int argc, char **argv)
return
client
.
doIt
(
parser
)
?
0
/*no error*/
:
1
/*error*/
;
}
static
bool
krun_has_error
=
false
;
void
ClientApp
::
delayedQuit
()
{
#ifndef KIOCORE_ONLY
// don't access the KRun instance later, it will be deleted after calling slots
if
(
static_cast
<
const
KRun
*>
(
sender
())
->
hasError
())
{
krun_has_error
=
true
;
}
#endif
}
static
void
checkArgumentCount
(
int
count
,
int
min
,
int
max
)
{
if
(
count
<
min
)
{
...
...
@@ -231,18 +219,19 @@ bool ClientApp::kde_open(const QString &url, const QString &mimeType, bool allow
info
.
url
.
setQuery
(
q
);
}
if
(
mimeType
.
isEmpty
())
{
KRun
*
run
=
new
KRun
(
info
.
url
,
nullptr
);
run
->
setRunExecutables
(
allowExec
);
run
->
setFollowRedirections
(
false
);
QObject
::
connect
(
run
,
&
KRun
::
finished
,
this
,
&
ClientApp
::
delayedQuit
);
QObject
::
connect
(
run
,
&
KRun
::
error
,
this
,
&
ClientApp
::
delayedQuit
);
qApp
->
exec
();
return
!
krun_has_error
;
}
else
{
return
KRun
::
runUrl
(
info
.
url
,
mimeType
,
nullptr
,
KRun
::
RunFlags
(
KRun
::
RunExecutables
));
}
auto
*
job
=
new
KIO
::
OpenUrlJob
(
info
.
url
,
mimeType
);
job
->
setUiDelegate
(
new
KIO
::
JobUiDelegate
(
KJobUiDelegate
::
AutoHandlingEnabled
,
nullptr
));
job
->
setRunExecutables
(
allowExec
);
job
->
setFollowRedirections
(
false
);
bool
job_had_error
=
false
;
QObject
::
connect
(
job
,
&
KJob
::
result
,
this
,
[
&
](
KJob
*
job
)
{
if
(
job
->
error
())
{
job_had_error
=
true
;
}
});
job
->
start
();
qApp
->
exec
();
return
!
job_had_error
;
}
#endif
...
...
kioclient/kioclient.h
View file @
8dfe577f
...
...
@@ -30,7 +30,6 @@ private Q_SLOTS:
void
slotPrintData
(
KIO
::
Job
*
job
,
const
QByteArray
&
data
);
void
slotEntries
(
KIO
::
Job
*
job
,
const
KIO
::
UDSEntryList
&
);
void
slotResult
(
KJob
*
);
void
delayedQuit
();
void
slotDialogCanceled
();
private:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment