From 568f83d964f941ea0bbf836aaf0519d33fb9d32a Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 26 Jul 2022 13:48:24 +0200 Subject: [PATCH] Core: Inline filepropertiesdialog.ui Change-Id: I256da32d9023886aecd2389a70c57b8572c46819 Reviewed-by: hjk Reviewed-by: Qt CI Bot --- src/plugins/coreplugin/CMakeLists.txt | 2 +- src/plugins/coreplugin/coreplugin.qbs | 2 +- .../dialogs/filepropertiesdialog.cpp | 134 +++++--- .../coreplugin/dialogs/filepropertiesdialog.h | 19 +- .../dialogs/filepropertiesdialog.ui | 323 ------------------ 5 files changed, 115 insertions(+), 365 deletions(-) delete mode 100644 src/plugins/coreplugin/dialogs/filepropertiesdialog.ui diff --git a/src/plugins/coreplugin/CMakeLists.txt b/src/plugins/coreplugin/CMakeLists.txt index 61ba1599c01..432f5070692 100644 --- a/src/plugins/coreplugin/CMakeLists.txt +++ b/src/plugins/coreplugin/CMakeLists.txt @@ -27,7 +27,7 @@ add_qtc_plugin(Core dialogs/addtovcsdialog.cpp dialogs/addtovcsdialog.h dialogs/addtovcsdialog.ui dialogs/codecselector.cpp dialogs/codecselector.h dialogs/externaltoolconfig.cpp dialogs/externaltoolconfig.h dialogs/externaltoolconfig.ui - dialogs/filepropertiesdialog.cpp dialogs/filepropertiesdialog.h dialogs/filepropertiesdialog.ui + dialogs/filepropertiesdialog.cpp dialogs/filepropertiesdialog.h dialogs/ioptionspage.cpp dialogs/ioptionspage.h dialogs/newdialog.cpp dialogs/newdialog.h dialogs/newdialogwidget.cpp dialogs/newdialogwidget.h diff --git a/src/plugins/coreplugin/coreplugin.qbs b/src/plugins/coreplugin/coreplugin.qbs index a659e5fcf11..7d299db4de4 100644 --- a/src/plugins/coreplugin/coreplugin.qbs +++ b/src/plugins/coreplugin/coreplugin.qbs @@ -204,7 +204,7 @@ Project { "addtovcsdialog.cpp", "addtovcsdialog.h", "addtovcsdialog.ui", "codecselector.cpp", "codecselector.h", "externaltoolconfig.cpp", "externaltoolconfig.h", "externaltoolconfig.ui", - "filepropertiesdialog.cpp", "filepropertiesdialog.h", "filepropertiesdialog.ui", + "filepropertiesdialog.cpp", "filepropertiesdialog.h", "ioptionspage.cpp", "ioptionspage.h", "newdialog.cpp", "newdialog.h", "newdialogwidget.cpp", "newdialogwidget.h", diff --git a/src/plugins/coreplugin/dialogs/filepropertiesdialog.cpp b/src/plugins/coreplugin/dialogs/filepropertiesdialog.cpp index 5236511adc0..7a5cda2e999 100644 --- a/src/plugins/coreplugin/dialogs/filepropertiesdialog.cpp +++ b/src/plugins/coreplugin/dialogs/filepropertiesdialog.cpp @@ -24,54 +24,111 @@ ****************************************************************************/ #include "filepropertiesdialog.h" -#include "ui_filepropertiesdialog.h" #include #include #include +#include #include +#include #include #include +#include #include #include +#include #include using namespace Utils; namespace Core { -FilePropertiesDialog::FilePropertiesDialog(const FilePath &filePath, QWidget *parent) : - QDialog(parent), - m_ui(new Ui::FilePropertiesDialog), - m_filePath(filePath) +FilePropertiesDialog::FilePropertiesDialog(const FilePath &filePath, QWidget *parent) + : QDialog(parent) + , m_name(new QLabel) + , m_path(new QLabel) + , m_mimeType(new QLabel) + , m_defaultEditor(new QLabel) + , m_lineEndings(new QLabel) + , m_indentation(new QLabel) + , m_owner(new QLabel) + , m_group(new QLabel) + , m_size(new QLabel) + , m_lastRead(new QLabel) + , m_lastModified(new QLabel) + , m_readable(new QCheckBox) + , m_writable(new QCheckBox) + , m_executable(new QCheckBox) + , m_symLink(new QCheckBox) + , m_filePath(filePath) { - m_ui->setupUi(this); + resize(400, 395); - connect(m_ui->readable, &QCheckBox::clicked, [this](bool checked) { + m_name->setTextInteractionFlags(Qt::TextSelectableByMouse); + m_path->setTextInteractionFlags(Qt::TextSelectableByMouse); + m_mimeType->setTextInteractionFlags(Qt::TextSelectableByMouse); + m_defaultEditor->setTextInteractionFlags(Qt::TextSelectableByMouse); + m_lineEndings->setTextInteractionFlags(Qt::TextSelectableByMouse); + m_indentation->setTextInteractionFlags(Qt::TextSelectableByMouse); + m_owner->setTextInteractionFlags(Qt::TextSelectableByMouse); + m_group->setTextInteractionFlags(Qt::TextSelectableByMouse); + m_size->setTextInteractionFlags(Qt::TextSelectableByMouse); + m_lastRead->setTextInteractionFlags(Qt::TextSelectableByMouse); + m_lastModified->setTextInteractionFlags(Qt::TextSelectableByMouse); + + m_symLink->setEnabled(false); + + auto buttonBox = new QDialogButtonBox; + buttonBox->setStandardButtons(QDialogButtonBox::Close); + + using namespace Layouting; + // clang-format off + Column { + Form { + tr("Name:"), m_name, br, + tr("Path:"), m_path, br, + tr("MIME type:"), m_mimeType, br, + tr("Default editor:"), m_defaultEditor, br, + tr("Line endings:"), m_lineEndings, br, + tr("Indentation:"), m_indentation, br, + tr("Owner:"), m_owner, br, + tr("Group:"), m_group, br, + tr("Size:"), m_size, br, + tr("Last read:"), m_lastRead, br, + tr("Last modified:"), m_lastModified, br, + tr("Readable:"), m_readable, br, + tr("Writable:"), m_writable, br, + tr("Executable:"), m_executable, br, + tr("Symbolic link:"), m_symLink, br + }, + buttonBox + }.attachTo(this); + // clang-format on + + connect(m_readable, &QCheckBox::clicked, [this](bool checked) { setPermission(QFile::ReadUser | QFile::ReadOwner, checked); }); - connect(m_ui->writable, &QCheckBox::clicked, [this](bool checked) { + connect(m_writable, &QCheckBox::clicked, [this](bool checked) { setPermission(QFile::WriteUser | QFile::WriteOwner, checked); }); - connect(m_ui->executable, &QCheckBox::clicked, [this](bool checked) { + connect(m_executable, &QCheckBox::clicked, [this](bool checked) { setPermission(QFile::ExeUser | QFile::ExeOwner, checked); }); + connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); refresh(); } -FilePropertiesDialog::~FilePropertiesDialog() -{ - delete m_ui; -} +FilePropertiesDialog::~FilePropertiesDialog() = default; void FilePropertiesDialog::detectTextFileSettings() { QFile file(m_filePath.toString()); if (!file.open(QIODevice::ReadOnly)) { - m_ui->lineEndings->setText(tr("Unknown")); - m_ui->indentation->setText(tr("Unknown")); + m_lineEndings->setText(tr("Unknown")); + m_indentation->setText(tr("Unknown")); return; } @@ -81,15 +138,15 @@ void FilePropertiesDialog::detectTextFileSettings() // Try to guess the files line endings if (data.contains("\r\n")) { - m_ui->lineEndings->setText(tr("Windows (CRLF)")); + m_lineEndings->setText(tr("Windows (CRLF)")); } else if (data.contains("\n")) { - m_ui->lineEndings->setText(tr("Unix (LF)")); + m_lineEndings->setText(tr("Unix (LF)")); } else if (data.contains("\r")) { - m_ui->lineEndings->setText(tr("Mac (CR)")); + m_lineEndings->setText(tr("Mac (CR)")); lineSeparator = '\r'; } else { // That does not look like a text file at all - m_ui->lineEndings->setText(tr("Unknown")); + m_lineEndings->setText(tr("Unknown")); return; } @@ -132,14 +189,14 @@ void FilePropertiesDialog::detectTextFileSettings() if (!indents.empty()) { if (tabIndented) { - m_ui->indentation->setText(tr("Mixed")); + m_indentation->setText(tr("Mixed")); } else { - m_ui->indentation->setText(tr("%1 Spaces").arg(max->first)); + m_indentation->setText(tr("%1 Spaces").arg(max->first)); } } else if (tabIndented) { - m_ui->indentation->setText(tr("Tabs")); + m_indentation->setText(tr("Tabs")); } else { - m_ui->indentation->setText(tr("Unknown")); + m_indentation->setText(tr("Unknown")); } } @@ -149,29 +206,30 @@ void FilePropertiesDialog::refresh() const QFileInfo fileInfo = m_filePath.toFileInfo(); QLocale locale; - m_ui->name->setText(fileInfo.fileName()); - m_ui->path->setText(QDir::toNativeSeparators(fileInfo.canonicalPath())); + m_name->setText(fileInfo.fileName()); + m_path->setText(QDir::toNativeSeparators(fileInfo.canonicalPath())); const Utils::MimeType mimeType = Utils::mimeTypeForFile(m_filePath); - m_ui->mimeType->setText(mimeType.name()); + m_mimeType->setText(mimeType.name()); const EditorTypeList factories = IEditorFactory::preferredEditorTypes(m_filePath); - m_ui->defaultEditor->setText(!factories.isEmpty() ? factories.at(0)->displayName() : tr("Undefined")); + m_defaultEditor->setText(!factories.isEmpty() ? factories.at(0)->displayName() + : tr("Undefined")); - m_ui->owner->setText(fileInfo.owner()); - m_ui->group->setText(fileInfo.group()); - m_ui->size->setText(locale.formattedDataSize(fileInfo.size())); - m_ui->readable->setChecked(fileInfo.isReadable()); - m_ui->writable->setChecked(fileInfo.isWritable()); - m_ui->executable->setChecked(fileInfo.isExecutable()); - m_ui->symLink->setChecked(fileInfo.isSymLink()); - m_ui->lastRead->setText(fileInfo.lastRead().toString(locale.dateTimeFormat())); - m_ui->lastModified->setText(fileInfo.lastModified().toString(locale.dateTimeFormat())); + m_owner->setText(fileInfo.owner()); + m_group->setText(fileInfo.group()); + m_size->setText(locale.formattedDataSize(fileInfo.size())); + m_readable->setChecked(fileInfo.isReadable()); + m_writable->setChecked(fileInfo.isWritable()); + m_executable->setChecked(fileInfo.isExecutable()); + m_symLink->setChecked(fileInfo.isSymLink()); + m_lastRead->setText(fileInfo.lastRead().toString(locale.dateTimeFormat())); + m_lastModified->setText(fileInfo.lastModified().toString(locale.dateTimeFormat())); if (mimeType.inherits("text/plain")) { detectTextFileSettings(); } else { - m_ui->lineEndings->setText(tr("Unknown")); - m_ui->indentation->setText(tr("Unknown")); + m_lineEndings->setText(tr("Unknown")); + m_indentation->setText(tr("Unknown")); } }); } diff --git a/src/plugins/coreplugin/dialogs/filepropertiesdialog.h b/src/plugins/coreplugin/dialogs/filepropertiesdialog.h index accc2ab2bd7..f339da65b5f 100644 --- a/src/plugins/coreplugin/dialogs/filepropertiesdialog.h +++ b/src/plugins/coreplugin/dialogs/filepropertiesdialog.h @@ -30,7 +30,8 @@ #include QT_BEGIN_NAMESPACE -namespace Ui { class FilePropertiesDialog; } +class QLabel; +class QCheckBox; QT_END_NAMESPACE namespace Core { @@ -49,7 +50,21 @@ private: void detectTextFileSettings(); private: - Ui::FilePropertiesDialog *m_ui = nullptr; + 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; }; diff --git a/src/plugins/coreplugin/dialogs/filepropertiesdialog.ui b/src/plugins/coreplugin/dialogs/filepropertiesdialog.ui deleted file mode 100644 index c194e0fad63..00000000000 --- a/src/plugins/coreplugin/dialogs/filepropertiesdialog.ui +++ /dev/null @@ -1,323 +0,0 @@ - - - FilePropertiesDialog - - - - 0 - 0 - 400 - 395 - - - - File Properties - - - - - - - - Owner: - - - - - - - - - - Qt::TextSelectableByMouse - - - - - - - Group: - - - - - - - - - - Qt::TextSelectableByMouse - - - - - - - Size: - - - - - - - - - - Qt::TextSelectableByMouse - - - - - - - true - - - - - - true - - - - - - - true - - - - - - true - - - - - - - true - - - - - - true - - - - - - - false - - - - - - true - - - - - - - - - - Qt::TextSelectableByMouse - - - - - - - - - - Qt::TextSelectableByMouse - - - - - - - - - - Qt::TextSelectableByMouse - - - - - - - - - - Qt::TextSelectableByMouse - - - - - - - Name: - - - - - - - Path: - - - - - - - Last read: - - - - - - - Last modified: - - - - - - - Readable: - - - - - - - Writable: - - - - - - - Executable: - - - - - - - Symbolic link: - - - - - - - MIME type: - - - - - - - Default editor: - - - - - - - - - - - - - - - - - - - - - Line endings: - - - - - - - Indentation: - - - - - - - - - - - - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Close - - - - - - - - - buttonBox - accepted() - FilePropertiesDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - FilePropertiesDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - -