diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,8 +24,7 @@ set(REQUIRED_QT_VERSION 5.5.0) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Widgets DBus X11Extras) -set(KF5_VERSION "5.18.0") # handled by release scripts -set(KF5_DEP_VERSION "5.17.0") # handled by release scripts +set(KF5_DEP_VERSION "5.33.0") find_package(KF5Config ${KF5_DEP_VERSION} REQUIRED) find_package(KF5ConfigWidgets ${KF5_DEP_VERSION} REQUIRED) diff --git a/autotests/kfiledialog_unittest.cpp b/autotests/kfiledialog_unittest.cpp --- a/autotests/kfiledialog_unittest.cpp +++ b/autotests/kfiledialog_unittest.cpp @@ -56,6 +56,24 @@ QStringList nameFilterList = QStringList() << QStringLiteral("c (*.cpp)") << QStringLiteral("h (*.h)"); dialog.setNameFilters(nameFilterList); QCOMPARE(dialog.nameFilters(), nameFilterList); + + dialog.show(); + KFileWidget *fw = findFileWidget(); + QVERIFY(fw); + QCOMPARE(fw->currentFilter(), QStringLiteral("*.cpp")); + } + + void testSetNameFilterNoParenthesis() + { + QFileDialog dialog; + + QStringList nameFilterList = QStringList() << QStringLiteral("*.cpp") << QStringLiteral("*.h"); + dialog.setNameFilters(nameFilterList); + QCOMPARE(dialog.nameFilters(), nameFilterList); + dialog.show(); + KFileWidget *fw = findFileWidget(); + QVERIFY(fw); + QCOMPARE(fw->currentFilter(), QStringLiteral("*.cpp")); } void testSelectNameFilter() diff --git a/src/platformtheme/kdeplatformfiledialoghelper.cpp b/src/platformtheme/kdeplatformfiledialoghelper.cpp --- a/src/platformtheme/kdeplatformfiledialoghelper.cpp +++ b/src/platformtheme/kdeplatformfiledialoghelper.cpp @@ -61,13 +61,15 @@ int ob = it->lastIndexOf(QLatin1Char('(')), cb = it->lastIndexOf(QLatin1Char(')')); + if (first) { + first = false; + } else { + str << '\n'; + } if (-1 != cb && ob < cb) { - if (first) { - first = false; - } else { - str << '\n'; - } str << it->mid(ob + 1, (cb - ob) - 1) << '|' << it->mid(0, ob); + } else { + str << (*it); } } @@ -127,7 +129,7 @@ { QUrl dirUrl = filename.adjusted(QUrl::RemoveFilename); m_fileWidget->setUrl(dirUrl); - m_fileWidget->setSelection(filename.toString()); + m_fileWidget->setSelectedUrl(filename); } void KDEPlatformFileDialog::setViewMode(QFileDialogOptions::ViewMode view) @@ -224,7 +226,7 @@ if (!entry.isDir()) { // this is probably a file remove the file part m_fileWidget->setUrl(directory.adjusted(QUrl::RemoveFilename)); - m_fileWidget->setSelection(directory.fileName()); + m_fileWidget->setSelectedUrl(directory); } else { m_fileWidget->setUrl(directory);