forked from qt-creator/qt-creator
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:
@@ -8,14 +8,15 @@
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/guiutils.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/mimeutils.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QLabel>
|
||||
#include <QLocale>
|
||||
@@ -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<QByteArray> 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
|
||||
|
@@ -3,47 +3,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utils/filepath.h>
|
||||
#include "core_global.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
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
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
Reference in New Issue
Block a user