Skip to content
Snippets Groups Projects
DapComboBoxForm.ui.qml 6.73 KiB
Newer Older
import QtQuick 2.0
konstantin.kukharenko's avatar
konstantin.kukharenko committed
import QtQuick.Controls 2.2
import QtQuick.Controls.Styles 1.4
import QtGraphicalEffects 1.0

ComboBox 
{
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis normalColorText Text color in normal state.
    property string normalColorText
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis hilightColorText Text color in selected state.
    property string hilightColorText
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis normalColorTopText Text color in the main line in normal state.
    property string normalColorTopText
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis hilightColorTopText Text color in the main line in active state.
    property string hilightColorTopText
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis normalColor Item color in normal state.
    property string normalColor
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis hilightColor Item color in selected state.
    property string hilightColor
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis normalTopColor Top string color in normal state.
    property string normalTopColor
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis hilightTopColor Top string color in selected state.
    property string hilightTopColor
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis widthPopupComboBoxNormal Width of the combo box in the normal state.
    property int widthPopupComboBoxNormal
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis widthPopupComboBoxActive Width of the ComboBox in the active state.
    property int widthPopupComboBoxActive
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis heightComboBoxNormal Height of the ComboBox in the normal state.
    property int heightComboBoxNormal
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis heightComboBoxActive Height of the ComboBox in the active state.
    property int heightComboBoxActive
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis sidePaddingNormal: Sets the indent from the edge of the right and left edges of the parent in the normal state.
    property int sidePaddingNormal
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis sidePaddingActive Sets the indent from the edge of the right and left edges of the parent in the active state.
    property int sidePaddingActive
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis topIndentNormal Sets the indent from the edge of the upper of the parent in the normal state.
    property int topIndentNormal
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis topIndentActive Sets the indent from the edge of the upper of the parent in the active state.
    property int topIndentActive
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis bottomIndentNormal Sets the indent from the edge of the lower of the parent in the normal state.
    property int bottomIndentNormal
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis bottomIndentActive Sets the indent from the edge of the lower of the parent in the active state.
    property int bottomIndentActive
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis paddingTopItemDelegate Indent above from item delegate.
    property int paddingTopItemDelegate
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis paddingBottomItemDelegate Indent below from item delegate.
    property int paddingBottomItemDelegate
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis heightListElement List item height.
    property int heightListElement
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis intervalListElement Spacing between items in a list.
    property int intervalListElement
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis bottomIntervalListElement Spacing from bottom to bottom.
    property int bottomIntervalListElement
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis topEffect Using an effect for the top element.
    property bool topEffect
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis indicatorImageNormal Indicator picture address for normal state.
    property string indicatorImageNormal
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis indicatorImageActive Indicator picture address for active state.
    property string indicatorImageActive
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis indicatorWidth Indicator width.
    property int indicatorWidth
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis indicatorHeight Indicator height.
    property int indicatorHeight
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    /// colorTopNormalDropShadow Color of the shadow effect of the combo box when minimized.
    property string colorTopNormalDropShadow
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    ///@detalis colorDropShadow Unboxed shadow color in expanded state.
    property string colorDropShadow
    ///@detalis fontComboBox Font setting combobox.
    property alias fontComboBox:customComboBox.font
konstantin.kukharenko's avatar
konstantin.kukharenko committed

    id: customComboBox
    width: popup.visible ? widthPopupComboBoxActive : widthPopupComboBoxNormal
    height: popup.visible ? heightComboBoxActive : heightComboBoxNormal
    anchors.verticalCenter: parent.verticalCenter

    //Icon icon near the text (arrow)
    indicator: 
        Image 
        {
            source: parent.popup.visible ? indicatorImageActive : indicatorImageNormal
            width: indicatorWidth
            height: indicatorHeight
            anchors.verticalCenter: parent.verticalCenter
            anchors.right: parent.right
            anchors.rightMargin: popup.visible ? sidePaddingActive : sidePaddingNormal
        }
konstantin.kukharenko's avatar
konstantin.kukharenko committed

    //Defining the background for the main line
    background: 
        Rectangle 
        {
            anchors.fill: parent
            color: parent.popup.visible ? hilightTopColor : normalTopColor
            radius: 2 * pt
            height: parent.height
        }
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    //Main line text settings
    contentItem: 
        Text 
        {
            id:textTopComboBox
            anchors.fill: parent
            anchors.leftMargin: popup.visible ? sidePaddingActive : sidePaddingNormal
            text: parent.displayText
            font: parent.font
            color: popup.visible ? hilightColorTopText : normalColorTopText
            verticalAlignment: Text.AlignVCenter
        }
konstantin.kukharenko's avatar
konstantin.kukharenko committed

    //Customize drop-down list with shadow effect
    popup: 
        Popup 
        {
            y: parent.height - 1
            width: parent.width + 1
            padding: 1
            contentItem:
                ListView 
                {
                    clip: true
                    implicitHeight: contentHeight
                    model: customComboBox.popup.visible ? customComboBox.delegateModel : null
                    ScrollIndicator.vertical: ScrollIndicator {}
                }
    
            background: 
                Rectangle
                {
                    width: customComboBox.background.width
                    color: normalColor
                    Rectangle 
                    {
                        id: contentCorner
                        anchors.fill: parent
                    }
        
                    DropShadow 
                    {
                        anchors.fill: parent
                        source: contentCorner
                        verticalOffset: 9 * pt
                        samples: 13 * pt
                        color: colorDropShadow
                    }
                }
        //Shadow effect for the top element.
        DropShadow 
            anchors.fill: if (topEffect)
                              parent
            source: if (topEffect)
                        background
            verticalOffset: if (topEffect)
                                9 * pt
                            else 0
            samples: if (topEffect)
                         13 * pt
                        else 0
            color: if (topEffect)
                       customComboBox.popup.visible ? colorDropShadow : colorTopNormalDropShadow
                    else "#00000000"