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
Graphics
Gwenview
Commits
ec1de82c
Commit
ec1de82c
authored
Jun 04, 2021
by
Marco Martin
Browse files
Ask dolphin with SortForUrl what sort we should use
parent
c541ecdf
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/mainwindow.cpp
View file @
ec1de82c
...
...
@@ -36,6 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <QMenuBar>
#include <QUrl>
#include <QMouseEvent>
#ifdef Q_OS_OSX
#include <QFileOpenEvent>
#endif
...
...
@@ -63,6 +64,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <KToolBarPopupAction>
#include <KXMLGUIFactory>
#include <KDirLister>
#ifndef GWENVIEW_SEMANTICINFO_BACKEND_NONE
#include "lib/semanticinfo/semanticinfodirmodel.h"
#endif
#ifdef KF5Purpose_FOUND
#include <PurposeWidgets/Menu>
#include <Purpose/AlternativesModel>
...
...
@@ -106,6 +110,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <lib/mimetypeutils.h>
#ifdef HAVE_QTDBUS
#include <lib/mpris2/mpris2service.h>
#include <QDBusPendingReply>
#endif
#include <lib/print/printhelper.h>
#include <lib/slideshow.h>
...
...
@@ -1076,6 +1081,57 @@ void MainWindow::setInitialUrl(const QUrl &_url)
{
Q_ASSERT
(
_url
.
isValid
());
QUrl
url
=
UrlUtils
::
fixUserEnteredUrl
(
_url
);
#ifdef HAVE_QTDBUS
QDBusMessage
message
=
QDBusMessage
::
createMethodCall
(
QStringLiteral
(
"org.freedesktop.FileManager1"
),
QStringLiteral
(
"/org/freedesktop/FileManager1"
),
QStringLiteral
(
"org.freedesktop.FileManager1"
),
QStringLiteral
(
"SortOrderForUrl"
));
QUrl
dirUrl
=
url
;
dirUrl
=
dirUrl
.
adjusted
(
QUrl
::
RemoveFilename
);
message
<<
dirUrl
.
toString
();
QDBusPendingCall
call
=
QDBusConnection
::
sessionBus
().
asyncCall
(
message
);
QDBusPendingCallWatcher
*
watcher
=
new
QDBusPendingCallWatcher
(
call
,
this
);
connect
(
watcher
,
&
QDBusPendingCallWatcher
::
finished
,
this
,
[
this
](
QDBusPendingCallWatcher
*
call
)
{
QDBusPendingReply
<
QString
,
QString
>
reply
=
*
call
;
// Fail silently
if
(
!
reply
.
isError
())
{
QString
columnName
=
reply
.
argumentAt
<
0
>
();
QString
orderName
=
reply
.
argumentAt
<
1
>
();
int
column
=
-
1
;
int
sortRole
=
-
1
;
Qt
::
SortOrder
order
=
orderName
==
QStringLiteral
(
"descending"
)
?
Qt
::
DescendingOrder
:
Qt
::
AscendingOrder
;
if
(
columnName
==
"text"
)
{
column
=
KDirModel
::
Name
;
sortRole
=
Qt
::
DisplayRole
;
}
else
if
(
columnName
==
"modificationtime"
)
{
column
=
KDirModel
::
ModifiedTime
;
sortRole
=
Qt
::
DisplayRole
;
}
else
if
(
columnName
==
"size"
)
{
column
=
KDirModel
::
Size
;
sortRole
=
Qt
::
DisplayRole
;
#ifndef GWENVIEW_SEMANTICINFO_BACKEND_NONE
}
else
if
(
columnName
==
"rating"
)
{
column
=
KDirModel
::
Name
;
sortRole
=
SemanticInfoDirModel
::
RatingRole
;
#endif
}
if
(
column
>=
0
&&
sortRole
>=
0
)
{
d
->
mDirModel
->
setSortRole
(
sortRole
);
d
->
mDirModel
->
sort
(
column
,
order
);
}
}
call
->
deleteLater
();
});
#endif
if
(
UrlUtils
::
urlIsDirectory
(
url
))
{
d
->
mBrowseAction
->
trigger
();
openDirUrl
(
url
);
...
...
Write
Preview
Markdown
is supported
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