# HG changeset patch # User Teemu Piippo # Date 1655927437 -10800 # Node ID 5188f8a74a5cefa78a1f01486956af2398d3f75e # Parent b7b29cb82360df6485a3881f3ce6b6ebd170f329 Add x, y, z properties to VectorInput diff -r b7b29cb82360 -r 5188f8a74a5c widgets/CMakeLists.txt --- a/widgets/CMakeLists.txt Wed Jun 22 21:46:38 2022 +0300 +++ b/widgets/CMakeLists.txt Wed Jun 22 22:50:37 2022 +0300 @@ -24,6 +24,7 @@ target_include_directories(ldforgewidgets PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") target_include_directories(ldforgewidgets PUBLIC "${CMAKE_CURRENT_BINARY_DIR}") target_link_libraries(ldforgewidgets Qt5::Widgets) +set_target_properties(ldforgewidgets PROPERTIES AUTOMOC 1) get_target_property(QT_QMAKE_EXECUTABLE Qt5::qmake LOCATION) execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_PLUGINS diff -r b7b29cb82360 -r 5188f8a74a5c widgets/vec3editor.cpp --- a/widgets/vec3editor.cpp Wed Jun 22 21:46:38 2022 +0300 +++ b/widgets/vec3editor.cpp Wed Jun 22 22:50:37 2022 +0300 @@ -13,7 +13,6 @@ VectorInput::VectorInput(QWidget *parent, QFlags flags) : QWidget{parent} { - this->ui.setupUi(this); if (flags.testFlag(NoMultiplyButton)) { this->ui.multiply->setVisible(false); @@ -50,6 +49,36 @@ Q_EMIT this->valueChanged(value); } +qreal VectorInput::x() const +{ + return this->ui.x->value(); +} + +qreal VectorInput::y() const +{ + return this->ui.y->value(); +} + +qreal VectorInput::z() const +{ + return this->ui.z->value(); +} + +void VectorInput::setX(qreal x) +{ + this->ui.x->setValue(x); +} + +void VectorInput::setY(qreal y) +{ + this->ui.y->setValue(y); +} + +void VectorInput::setZ(qreal z) +{ + this->ui.z->setValue(z); +} + std::array VectorInput::spinboxes() { return {this->ui.x, this->ui.y, this->ui.z}; diff -r b7b29cb82360 -r 5188f8a74a5c widgets/vec3editor.h --- a/widgets/vec3editor.h Wed Jun 22 21:46:38 2022 +0300 +++ b/widgets/vec3editor.h Wed Jun 22 22:50:37 2022 +0300 @@ -6,6 +6,9 @@ class VectorInput : public QWidget { Q_OBJECT + Q_PROPERTY(qreal x READ x WRITE setX) + Q_PROPERTY(qreal y READ y WRITE setY) + Q_PROPERTY(qreal z READ z WRITE setZ) Ui_Vec3Editor ui; public: enum Flag @@ -17,8 +20,13 @@ ~VectorInput(); glm::vec3 value() const; void setValue(const glm::vec3& value); -Q_SIGNALS: - void valueChanged(const glm::vec3& value); + qreal x() const; + qreal y() const; + qreal z() const; + Q_SLOT void setX(qreal x); + Q_SLOT void setY(qreal y); + Q_SLOT void setZ(qreal z); + Q_SIGNAL void valueChanged(const glm::vec3& value); private: std::array spinboxes(); Q_SLOT void multiplyPressed();