From 96f1a8055508b26667373c7adeda9eb635a57f50 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 22 Apr 2025 10:28:29 +0200 Subject: [PATCH] Core: Hide FilePropertiesDialog in .cpp And de-Q_OBJECT-ify and use dialogParent(). Task-number: QTCREATORBUG-26870 Change-Id: Icca49cfc203a902fd1479026b12fb2ae74c0cc30 Reviewed-by: Jarek Kobus --- .../dialogs/filepropertiesdialog.cpp | 43 ++++++++++++++++--- .../coreplugin/dialogs/filepropertiesdialog.h | 41 ++---------------- src/plugins/coreplugin/documentmanager.cpp | 3 +- 3 files changed, 42 insertions(+), 45 deletions(-) diff --git a/src/plugins/coreplugin/dialogs/filepropertiesdialog.cpp b/src/plugins/coreplugin/dialogs/filepropertiesdialog.cpp index 21b22c1caf0..3ade358c7a6 100644 --- a/src/plugins/coreplugin/dialogs/filepropertiesdialog.cpp +++ b/src/plugins/coreplugin/dialogs/filepropertiesdialog.cpp @@ -8,14 +8,15 @@ #include #include +#include #include #include #include #include #include +#include #include -#include #include #include #include @@ -24,8 +25,36 @@ using namespace Utils; namespace Core { -FilePropertiesDialog::FilePropertiesDialog(const FilePath &filePath, QWidget *parent) - : QDialog(parent) +class FilePropertiesDialog final : public QDialog +{ +public: + explicit FilePropertiesDialog(const FilePath &filePath); + +private: + void refresh(); + void setPermission(QFile::Permissions newPermissions, bool set); + void detectTextFileSettings(); + + QLabel *m_name; + QLabel *m_path; + QLabel *m_mimeType; + QLabel *m_defaultEditor; + QLabel *m_lineEndings; + QLabel *m_indentation; + QLabel *m_owner; + QLabel *m_group; + QLabel *m_size; + QLabel *m_lastRead; + QLabel *m_lastModified; + QCheckBox *m_readable; + QCheckBox *m_writable; + QCheckBox *m_executable; + QCheckBox *m_symLink; + const FilePath m_filePath; +}; + +FilePropertiesDialog::FilePropertiesDialog(const FilePath &filePath) + : QDialog(dialogParent()) , m_name(new QLabel) , m_path(new QLabel) , m_mimeType(new QLabel) @@ -101,8 +130,6 @@ FilePropertiesDialog::FilePropertiesDialog(const FilePath &filePath, QWidget *pa refresh(); } -FilePropertiesDialog::~FilePropertiesDialog() = default; - void FilePropertiesDialog::detectTextFileSettings() { const Result res = m_filePath.fileContents(/*maxsize*/ 50000); @@ -228,4 +255,10 @@ void FilePropertiesDialog::setPermission(QFile::Permissions newPermissions, bool refresh(); } +void executeFilePropertiesDialog(const FilePath &filePath) +{ + FilePropertiesDialog dialog(filePath); + dialog.exec(); +} + } // Core diff --git a/src/plugins/coreplugin/dialogs/filepropertiesdialog.h b/src/plugins/coreplugin/dialogs/filepropertiesdialog.h index d3cbe24dad5..b46c8ac7fcd 100644 --- a/src/plugins/coreplugin/dialogs/filepropertiesdialog.h +++ b/src/plugins/coreplugin/dialogs/filepropertiesdialog.h @@ -3,47 +3,12 @@ #pragma once -#include +#include "core_global.h" -#include - -QT_BEGIN_NAMESPACE -class QLabel; -class QCheckBox; -QT_END_NAMESPACE +namespace Utils { class FilePath; } namespace Core { -class FilePropertiesDialog : public QDialog -{ - Q_OBJECT - -public: - explicit FilePropertiesDialog(const Utils::FilePath &filePath, QWidget *parent = nullptr); - ~FilePropertiesDialog() override; - -private: - void refresh(); - void setPermission(QFile::Permissions newPermissions, bool set); - void detectTextFileSettings(); - -private: - QLabel *m_name; - QLabel *m_path; - QLabel *m_mimeType; - QLabel *m_defaultEditor; - QLabel *m_lineEndings; - QLabel *m_indentation; - QLabel *m_owner; - QLabel *m_group; - QLabel *m_size; - QLabel *m_lastRead; - QLabel *m_lastModified; - QCheckBox *m_readable; - QCheckBox *m_writable; - QCheckBox *m_executable; - QCheckBox *m_symLink; - const Utils::FilePath m_filePath; -}; +CORE_EXPORT void executeFilePropertiesDialog(const Utils::FilePath &filePath); } // Core diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp index 43f5d85cdde..df824715138 100644 --- a/src/plugins/coreplugin/documentmanager.cpp +++ b/src/plugins/coreplugin/documentmanager.cpp @@ -1018,8 +1018,7 @@ bool DocumentManager::saveModifiedDocument(IDocument *document, const QString &m void DocumentManager::showFilePropertiesDialog(const FilePath &filePath) { - FilePropertiesDialog properties(filePath); - properties.exec(); + Core::executeFilePropertiesDialog(filePath); } /*!