1
0
mirror of https://invent.kde.org/system/dolphin synced 2024-07-04 17:30:55 +00:00

Port to Qt6

This commit is contained in:
Méven Car 2023-05-07 18:27:41 +02:00
parent 7056356c2e
commit 76e3eab6ea
No known key found for this signature in database
16 changed files with 56 additions and 52 deletions

View File

@ -7,8 +7,8 @@ set (RELEASE_SERVICE_VERSION_MICRO "70")
set (RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}") set (RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}")
project(Dolphin VERSION ${RELEASE_SERVICE_VERSION}) project(Dolphin VERSION ${RELEASE_SERVICE_VERSION})
set(QT_MIN_VERSION "5.15.2") set(QT_MIN_VERSION "6.4.0")
set(KF6_MIN_VERSION "5.102.0") set(KF6_MIN_VERSION "5.240.0")
# ECM setup # ECM setup
find_package(ECM ${KF6_MIN_VERSION} CONFIG REQUIRED) find_package(ECM ${KF6_MIN_VERSION} CONFIG REQUIRED)
@ -32,14 +32,14 @@ ecm_setup_version(${RELEASE_SERVICE_VERSION} VARIABLE_PREFIX DOLPHIN
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/src/dolphin_version.h" VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/src/dolphin_version.h"
) )
ecm_setup_version("5.0.0" VARIABLE_PREFIX DOLPHINVCS ecm_setup_version(${RELEASE_SERVICE_VERSION} VARIABLE_PREFIX DOLPHINVCS
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/dolphinvcs_version.h" VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/dolphinvcs_version.h"
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/DolphinVcsConfigVersion.cmake" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/DolphinVcsConfigVersion.cmake"
SOVERSION 5 SOVERSION ${QT_MAJOR_VERSION}
) )
ecm_setup_version("5.0.0" VARIABLE_PREFIX DOLPHINPRIVATE ecm_setup_version(${RELEASE_SERVICE_VERSION} VARIABLE_PREFIX DOLPHINPRIVATE
SOVERSION 5 SOVERSION ${QT_MAJOR_VERSION}
) )
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
@ -77,16 +77,17 @@ find_package(KF6 ${KF6_MIN_VERSION} REQUIRED COMPONENTS
WindowSystem WindowSystem
WidgetsAddons WidgetsAddons
Codecs Codecs
MoreTools
) )
find_package(KF6MoreTools) find_package(KUserFeedbackQt6 1.2.0)
find_package(KUserFeedback 1.2.0)
set_package_properties(KUserFeedback set_package_properties(KUserFeedback
PROPERTIES TYPE OPTIONAL PROPERTIES TYPE OPTIONAL
PURPOSE "Used for submission of telemetry data" PURPOSE "Used for submission of telemetry data"
) )
if(KUserFeedback_FOUND) if(KUserFeedbackQt6_FOUND)
message ("HAVE_KUSERFEEDBACK")
set(HAVE_KUSERFEEDBACK TRUE) set(HAVE_KUSERFEEDBACK TRUE)
endif() endif()
@ -119,7 +120,7 @@ set_package_properties(KF6Baloo PROPERTIES DESCRIPTION "Baloo Core libraries"
PURPOSE "For adding desktop-wide search and tagging support to dolphin" PURPOSE "For adding desktop-wide search and tagging support to dolphin"
) )
find_package(KF6BalooWidgets 19.07.70) find_package(KF6BalooWidgets 23.07.70)
set_package_properties(KF6BalooWidgets PROPERTIES DESCRIPTION "Baloos Widgets" set_package_properties(KF6BalooWidgets PROPERTIES DESCRIPTION "Baloos Widgets"
URL "https://www.kde.org" URL "https://www.kde.org"
TYPE OPTIONAL TYPE OPTIONAL
@ -150,11 +151,6 @@ else()
set(HAVE_TERMINAL TRUE) set(HAVE_TERMINAL TRUE)
endif() endif()
ecm_set_disabled_deprecation_versions(
QT 5.15
KF 5.90
)
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(doc) add_subdirectory(doc)

View File

@ -208,6 +208,7 @@ target_link_libraries(
KF6::WindowSystem KF6::WindowSystem
KF6::WidgetsAddons KF6::WidgetsAddons
KF6::Codecs KF6::Codecs
KF6::KCMUtils
KF6::MoreTools KF6::MoreTools
) )
@ -443,8 +444,8 @@ endif()
if (HAVE_KUSERFEEDBACK) if (HAVE_KUSERFEEDBACK)
target_link_libraries( target_link_libraries(
dolphinstatic dolphinstatic
KUserFeedbackCore KUserFeedbackCoreQt6
KUserFeedbackWidgets KUserFeedbackWidgetsQt6
) )
endif() endif()
@ -473,7 +474,7 @@ target_link_libraries(dolphin
if (HAVE_X11) if (HAVE_X11)
if (QT_MAJOR_VERSION STREQUAL "5") if (QT_MAJOR_VERSION STREQUAL "5")
target_link_libraries(dolphin PRIVATE Qt5::X11Extras) target_link_libraries(dolphin PRIVATE Qt{QT_MAJOR_VERSION}::X11Extras)
else() else()
target_link_libraries(dolphin PRIVATE Qt::GuiPrivate) target_link_libraries(dolphin PRIVATE Qt::GuiPrivate)
endif() endif()

View File

@ -42,7 +42,7 @@ DolphinNavigatorsWidgetAction::DolphinNavigatorsWidgetAction(QWidget *parent)
void DolphinNavigatorsWidgetAction::adjustSpacing() void DolphinNavigatorsWidgetAction::adjustSpacing()
{ {
m_previousWindowWidth = parentWidget()->window()->width(); m_previousWindowWidth = qobject_cast<QWidget *>(parent())->window()->width();
auto viewGeometries = m_viewGeometriesHelper.viewGeometries(); auto viewGeometries = m_viewGeometriesHelper.viewGeometries();
const int widthOfSplitterPrimary = viewGeometries.globalXOfPrimary + viewGeometries.widthOfPrimary - viewGeometries.globalXOfNavigatorsWidget; const int widthOfSplitterPrimary = viewGeometries.globalXOfPrimary + viewGeometries.widthOfPrimary - viewGeometries.globalXOfNavigatorsWidget;
const QList<int> splitterSizes = {widthOfSplitterPrimary, m_splitter->width() - widthOfSplitterPrimary}; const QList<int> splitterSizes = {widthOfSplitterPrimary, m_splitter->width() - widthOfSplitterPrimary};
@ -298,7 +298,7 @@ DolphinNavigatorsWidgetAction::ViewGeometriesHelper::ViewGeometriesHelper(QWidge
bool DolphinNavigatorsWidgetAction::ViewGeometriesHelper::eventFilter(QObject *watched, QEvent *event) bool DolphinNavigatorsWidgetAction::ViewGeometriesHelper::eventFilter(QObject *watched, QEvent *event)
{ {
if (event->type() == QEvent::Resize) { if (event->type() == QEvent::Resize) {
if (m_navigatorsWidgetAction->parentWidget()->window()->width() != m_navigatorsWidgetAction->m_previousWindowWidth) { if (qobject_cast<QWidget*>(m_navigatorsWidgetAction->parent())->window()->width() != m_navigatorsWidgetAction->m_previousWindowWidth) {
// The window is being resized which means not all widgets have gotten their new sizes yet. // The window is being resized which means not all widgets have gotten their new sizes yet.
// Let's wait a bit so the sizes of the navigatorsWidget and the viewContainers have all // Let's wait a bit so the sizes of the navigatorsWidget and the viewContainers have all
// had a chance to be updated. // had a chance to be updated.

View File

@ -46,15 +46,16 @@
#include <QStandardPaths> #include <QStandardPaths>
#include <QTextDocument> #include <QTextDocument>
#include <KPluginFactory>
K_PLUGIN_CLASS_WITH_JSON(DolphinPart, "dolphinpart.json") K_PLUGIN_CLASS_WITH_JSON(DolphinPart, "dolphinpart.json")
DolphinPart::DolphinPart(QWidget *parentWidget, QObject *parent, const KPluginMetaData &metaData, const QVariantList &args) DolphinPart::DolphinPart(QWidget *parentWidget, QObject *parent, const KPluginMetaData &metaData, const QVariantList &args)
: KParts::ReadOnlyPart(parent) : KParts::ReadOnlyPart(parent, metaData)
, m_openTerminalAction(nullptr) , m_openTerminalAction(nullptr)
, m_removeAction(nullptr) , m_removeAction(nullptr)
{ {
Q_UNUSED(args) Q_UNUSED(args)
setMetaData(metaData);
m_extension = new DolphinPartBrowserExtension(this); m_extension = new DolphinPartBrowserExtension(this);

View File

@ -32,7 +32,7 @@ DolphinTabBar::DolphinTabBar(QWidget *parent)
void DolphinTabBar::dragEnterEvent(QDragEnterEvent *event) void DolphinTabBar::dragEnterEvent(QDragEnterEvent *event)
{ {
const QMimeData *mimeData = event->mimeData(); const QMimeData *mimeData = event->mimeData();
const int index = tabAt(event->pos()); const int index = tabAt(event->position().toPoint());
if (mimeData->hasUrls()) { if (mimeData->hasUrls()) {
event->acceptProposedAction(); event->acceptProposedAction();
@ -52,7 +52,7 @@ void DolphinTabBar::dragLeaveEvent(QDragLeaveEvent *event)
void DolphinTabBar::dragMoveEvent(QDragMoveEvent *event) void DolphinTabBar::dragMoveEvent(QDragMoveEvent *event)
{ {
const QMimeData *mimeData = event->mimeData(); const QMimeData *mimeData = event->mimeData();
const int index = tabAt(event->pos()); const int index = tabAt(event->position().toPoint());
if (mimeData->hasUrls()) { if (mimeData->hasUrls()) {
updateAutoActivationTimer(index); updateAutoActivationTimer(index);
@ -67,7 +67,7 @@ void DolphinTabBar::dropEvent(QDropEvent *event)
updateAutoActivationTimer(-1); updateAutoActivationTimer(-1);
const QMimeData *mimeData = event->mimeData(); const QMimeData *mimeData = event->mimeData();
const int index = tabAt(event->pos()); const int index = tabAt(event->position().toPoint());
if (mimeData->hasUrls()) { if (mimeData->hasUrls()) {
Q_EMIT tabDropEvent(index, event); Q_EMIT tabDropEvent(index, event);

View File

@ -118,7 +118,7 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel *model, QO
m_directoryContentsCounter = new KDirectoryContentsCounter(m_model, this); m_directoryContentsCounter = new KDirectoryContentsCounter(m_model, this);
connect(m_directoryContentsCounter, &KDirectoryContentsCounter::result, this, &KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived); connect(m_directoryContentsCounter, &KDirectoryContentsCounter::result, this, &KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived);
const QString pluginNamespace = QStringLiteral("kf" QT_STRINGIFY(QT_VERSION_MAJOR)) + QStringLiteral("/overlayicon"); const QString pluginNamespace = QStringLiteral("kf" QT_STRINGIFY(QT_MAJOR_VERSION)) + QStringLiteral("/overlayicon");
const auto plugins = KPluginMetaData::findPlugins(pluginNamespace, {}, KPluginMetaData::AllowEmptyMetaData); const auto plugins = KPluginMetaData::findPlugins(pluginNamespace, {}, KPluginMetaData::AllowEmptyMetaData);
for (const KPluginMetaData &data : plugins) { for (const KPluginMetaData &data : plugins) {
auto instance = QPluginLoader(data.fileName()).instance(); auto instance = QPluginLoader(data.fileName()).instance();

View File

@ -142,7 +142,7 @@ static bool isInternalDrag(const QMimeData *mimeData)
void PlacesPanel::dragMoveEvent(QDragMoveEvent *event) void PlacesPanel::dragMoveEvent(QDragMoveEvent *event)
{ {
const QModelIndex index = indexAt(event->pos()); const QModelIndex index = indexAt(event->position().toPoint());
if (index.isValid()) { if (index.isValid()) {
auto *placesModel = static_cast<KFilePlacesModel *>(model()); auto *placesModel = static_cast<KFilePlacesModel *>(model());

View File

@ -300,7 +300,7 @@ void ContextMenuSettingsPage::loadServices()
} }
// Load JSON-based plugins that implement the KFileItemActionPlugin interface // Load JSON-based plugins that implement the KFileItemActionPlugin interface
const auto jsonPlugins = KPluginMetaData::findPlugins(QStringLiteral("kf" QT_STRINGIFY(QT_VERSION_MAJOR)) + QStringLiteral("/kfileitemaction")); const auto jsonPlugins = KPluginMetaData::findPlugins(QStringLiteral("kf" QT_STRINGIFY(QT_MAJOR_VERSION)) + QStringLiteral("/kfileitemaction"));
for (const auto &jsonMetadata : jsonPlugins) { for (const auto &jsonMetadata : jsonPlugins) {
const QString desktopEntryName = jsonMetadata.pluginId(); const QString desktopEntryName = jsonMetadata.pluginId();

View File

@ -19,16 +19,17 @@
K_PLUGIN_CLASS_WITH_JSON(DolphinGeneralConfigModule, "kcmdolphingeneral.json") K_PLUGIN_CLASS_WITH_JSON(DolphinGeneralConfigModule, "kcmdolphingeneral.json")
DolphinGeneralConfigModule::DolphinGeneralConfigModule(QWidget *parent, const QVariantList &args) DolphinGeneralConfigModule::DolphinGeneralConfigModule(QObject *parent, const KPluginMetaData &data)
: KCModule(parent, args) : KCModule(qobject_cast<QWidget *>(parent), data)
, m_pages() , m_pages()
{ {
setButtons(KCModule::Default | KCModule::Help | KCModule::Apply); setButtons(KCModule::Default | KCModule::Help | KCModule::Apply);
QVBoxLayout *topLayout = new QVBoxLayout(this); const auto parentWidget = qobject_cast<QWidget *>(parent);
QVBoxLayout *topLayout = new QVBoxLayout(parentWidget);
topLayout->setContentsMargins(0, 0, 0, 0); topLayout->setContentsMargins(0, 0, 0, 0);
QTabWidget *tabWidget = new QTabWidget(this); QTabWidget *tabWidget = new QTabWidget(parentWidget);
// initialize 'Behavior' tab // initialize 'Behavior' tab
BehaviorSettingsPage *behaviorPage = new BehaviorSettingsPage(QUrl::fromLocalFile(QDir::homePath()), tabWidget); BehaviorSettingsPage *behaviorPage = new BehaviorSettingsPage(QUrl::fromLocalFile(QDir::homePath()), tabWidget);

View File

@ -21,7 +21,7 @@ class DolphinGeneralConfigModule : public KCModule
Q_OBJECT Q_OBJECT
public: public:
DolphinGeneralConfigModule(QWidget *parent, const QVariantList &args); DolphinGeneralConfigModule(QObject *parent, const KPluginMetaData &data);
~DolphinGeneralConfigModule() override; ~DolphinGeneralConfigModule() override;
void save() override; void save() override;

View File

@ -15,16 +15,17 @@
K_PLUGIN_CLASS_WITH_JSON(DolphinNavigationConfigModule, "kcmdolphinnavigation.json") K_PLUGIN_CLASS_WITH_JSON(DolphinNavigationConfigModule, "kcmdolphinnavigation.json")
DolphinNavigationConfigModule::DolphinNavigationConfigModule(QWidget *parent, const QVariantList &args) DolphinNavigationConfigModule::DolphinNavigationConfigModule(QObject *parent)
: KCModule(parent, args) : KCModule(qobject_cast<QWidget *>(parent))
, m_navigation(nullptr) , m_navigation(nullptr)
{ {
setButtons(KCModule::Default | KCModule::Help | KCModule::Apply); setButtons(KCModule::Default | KCModule::Help | KCModule::Apply);
QVBoxLayout *topLayout = new QVBoxLayout(this); const auto parentWidget = qobject_cast<QWidget *>(parent);
QVBoxLayout *topLayout = new QVBoxLayout(parentWidget);
topLayout->setContentsMargins(0, 0, 0, 0); topLayout->setContentsMargins(0, 0, 0, 0);
m_navigation = new NavigationSettingsPage(this); m_navigation = new NavigationSettingsPage(parentWidget);
connect(m_navigation, &NavigationSettingsPage::changed, this, &DolphinNavigationConfigModule::markAsChanged); connect(m_navigation, &NavigationSettingsPage::changed, this, &DolphinNavigationConfigModule::markAsChanged);
topLayout->addWidget(m_navigation, 0, {}); topLayout->addWidget(m_navigation, 0, {});
} }

View File

@ -19,7 +19,7 @@ class DolphinNavigationConfigModule : public KCModule
Q_OBJECT Q_OBJECT
public: public:
DolphinNavigationConfigModule(QWidget *parent, const QVariantList &args); DolphinNavigationConfigModule(QObject *parent);
~DolphinNavigationConfigModule() override; ~DolphinNavigationConfigModule() override;
void save() override; void save() override;

View File

@ -10,6 +10,7 @@
#include <KLocalizedString> #include <KLocalizedString>
#include <KPluginFactory> #include <KPluginFactory>
#include <KCModule>
#include <QDBusConnection> #include <QDBusConnection>
#include <QDBusMessage> #include <QDBusMessage>
@ -19,16 +20,17 @@
K_PLUGIN_CLASS_WITH_JSON(DolphinViewModesConfigModule, "kcmdolphinviewmodes.json") K_PLUGIN_CLASS_WITH_JSON(DolphinViewModesConfigModule, "kcmdolphinviewmodes.json")
DolphinViewModesConfigModule::DolphinViewModesConfigModule(QWidget *parent, const QVariantList &args) DolphinViewModesConfigModule::DolphinViewModesConfigModule(QObject *parent, const KPluginMetaData &data)
: KCModule(parent, args) : KCModule(qobject_cast<QWidget *>(parent), data)
, m_tabs() , m_tabs()
{ {
setButtons(KCModule::Default | KCModule::Help | KCModule::Apply); setButtons(KCModule::Default | KCModule::Help | KCModule::Apply);
QVBoxLayout *topLayout = new QVBoxLayout(this); const auto parentWidget = qobject_cast<QWidget *>(parent);
QVBoxLayout *topLayout = new QVBoxLayout(parentWidget);
topLayout->setContentsMargins(0, 0, 0, 0); topLayout->setContentsMargins(0, 0, 0, 0);
QTabWidget *tabWidget = new QTabWidget(this); QTabWidget *tabWidget = new QTabWidget(parentWidget);
// Initialize 'Icons' tab // Initialize 'Icons' tab
ViewSettingsTab *iconsTab = new ViewSettingsTab(ViewSettingsTab::IconsMode, tabWidget); ViewSettingsTab *iconsTab = new ViewSettingsTab(ViewSettingsTab::IconsMode, tabWidget);

View File

@ -19,7 +19,7 @@ class DolphinViewModesConfigModule : public KCModule
Q_OBJECT Q_OBJECT
public: public:
DolphinViewModesConfigModule(QWidget *parent, const QVariantList &args); DolphinViewModesConfigModule(QObject *parent, const KPluginMetaData &data);
~DolphinViewModesConfigModule() override; ~DolphinViewModesConfigModule() override;
void save() override; void save() override;

View File

@ -6,7 +6,8 @@
#include "trashsettingspage.h" #include "trashsettingspage.h"
#include <KCModuleProxy> #include <KCModuleLoader>
#include <KCModule>
#include <KPluginMetaData> #include <KPluginMetaData>
#include <QFormLayout> #include <QFormLayout>
@ -16,12 +17,13 @@ TrashSettingsPage::TrashSettingsPage(QWidget *parent)
{ {
QFormLayout *topLayout = new QFormLayout(this); QFormLayout *topLayout = new QFormLayout(this);
m_proxy = new KCModuleProxy(KPluginMetaData(QStringLiteral("kcm_trash"))); m_kcm = KCModuleLoader::loadModule(KPluginMetaData(QStringLiteral("kcm_trash")));
topLayout->addRow(m_proxy);
topLayout->addRow(m_kcm->widget());
loadSettings(); loadSettings();
connect(m_proxy, &KCModuleProxy::changed, this, &TrashSettingsPage::changed); connect(m_kcm, &KCModule::needsSaveChanged, this, &TrashSettingsPage::changed);
} }
TrashSettingsPage::~TrashSettingsPage() TrashSettingsPage::~TrashSettingsPage()
@ -30,15 +32,15 @@ TrashSettingsPage::~TrashSettingsPage()
void TrashSettingsPage::applySettings() void TrashSettingsPage::applySettings()
{ {
m_proxy->save(); m_kcm->save();
} }
void TrashSettingsPage::restoreDefaults() void TrashSettingsPage::restoreDefaults()
{ {
m_proxy->defaults(); m_kcm->defaults();
} }
void TrashSettingsPage::loadSettings() void TrashSettingsPage::loadSettings()
{ {
m_proxy->load(); m_kcm->load();
} }

View File

@ -8,7 +8,7 @@
#include "settings/settingspagebase.h" #include "settings/settingspagebase.h"
class KCModuleProxy; class KCModule;
/** /**
* @brief Tab page for the 'Trash' settings of the Dolphin settings dialog, it uses the KCM. * @brief Tab page for the 'Trash' settings of the Dolphin settings dialog, it uses the KCM.
@ -29,7 +29,7 @@ public:
private: private:
void loadSettings(); void loadSettings();
KCModuleProxy *m_proxy; KCModule *m_kcm;
}; };
#endif #endif