refactor: use ui file to replace manual layout in metadata dialog
This commit is contained in:
@@ -76,6 +76,8 @@ set (PPIC_HEADER_FILES
|
||||
|
||||
set (PPIC_UI_FILES
|
||||
app/settingsdialog.ui
|
||||
app/aboutdialog.ui
|
||||
app/metadatadialog.ui
|
||||
)
|
||||
|
||||
set (PPIC_QRC_FILES
|
||||
|
||||
@@ -18,7 +18,7 @@ static QString loadEmbeddedHtml(QString&& path) {
|
||||
}
|
||||
|
||||
AboutDialog::AboutDialog(QWidget *parent)
|
||||
: QDialog(parent), ui(new Ui::AboutDialog)
|
||||
: QDialog(parent), ui(new QT_PREPEND_NAMESPACE(Ui::AboutDialog))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
class AboutDialog;
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include "metadatadialog.h"
|
||||
#include "ui_metadatadialog.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPainter>
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QTreeView>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHeaderView>
|
||||
|
||||
#include "metadatamodel.h"
|
||||
@@ -73,30 +73,33 @@ protected:
|
||||
};
|
||||
|
||||
MetadataDialog::MetadataDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_treeView(new PropertyTreeView(this))
|
||||
: QDialog(parent), ui(new QT_PREPEND_NAMESPACE(Ui::MetadataDialog))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
||||
|
||||
// YYC MARK:
|
||||
// Because we use custom QTreeView and we do not want to expose it to public domain.
|
||||
// So I have to use this way as the compromise.
|
||||
|
||||
// Create our custom QTreeView and insert them
|
||||
m_treeView = new PropertyTreeView(this);
|
||||
auto* layout = ui->verticalLayout;
|
||||
const int index = layout->indexOf(ui->m_buttonBox);
|
||||
layout->insertWidget(index, m_treeView);
|
||||
|
||||
// Setup our custom QTreeView
|
||||
m_treeView->setRootIsDecorated(false);
|
||||
m_treeView->setIndentation(0);
|
||||
m_treeView->setItemDelegate(new PropertyTreeItemDelegate(m_treeView));
|
||||
m_treeView->header()->resizeSection(0, sizeHint().width() / 2);
|
||||
|
||||
setWindowTitle(tr("Image Metadata"));
|
||||
|
||||
QDialogButtonBox * buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
|
||||
|
||||
setLayout(new QVBoxLayout);
|
||||
layout()->addWidget(m_treeView);
|
||||
layout()->addWidget(buttonBox);
|
||||
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::close);
|
||||
|
||||
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
||||
connect(ui->m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::close);
|
||||
}
|
||||
|
||||
MetadataDialog::~MetadataDialog()
|
||||
{
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MetadataDialog::setMetadataModel(MetadataModel * model)
|
||||
|
||||
@@ -11,6 +11,12 @@ QT_BEGIN_NAMESPACE
|
||||
class QTreeView;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
class MetadataDialog;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class MetadataModel;
|
||||
class MetadataDialog : public QDialog
|
||||
{
|
||||
@@ -25,6 +31,7 @@ public:
|
||||
|
||||
private:
|
||||
QTreeView * m_treeView = nullptr;
|
||||
QT_PREPEND_NAMESPACE(Ui::MetadataDialog) *ui;
|
||||
};
|
||||
|
||||
#endif // METADATADIALOG_H
|
||||
|
||||
23
app/metadatadialog.ui
Normal file
23
app/metadatadialog.ui
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MetadataDialog</class>
|
||||
<widget class="QDialog" name="MetadataDialog">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::NonModal</enum>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Image Metadata</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="m_buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -83,7 +83,7 @@ static EnumComboBoxTransformer<Qt::HighDpiScaleFactorRoundingPolicy, QString> HI
|
||||
};
|
||||
|
||||
SettingsDialog::SettingsDialog(QWidget *parent)
|
||||
: QDialog(parent), ui(new Ui::SettingsDialog)
|
||||
: QDialog(parent), ui(new QT_PREPEND_NAMESPACE(Ui::SettingsDialog))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<ul>
|
||||
<li><u>Catalan</u>: Toni Estévez</li>
|
||||
<li><u>Chinese (Simplified)</u>: Percy Hong</li>
|
||||
<li><u>Dutch</u>: Heimen Stoffels</li>
|
||||
<li><u>French</u>: J. Lavoie, K. Herbert, Maxime Leroy</li>
|
||||
<li><u>German</u>: K. Herbert, J. Lavoie, sal0max</li>
|
||||
<li><u>Indonesian</u>: liimee, Reza Almanda</li>
|
||||
<li><u>Italian</u>: albanobattistella</li>
|
||||
<li><u>Japanese</u>: Black Cat, mmahhi, Percy Hong</li>
|
||||
<li><u>Korean</u>: VenusGirl</li>
|
||||
<li><u>Norwegian Bokmål</u>: Allan Nordhøy, ovl-1</li>
|
||||
<li><u>Punjabi (Pakistan)</u>: bgo-eiu</li>
|
||||
<li><u>Russian</u>: Sergey Shornikov, Artem, Andrey</li>
|
||||
<li><u>Sinhala</u>: HelaBasa</li>
|
||||
<li><u>Slovenian</u>: Andrej Poženel - SDT</li>
|
||||
<li><u>Spanish</u>: Toni Estévez, Génesis Toxical, William(ѕ)ⁿ, gallegonovato</li>
|
||||
<li><u>Tamil</u>: தமிழ்நேரம் (TamilNeram)</li>
|
||||
<li><u>Turkish</u>: E-Akcaer, Oğuz Ersen, Sabri Ünal</li>
|
||||
<li><u>Ukrainian</u>: Dan, volkov, Сергій</li>
|
||||
<li><u>Vietnamese</u>: Loc Huynh</li>
|
||||
</ul>
|
||||
Reference in New Issue
Block a user