1#ifndef __PROPERTYFIELDS_H
2#define __PROPERTYFIELDS_H
8#include <QIntValidator>
19 : _numberOnly(numberOnly)
21 setLayout(
new QHBoxLayout);
22 layout()->setContentsMargins(0, 0, 0, 0);
23 _le =
new QLineEdit(
this);
25 layout()->addWidget(
_le);
28 _le->setValidator(
new QIntValidator(
_le));
46 const bool _numberOnly;
51 : _folderOnly(folderOnly)
53 _pb =
new QPushButton(
this);
55 _pb->setFixedSize(24, 24);
57 _pb->setProperty(
"type",
"PropertyFieldPath");
58 layout()->addWidget(_pb);
60 connect(_pb, &QPushButton::pressed, [&] {
62 QString currPath = QFileInfo(
_le->text()).path();
64 if (currPath.length() == 0) {
65 currPath = QDir::homePath();
69 path = QFileDialog::getExistingDirectory(
70 this,
"Select directory", currPath, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
72 path = QFileDialog::getOpenFileName(
this,
"Select file", currPath);
75 if (path.length() > 0) {
83 const bool _folderOnly;
92 setLayout(
new QHBoxLayout);
93 layout()->setContentsMargins(0, 0, 0, 0);
94 _cb =
new QComboBox(
this);
95 _cb->setEditable(editable);
97 layout()->addWidget(_cb);
98 connect(_cb,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
104 _cb->setCurrentText(text);
109 QVariant data = _cb->currentData();
111 if (data.isValid()) {
112 return data.toString();
114 return _cb->currentText();
124 void addItem(
const QString& text,
const QVariant v = QVariant())
126 _cb->addItem(text, v);
131 _cb->model()->sort(0);
144 _pb =
new QPushButton(
this);
146 _pb->setFixedSize(24, 24);
148 _pb->setProperty(
"type",
"PropertyFieldPath");
149 layout()->addWidget(_pb);
151 _cd =
new QColorDialog(
this);
153 connect(_pb, &QPushButton::pressed, [&] {
154 _cd->setCurrentColor(QColor(
_le->text()));
155 if (_cd->exec() == QDialog::Accepted) {
156 _le->setText(_cd->selectedColor().name(QColor::HexRgb).toUpper());
Definition propertyfields.h:86
void addItems(const QStringList &list)
Definition propertyfields.h:118
void setPropText(const QString &text) override
Definition propertyfields.h:102
void sort()
Definition propertyfields.h:129
QString propText() override
Definition propertyfields.h:107
void addItem(const QString &text, const QVariant v=QVariant())
Definition propertyfields.h:124
PropertyFieldCombo(bool editable=true)
Definition propertyfields.h:90
void currentTextChanged(const QString &text)
Definition propertyfields.h:141
PropertyFieldColor()
Definition propertyfields.h:142
Definition propertyfields.h:12
virtual QString propText()=0
virtual void setPropText(const QString &text)=0
Definition propertyfields.h:49
PropertyFieldPath(bool folderOnly=false)
Definition propertyfields.h:50
Definition propertyfields.h:17
QString propText() override
Definition propertyfields.h:37
PropertyFieldText(bool numberOnly=false)
Definition propertyfields.h:18
void setPropText(const QString &text) override
Definition propertyfields.h:32
QLineEdit * _le
Definition propertyfields.h:43