| 162 | class Dialog : public QDialog { |
| 163 | public: |
| 164 | Dialog(Handler* h) |
| 165 | { |
| 166 | setWindowFlags(Qt::Popup); |
| 167 | setModal(false); |
| 168 | // clang-format off |
| 169 | enum PType{ X, Y }; |
| 170 | // clang-format on |
| 171 | auto dsbx = [h, this](PType type) { |
| 172 | auto ds = new DoubleSpinBox(this); |
| 173 | ds->setDecimals(3); |
| 174 | ds->setRange(-1000, +1000); |
| 175 | ds->setSuffix(QObject::tr(" mm")); |
| 176 | ds->setValue(type == X ? h->pos().x() : h->pos().y()); |
| 177 | connect(ds, qOverload<double>(&QDoubleSpinBox::valueChanged), |
| 178 | [h, type](auto val) { |
| 179 | if (type == X) |
| 180 | h->setPos({ val, h->pos().y() }); |
| 181 | else |
| 182 | h->setPos({ h->pos().x(), val }); |
| 183 | h->shape->updateOtherHandlers(h); |
| 184 | h->shape->redraw(); |
| 185 | }); |
| 186 | return ds; |
| 187 | }; |
| 188 | |
| 189 | auto gl = new QGridLayout(this); |
| 190 | gl->addWidget(new QLabel("X:", this), 0, 0); |
| 191 | gl->addWidget(new QLabel("Y:", this), 1, 0); |
| 192 | gl->addWidget(dsbx(X), 0, 1); |
| 193 | gl->addWidget(dsbx(Y), 1, 1); |
| 194 | #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) |
| 195 | gl->setMargin(6); |
| 196 | #else |
| 197 | gl->setContentsMargins(6, 6, 6, 6); |
| 198 | #endif |
| 199 | } |
| 200 | ~Dialog() = default; |
| 201 | void leaveEvent(QEvent*) override { reject(); }; |
| 202 | } dialog(this); |