Skip to content
Snippets Groups Projects

Lib feature 2624

Closed konstantin.kukharenko requested to merge lib-feature-2624 into master
2 unresolved threads
1 file
+ 52
15
Compare changes
  • Side-by-side
  • Inline
+ 52
15
@@ -11,6 +11,8 @@ import QtGraphicalEffects 1.0
///@fontSizeComboBox - font size for the entire widget (px).
///@widthPopupComboBoxActive and @widthPopupComboBoxNormal - width of the combo box
/// in the active state and in the normal state
///@heightComboBoxNormal and @heightComboBoxActive - height of the combo box
/// in the active state and in the normal state
///@sidePaddingActive and @sidePaddingNormal - padding width of the combo box in the active state
/// and in the normal state
///@sidePaddingActive and @sidePaddingNormal - sets the indent from the edge of the right and left
@@ -20,6 +22,10 @@ import QtGraphicalEffects 1.0
/// - sets the indent from the edge of the upper and lower edges of the parent in the active and normal state
///@indicatorImageNormal and @indicatorImageActive - indicator picture address for active and normal state
///@indicatorWidth and @indicatorHeight - indicator width and height
///@heightListElement - List item height
///@intervalListElement - spacing between items in a list
///@bottomIntervalListElement - spacing from bottom to bottom
///@topEffect - Using an effect for the top element
ComboBox {
@@ -27,13 +33,20 @@ ComboBox {
property string hilightColorText: "#FFFFFF"
property string normalColorTopText:normalColorText
property string hilightColorTopText:normalColorText
property string normalColor: "#FFFFFF"
property string hilightColor: "#330F54"
property string normalTopColor: normalColor
property string hilightTopColor: normalColor
property int fontSizeComboBox: 16*pt
property int widthPopupComboBoxNormal: parent.width
property int widthPopupComboBoxActive: widthPopupComboBoxNormal
property int heightComboBoxNormal: parent.height
property int heightComboBoxActive: heightComboBoxNormal
property int sidePaddingNormal:16 * pt
property int sidePaddingActive:sidePaddingNormal
@@ -43,6 +56,11 @@ ComboBox {
property int bottomIndentNormal:14 * pt
property int bottomIndentActive:bottomIndentNormal
property int heightListElement: 32 * pt
property int intervalListElement: 10 * pt
property int bottomIntervalListElement:intervalListElement
property bool topEffect: true
property string indicatorImageNormal: "qrc:/res/icons/ic_arrow_drop_down_dark_blue.png"
property string indicatorImageActive: "qrc:/res/icons/ic_arrow_drop_up_dark_blue.png"
property int indicatorWidth: 24*pt
property int indicatorHeight: indicatorWidth
id: customComboBox
width: popup.visible ? widthPopupComboBoxActive : widthPopupComboBoxNormal
height: parent.height
height: popup.visible ? heightComboBoxActive : heightComboBoxNormal
anchors.verticalCenter: parent.verticalCenter
delegate:ItemDelegate {
width: parent.width
height:{
if(index == currentIndex) return 0
else return 42*pt
if(index != currentIndex)
{
if(index == customComboBox.count - 2)
{
if(index+1 == currentIndex) return heightListElement + bottomIntervalListElement
else return heightListElement + intervalListElement
}
if (index == customComboBox.count - 1) return heightListElement + bottomIntervalListElement
return heightListElement + intervalListElement
}
else return 0
}
contentItem: Text {
id:textDelegateComboBox
anchors.fill: parent
anchors.topMargin: 8 * pt
anchors.leftMargin: popup.visible ? sidePaddingActive : sidePaddingNormal
verticalAlignment: Qt.AlignTop
verticalAlignment: Qt.AlignCenter
font.family: fontRobotoRegular.name
font.pixelSize: fontSizeComboBox
text: {if(index != currentIndex) return modelData;}
@@ -73,7 +102,14 @@ ComboBox {
background: Rectangle {
anchors.fill: parent
anchors.bottomMargin: 10 * pt
anchors.bottomMargin: {
if(index == customComboBox.count - 2)
{
if(index+1 == currentIndex) return bottomIntervalListElement
else return intervalListElement
}
if (index == customComboBox.count - 1) return bottomIntervalListElement
}
color: hovered ? hilightColor : normalColor
}
@@ -93,7 +129,7 @@ ComboBox {
background: Rectangle {
anchors.fill: parent
color: parent.popup.visible ? normalColor : "transparent"
color: parent.popup.visible ? hilightTopColor : normalTopColor
radius: 2 * pt
height: parent.height
@@ -102,12 +138,11 @@ ComboBox {
contentItem: Text {
anchors.fill: parent
anchors.leftMargin: popup.visible ? sidePaddingActive : sidePaddingNormal
anchors.topMargin: popup.visible ? topIndentActive : topIndentNormal
text: parent.displayText
font.family: fontRobotoRegular.name
font.pixelSize: fontSizeComboBox
color: popup.visible ? hilightColorTopText : normalColorTopText
verticalAlignment: Text.AlignTop
verticalAlignment: Text.AlignVCenter
}
popup: Popup {
@@ -123,9 +158,11 @@ ComboBox {
background: Rectangle {
width: customComboBox.background.width
color: parent.color
Rectangle {
id: contentCorner
anchors.fill: parent
}
DropShadow {
@@ -133,16 +170,16 @@ ComboBox {
source: contentCorner
verticalOffset: 9 * pt
samples: 13 * pt
color: "#40000000"
color: "#40ABABAB"
}
}
}
}
DropShadow {
anchors.fill: parent
source: background
verticalOffset: 9 * pt
samples: 13 * pt
color: "#40000000"
anchors.fill: if(topEffect) parent
source: if(topEffect) background
verticalOffset: if(topEffect) 9 * pt
samples: if(topEffect) 13 * pt
color: if(topEffect) customComboBox.popup.visible ? "#40ABABAB" : "#00000000"
}
}
Loading