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
System
Dolphin
Commits
74107227
Commit
74107227
authored
Mar 10, 2020
by
Piotr Henryk Dabrowski
Browse files
update KParts' ReadOnlyPart::localFilePath in DolphinPart::openUrl()
parent
b5885871
Pipeline
#45663
passed with stage
in 6 minutes and 52 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/dolphinpart.cpp
View file @
74107227
...
...
@@ -283,6 +283,18 @@ void DolphinPart::updatePasteAction()
Q_EMIT
m_extension
->
setActionText
(
"paste"
,
pasteInfo
.
second
);
}
QString
DolphinPart
::
urlToLocalFilePath
(
const
QUrl
&
url
)
{
KIO
::
StatJob
*
statJob
=
KIO
::
mostLocalUrl
(
url
);
KJobWidgets
::
setWindow
(
statJob
,
widget
());
statJob
->
exec
();
QUrl
localUrl
=
statJob
->
mostLocalUrl
();
if
(
localUrl
.
isLocalFile
())
{
return
localUrl
.
toLocalFile
();
}
return
QString
();
}
bool
DolphinPart
::
openUrl
(
const
QUrl
&
url
)
{
bool
reload
=
arguments
().
reload
();
...
...
@@ -293,7 +305,8 @@ bool DolphinPart::openUrl(const QUrl &url)
if
(
m_view
->
url
()
==
url
&&
!
reload
)
{
// DolphinView won't do anything in that case, so don't emit started
return
true
;
}
setUrl
(
url
);
// remember it at the KParts level
setUrl
(
url
);
// remember url at the KParts level
setLocalFilePath
(
urlToLocalFilePath
(
url
));
// remember local path at the KParts level
QUrl
visibleUrl
(
url
);
if
(
!
m_nameFilter
.
isEmpty
())
{
visibleUrl
.
setPath
(
visibleUrl
.
path
()
+
'/'
+
m_nameFilter
);
...
...
@@ -310,7 +323,7 @@ bool DolphinPart::openUrl(const QUrl &url)
m_view
->
reload
();
// Disable "Find File" and "Open Terminal" actions for non-file URLs,
// e.g. ftp, smb, etc. #279283
const
bool
isLocalUrl
=
url
.
isL
ocalFile
(
);
const
bool
isLocalUrl
=
!
(
l
ocalFile
Path
().
isEmpty
()
);
m_findFileAction
->
setEnabled
(
isLocalUrl
);
if
(
m_openTerminalAction
)
{
m_openTerminalAction
->
setEnabled
(
isLocalUrl
);
...
...
@@ -542,16 +555,25 @@ void DolphinPart::setNameFilter(const QString& nameFilter)
// TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
}
QString
DolphinPart
::
localFilePathOrHome
()
const
{
const
QString
localPath
=
localFilePath
();
if
(
!
localPath
.
isEmpty
())
{
return
localPath
;
}
return
QDir
::
homePath
();
}
void
DolphinPart
::
slotOpenTerminal
()
{
KToolInvocation
::
invokeTerminal
(
QString
(),
KParts
::
ReadOnlyPart
::
localFilePath
());
KToolInvocation
::
invokeTerminal
(
QString
(),
localFilePath
OrHome
());
}
void
DolphinPart
::
slotFindFile
()
{
QMenu
searchTools
;
KMoreToolsMenuFactory
(
"dolphin/search-tools"
).
fillMenuFromGroupingNames
(
&
searchTools
,
{
"files-find"
},
QUrl
::
fromLocalFile
(
KParts
::
ReadOnlyPart
::
localFilePath
())
&
searchTools
,
{
"files-find"
},
QUrl
::
fromLocalFile
(
localFilePath
OrHome
())
);
QList
<
QAction
*>
actions
=
searchTools
.
actions
();
if
(
!
(
actions
.
isEmpty
()))
{
...
...
src/dolphinpart.h
View file @
74107227
...
...
@@ -218,6 +218,8 @@ private:
void
openSelectionDialog
(
const
QString
&
title
,
const
QString
&
text
,
bool
selectItems
);
QString
urlToLocalFilePath
(
const
QUrl
&
url
);
QString
localFilePathOrHome
()
const
;
private:
DolphinView
*
m_view
;
...
...
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