add a modal line editior dialog
This commit is contained in:
parent
e4119c5189
commit
d84dde0cb2
|
@ -15,6 +15,9 @@ target_sources(${PROJECT_NAME}
|
|||
adduniversedialog.cpp
|
||||
adduniversedialog.h
|
||||
adduniversedialog.ui
|
||||
lineeditdialog.cpp
|
||||
lineeditdialog.h
|
||||
lineeditdialog.ui
|
||||
multiverseitem.h
|
||||
multiverseitem.cpp
|
||||
multiversemodel.h
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
#include "lineeditdialog.h"
|
||||
#include "ui_lineeditdialog.h"
|
||||
|
||||
LineEditDialog::LineEditDialog(QWidget *parent, QString label, int length,
|
||||
QString value, QString placeholder) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::LineEditDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->label->setText(label);
|
||||
if (length > 0)
|
||||
ui->lineEdit->setMaxLength(length);
|
||||
ui->lineEdit->setText(value);
|
||||
ui->lineEdit->setPlaceholderText(placeholder);
|
||||
|
||||
connect(this, &LineEditDialog::accepted,
|
||||
this, [this]() {emit submit(ui->lineEdit->text());});
|
||||
}
|
||||
|
||||
LineEditDialog::~LineEditDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
#ifndef LINEEDITDIALOG_H
|
||||
#define LINEEDITDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class LineEditDialog;
|
||||
}
|
||||
|
||||
class LineEditDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LineEditDialog(QWidget *parent = nullptr,
|
||||
QString label = "line", int length = 0,
|
||||
QString value = "", QString placeholder = "");
|
||||
~LineEditDialog();
|
||||
|
||||
signals:
|
||||
void submit(QString);
|
||||
|
||||
private:
|
||||
Ui::LineEditDialog *ui;
|
||||
};
|
||||
|
||||
#endif // LINEEDITDIALOG_H
|
|
@ -0,0 +1,81 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LineEditDialog</class>
|
||||
<widget class="QDialog" name="LineEditDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>82</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>LineEditDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>LineEditDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
Loading…
Reference in New Issue