| 1 |
namespace phoenix { |
| 2 |
|
| 3 |
Size pLineEdit::minimumSize() { |
| 4 |
Size size = pFont::size(qtWidget->font(), lineEdit.state.text); |
| 5 |
return {size.width + 12, size.height + 12}; |
| 6 |
} |
| 7 |
|
| 8 |
void pLineEdit::setEditable(bool editable) { |
| 9 |
qtLineEdit->setReadOnly(!editable); |
| 10 |
} |
| 11 |
|
| 12 |
void pLineEdit::setText(string text) { |
| 13 |
qtLineEdit->setText(QString::fromUtf8(text)); |
| 14 |
} |
| 15 |
|
| 16 |
string pLineEdit::text() { |
| 17 |
return qtLineEdit->text().toUtf8().constData(); |
| 18 |
} |
| 19 |
|
| 20 |
void pLineEdit::constructor() { |
| 21 |
qtWidget = qtLineEdit = new QLineEdit; |
| 22 |
connect(qtLineEdit, SIGNAL(returnPressed()), SLOT(onActivate())); |
| 23 |
connect(qtLineEdit, SIGNAL(textEdited(const QString&)), SLOT(onChange())); |
| 24 |
|
| 25 |
pWidget::synchronizeState(); |
| 26 |
setEditable(lineEdit.state.editable); |
| 27 |
setText(lineEdit.state.text); |
| 28 |
} |
| 29 |
|
| 30 |
void pLineEdit::destructor() { |
| 31 |
delete qtLineEdit; |
| 32 |
qtWidget = qtLineEdit = nullptr; |
| 33 |
} |
| 34 |
|
| 35 |
void pLineEdit::orphan() { |
| 36 |
destructor(); |
| 37 |
constructor(); |
| 38 |
} |
| 39 |
|
| 40 |
void pLineEdit::onActivate() { |
| 41 |
if(lineEdit.onActivate) lineEdit.onActivate(); |
| 42 |
} |
| 43 |
|
| 44 |
void pLineEdit::onChange() { |
| 45 |
lineEdit.state.text = text(); |
| 46 |
if(lineEdit.onChange) lineEdit.onChange(); |
| 47 |
} |
| 48 |
|
| 49 |
} |