From 832e157ecd1a1640b82425358b20fff416a2f8b7 Mon Sep 17 00:00:00 2001 From: Emmanuel Pescosta Date: Thu, 26 Feb 2015 17:40:06 +0100 Subject: [PATCH] Port away from KDELibs4Support (we only use KDELibs4Support when baloo isn't present, because KFileMetaDataWidget is in KDELibs4Support) Reviewed-By: Vishesh Handa --- CMakeLists.txt | 10 +++- src/CMakeLists.txt | 47 ++++++++++++++----- src/dolphinmainwindow.cpp | 6 ++- src/dolphinmainwindow.h | 4 +- src/dolphinpart.cpp | 7 ++- src/kitemviews/kitemlistcontroller.cpp | 7 ++- src/panels/folders/folderspanel.cpp | 4 +- src/panels/folders/treeviewcontextmenu.cpp | 3 +- src/panels/places/placesitemeditdialog.cpp | 1 - src/panels/places/placesitemmodel.cpp | 2 - src/search/dolphinsearchbox.cpp | 18 ++++--- src/settings/startup/startupsettingspage.cpp | 4 +- .../viewmodes/dolphinfontrequester.cpp | 10 ++-- src/settings/viewpropertiesdialog.cpp | 1 - src/tests/kfileitemlistviewtest.cpp | 2 +- src/tests/kfileitemmodelbenchmark.cpp | 10 ++-- src/tests/kfileitemmodeltest.cpp | 10 ++-- src/tests/kitemlistcontrollertest.cpp | 4 +- src/views/dolphinview.cpp | 1 - src/views/renamedialog.cpp | 1 - 20 files changed, 96 insertions(+), 56 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f31def98e1..9c2b109af0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,6 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS DocTools Init KCMUtils - KDELibs4Support NewStuff CoreAddons I18n @@ -53,6 +52,11 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS KIO Parts Solid + IconThemes + Completion + TextEditor + WindowSystem + Notifications ) find_package(KF5 ${KF5_MIN_VERSION} COMPONENTS Activities @@ -83,6 +87,10 @@ set_package_properties(KF5FileMetaData PROPERTIES if (KF5Baloo_FOUND AND KF5BalooWidgets_FOUND AND KF5FileMetaData_FOUND) message(STATUS "Baloo packages are found") set(HAVE_BALOO TRUE) +else() + find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS + KDELibs4Support # for KFileMetaDataWidget + ) endif() add_subdirectory(src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1b04a642b1..9ea45e34b6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,8 +3,18 @@ configure_file(config-baloo.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-baloo.h) configure_file(config-dolphin.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-dolphin.h) -add_definitions(-DTRANSLATION_DOMAIN=\"dolphin\" -DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS) -remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_URL_CAST_FROM_STRING) +add_definitions( + -DTRANSLATION_DOMAIN=\"dolphin\" + -DQT_USE_FAST_CONCATENATION + -DQT_USE_FAST_OPERATOR_PLUS +) +remove_definitions( + -DQT_NO_CAST_FROM_BYTEARRAY + -DQT_NO_URL_CAST_FROM_STRING + -DQT_NO_SIGNALS_SLOTS_KEYWORDS + -DQT_NO_CAST_FROM_ASCII + -DQT_NO_CAST_TO_ASCII +) if(X11_Xrender_FOUND) set(HAVE_XRENDER TRUE) @@ -132,7 +142,16 @@ add_library(dolphinprivate ${dolphinprivate_LIB_SRCS}) target_link_libraries( dolphinprivate PUBLIC dolphinvcs - KF5::KDELibs4Support + Qt5::Gui + KF5::I18n + KF5::IconThemes + KF5::KIOCore + KF5::KIOWidgets + KF5::KIOFileWidgets + KF5::Completion + KF5::TextEditor + KF5::WindowSystem + KF5::ConfigCore KF5::NewStuff ) @@ -143,6 +162,11 @@ if(HAVE_BALOO) KF5::Baloo KF5::BalooWidgets ) +else() + target_link_libraries( + dolphinprivate PUBLIC + KF5::KDELibs4Support # for KFileMetaDataWidget + ) endif() if(X11_Xrender_FOUND) @@ -168,7 +192,6 @@ add_library(dolphinpart MODULE ${dolphinpart_SRCS}) target_link_libraries(dolphinpart dolphinprivate - KF5::KDELibs4Support ) install(TARGETS dolphinpart DESTINATION ${PLUGIN_INSTALL_DIR}) @@ -261,16 +284,14 @@ target_include_directories(kdeinit_dolphin PRIVATE ${PHONON_INCLUDES}) target_link_libraries(kdeinit_dolphin dolphinprivate - KF5::NewStuff KF5::Parts KF5::KCMUtils KF5::Solid - KF5::KIOFileWidgets - Phonon::phonon4qt5 - KF5::KDELibs4Support - KF5::I18n KF5::CoreAddons KF5::DBusAddons + KF5::Bookmarks + KF5::Notifications + Phonon::phonon4qt5 ) if (KF5Activities_FOUND) @@ -338,10 +359,10 @@ add_library(kcm_dolphinnavigation MODULE ${kcm_dolphinnavigation_PART_SRCS}) add_library(kcm_dolphinservices MODULE ${kcm_dolphinservices_PART_SRCS}) add_library(kcm_dolphingeneral MODULE ${kcm_dolphingeneral_PART_SRCS}) -target_link_libraries(kcm_dolphinviewmodes KF5::KDELibs4Support dolphinprivate) -target_link_libraries(kcm_dolphinnavigation KF5::KDELibs4Support dolphinprivate) -target_link_libraries(kcm_dolphinservices KF5::KDELibs4Support dolphinprivate) -target_link_libraries(kcm_dolphingeneral KF5::KDELibs4Support dolphinprivate) +target_link_libraries(kcm_dolphinviewmodes dolphinprivate) +target_link_libraries(kcm_dolphinnavigation dolphinprivate) +target_link_libraries(kcm_dolphinservices dolphinprivate) +target_link_libraries(kcm_dolphingeneral dolphinprivate) install(TARGETS kcm_dolphinviewmodes DESTINATION ${PLUGIN_INSTALL_DIR} ) install(TARGETS kcm_dolphinnavigation DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 0ee6e5c2cc..1eda03e3c7 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -53,7 +53,6 @@ #include #include #include -#include #include #include #include @@ -687,7 +686,10 @@ void DolphinMainWindow::openTerminal() // If the given directory is not local, it can still be the URL of an // ioslave using UDS_LOCAL_PATH which to be converted first. - QUrl url = KIO::NetAccess::mostLocalUrl(m_activeViewContainer->url(), this); + KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url()); + KJobWidgets::setWindow(statJob, this); + statJob->exec(); + QUrl url = statJob->mostLocalUrl(); //If the URL is local after the above conversion, set the directory. if (url.isLocalFile()) { diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index e3188aee56..5066657ef8 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -31,7 +31,7 @@ #include #include -#include +#include typedef KIO::FileUndoManager::CommandType CommandType; @@ -493,7 +493,7 @@ private: DolphinViewActionHandler* m_actionHandler; DolphinRemoteEncoding* m_remoteEncoding; - QWeakPointer m_settingsDialog; + QPointer m_settingsDialog; // Members for the toolbar menu that is shown when the menubar is hidden: QToolButton* m_controlButton; diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index 35f328be55..ea0ffd92c6 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -38,6 +37,7 @@ #include #include #include +#include #include "dolphinpart_ext.h" #include "dolphinnewfilemenu.h" @@ -541,7 +541,10 @@ void DolphinPart::slotOpenTerminal() // If the given directory is not local, it can still be the URL of an // ioslave using UDS_LOCAL_PATH which to be converted first. - u = KIO::NetAccess::mostLocalUrl(u, widget()); + KIO::StatJob* statJob = KIO::mostLocalUrl(u); + KJobWidgets::setWindow(statJob, widget()); + statJob->exec(); + u = statJob->mostLocalUrl(); //If the URL is local after the above conversion, set the directory. if (u.isLocalFile()) { diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index 6c32e4b37f..a9ebf97af9 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -917,7 +917,8 @@ bool KItemListController::dropEvent(QGraphicsSceneDragDropEvent* event, const QT emit itemDropEvent(m_view->itemAt(pos), event); } - QAccessible::updateAccessibility(view(), 0, QAccessible::DragDropEnd); + QAccessibleEvent accessibilityEvent(view(), QAccessible::DragDropEnd); + QAccessible::updateAccessibility(&accessibilityEvent); return true; } @@ -1171,7 +1172,9 @@ void KItemListController::startDragging() drag->setHotSpot(hotSpot); drag->exec(Qt::MoveAction | Qt::CopyAction | Qt::LinkAction, Qt::CopyAction); - QAccessible::updateAccessibility(view(), 0, QAccessible::DragDropStart); + + QAccessibleEvent accessibilityEvent(view(), QAccessible::DragDropStart); + QAccessible::updateAccessibility(&accessibilityEvent); } KItemListWidget* KItemListController::hoveredWidget() const diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp index e99c673bc1..13df9019bf 100644 --- a/src/panels/folders/folderspanel.cpp +++ b/src/panels/folders/folderspanel.cpp @@ -208,7 +208,7 @@ void FoldersPanel::slotItemContextMenuRequested(int index, const QPointF& pos) const KFileItem fileItem = m_model->fileItem(index); - QWeakPointer contextMenu = new TreeViewContextMenu(this, fileItem); + QPointer contextMenu = new TreeViewContextMenu(this, fileItem); contextMenu.data()->open(); if (contextMenu.data()) { delete contextMenu.data(); @@ -219,7 +219,7 @@ void FoldersPanel::slotViewContextMenuRequested(const QPointF& pos) { Q_UNUSED(pos); - QWeakPointer contextMenu = new TreeViewContextMenu(this, KFileItem()); + QPointer contextMenu = new TreeViewContextMenu(this, KFileItem()); contextMenu.data()->open(); if (contextMenu.data()) { delete contextMenu.data(); diff --git a/src/panels/folders/treeviewcontextmenu.cpp b/src/panels/folders/treeviewcontextmenu.cpp index bbdf783cd1..e45fcd67e0 100644 --- a/src/panels/folders/treeviewcontextmenu.cpp +++ b/src/panels/folders/treeviewcontextmenu.cpp @@ -42,6 +42,7 @@ #include #include #include +#include TreeViewContextMenu::TreeViewContextMenu(FoldersPanel* parent, const KFileItem& fileInfo) : @@ -148,7 +149,7 @@ void TreeViewContextMenu::open() } } - QWeakPointer popupPtr = popup; + QPointer popupPtr = popup; popup->exec(QCursor::pos()); if (popupPtr.data()) { popupPtr.data()->deleteLater(); diff --git a/src/panels/places/placesitemeditdialog.cpp b/src/panels/places/placesitemeditdialog.cpp index d5ca4bf4fd..d035b0403f 100644 --- a/src/panels/places/placesitemeditdialog.cpp +++ b/src/panels/places/placesitemeditdialog.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp index 354d4a43e9..bc7c2b7d30 100644 --- a/src/panels/places/placesitemmodel.cpp +++ b/src/panels/places/placesitemmodel.cpp @@ -26,13 +26,11 @@ #include "dolphin_generalsettings.h" #include -#include #include #include "dolphindebug.h" #include #include #include -#include #include #include #include diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp index d4ebba8c02..524c4462f5 100644 --- a/src/search/dolphinsearchbox.cpp +++ b/src/search/dolphinsearchbox.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #ifdef HAVE_BALOO @@ -130,9 +131,11 @@ QUrl DolphinSearchBox::urlForSearching() const url = balooUrlForSearching(); } else { url.setScheme("filenamesearch"); - url.addQueryItem("search", m_searchInput->text()); + + QUrlQuery query; + query.addQueryItem("search", m_searchInput->text()); if (m_contentButton->isChecked()) { - url.addQueryItem("checkContent", "yes"); + query.addQueryItem("checkContent", "yes"); } QString encodedUrl; @@ -144,7 +147,9 @@ QUrl DolphinSearchBox::urlForSearching() const } else { encodedUrl = m_searchPath.url(); } - url.addQueryItem("url", encodedUrl); + query.addQueryItem("url", encodedUrl); + + url.setQuery(query); } return url; @@ -155,9 +160,10 @@ void DolphinSearchBox::fromSearchUrl(const QUrl& url) if (url.scheme() == "baloosearch") { fromBalooSearchUrl(url); } else if (url.scheme() == "filenamesearch") { - setText(url.queryItemValue("search")); - setSearchPath(QUrl::fromUserInput(url.queryItemValue("url"), QString(), QUrl::AssumeLocalFile)); - m_contentButton->setChecked(url.queryItemValue("checkContent") == "yes"); + const QUrlQuery query(url); + setText(query.queryItemValue("search")); + setSearchPath(QUrl::fromUserInput(query.queryItemValue("url"), QString(), QUrl::AssumeLocalFile)); + m_contentButton->setChecked(query.queryItemValue("checkContent") == "yes"); } else { setText(QString()); setSearchPath(url); diff --git a/src/settings/startup/startupsettingspage.cpp b/src/settings/startup/startupsettingspage.cpp index baba7f8a13..21b213cd52 100644 --- a/src/settings/startup/startupsettingspage.cpp +++ b/src/settings/startup/startupsettingspage.cpp @@ -24,7 +24,6 @@ #include "dolphin_generalsettings.h" -#include #include #include #include @@ -36,6 +35,7 @@ #include #include #include +#include #include "views/dolphinview.h" @@ -165,7 +165,7 @@ void StartupSettingsPage::slotSettingsChanged() void StartupSettingsPage::selectHomeUrl() { const QString homeUrl = m_homeUrl->text(); - QUrl url = KFileDialog::getExistingDirectoryUrl(QUrl::fromLocalFile(homeUrl), this); + QUrl url = QFileDialog::getExistingDirectoryUrl(this, QString(), QUrl::fromLocalFile(homeUrl)); if (!url.isEmpty()) { m_homeUrl->setText(url.toDisplayString(QUrl::PreferLocalFile)); slotSettingsChanged(); diff --git a/src/settings/viewmodes/dolphinfontrequester.cpp b/src/settings/viewmodes/dolphinfontrequester.cpp index 4d8b4813c4..b9c5d97cf8 100644 --- a/src/settings/viewmodes/dolphinfontrequester.cpp +++ b/src/settings/viewmodes/dolphinfontrequester.cpp @@ -19,13 +19,13 @@ #include "dolphinfontrequester.h" -#include #include #include #include #include #include +#include DolphinFontRequester::DolphinFontRequester(QWidget* parent) : QWidget(parent), @@ -86,11 +86,9 @@ QFont DolphinFontRequester::customFont() const void DolphinFontRequester::openFontDialog() { - QFont font = m_customFont; - const int result = KFontDialog::getFont(font, - KFontChooser::NoDisplayFlags, - this); - if (result == KFontDialog::Accepted) { + bool ok = false; + const QFont font = QFontDialog::getFont(&ok, this); + if (ok) { m_customFont = font; m_modeCombo->setFont(m_customFont); emit changed(); diff --git a/src/settings/viewpropertiesdialog.cpp b/src/settings/viewpropertiesdialog.cpp index aa7e4b4a0b..be7fe0d867 100644 --- a/src/settings/viewpropertiesdialog.cpp +++ b/src/settings/viewpropertiesdialog.cpp @@ -30,7 +30,6 @@ #include #include -#include #include #include #include diff --git a/src/tests/kfileitemlistviewtest.cpp b/src/tests/kfileitemlistviewtest.cpp index 5c40abba36..cac4f7a587 100644 --- a/src/tests/kfileitemlistviewtest.cpp +++ b/src/tests/kfileitemlistviewtest.cpp @@ -56,7 +56,7 @@ void KFileItemListViewTest::init() m_graphicsView = new QGraphicsView(); m_graphicsView->show(); - QTest::qWaitForWindowShown(m_graphicsView); + QTest::qWaitForWindowExposed(m_graphicsView); } void KFileItemListViewTest::cleanup() diff --git a/src/tests/kfileitemmodelbenchmark.cpp b/src/tests/kfileitemmodelbenchmark.cpp index c970a7198c..b73485efbf 100644 --- a/src/tests/kfileitemmodelbenchmark.cpp +++ b/src/tests/kfileitemmodelbenchmark.cpp @@ -29,18 +29,20 @@ #include "testdir.h" -void myMessageOutput(QtMsgType type, const char* msg) +void myMessageOutput(QtMsgType type, const QMessageLogContext& context, const QString& msg) { + Q_UNUSED(context); + switch (type) { case QtDebugMsg: break; case QtWarningMsg: break; case QtCriticalMsg: - fprintf(stderr, "Critical: %s\n", msg); + fprintf(stderr, "Critical: %s\n", msg.toLocal8Bit().data()); break; case QtFatalMsg: - fprintf(stderr, "Fatal: %s\n", msg); + fprintf(stderr, "Fatal: %s\n", msg.toLocal8Bit().data()); abort(); default: break; @@ -317,7 +319,7 @@ void KFileItemModelBenchmark::insertManyChildItems() KFileItemList KFileItemModelBenchmark::createFileItemList(const QStringList& fileNames, const QString& prefix) { // Suppress 'file does not exist anymore' messages from KFileItemPrivate::init(). - qInstallMsgHandler(myMessageOutput); + qInstallMessageHandler(myMessageOutput); KFileItemList result; foreach (const QString& name, fileNames) { diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp index cf50db02a4..eba32e1e1c 100644 --- a/src/tests/kfileitemmodeltest.cpp +++ b/src/tests/kfileitemmodeltest.cpp @@ -29,18 +29,20 @@ #include "kitemviews/private/kfileitemmodeldirlister.h" #include "testdir.h" -void myMessageOutput(QtMsgType type, const char* msg) +void myMessageOutput(QtMsgType type, const QMessageLogContext& context, const QString& msg) { + Q_UNUSED(context); + switch (type) { case QtDebugMsg: break; case QtWarningMsg: break; case QtCriticalMsg: - fprintf(stderr, "Critical: %s\n", msg); + fprintf(stderr, "Critical: %s\n", msg.toLocal8Bit().data()); break; case QtFatalMsg: - fprintf(stderr, "Fatal: %s\n", msg); + fprintf(stderr, "Fatal: %s\n", msg.toLocal8Bit().data()); abort(); default: break; @@ -107,7 +109,7 @@ void KFileItemModelTest::init() { // The item-model tests result in a huge number of debugging // output from kdelibs. Only show critical and fatal messages. - qInstallMsgHandler(myMessageOutput); + qInstallMessageHandler(myMessageOutput); qRegisterMetaType("KItemRange"); qRegisterMetaType("KItemRangeList"); diff --git a/src/tests/kitemlistcontrollertest.cpp b/src/tests/kitemlistcontrollertest.cpp index dafb9f854a..e34731fa4b 100644 --- a/src/tests/kitemlistcontrollertest.cpp +++ b/src/tests/kitemlistcontrollertest.cpp @@ -142,7 +142,7 @@ void KItemListControllerTest::initTestCase() QVERIFY(spyDirectoryLoadingCompleted.wait()); m_container->show(); - QTest::qWaitForWindowShown(m_container); + QTest::qWaitForWindowExposed(m_container); } void KItemListControllerTest::cleanupTestCase() @@ -460,7 +460,7 @@ void KItemListControllerTest::testKeyboardNavigation_data() selectionBehaviorNames[selectionBehavior] + ", " + groupingEnabledNames[groupingEnabled]; - const QByteArray testNameAscii = testName.toAscii(); + const QByteArray testNameAscii = testName.toLatin1(); QTest::newRow(testNameAscii.data()) << layout diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 4129cc2174..191cd65119 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include diff --git a/src/views/renamedialog.cpp b/src/views/renamedialog.cpp index 6d009ba9a6..be9e34c4a1 100644 --- a/src/views/renamedialog.cpp +++ b/src/views/renamedialog.cpp @@ -23,7 +23,6 @@ #include #include #include -#include //TODO port to QCollator #include #include