Macros: inline savedialog.ui

Change-Id: If86a77536a19606af2a810a0bde622e71fd18783
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
hjk
2022-07-20 17:08:49 +02:00
parent 0e0a5a5db8
commit 80aef9c0ef
5 changed files with 42 additions and 114 deletions

View File

@@ -14,6 +14,6 @@ add_qtc_plugin(Macros
macrosconstants.h macrosconstants.h
macrosplugin.cpp macrosplugin.h macrosplugin.cpp macrosplugin.h
macrotextfind.cpp macrotextfind.h macrotextfind.cpp macrotextfind.h
savedialog.cpp savedialog.h savedialog.ui savedialog.cpp savedialog.h
texteditormacrohandler.cpp texteditormacrohandler.h texteditormacrohandler.cpp texteditormacrohandler.h
) )

View File

@@ -39,7 +39,6 @@ QtcPlugin {
"macrotextfind.h", "macrotextfind.h",
"savedialog.cpp", "savedialog.cpp",
"savedialog.h", "savedialog.h",
"savedialog.ui",
"texteditormacrohandler.cpp", "texteditormacrohandler.cpp",
"texteditormacrohandler.h", "texteditormacrohandler.h",
] ]

View File

@@ -24,33 +24,54 @@
****************************************************************************/ ****************************************************************************/
#include "savedialog.h" #include "savedialog.h"
#include "ui_savedialog.h"
#include <QLineEdit> #include <utils/layoutbuilder.h>
#include <QCheckBox> #include <QCheckBox>
#include <QDialogButtonBox>
#include <QLineEdit>
#include <QRegularExpressionValidator> #include <QRegularExpressionValidator>
using namespace Macros::Internal; using namespace Utils;
namespace Macros::Internal {
SaveDialog::SaveDialog(QWidget *parent) : SaveDialog::SaveDialog(QWidget *parent) :
QDialog(parent), QDialog(parent)
ui(new Ui::SaveDialog)
{ {
ui->setupUi(this); resize(219, 91);
ui->name->setValidator(new QRegularExpressionValidator(QRegularExpression(QLatin1String("\\w*")), this)); setWindowTitle(tr("Save Macro"));
m_name = new QLineEdit;
m_name->setValidator(new QRegularExpressionValidator(QRegularExpression(QLatin1String("\\w*")), this));
m_description = new QLineEdit;
auto buttonBox = new QDialogButtonBox;
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Save);
using namespace Layouting;
Form {
tr("Name:"), m_name, Break(),
tr("Description:"), m_description, Break(),
buttonBox
}.attachTo(this);
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
} }
SaveDialog::~SaveDialog() SaveDialog::~SaveDialog() = default;
{
delete ui;
}
QString SaveDialog::name() const QString SaveDialog::name() const
{ {
return ui->name->text(); return m_name->text();
} }
QString SaveDialog::description() const QString SaveDialog::description() const
{ {
return ui->description->text(); return m_description->text();
} }
} // Macros::Internal

View File

@@ -27,10 +27,11 @@
#include <QDialog> #include <QDialog>
namespace Macros { QT_BEGIN_NAMESPACE
namespace Internal { class QLineEdit;
QT_END_NAMESPACE
namespace Ui { class SaveDialog; } namespace Macros::Internal {
class SaveDialog : public QDialog class SaveDialog : public QDialog
{ {
@@ -44,9 +45,8 @@ public:
QString description() const; QString description() const;
private: private:
Ui::SaveDialog *ui; QLineEdit *m_name;
QLineEdit *m_description;
}; };
} // Macros::Internal
} // namespace Internal
} // namespace Macros

View File

@@ -1,92 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Macros::Internal::SaveDialog</class>
<widget class="QDialog" name="Macros::Internal::SaveDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>219</width>
<height>91</height>
</rect>
</property>
<property name="windowTitle">
<string>Save Macro</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="name"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="description">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>name</tabstop>
<tabstop>description</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Macros::Internal::SaveDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>264</x>
<y>185</y>
</hint>
<hint type="destinationlabel">
<x>204</x>
<y>172</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Macros::Internal::SaveDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>62</x>
<y>185</y>
</hint>
<hint type="destinationlabel">
<x>47</x>
<y>171</y>
</hint>
</hints>
</connection>
</connections>
</ui>