Core: Hide FilePropertiesDialog in .cpp

And de-Q_OBJECT-ify and use dialogParent().

Task-number: QTCREATORBUG-26870
Change-Id: Icca49cfc203a902fd1479026b12fb2ae74c0cc30
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2025-04-22 10:28:29 +02:00
parent 37ad3cddb3
commit 96f1a80555
3 changed files with 42 additions and 45 deletions

View File

@@ -8,14 +8,15 @@
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/guiutils.h>
#include <utils/layoutbuilder.h> #include <utils/layoutbuilder.h>
#include <utils/mimeutils.h> #include <utils/mimeutils.h>
#include <QCheckBox> #include <QCheckBox>
#include <QDateTime> #include <QDateTime>
#include <QDebug> #include <QDebug>
#include <QDialog>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QDir>
#include <QFileInfo> #include <QFileInfo>
#include <QLabel> #include <QLabel>
#include <QLocale> #include <QLocale>
@@ -24,8 +25,36 @@ using namespace Utils;
namespace Core { namespace Core {
FilePropertiesDialog::FilePropertiesDialog(const FilePath &filePath, QWidget *parent) class FilePropertiesDialog final : public QDialog
: QDialog(parent) {
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_name(new QLabel)
, m_path(new QLabel) , m_path(new QLabel)
, m_mimeType(new QLabel) , m_mimeType(new QLabel)
@@ -101,8 +130,6 @@ FilePropertiesDialog::FilePropertiesDialog(const FilePath &filePath, QWidget *pa
refresh(); refresh();
} }
FilePropertiesDialog::~FilePropertiesDialog() = default;
void FilePropertiesDialog::detectTextFileSettings() void FilePropertiesDialog::detectTextFileSettings()
{ {
const Result<QByteArray> res = m_filePath.fileContents(/*maxsize*/ 50000); const Result<QByteArray> res = m_filePath.fileContents(/*maxsize*/ 50000);
@@ -228,4 +255,10 @@ void FilePropertiesDialog::setPermission(QFile::Permissions newPermissions, bool
refresh(); refresh();
} }
void executeFilePropertiesDialog(const FilePath &filePath)
{
FilePropertiesDialog dialog(filePath);
dialog.exec();
}
} // Core } // Core

View File

@@ -3,47 +3,12 @@
#pragma once #pragma once
#include <utils/filepath.h> #include "core_global.h"
#include <QDialog> namespace Utils { class FilePath; }
QT_BEGIN_NAMESPACE
class QLabel;
class QCheckBox;
QT_END_NAMESPACE
namespace Core { namespace Core {
class FilePropertiesDialog : public QDialog CORE_EXPORT void executeFilePropertiesDialog(const Utils::FilePath &filePath);
{
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 } // Core

View File

@@ -1018,8 +1018,7 @@ bool DocumentManager::saveModifiedDocument(IDocument *document, const QString &m
void DocumentManager::showFilePropertiesDialog(const FilePath &filePath) void DocumentManager::showFilePropertiesDialog(const FilePath &filePath)
{ {
FilePropertiesDialog properties(filePath); Core::executeFilePropertiesDialog(filePath);
properties.exec();
} }
/*! /*!