diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-08-09 13:42:56 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-08-11 07:21:26 +0000 |
commit | 0bf6a3f4255c2e082db1f84de19034f05c48ce56 (patch) | |
tree | 249c285f319ceb85ffe6ac38f5cd7b3808c0009c /src/quicktemplates2/qquickcombobox.cpp | |
parent | 038a0c308a03977d3694e16b31c1cf7c7e1a5611 (diff) |
Add ComboBox::flat
[ChangeLog][ComboBox] Added a flat property that provides more suitable
looks for using ComboBox in a ToolBar.
Task-number: QTBUG-54935
Change-Id: Id458a078486aeac5d542a57f3ed247d63d25e95c
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickcombobox.cpp')
-rw-r--r-- | src/quicktemplates2/qquickcombobox.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index f6dfa195..59c108c2 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -154,7 +154,7 @@ class QQuickComboBoxPrivate : public QQuickControlPrivate Q_DECLARE_PUBLIC(QQuickComboBox) public: - QQuickComboBoxPrivate() : pressed(false), ownModel(false), hasDisplayText(false), hasCurrentIndex(false), + QQuickComboBoxPrivate() : flat(false), pressed(false), ownModel(false), hasDisplayText(false), hasCurrentIndex(false), highlightedIndex(-1), currentIndex(-1), delegateModel(nullptr), delegate(nullptr), indicator(nullptr), popup(nullptr) { } @@ -174,6 +174,7 @@ public: void createDelegateModel(); + bool flat; bool pressed; bool ownModel; bool hasDisplayText; @@ -438,6 +439,36 @@ QQmlInstanceModel *QQuickComboBox::delegateModel() const } /*! + \since QtQuick.Controls 2.1 + \qmlproperty bool QtQuick.Controls::ComboBox::flat + + This property holds whether the combo box button is flat. + + A flat combo box button does not draw a background unless it is interacted + with. In comparison to normal combo boxes, flat combo boxes provide looks + that make them stand out less from the rest of the UI. For instance, when + placing a combo box into a tool bar, it may be desirable to make the combo + box flat so it matches better with the flat looks of tool buttons. + + The default value is \c false. +*/ +bool QQuickComboBox::isFlat() const +{ + Q_D(const QQuickComboBox); + return d->flat; +} + +void QQuickComboBox::setFlat(bool flat) +{ + Q_D(QQuickComboBox); + if (d->flat == flat) + return; + + d->flat = flat; + emit flatChanged(); +} + +/*! \qmlproperty bool QtQuick.Controls::ComboBox::pressed This property holds whether the combo box button is pressed. |