diff --git a/DbGuiLib.pro b/DbGuiLib.pro new file mode 100644 index 0000000..afc4729 --- /dev/null +++ b/DbGuiLib.pro @@ -0,0 +1,37 @@ +QT += core gui widgets + +PROJECT_ROOT = ../.. + +TARGET = dbgui + +DEFINES += DBGUILIB_LIBRARY + +SOURCES += ledindicator.cpp \ + matrix4x4widget.cpp \ + quaternionwidget.cpp \ + urlwidget.cpp \ + vector2dwidget.cpp \ + vector3dwidget.cpp \ + vector4dwidget.cpp \ + stringlistwidget.cpp \ + editorfactory.cpp + +HEADERS += dbguilib_global.h \ + ledindicator.h \ + limitedspinbox.h \ + matrix4x4widget.h \ + quaternionwidget.h \ + urlwidget.h \ + vector2dwidget.h \ + vector3dwidget.h \ + vector4dwidget.h \ + stringlistwidget.h \ + editorfactory.h + +FORMS += qstringlistwidget.ui + +RESOURCES += + +TRANSLATIONS += + +include($${PROJECT_ROOT}/lib.pri) diff --git a/dbguilib_global.h b/dbguilib_global.h new file mode 100644 index 0000000..83a4253 --- /dev/null +++ b/dbguilib_global.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +#if defined(DBGUILIB_LIBRARY) +# define DBGUILIB_EXPORT Q_DECL_EXPORT +#else +# define DBGUILIB_EXPORT Q_DECL_IMPORT +#endif diff --git a/editorfactory.cpp b/editorfactory.cpp new file mode 100644 index 0000000..393e746 --- /dev/null +++ b/editorfactory.cpp @@ -0,0 +1,87 @@ +#include "editorfactory.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "limitedspinbox.h" +#include "stringlistwidget.h" +#include "urlwidget.h" +#include "matrix4x4widget.h" +#include "vector2dwidget.h" +#include "vector3dwidget.h" +#include "vector4dwidget.h" +#include "quaternionwidget.h" + +BetterItemFactory::BetterItemFactory() : + QItemEditorFactory() +{ + registerEditor(QVariant::Bool, new QStandardItemEditorCreator()); + registerEditor(QVariant::Int, new QStandardItemEditorCreator::min(), std::numeric_limits::max()> >()); + //registerEditor(QVariant::UInt, new QStandardItemEditorCreator::min(), std::numeric_limits::max()> >()); + //registerEditor(QVariant::LongLong, new QStandardItemEditorCreator::min(), std::numeric_limits::max()> >()); //TODO: implement 64 bit + //registerEditor(QVariant::ULongLong, new QStandardItemEditorCreator::min(), std::numeric_limits::max()> >()); //TODO: implement 64 bit + registerEditor(QVariant::Double, new QStandardItemEditorCreator()); + registerEditor(QMetaType::Float, new QStandardItemEditorCreator()); //TODO: Make this a real QFloatSpinBox + registerEditor(QVariant::ULongLong, new QStandardItemEditorCreator::min(), std::numeric_limits::max()> >()); + //registerEditor(QVariant::Map, Q_NULLPTR); //TODO + //registerEditor(QVariant::List, Q_NULLPTR); //TODO + registerEditor(QVariant::String, new QStandardItemEditorCreator()); + registerEditor(QVariant::StringList, new QStandardItemEditorCreator()); + //registerEditor(QVariant::ByteArray, Q_NULLPTR); //TODO + //registerEditor(QVariant::BitArray, Q_NULLPTR); //TODO + registerEditor(QVariant::Date, new QStandardItemEditorCreator()); + registerEditor(QVariant::Time, new QStandardItemEditorCreator()); + registerEditor(QVariant::DateTime, new QStandardItemEditorCreator()); + registerEditor(QVariant::Url, new QStandardItemEditorCreator()); //TODO + //registerEditor(QVariant::Locale, Q_NULLPTR); //TODO + //registerEditor(QVariant::Rect, Q_NULLPTR); //TODO + //registerEditor(QVariant::RectF, Q_NULLPTR); //TODO + //registerEditor(QVariant::Size, Q_NULLPTR); //TODO + //registerEditor(QVariant::SizeF, Q_NULLPTR); //TODO + //registerEditor(QVariant::Line, Q_NULLPTR); //TODO + //registerEditor(QVariant::LineF, Q_NULLPTR); //TODO + //registerEditor(QVariant::Point, Q_NULLPTR); //TODO + //registerEditor(QVariant::PointF, Q_NULLPTR); //TODO + //registerEditor(QVariant::RegExp, Q_NULLPTR); //TODO + //registerEditor(QVariant::RegularExpression, Q_NULLPTR); //TODO + //registerEditor(QVariant::Hash, Q_NULLPTR); //TODO + //registerEditor(QVariant::EasingCurve, Q_NULLPTR); //TODO + //registerEditor(QVariant::Uuid, Q_NULLPTR); //TODO + //registerEditor(QVariant::ModelIndex, Q_NULLPTR); //TODO + //registerEditor(QVariant::PersistentModelIndex, Q_NULLPTR); //TODO + + //registerEditor(QVariant::Font, Q_NULLPTR); //TODO + //registerEditor(QVariant::Pixmap, Q_NULLPTR); //TODO + //registerEditor(QVariant::Brush, Q_NULLPTR); //TODO + //registerEditor(QVariant::Color, Q_NULLPTR); //TODO + //registerEditor(QVariant::Palette, Q_NULLPTR); //TODO + //registerEditor(QVariant::Image, Q_NULLPTR); //TODO + //registerEditor(QVariant::Polygon, Q_NULLPTR); //TODO + //registerEditor(QVariant::Region, Q_NULLPTR); //TODO + //registerEditor(QVariant::Bitmap, Q_NULLPTR); //TODO + //registerEditor(QVariant::Cursor, Q_NULLPTR); //TODO + registerEditor(QVariant::KeySequence, new QStandardItemEditorCreator()); //TODO + //registerEditor(QVariant::Pen, Q_NULLPTR); //TODO + //registerEditor(QVariant::TextLength, Q_NULLPTR); //TODO + //registerEditor(QVariant::TextFormat, Q_NULLPTR); //TODO + //registerEditor(QVariant::Matrix, Q_NULLPTR); //TODO + //registerEditor(QVariant::Transform, Q_NULLPTR); //TODO + registerEditor(QVariant::Matrix4x4, new QStandardItemEditorCreator()); + registerEditor(QVariant::Vector2D, new QStandardItemEditorCreator()); + registerEditor(QVariant::Vector3D, new QStandardItemEditorCreator()); + registerEditor(QVariant::Vector4D, new QStandardItemEditorCreator()); + registerEditor(QVariant::Quaternion, new QStandardItemEditorCreator()); + //registerEditor(QVariant::PolygonF, Q_NULLPTR); //TODO + //registerEditor(QVariant::Icon, Q_NULLPTR); //TODO + + //registerEditor(QVariant::SizePolicy, Q_NULLPTR); //TODO +} diff --git a/editorfactory.h b/editorfactory.h new file mode 100644 index 0000000..5072a65 --- /dev/null +++ b/editorfactory.h @@ -0,0 +1,10 @@ +#pragma once + +#include +#include "dbguilib_global.h" + +class DBGUILIB_EXPORT BetterItemFactory : public QItemEditorFactory +{ +public: + BetterItemFactory(); +}; diff --git a/ledindicator.cpp b/ledindicator.cpp new file mode 100644 index 0000000..acb63bb --- /dev/null +++ b/ledindicator.cpp @@ -0,0 +1,37 @@ +#include "ledindicator.h" + +#include + +LedIndicator::LedIndicator(QWidget *parent) : + QWidget(parent) +{ + setMinimumSize(16, 16); +} + +void LedIndicator::setColor(const QColor &color) +{ + m_color = color; + repaint(); +} + +void LedIndicator::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event) + + QRect ellipseRect; + + if(width() < height()) + ellipseRect = QRect(0, height() / 2 - width() / 2, width(), width()); + else if(width() > height()) + ellipseRect = QRect(width() / 2 - height() / 2, 0, height(), height()); + else + ellipseRect = rect(); + + ellipseRect.setWidth(ellipseRect.width() - 1); + ellipseRect.setHeight(ellipseRect.height() - 1); + + QPainter painter(this); + painter.setPen(Qt::black); + painter.setBrush(m_color); + painter.drawEllipse(ellipseRect); +} diff --git a/ledindicator.h b/ledindicator.h new file mode 100644 index 0000000..dadf2c5 --- /dev/null +++ b/ledindicator.h @@ -0,0 +1,23 @@ +#pragma once + +#include +#include "dbguilib_global.h" + +#include + +class DBGUILIB_EXPORT LedIndicator : public QWidget +{ + Q_OBJECT + +public: + LedIndicator(QWidget *parent = Q_NULLPTR); + + void setColor(const QColor &color); + +protected: + // QWidget interface + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + +private: + QColor m_color; +}; diff --git a/limitedspinbox.h b/limitedspinbox.h new file mode 100644 index 0000000..2e882a2 --- /dev/null +++ b/limitedspinbox.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +template +class LimitedSpinBox : public QSpinBox +{ + //No Q_OBJECT because template (not needed anyways) + +public: + LimitedSpinBox(QWidget *parent = Q_NULLPTR); +}; + +template +LimitedSpinBox::LimitedSpinBox(QWidget *parent) : QSpinBox(parent) +{ + setRange(Tmin, Tmax); +} diff --git a/matrix4x4widget.cpp b/matrix4x4widget.cpp new file mode 100644 index 0000000..9f4fe88 --- /dev/null +++ b/matrix4x4widget.cpp @@ -0,0 +1,69 @@ +#include "matrix4x4widget.h" + +#include +#include +#include + +Matrix4x4Widget::Matrix4x4Widget(QWidget *parent) : + QWidget(parent) +{ + auto layout = new QGridLayout(this); + layout->setMargin(0); + layout->addWidget(m_doubleSpinBox11 = new QDoubleSpinBox(this), 0, 0); + layout->addWidget(m_doubleSpinBox12 = new QDoubleSpinBox(this), 0, 1); + layout->addWidget(m_doubleSpinBox13 = new QDoubleSpinBox(this), 0, 2); + layout->addWidget(m_doubleSpinBox14 = new QDoubleSpinBox(this), 0, 3); + layout->addWidget(m_doubleSpinBox21 = new QDoubleSpinBox(this), 1, 0); + layout->addWidget(m_doubleSpinBox22 = new QDoubleSpinBox(this), 1, 1); + layout->addWidget(m_doubleSpinBox23 = new QDoubleSpinBox(this), 1, 2); + layout->addWidget(m_doubleSpinBox24 = new QDoubleSpinBox(this), 1, 3); + layout->addWidget(m_doubleSpinBox31 = new QDoubleSpinBox(this), 2, 0); + layout->addWidget(m_doubleSpinBox32 = new QDoubleSpinBox(this), 2, 1); + layout->addWidget(m_doubleSpinBox33 = new QDoubleSpinBox(this), 2, 2); + layout->addWidget(m_doubleSpinBox34 = new QDoubleSpinBox(this), 2, 3); + layout->addWidget(m_doubleSpinBox41 = new QDoubleSpinBox(this), 3, 0); + layout->addWidget(m_doubleSpinBox42 = new QDoubleSpinBox(this), 3, 1); + layout->addWidget(m_doubleSpinBox43 = new QDoubleSpinBox(this), 3, 2); + layout->addWidget(m_doubleSpinBox44 = new QDoubleSpinBox(this), 3, 3); + setLayout(layout); +} + +QMatrix4x4 Matrix4x4Widget::value() const +{ + return QMatrix4x4(m_doubleSpinBox11->value(), m_doubleSpinBox12->value(), m_doubleSpinBox13->value(), m_doubleSpinBox14->value(), + m_doubleSpinBox21->value(), m_doubleSpinBox22->value(), m_doubleSpinBox23->value(), m_doubleSpinBox24->value(), + m_doubleSpinBox31->value(), m_doubleSpinBox32->value(), m_doubleSpinBox33->value(), m_doubleSpinBox34->value(), + m_doubleSpinBox41->value(), m_doubleSpinBox42->value(), m_doubleSpinBox43->value(), m_doubleSpinBox44->value()); +} + +void Matrix4x4Widget::setValue(const QMatrix4x4 &value) +{ + { + auto row = value.row(0); + m_doubleSpinBox11->setValue(row.x()); + m_doubleSpinBox12->setValue(row.y()); + m_doubleSpinBox13->setValue(row.z()); + m_doubleSpinBox14->setValue(row.w()); + } + { + auto row = value.row(1); + m_doubleSpinBox21->setValue(row.x()); + m_doubleSpinBox22->setValue(row.y()); + m_doubleSpinBox23->setValue(row.z()); + m_doubleSpinBox24->setValue(row.w()); + } + { + auto row = value.row(2); + m_doubleSpinBox31->setValue(row.x()); + m_doubleSpinBox32->setValue(row.y()); + m_doubleSpinBox33->setValue(row.z()); + m_doubleSpinBox34->setValue(row.w()); + } + { + auto row = value.row(3); + m_doubleSpinBox41->setValue(row.x()); + m_doubleSpinBox42->setValue(row.y()); + m_doubleSpinBox43->setValue(row.z()); + m_doubleSpinBox44->setValue(row.w()); + } +} diff --git a/matrix4x4widget.h b/matrix4x4widget.h new file mode 100644 index 0000000..93d402d --- /dev/null +++ b/matrix4x4widget.h @@ -0,0 +1,29 @@ +#pragma once + +#include +#include "dbguilib_global.h" + +#include + +class QDoubleSpinBox; + +class DBGUILIB_EXPORT Matrix4x4Widget : public QWidget +{ + Q_OBJECT + Q_PROPERTY(QMatrix4x4 value READ value WRITE setValue NOTIFY valueChanged USER true) + +public: + Matrix4x4Widget(QWidget *parent = Q_NULLPTR); + + QMatrix4x4 value() const; + void setValue(const QMatrix4x4 &value); + +Q_SIGNALS: + void valueChanged(const QMatrix4x4 &value); + +private: + QDoubleSpinBox *m_doubleSpinBox11, *m_doubleSpinBox12, *m_doubleSpinBox13, *m_doubleSpinBox14; + QDoubleSpinBox *m_doubleSpinBox21, *m_doubleSpinBox22, *m_doubleSpinBox23, *m_doubleSpinBox24; + QDoubleSpinBox *m_doubleSpinBox31, *m_doubleSpinBox32, *m_doubleSpinBox33, *m_doubleSpinBox34; + QDoubleSpinBox *m_doubleSpinBox41, *m_doubleSpinBox42, *m_doubleSpinBox43, *m_doubleSpinBox44; +}; diff --git a/qstringlistwidget.ui b/qstringlistwidget.ui new file mode 100644 index 0000000..e863010 --- /dev/null +++ b/qstringlistwidget.ui @@ -0,0 +1,49 @@ + + + QStringListWidget + + + + 0 + 0 + 452 + 369 + + + + Form + + + + + + + + Add entry + + + + + + + Delete entry + + + + + + + + + QAbstractItemView::InternalMove + + + QAbstractItemView::ExtendedSelection + + + + + + + + diff --git a/quaternionwidget.cpp b/quaternionwidget.cpp new file mode 100644 index 0000000..cbb3a1d --- /dev/null +++ b/quaternionwidget.cpp @@ -0,0 +1,29 @@ +#include "quaternionwidget.h" + +#include +#include + +QuaternionWidget::QuaternionWidget(QWidget *parent) : + QWidget(parent) +{ + auto layout = new QHBoxLayout(this); + layout->setMargin(0); + layout->addWidget(m_doubleSpinBoxX = new QDoubleSpinBox(this)); + layout->addWidget(m_doubleSpinBoxY = new QDoubleSpinBox(this)); + layout->addWidget(m_doubleSpinBoxZ = new QDoubleSpinBox(this)); + layout->addWidget(m_doubleSpinBoxScalar = new QDoubleSpinBox(this)); + setLayout(layout); +} + +QQuaternion QuaternionWidget::value() const +{ + return QQuaternion(m_doubleSpinBoxX->value(), m_doubleSpinBoxY->value(), m_doubleSpinBoxZ->value(), m_doubleSpinBoxScalar->value()); +} + +void QuaternionWidget::setValue(const QQuaternion &value) +{ + m_doubleSpinBoxX->setValue(value.x()); + m_doubleSpinBoxY->setValue(value.y()); + m_doubleSpinBoxZ->setValue(value.z()); + m_doubleSpinBoxScalar->setValue(value.scalar()); +} diff --git a/quaternionwidget.h b/quaternionwidget.h new file mode 100644 index 0000000..2961b4f --- /dev/null +++ b/quaternionwidget.h @@ -0,0 +1,29 @@ +#pragma once + +#include +#include "dbguilib_global.h" + +#include + +class QDoubleSpinBox; + +class DBGUILIB_EXPORT QuaternionWidget : public QWidget +{ + Q_OBJECT + Q_PROPERTY(QQuaternion value READ value WRITE setValue NOTIFY valueChanged USER true) + +public: + QuaternionWidget(QWidget *parent = Q_NULLPTR); + + QQuaternion value() const; + void setValue(const QQuaternion &value); + +Q_SIGNALS: + void valueChanged(const QQuaternion &value); + +private: + QDoubleSpinBox *m_doubleSpinBoxX; + QDoubleSpinBox *m_doubleSpinBoxY; + QDoubleSpinBox *m_doubleSpinBoxZ; + QDoubleSpinBox *m_doubleSpinBoxScalar; +}; diff --git a/stringlistwidget.cpp b/stringlistwidget.cpp new file mode 100644 index 0000000..6d290d9 --- /dev/null +++ b/stringlistwidget.cpp @@ -0,0 +1,70 @@ +#include "stringlistwidget.h" +#include "ui_qstringlistwidget.h" + +#include + +StringListWidget::StringListWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::QStringListWidget), + m_model(new QStringListModel(this)) +{ + setup(); +} + +StringListWidget::StringListWidget(const QStringList &stringList, QWidget *parent) : + QWidget(parent), + ui(new Ui::QStringListWidget), + m_model(new QStringListModel(stringList, this)) +{ + setup(); +} + +StringListWidget::~StringListWidget() +{ + delete ui; +} + +QStringList StringListWidget::value() const +{ + return m_model->stringList(); +} + +void StringListWidget::setValue(const QStringList &stringList) +{ + m_model->setStringList(stringList); +} + +void StringListWidget::addPressed() +{ + auto index = ui->listView->currentIndex(); + + m_model->insertRow(index.isValid() ? index.row() + 1: m_model->rowCount()); +} + +void StringListWidget::deletePressed() +{ + auto index = ui->listView->currentIndex(); + + if(!index.isValid()) + return; + + m_model->removeRow(index.row()); +} + +void StringListWidget::selectionChanged() +{ + ui->pushButtonDelete->setEnabled(ui->listView->currentIndex().isValid()); +} + +void StringListWidget::setup() +{ + ui->setupUi(this); + + ui->listView->setModel(m_model); + + connect(ui->pushButtonAdd, &QAbstractButton::pressed, this, &StringListWidget::addPressed); + connect(ui->pushButtonDelete, &QAbstractButton::pressed, this, &StringListWidget::deletePressed); + connect(ui->listView->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &StringListWidget::selectionChanged); + + selectionChanged(); +} diff --git a/stringlistwidget.h b/stringlistwidget.h new file mode 100644 index 0000000..f132cd0 --- /dev/null +++ b/stringlistwidget.h @@ -0,0 +1,36 @@ +#pragma once + +#include +#include "dbguilib_global.h" + +class QStringListModel; + +namespace Ui { class QStringListWidget; } + +class DBGUILIB_EXPORT StringListWidget : public QWidget +{ + Q_OBJECT + Q_PROPERTY(QStringList value READ value WRITE setValue NOTIFY valueChanged USER true) + +public: + explicit StringListWidget(QWidget *parent = Q_NULLPTR); + explicit StringListWidget(const QStringList &value, QWidget *parent = Q_NULLPTR); + ~StringListWidget(); + + QStringList value() const; + void setValue(const QStringList &value); + +Q_SIGNALS: + void valueChanged(const QStringList &value); + +private Q_SLOTS: + void addPressed(); + void deletePressed(); + void selectionChanged(); + +private: + void setup(); + + Ui::QStringListWidget *ui; + QStringListModel *m_model; +}; diff --git a/urlwidget.cpp b/urlwidget.cpp new file mode 100644 index 0000000..053b470 --- /dev/null +++ b/urlwidget.cpp @@ -0,0 +1,37 @@ +#include "urlwidget.h" + +#include +#include +#include +#include + +UrlWidget::UrlWidget(QWidget *parent) : + QWidget(parent) +{ + auto layout = new QHBoxLayout(this); + layout->setMargin(0); + layout->addWidget(m_lineEdit = new QLineEdit(this)); + { + auto toolButton = new QToolButton(this); + connect(toolButton, &QAbstractButton::pressed, this, &UrlWidget::pressed); + layout->addWidget(toolButton); + } + setLayout(layout); +} + +QUrl UrlWidget::value() const +{ + return QUrl(m_lineEdit->text()); +} + +void UrlWidget::setValue(const QUrl &value) +{ + m_lineEdit->setText(value.toString()); +} + +void UrlWidget::pressed() +{ + auto path = QFileDialog::getOpenFileName(this); + if(!path.isEmpty()) + m_lineEdit->setText(path); +} diff --git a/urlwidget.h b/urlwidget.h new file mode 100644 index 0000000..d77d440 --- /dev/null +++ b/urlwidget.h @@ -0,0 +1,29 @@ +#pragma once + +#include +#include "dbguilib_global.h" + +#include + +class QLineEdit; + +class DBGUILIB_EXPORT UrlWidget : public QWidget +{ + Q_OBJECT + Q_PROPERTY(QUrl value READ value WRITE setValue NOTIFY valueChanged USER true) + +public: + UrlWidget(QWidget *parent = Q_NULLPTR); + + QUrl value() const; + void setValue(const QUrl &value); + +Q_SIGNALS: + void valueChanged(const QUrl &value); + +private Q_SLOTS: + void pressed(); + +private: + QLineEdit *m_lineEdit; +}; diff --git a/vector2dwidget.cpp b/vector2dwidget.cpp new file mode 100644 index 0000000..d0de5d3 --- /dev/null +++ b/vector2dwidget.cpp @@ -0,0 +1,25 @@ +#include "vector2dwidget.h" + +#include +#include + +Vector2DWidget::Vector2DWidget(QWidget *parent) : + QWidget(parent) +{ + auto layout = new QHBoxLayout(this); + layout->setMargin(0); + layout->addWidget(m_doubleSpinBoxX = new QDoubleSpinBox(this)); + layout->addWidget(m_doubleSpinBoxY = new QDoubleSpinBox(this)); + setLayout(layout); +} + +QVector2D Vector2DWidget::value() const +{ + return QVector2D(m_doubleSpinBoxX->value(), m_doubleSpinBoxY->value()); +} + +void Vector2DWidget::setValue(const QVector2D &value) +{ + m_doubleSpinBoxX->setValue(value.x()); + m_doubleSpinBoxY->setValue(value.y()); +} diff --git a/vector2dwidget.h b/vector2dwidget.h new file mode 100644 index 0000000..1513b37 --- /dev/null +++ b/vector2dwidget.h @@ -0,0 +1,27 @@ +#pragma once + +#include +#include "dbguilib_global.h" + +#include + +class QDoubleSpinBox; + +class DBGUILIB_EXPORT Vector2DWidget : public QWidget +{ + Q_OBJECT + Q_PROPERTY(QVector2D value READ value WRITE setValue NOTIFY valueChanged USER true) + +public: + Vector2DWidget(QWidget *parent = Q_NULLPTR); + + QVector2D value() const; + void setValue(const QVector2D &value); + +Q_SIGNALS: + void valueChanged(const QVector2D &value); + +private: + QDoubleSpinBox *m_doubleSpinBoxX; + QDoubleSpinBox *m_doubleSpinBoxY; +}; diff --git a/vector3dwidget.cpp b/vector3dwidget.cpp new file mode 100644 index 0000000..4ae3501 --- /dev/null +++ b/vector3dwidget.cpp @@ -0,0 +1,27 @@ +#include "vector3dwidget.h" + +#include +#include + +Vector3DWidget::Vector3DWidget(QWidget *parent) : + QWidget(parent) +{ + auto layout = new QHBoxLayout(this); + layout->setMargin(0); + layout->addWidget(m_doubleSpinBoxX = new QDoubleSpinBox(this)); + layout->addWidget(m_doubleSpinBoxY = new QDoubleSpinBox(this)); + layout->addWidget(m_doubleSpinBoxZ = new QDoubleSpinBox(this)); + setLayout(layout); +} + +QVector3D Vector3DWidget::value() const +{ + return QVector3D(m_doubleSpinBoxX->value(), m_doubleSpinBoxY->value(), m_doubleSpinBoxZ->value()); +} + +void Vector3DWidget::setValue(const QVector3D &value) +{ + m_doubleSpinBoxX->setValue(value.x()); + m_doubleSpinBoxY->setValue(value.y()); + m_doubleSpinBoxZ->setValue(value.z()); +} diff --git a/vector3dwidget.h b/vector3dwidget.h new file mode 100644 index 0000000..ee8c3ce --- /dev/null +++ b/vector3dwidget.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include "dbguilib_global.h" + +#include + +class QDoubleSpinBox; + +class DBGUILIB_EXPORT Vector3DWidget : public QWidget +{ + Q_OBJECT + Q_PROPERTY(QVector3D value READ value WRITE setValue NOTIFY valueChanged USER true) + +public: + Vector3DWidget(QWidget *parent = Q_NULLPTR); + + QVector3D value() const; + void setValue(const QVector3D &value); + +Q_SIGNALS: + void valueChanged(const QVector3D &value); + +private: + QDoubleSpinBox *m_doubleSpinBoxX; + QDoubleSpinBox *m_doubleSpinBoxY; + QDoubleSpinBox *m_doubleSpinBoxZ; +}; diff --git a/vector4dwidget.cpp b/vector4dwidget.cpp new file mode 100644 index 0000000..9fa4fb0 --- /dev/null +++ b/vector4dwidget.cpp @@ -0,0 +1,28 @@ +#include "vector4dwidget.h" + +#include +#include + +Vector4DWidget::Vector4DWidget(QWidget *parent) : QWidget(parent) +{ + auto layout = new QHBoxLayout(this); + layout->setMargin(0); + layout->addWidget(m_doubleSpinBoxX = new QDoubleSpinBox(this)); + layout->addWidget(m_doubleSpinBoxY = new QDoubleSpinBox(this)); + layout->addWidget(m_doubleSpinBoxZ = new QDoubleSpinBox(this)); + layout->addWidget(m_doubleSpinBoxW = new QDoubleSpinBox(this)); + setLayout(layout); +} + +QVector4D Vector4DWidget::value() const +{ + return QVector4D(m_doubleSpinBoxX->value(), m_doubleSpinBoxY->value(), m_doubleSpinBoxZ->value(), m_doubleSpinBoxW->value()); +} + +void Vector4DWidget::setValue(const QVector4D &value) +{ + m_doubleSpinBoxX->setValue(value.x()); + m_doubleSpinBoxY->setValue(value.y()); + m_doubleSpinBoxZ->setValue(value.z()); + m_doubleSpinBoxW->setValue(value.w()); +} diff --git a/vector4dwidget.h b/vector4dwidget.h new file mode 100644 index 0000000..28238b8 --- /dev/null +++ b/vector4dwidget.h @@ -0,0 +1,32 @@ +#ifndef VECTOR4DWIDGET_H +#define VECTOR4DWIDGET_H + +#include +#include "dbguilib_global.h" + +#include + +class QDoubleSpinBox; + +class DBGUILIB_EXPORT Vector4DWidget : public QWidget +{ + Q_OBJECT + Q_PROPERTY(QVector4D value READ value WRITE setValue NOTIFY valueChanged USER true) + +public: + Vector4DWidget(QWidget *parent = Q_NULLPTR); + + QVector4D value() const; + void setValue(const QVector4D &value); + +Q_SIGNALS: + void valueChanged(const QVector4D &value); + +private: + QDoubleSpinBox *m_doubleSpinBoxX; + QDoubleSpinBox *m_doubleSpinBoxY; + QDoubleSpinBox *m_doubleSpinBoxZ; + QDoubleSpinBox *m_doubleSpinBoxW; +}; + +#endif // VECTOR4DWIDGET_H