diff --git a/src/platformtheme/kdeplatformsystemtrayicon.cpp b/src/platformtheme/kdeplatformsystemtrayicon.cpp index 11677e3..3c0b215 100644 --- a/src/platformtheme/kdeplatformsystemtrayicon.cpp +++ b/src/platformtheme/kdeplatformsystemtrayicon.cpp @@ -1,359 +1,359 @@ /* This file is part of the KDE libraries * Copyright 2014 Martin Gräßlin * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License or ( at * your option ) version 3 or, at the discretion of KDE e.V. ( which shall * act as a proxy as in section 14 of the GPLv3 ), any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "kdeplatformsystemtrayicon.h" #include #include #include #include #include #include #ifdef DBUS_SUPPORT_ENABLED #include #endif SystemTrayMenu::SystemTrayMenu() : QPlatformMenu() , m_tag(0) , m_menu(new QMenu()) { connect(m_menu.data(), &QMenu::aboutToShow, this, &QPlatformMenu::aboutToShow); connect(m_menu.data(), &QMenu::aboutToHide, this, &QPlatformMenu::aboutToHide); } SystemTrayMenu::~SystemTrayMenu() { if (m_menu) { m_menu->deleteLater(); } } QPlatformMenuItem *SystemTrayMenu::createMenuItem() const { return new SystemTrayMenuItem(); } void SystemTrayMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before) { if (SystemTrayMenuItem *ours = qobject_cast(menuItem)) { bool inserted = false; if (SystemTrayMenuItem *oursBefore = qobject_cast(before)) { for (auto it = m_items.begin(); it != m_items.end(); ++it) { if (*it == oursBefore) { m_items.insert(it, ours); if (m_menu) { m_menu->insertAction(oursBefore->action(), ours->action()); } inserted = true; break; } } } if (!inserted) { m_items.append(ours); if (m_menu) { m_menu->addAction(ours->action()); } } } } QPlatformMenuItem *SystemTrayMenu::menuItemAt(int position) const { if (position < m_items.size()) { return m_items.at(position); } return Q_NULLPTR; } QPlatformMenuItem *SystemTrayMenu::menuItemForTag(quintptr tag) const { auto it = std::find_if(m_items.constBegin(), m_items.constEnd(), [tag](SystemTrayMenuItem *item) { return item->tag() == tag; }); if (it != m_items.constEnd()) { return *it; } return Q_NULLPTR; } void SystemTrayMenu::removeMenuItem(QPlatformMenuItem *menuItem) { if (SystemTrayMenuItem *ours = qobject_cast(menuItem)) { m_items.removeOne(ours); if (ours->action() && m_menu) { m_menu->removeAction(ours->action()); } } } void SystemTrayMenu::setEnabled(bool enabled) { if (!m_menu) { return; } m_menu->setEnabled(enabled); } void SystemTrayMenu::setIcon(const QIcon &icon) { if (!m_menu) { return; } m_menu->setIcon(icon); } void SystemTrayMenu::setTag(quintptr tag) { m_tag = tag; } void SystemTrayMenu::setText(const QString &text) { if (!m_menu) { return; } m_menu->setTitle(text); } void SystemTrayMenu::setVisible(bool visible) { if (!m_menu) { return; } m_menu->setVisible(visible); } void SystemTrayMenu::syncMenuItem(QPlatformMenuItem *menuItem) { Q_UNUSED(menuItem) // nothing to do } void SystemTrayMenu::syncSeparatorsCollapsible(bool enable) { if (!m_menu) { return; } m_menu->setSeparatorsCollapsible(enable); } quintptr SystemTrayMenu::tag() const { return m_tag; } QMenu *SystemTrayMenu::menu() const { return m_menu.data(); } SystemTrayMenuItem::SystemTrayMenuItem() : QPlatformMenuItem() , m_tag(0) , m_action(new QAction(this)) { connect(m_action, &QAction::triggered, this, &QPlatformMenuItem::activated); connect(m_action, &QAction::hovered, this, &QPlatformMenuItem::hovered); } SystemTrayMenuItem::~SystemTrayMenuItem() { } void SystemTrayMenuItem::setCheckable(bool checkable) { m_action->setCheckable(checkable); } void SystemTrayMenuItem::setChecked(bool isChecked) { m_action->setChecked(isChecked); } void SystemTrayMenuItem::setEnabled(bool enabled) { m_action->setEnabled(enabled); } void SystemTrayMenuItem::setFont(const QFont &font) { m_action->setFont(font); } void SystemTrayMenuItem::setIcon(const QIcon &icon) { m_action->setIcon(icon); } void SystemTrayMenuItem::setIsSeparator(bool isSeparator) { m_action->setSeparator(isSeparator); } void SystemTrayMenuItem::setMenu(QPlatformMenu *menu) { if (SystemTrayMenu *ourMenu = qobject_cast(menu)) { m_action->setMenu(ourMenu->menu()); } } void SystemTrayMenuItem::setRole(QPlatformMenuItem::MenuRole role) { Q_UNUSED(role) } void SystemTrayMenuItem::setShortcut(const QKeySequence &shortcut) { m_action->setShortcut(shortcut); } void SystemTrayMenuItem::setTag(quintptr tag) { m_tag = tag; } void SystemTrayMenuItem::setText(const QString &text) { m_action->setText(text); } void SystemTrayMenuItem::setVisible(bool isVisible) { m_action->setVisible(isVisible); } void SystemTrayMenuItem::setIconSize(int size) { Q_UNUSED(size); } quintptr SystemTrayMenuItem::tag() const { return m_tag; } QAction *SystemTrayMenuItem::action() const { return m_action; } KDEPlatformSystemTrayIcon::KDEPlatformSystemTrayIcon() : QPlatformSystemTrayIcon() , m_sni(Q_NULLPTR) { } KDEPlatformSystemTrayIcon::~KDEPlatformSystemTrayIcon() { } void KDEPlatformSystemTrayIcon::init() { if (!m_sni) { m_sni = new KStatusNotifierItem(); m_sni->setStandardActionsEnabled(false); m_sni->setTitle(QApplication::applicationDisplayName()); connect(m_sni, &KStatusNotifierItem::activateRequested, [this](bool active, const QPoint &pos) { Q_UNUSED(active) Q_UNUSED(pos) emit activated(QPlatformSystemTrayIcon::Trigger); }); connect(m_sni, &KStatusNotifierItem::secondaryActivateRequested, [this](const QPoint &pos) { Q_UNUSED(pos) - emit activated(QPlatformSystemTrayIcon::Context); + emit activated(QPlatformSystemTrayIcon::MiddleClick); }); } } void KDEPlatformSystemTrayIcon::cleanup() { delete m_sni; m_sni = Q_NULLPTR; } void KDEPlatformSystemTrayIcon::updateIcon(const QIcon &icon) { if (!m_sni) { return; } if (icon.name().isEmpty()) { m_sni->setIconByPixmap(icon); m_sni->setToolTipIconByPixmap(icon); } else { m_sni->setIconByName(icon.name()); m_sni->setToolTipIconByName(icon.name()); } } void KDEPlatformSystemTrayIcon::updateToolTip(const QString &tooltip) { if (!m_sni) { return; } m_sni->setToolTipTitle(tooltip); } void KDEPlatformSystemTrayIcon::updateMenu(QPlatformMenu *menu) { if (!m_sni) { return; } if (SystemTrayMenu *ourMenu = qobject_cast(menu)) { m_sni->setContextMenu(ourMenu->menu()); } } QPlatformMenu *KDEPlatformSystemTrayIcon::createMenu() const { return new SystemTrayMenu(); } QRect KDEPlatformSystemTrayIcon::geometry() const { // StatusNotifierItem doesn't provide the geometry return QRect(); } void KDEPlatformSystemTrayIcon::showMessage(const QString &title, const QString &msg, const QIcon &icon, MessageIcon iconType, int secs) { Q_UNUSED(iconType) if (!m_sni) { return; } m_sni->showMessage(title, msg, icon.name(), secs); } bool KDEPlatformSystemTrayIcon::isSystemTrayAvailable() const { #ifdef DBUS_SUPPORT_ENABLED QDBusInterface systrayHost(QStringLiteral("org.kde.StatusNotifierWatcher"), QStringLiteral("/StatusNotifierWatcher"), QStringLiteral("org.kde.StatusNotifierWatcher")); if (systrayHost.isValid()) { return systrayHost.property("IsStatusNotifierHostRegistered").toBool(); } #endif return false; } bool KDEPlatformSystemTrayIcon::supportsMessages() const { return true; } diff --git a/src/platformtheme/plintegration-cumpatch1.diff b/src/platformtheme/plintegration-cumpatch1.diff index b63592b..5d4c993 100644 --- a/src/platformtheme/plintegration-cumpatch1.diff +++ b/src/platformtheme/plintegration-cumpatch1.diff @@ -1,330 +1,331 @@ We were forked off frameworkintegration around the time that plasma-integration was also split off that framework. This file lists potentially relevant changes from plasma-integration's creation (c0ffbc2d87f7711b660d80a70b2c422a9152392e) until f33d00ef1321b96395ed4007df1d10b451d5ce5f (20170320) 20171129: merging plasma-integration commits (in reverse order): 0a6be721e4e35b54c2fba6a59243eea3c5d912d4 Implement support for selected mime type filters 7a7dfffba98d383821c39ac68de6e8aabe45b7ed Implement QPlatformTheme::fileIconPixmap() to make QFileIconProvider work. 4aef17e64f564331c79d5307dd6aeded828bf382 Replace Q_DECL_OVERRIDE with override f25c5e10d0235c2d383e998bddc39fb35517ce9e Fix deprecation warnings. setSelection -> setSelectedUrl ui -> uiDelegate 0dafb9403266d6064074250d44b74dc0db946cfb Make sure we always set a default mime filter in save mode 4be9b478e5296914258b77eb02c2583ee0e84c7c Allow to disable blinking cursor completely 267e7c635733031d2990e78637cf6c10a56f9f05 Don't ignore initially selected mime type filter +b0059b1c8342b5ef95b054a0a5081b5db7e1c7bb Middle-click on QSystemTrayIcon сauses context menu 20170425: synced with the following plasma-integration commits (everything related to QDbusMenuBar is irrelevant on Mac): Fix warning when no initial directory is set. (7bca66673f9575083181ca1b0a9602ba077c9016) [KHintsSettings] Emit QGuiApplication::paletteChanged when run as QApplication (ab3298b3f5f728765d5afa8830aa7793140617c8) Do not treat filename in selection as URL (e70f8134a2bc4b3647e245c05f469aeed462a246) Use the native dialog if there's no QApplication (c6305f5edbbd15244d79cfc7569352cf6f6ea4d6) (in KdeMacTheme::usePlatformNativeDialog()) 20170119: synced, among others with the current version of these plasma-integration commits: 8fefab22498c15643e87ae104ef1d5fbfef8f539 Mon Sep 17 00:00:00 2001 7bbbd93cd3fc0abdffd3fa7f144cb50a33fafad9 Mon Sep 17 00:00:00 2001 ### Done: diff --git a/src/platformtheme/kdeplatformfiledialoghelper.cpp b/src/platformtheme/kdeplatformfiledialoghelper.cpp index 139c35d..15b5e90 100644 --- a/src/platformtheme/kdeplatformfiledialoghelper.cpp +++ b/src/platformtheme/kdeplatformfiledialoghelper.cpp @@ -288,6 +288,8 @@ void KDEPlatformFileDialogHelper::initializeDialog() // overwrite option if (options()->testOption(QFileDialogOptions::FileDialogOption::DontConfirmOverwrite)) { dialog->m_fileWidget->setConfirmOverwrite(false); + } else if (options()->acceptMode() == QFileDialogOptions::AcceptSave) { + dialog->m_fileWidget->setConfirmOverwrite(true); } } } @@ -328,11 +330,11 @@ void KDEPlatformFileDialogHelper::restoreSize() bool KDEPlatformFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) { - Q_UNUSED(parent) initializeDialog(); m_dialog->setWindowFlags(windowFlags); m_dialog->setWindowModality(windowModality); restoreSize(); + m_dialog->windowHandle()->setTransientParent(parent); // Use a delayed show here to delay show() after the internal Qt invisible QDialog. // The delayed call shouldn't matter, because for other "real" native QPlatformDialog // implementation like Mac and Windows, the native dialog is not necessarily diff --git a/src/platformtheme/khintssettings.cpp b/src/platformtheme/khintssettings.cpp index edbed5f..7768a1c 100644 --- a/src/platformtheme/khintssettings.cpp +++ b/src/platformtheme/khintssettings.cpp @@ -375,12 +375,6 @@ void KHintsSettings::loadPalettes() return; } - path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("plasma/look-and-feel/org.kde.loonandfeel/contents/colors")); - if (!path.isEmpty()) { - m_palettes[QPlatformTheme::SystemPalette] = new QPalette(KColorScheme::createApplicationPalette(KSharedConfig::openConfig(path))); - return; - } - const QString scheme = readConfigValue(QStringLiteral("General"), QStringLiteral("ColorScheme"), QStringLiteral("Breeze")).toString(); path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("color-schemes/") + scheme + QStringLiteral(".colors")); diff --git not done ### ### not done: There is little point changing the default fixed font in kfontsettingsdata.cpp (from Oxygen Mono to Hack); it's overridden in kfontsettingsdatamac.m (Monaco is close enough to Hack but still more elegant; has true Italic instead of an improved slanted (Oblique) mode. diff --git a/autotests/kfiledialog_unittest.cpp b/autotests/kfiledialog_unittest.cpp index 59915da..b32cd8e 100644 --- a/autotests/kfiledialog_unittest.cpp +++ b/autotests/kfiledialog_unittest.cpp @@ -19,6 +19,9 @@ */ #include +#include +#include +#include #include #include #include @@ -200,7 +203,61 @@ private Q_SLOTS: QCOMPARE(dialog.fileMode(), qtFileMode); } + + void testSaveOverwrite_data() + { + QTest::addColumn("qtOverwriteOption"); + QTest::addColumn("messageBoxExpected"); + QTest::newRow("checkoverwrite") << false << true; + QTest::newRow("allowoverwrite") << true << false; + } + + void testSaveOverwrite() + { + QFETCH(bool, qtOverwriteOption); + QFETCH(bool, messageBoxExpected); + + QTemporaryFile tempFile(QDir::tempPath()+"/kfiledialogtest_XXXXXX"); + tempFile.setAutoRemove(true); + tempFile.open(); + QString tempName = tempFile.fileName(); + tempFile.close(); + int idx = tempName.lastIndexOf('/'); + + QFileDialog dialog; + dialog.setAcceptMode(QFileDialog::AcceptSave); + if (qtOverwriteOption) dialog.setOption(QFileDialog::DontConfirmOverwrite); + dialog.setDirectory(tempName.left(idx+1)); + dialog.selectFile(tempName.mid(idx+1)); + dialog.open(); + + KFileWidget *fw = findFileWidget(); + QVERIFY(fw); + QTest::qWaitForWindowExposed(fw->window()); + QCOMPARE(fw->isVisible(), true); + + messageBoxSeen = false; + QTimer::singleShot(500, this, SLOT(checkMessageBox())); + fw->slotOk(); + + fw->slotCancel(); + QVERIFY(messageBoxSeen == messageBoxExpected); + } + +protected Q_SLOTS: + void checkMessageBox() + { + QDialog *msgbox = findMessageBox(); + if (!msgbox) return; + QTest::qWaitForWindowExposed(msgbox); + QCOMPARE(msgbox->isVisible(), true); + messageBoxSeen = true; + msgbox->close(); + } + private: + bool messageBoxSeen; + static QString fileViewToString(KFile::FileView fv) { switch (fv) { @@ -230,6 +287,18 @@ private: Q_ASSERT(widgets.count() == 1); return (widgets.count() == 1) ? widgets.first() : Q_NULLPTR; } + + static QDialog *findMessageBox() + { + QList widgets; + foreach (QWidget *widget, QApplication::topLevelWidgets()) { + QDialog *dlg = widget->findChild(); + if (dlg) { + widgets.append(dlg); + } + } + return (widgets.count() == 1) ? widgets.first() : Q_NULLPTR; + } }; QTEST_MAIN(KFileDialog_UnitTest) diff --git a/src/platformtheme/kfontsettingsdata.cpp b/src/platformtheme/kfontsettingsdata.cpp index a43e8be..d3f8fe3 100644 --- a/src/platformtheme/kfontsettingsdata.cpp +++ b/src/platformtheme/kfontsettingsdata.cpp @@ -54,7 +54,7 @@ static const char DefaultFont[] = "Noto Sans"; static const KFontData DefaultFontData[KFontSettingsData::FontTypesCount] = { { GeneralId, "font", DefaultFont, 10, -1, QFont::SansSerif }, - { GeneralId, "fixed", "Oxygen Mono", 9, -1, QFont::Monospace }, + { GeneralId, "fixed", "Hack", 9, -1, QFont::Monospace }, { GeneralId, "toolBarFont", DefaultFont, 9, -1, QFont::SansSerif }, { GeneralId, "menuFont", DefaultFont, 10, -1, QFont::SansSerif }, { "WM", "activeFont", DefaultFont, 10, -1, QFont::SansSerif }, diff --git a/tests/qfiledialogtest.cpp b/tests/qfiledialogtest.cpp index 1d69ea1..329eabf 100644 --- a/tests/qfiledialogtest.cpp +++ b/tests/qfiledialogtest.cpp @@ -31,6 +31,8 @@ int main(int argc, char **argv) parser.addHelpOption(); parser.addOption(QCommandLineOption(QStringList(QStringLiteral("staticFunction")), QStringLiteral("Test one of the static convenience function: 'getOpenFileUrl', 'getExistingDirectory'"), QStringLiteral("function name"))); parser.addOption(QCommandLineOption(QStringList(QStringLiteral("acceptMode")), QStringLiteral("File dialog acceptMode: 'open' or 'save'"), QStringLiteral("type"), QStringLiteral("open"))); + parser.addOption(QCommandLineOption(QStringList(QStringLiteral("confirmOverwrite")), QStringLiteral("Test overwrite option: 'on' or 'off'"), QStringLiteral("option"), QStringLiteral("on"))); + parser.addOption(QCommandLineOption(QStringList(QStringLiteral("nativeDialog")), QStringLiteral("Use the platform native dialog: 'on' or 'off'"), QStringLiteral("option"), QStringLiteral("on"))); parser.addOption(QCommandLineOption(QStringList(QStringLiteral("fileMode")), QStringLiteral("File dialog fileMode: 'AnyFile' or 'ExistingFile' or 'Directory' or 'ExistingFiles'"), QStringLiteral("type"))); parser.addOption(QCommandLineOption(QStringList(QStringLiteral("nameFilter")), QStringLiteral("Dialog nameFilter, e. g. 'cppfiles (*.cpp *.h *.hpp)', can be specified multiple times"), QStringLiteral("nameFilter"), QStringLiteral("Everything (*)"))); // add option mimeTypeFilter later @@ -83,6 +85,14 @@ int main(int argc, char **argv) dialog.selectNameFilter(selectNameFilter); } + if (parser.value(QStringLiteral("confirmOverwrite")) == QStringLiteral("off")) { + dialog.setOption(QFileDialog::DontConfirmOverwrite, true); + } + + if (parser.value(QStringLiteral("nativeDialog")) == QStringLiteral("off")) { + dialog.setOption(QFileDialog::DontUseNativeDialog, true); + } + dialog.setDirectory(parser.value(QStringLiteral("selectDirectory"))); dialog.selectFile(parser.value(QStringLiteral("selectFile"))); From 8fefab22498c15643e87ae104ef1d5fbfef8f539 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 23 Dec 2016 15:46:41 +0100 Subject: [PATCH] Fix compilation with Qt 5.8. --- src/platformtheme/kdeplatformfiledialoghelper.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/platformtheme/kdeplatformfiledialoghelper.cpp b/src/platformtheme/kdeplatformfiledialoghelper.cpp index 7e7e2e9..990b983 100644 --- a/src/platformtheme/kdeplatformfiledialoghelper.cpp +++ b/src/platformtheme/kdeplatformfiledialoghelper.cpp @@ -365,7 +365,13 @@ void KDEPlatformFileDialogHelper::selectFile(const QUrl &filename) // Qt 5 at least <= 5.8.0 does not derive the directory from the passed url // and set the initialDirectory option accordingly, also not for known schemes // like file://, so we have to do it ourselves + + // Syntax-wise we have to use a copy ctor until Qt 5.7.x and clone() since Qt 5.8. +#if QT_VERSION < QT_VERSION_CHECK(5, 8, 0) QSharedPointer opt(new QFileDialogOptions(*options())); +#else + auto opt = options()->clone(); +#endif opt->setInitialDirectory(m_dialog->directory()); setOptions(opt); } -- 2.11.0 From 7bbbd93cd3fc0abdffd3fa7f144cb50a33fafad9 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Thu, 22 Dec 2016 19:51:32 +0100 Subject: [PATCH] Fix Plasma-QPA filedialog to show wrong directory with QFileDialog::selectUrl() Summary: QFileDialog does not set the initialDirectory option in codepaths from QFileDialog::selectUrl(...) or QFileDialog::selectFile(...) when passing the task on to the native widget. So KDEPlatformFileDialogHelper has to make sure itself that info is kept. Because KDEPlatformFileDialogHelper::initializeDialog() calls setDirectory(options()->initialDirectory()); as intended, usually during the show event. And by that it resets any otherwise wanted state of the filewidget it had from previous setup calls via QFileDialog, and instead to whatever value the initialDirectory option had before, usually the working directory as set during initialization. Test Plan: New unit test kfiledialog_unittest testSelectUrl no longer fails with added code, also behaves now as expected with code e.g. from KUrlRequester. Reviewers: #plasma, #frameworks, dfaure Reviewed By: #plasma, graesslin, dfaure Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D3796 --- autotests/kfiledialog_unittest.cpp | 18 ++++++++++++++++++ src/platformtheme/kdeplatformfiledialoghelper.cpp | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/autotests/kfiledialog_unittest.cpp b/autotests/kfiledialog_unittest.cpp index b32cd8e..47a5543 100644 --- a/autotests/kfiledialog_unittest.cpp +++ b/autotests/kfiledialog_unittest.cpp @@ -77,6 +77,24 @@ private Q_SLOTS: QCOMPARE(dialog.directory().absolutePath(), QDir::rootPath()); } + void testSelectUrl() + { + QTemporaryFile tempFile(QDir::tempPath()+"/kfiledialogtest_XXXXXX"); + tempFile.setAutoRemove(true); + tempFile.open(); + QString tempName = tempFile.fileName(); + QUrl url = QUrl::fromLocalFile(tempName); + int idx = tempName.lastIndexOf('/'); + QUrl directoryUrl = QUrl::fromLocalFile(tempName.left(idx+1)); + + QFileDialog dialog; + dialog.selectUrl(url); + dialog.show(); + + // check if dialog was set to base directory url of the passed file url + QCOMPARE(dialog.directoryUrl(), directoryUrl); + } + void testViewMode() { // Open a file dialog, and change view mode to tree diff --git a/src/platformtheme/kdeplatformfiledialoghelper.cpp b/src/platformtheme/kdeplatformfiledialoghelper.cpp index 15b5e90..7e7e2e9 100644 --- a/src/platformtheme/kdeplatformfiledialoghelper.cpp +++ b/src/platformtheme/kdeplatformfiledialoghelper.cpp @@ -361,6 +361,13 @@ QUrl KDEPlatformFileDialogHelper::directory() const void KDEPlatformFileDialogHelper::selectFile(const QUrl &filename) { m_dialog->selectFile(filename); + + // Qt 5 at least <= 5.8.0 does not derive the directory from the passed url + // and set the initialDirectory option accordingly, also not for known schemes + // like file://, so we have to do it ourselves + QSharedPointer opt(new QFileDialogOptions(*options())); + opt->setInitialDirectory(m_dialog->directory()); + setOptions(opt); } void KDEPlatformFileDialogHelper::setDirectory(const QUrl &directory) -- 2.11.0