| 29 | static const int MIN_FIELD_WIDTH = 120; |
| 30 | |
| 31 | WidgetSettingString::WidgetSettingString(QTreeWidget* tree, QTreeWidgetItem* item, const SettingMetaString& meta, |
| 32 | SettingDataSet& data_set) |
| 33 | : WidgetSettingBase(tree, item), meta(meta), data_set(data_set), field(new QLineEdit(this)), timer(new QTimer(this)) { |
| 34 | this->field->setText(this->data().GetValue()); |
| 35 | QFont font = tree->font(); |
| 36 | if (meta.key == "force_device_uuid") { |
| 37 | font.setFamily("Consolas"); |
| 38 | font.setPointSize(10); |
| 39 | } |
| 40 | this->field->setFont(font); |
| 41 | this->field->setToolTip(this->field->text()); |
| 42 | this->field->show(); |
| 43 | |
| 44 | this->connect(this->field, SIGNAL(textEdited(const QString&)), this, SLOT(OnTextEdited(const QString&))); |
| 45 | this->connect(this->field, SIGNAL(returnPressed()), this, SLOT(OnTextReturnPressed())); |
| 46 | this->connect(this->timer, SIGNAL(timeout()), this, SLOT(OnTextReturnPressed())); |
| 47 | |
| 48 | this->timer->setSingleShot(true); |
| 49 | |
| 50 | this->item->setText(0, GetLabel(this->meta).c_str()); |
| 51 | this->item->setFont(0, this->tree->font()); |
| 52 | this->item->setToolTip(0, meta.description.c_str()); |
| 53 | this->item->setSizeHint(0, QSize(0, ITEM_HEIGHT)); |
| 54 | this->tree->setItemWidget(this->item, 0, this); |
| 55 | |
| 56 | this->Refresh(REFRESH_ENABLE_AND_STATE); |
| 57 | } |
| 58 | |
| 59 | void WidgetSettingString::Refresh(RefreshAreas refresh_areas) { |
| 60 | const SettingDependenceMode enabled = ::CheckDependence(this->meta, data_set); |