summaryrefslogtreecommitdiff
path: root/vcl/qt5/QtBuilder.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/qt5/QtBuilder.cxx')
-rw-r--r--vcl/qt5/QtBuilder.cxx31
1 files changed, 31 insertions, 0 deletions
diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx
index 73ad72ec424b..1b219567c199 100644
--- a/vcl/qt5/QtBuilder.cxx
+++ b/vcl/qt5/QtBuilder.cxx
@@ -256,6 +256,12 @@ QObject* QtBuilder::makeObject(QObject* pParent, std::u16string_view sName, cons
pFrame->setFrameShape(bVertical ? QFrame::VLine : QFrame::HLine);
pObject = pFrame;
}
+ else if (sName == u"GtkSpinButton")
+ {
+ QDoubleSpinBox* pSpinBox = new QDoubleSpinBox(pParentWidget);
+ setSpinButtonProperties(*pSpinBox, rMap);
+ pObject = pSpinBox;
+ }
else if (sName == u"GtkTextView")
{
pObject = new QPlainTextEdit(pParentWidget);
@@ -557,6 +563,31 @@ void QtBuilder::setProperties(QObject* pObject, stringmap& rProps)
}
}
+void QtBuilder::setSpinButtonProperties(QDoubleSpinBox& rSpinBox, stringmap& rProps)
+{
+ auto aDigitsIt = rProps.find(u"digits"_ustr);
+ sal_Int32 nDigits = (aDigitsIt != rProps.end()) ? aDigitsIt->second.toInt32() : 0;
+ rSpinBox.setDecimals(nDigits);
+
+ auto aAdjustmentIt = rProps.find("adjustment");
+ if (aAdjustmentIt != rProps.end())
+ {
+ const Adjustment* pAdjustment = get_adjustment_by_name(aAdjustmentIt->second);
+ assert(pAdjustment && "referenced adjustment doesn't exist");
+ for (auto const & [ rKey, rValue ] : *pAdjustment)
+ {
+ if (rKey == u"upper")
+ rSpinBox.setMaximum(rValue.toDouble());
+ else if (rKey == u"lower")
+ rSpinBox.setMinimum(rValue.toDouble());
+ else if (rKey == "value")
+ rSpinBox.setValue(rValue.toDouble());
+ else if (rKey == "step-increment")
+ rSpinBox.setSingleStep(rValue.toDouble());
+ }
+ }
+}
+
QWidget* QtBuilder::windowForObject(QObject* pObject)
{
if (QWidget* pWidget = qobject_cast<QWidget*>(pObject))