diff --git a/kioslave/desktop/CMakeLists.txt b/kioslave/desktop/CMakeLists.txt --- a/kioslave/desktop/CMakeLists.txt +++ b/kioslave/desktop/CMakeLists.txt @@ -2,7 +2,7 @@ add_library(kio_desktop MODULE kio_desktop.cpp) -target_link_libraries(kio_desktop KF5::KIOCore KF5::KDELibs4Support) +target_link_libraries(kio_desktop Qt5::DBus Qt5::Gui KF5::KIOCore) set_target_properties(kio_desktop PROPERTIES OUTPUT_NAME "desktop") @@ -12,7 +12,7 @@ add_library(desktopnotifier MODULE desktopnotifier.cpp) kcoreaddons_desktop_to_json(desktopnotifier desktopnotifier.desktop) -target_link_libraries(desktopnotifier KF5::KIOCore KF5::DBusAddons KF5::KDELibs4Support) +target_link_libraries(desktopnotifier KF5::KIOCore KF5::DBusAddons) install(TARGETS desktopnotifier DESTINATION ${PLUGIN_INSTALL_DIR}/kf5/kded) diff --git a/kioslave/desktop/desktopnotifier.cpp b/kioslave/desktop/desktopnotifier.cpp --- a/kioslave/desktop/desktopnotifier.cpp +++ b/kioslave/desktop/desktopnotifier.cpp @@ -19,16 +19,13 @@ #include "desktopnotifier.h" #include -#include -#include #include #include -#include - #include -#include +#include +#include K_PLUGIN_FACTORY_WITH_JSON(DesktopNotifierFactory, "desktopnotifier.json", @@ -72,9 +69,11 @@ checkDesktopLocation(); } else { // Emitting FilesAdded forces a re-read of the dir - KUrl url("desktop:/"); - url.addPath(KUrl::relativePath(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), path)); - url.cleanPath(); + QUrl url; + url.setScheme(QStringLiteral("desktop")); + const auto relativePath = QDir(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)).relativeFilePath(path); + url.setPath(QStringLiteral("%1/%2").arg(url.path(), relativePath)); + url.setPath(QDir::cleanPath(url.path())); org::kde::KDirNotify::emitFilesAdded(url); } } diff --git a/kioslave/desktop/kio_desktop.cpp b/kioslave/desktop/kio_desktop.cpp --- a/kioslave/desktop/kio_desktop.cpp +++ b/kioslave/desktop/kio_desktop.cpp @@ -19,20 +19,14 @@ #include "kio_desktop.h" -#include -#include #include #include #include -#include -#include -#include -#include -#include #include #include +#include #include #include #include @@ -45,8 +39,7 @@ { // necessary to use other kio slaves QCoreApplication app(argc, argv); - KComponentData("kio_desktop", "kdelibs4"); - KLocale::global(); + app.setApplicationName("kio_desktop"); // start the slave DesktopProtocol slave(argv[1], argv[2], argv[3]); @@ -97,12 +90,20 @@ desktopPath + "/trash.desktop"); // Copy the desktop links - const QStringList links = KGlobal::dirs()->findAllResources("data", QStringLiteral("kio_desktop/DesktopLinks/*"), - KStandardDirs::NoDuplicates); + QSet links; + const auto dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("kio_desktop/DesktopLinks"), QStandardPaths::LocateDirectory); + for (const auto &dir : dirs) { + const auto fileNames = QDir(dir).entryList({QStringLiteral("*.desktop")}); + for (const auto &file : fileNames) { + links += file; + } + } + foreach (const QString &link, links) { - KDesktopFile file(link); + const auto fullPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kio_desktop/DesktopLinks/%1").arg(link)); + KDesktopFile file(fullPath); if (!file.desktopGroup().readEntry("Hidden", false)) - QFile::copy(link, desktopPath + link.mid(link.lastIndexOf('/'))); + QFile::copy(fullPath, QStringLiteral("%1/%2").arg(desktopPath, link)); } } #endif @@ -119,7 +120,7 @@ { KIO::ForwardingSlaveBase::listDir(url); - KUrl actual; + QUrl actual; rewriteUrl(url, actual); QDBusInterface kded(QStringLiteral("org.kde.kded5"), QStringLiteral("/modules/desktopnotifier"), QStringLiteral("org.kde.DesktopNotifier")); @@ -132,12 +133,12 @@ if (name == QLatin1String(".") || name == QLatin1String("..")) return QString(); - KUrl url = processedUrl(); - url.addPath(name); + QUrl url = processedUrl(); + url.setPath(QStringLiteral("%1/%2").arg(url.path(), name)); if (entry.isDir()) { - url.addPath(QStringLiteral(".directory")); - if (!KStandardDirs::exists(url.path())) + url.setPath(QStringLiteral("%1/.directory").arg(url.path())); + if (!QFileInfo::exists(url.path())) return QString(); return url.path(); diff --git a/kioslave/desktop/tests/CMakeLists.txt b/kioslave/desktop/tests/CMakeLists.txt --- a/kioslave/desktop/tests/CMakeLists.txt +++ b/kioslave/desktop/tests/CMakeLists.txt @@ -1,5 +1,5 @@ add_executable(testdesktop kio_desktop_test.cpp) -target_link_libraries(testdesktop KF5::KIOWidgets KF5::Solid Qt5::Test KF5::KDELibs4Support) +target_link_libraries(testdesktop KF5::KIOWidgets KF5::Solid Qt5::Test) ecm_mark_as_test(testdesktop) add_test(testdesktop testdesktop) diff --git a/kioslave/desktop/tests/kio_desktop_test.cpp b/kioslave/desktop/tests/kio_desktop_test.cpp --- a/kioslave/desktop/tests/kio_desktop_test.cpp +++ b/kioslave/desktop/tests/kio_desktop_test.cpp @@ -18,12 +18,10 @@ */ #include -#include -#include #include #include -#include -#include +#include +#include #include #include @@ -54,7 +52,7 @@ void testCopyToDesktop() { - KTemporaryFile tempFile; + QTemporaryFile tempFile; QVERIFY(tempFile.open()); tempFile.write( "Hello world\n", 12 ); QString fileName = tempFile.fileName(); @@ -128,6 +126,6 @@ QString m_testFileName; }; -QTEST_KDEMAIN(TestDesktop, NoGUI) +QTEST_GUILESS_MAIN(TestDesktop) #include "kio_desktop_test.moc"