Skip to content
Snippets Groups Projects
Commit dd91e44d authored by andrey.daragan's avatar andrey.daragan
Browse files

Merge branch 'feature-2624' into 'master'

Feature 2624

See merge request !4
parents 4c38710d 2eaadfe0
No related branches found
No related tags found
1 merge request!4Feature 2624
...@@ -3,6 +3,7 @@ import QtQuick.Controls 2.2 ...@@ -3,6 +3,7 @@ import QtQuick.Controls 2.2
import QtQuick.Controls.Styles 1.4 import QtQuick.Controls.Styles 1.4
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
///About property ///About property
///@hilightColor - color of the selected item ///@hilightColor - color of the selected item
///@normalColor - color of item ///@normalColor - color of item
...@@ -11,6 +12,8 @@ import QtGraphicalEffects 1.0 ...@@ -11,6 +12,8 @@ import QtGraphicalEffects 1.0
///@fontSizeComboBox - font size for the entire widget (px). ///@fontSizeComboBox - font size for the entire widget (px).
///@widthPopupComboBoxActive and @widthPopupComboBoxNormal - width of the combo box ///@widthPopupComboBoxActive and @widthPopupComboBoxNormal - width of the combo box
/// in the active state and in the normal state /// 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 ///@sidePaddingActive and @sidePaddingNormal - padding width of the combo box in the active state
/// and in the normal state /// and in the normal state
///@sidePaddingActive and @sidePaddingNormal - sets the indent from the edge of the right and left ///@sidePaddingActive and @sidePaddingNormal - sets the indent from the edge of the right and left
...@@ -20,20 +23,35 @@ import QtGraphicalEffects 1.0 ...@@ -20,20 +23,35 @@ 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 /// - 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 ///@indicatorImageNormal and @indicatorImageActive - indicator picture address for active and normal state
///@indicatorWidth and @indicatorHeight - indicator width and height ///@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
///@colorTopNormalDropShadow - Color of the shadow effect of the combo box when minimized
///@colorDropShadow - Unboxed shadow color in expanded state
///@paddingTopItemDelegate - indent above and below from item delegate
ComboBox { ComboBox {
property string normalColorText: "#070023" property string normalColorText: "#070023"
property string hilightColorText: "#FFFFFF" property string hilightColorText: "#FFFFFF"
property string normalColorTopText:normalColorText property string normalColorTopText:normalColorText
property string hilightColorTopText:normalColorText property string hilightColorTopText:normalColorText
property string normalColor: "#FFFFFF" property string normalColor: "#FFFFFF"
property string hilightColor: "#330F54" property string hilightColor: "#330F54"
property string normalTopColor: normalColor
property string hilightTopColor: normalColor
property int fontSizeComboBox: 16*pt property int fontSizeComboBox: 16*pt
property int widthPopupComboBoxNormal: parent.width property int widthPopupComboBoxNormal: parent.width
property int widthPopupComboBoxActive: widthPopupComboBoxNormal property int widthPopupComboBoxActive: widthPopupComboBoxNormal
property int heightComboBoxNormal: parent.height
property int heightComboBoxActive: heightComboBoxNormal
property int sidePaddingNormal:16 * pt property int sidePaddingNormal:16 * pt
property int sidePaddingActive:sidePaddingNormal property int sidePaddingActive:sidePaddingNormal
...@@ -43,46 +61,79 @@ ComboBox { ...@@ -43,46 +61,79 @@ ComboBox {
property int bottomIndentNormal:14 * pt property int bottomIndentNormal:14 * pt
property int bottomIndentActive:bottomIndentNormal property int bottomIndentActive:bottomIndentNormal
property int paddingTopItemDelegate:8 * pt
property int paddingBottomItemDelegate:paddingTopItemDelegate
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 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 string indicatorImageActive: "qrc:/res/icons/ic_arrow_drop_up_dark_blue.png"
property int indicatorWidth: 24*pt property int indicatorWidth: 24*pt
property int indicatorHeight: indicatorWidth property int indicatorHeight: indicatorWidth
property string colorTopNormalDropShadow:"#00000000"
property string colorDropShadow:"#40ABABAB"
id: customComboBox id: customComboBox
width: popup.visible ? widthPopupComboBoxActive : widthPopupComboBoxNormal width: popup.visible ? widthPopupComboBoxActive : widthPopupComboBoxNormal
height: parent.height height: popup.visible ? heightComboBoxActive : heightComboBoxNormal
anchors.verticalCenter: parent.verticalCenter
delegate:ItemDelegate { delegate:ItemDelegate {
width: parent.width width: parent.width
///Adjusting the height of the line, taking into account that the second element from the end may be the last.
height:{ height:{
if(index == currentIndex) return 0 if(index != currentIndex)
else return 42*pt {
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
} }
///Text item
contentItem: Text { contentItem: Text {
id:textDelegateComboBox id:textDelegateComboBox
anchors.fill: parent anchors.fill: parent
anchors.topMargin: 8 * pt anchors.topMargin: paddingTopItemDelegate
anchors.leftMargin: popup.visible ? sidePaddingActive : sidePaddingNormal anchors.leftMargin: popup.visible ? sidePaddingActive : sidePaddingNormal
verticalAlignment: Qt.AlignTop
font.family: fontRobotoRegular.name font.family: fontRobotoRegular.name
font.pixelSize: fontSizeComboBox font.pixelSize: fontSizeComboBox
text: {if(index != currentIndex) return modelData;} text: {if(index != currentIndex) return modelData;}
color: hovered ? hilightColorText : normalColorText color: hovered ? hilightColorText : normalColorText
} }
//Indent from the bottom edge or the next line that will not stand out when you hover over the mouse
background: Rectangle { background: Rectangle {
anchors.fill: parent 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
return intervalListElement
}
color: hovered ? hilightColor : normalColor color: hovered ? hilightColor : normalColor
} //the list text
}
highlighted: parent.highlightedIndex === index highlighted: parent.highlightedIndex === index
} }
//Icon icon near the text (arrow)
indicator: Image { indicator: Image {
source: parent.popup.visible ? indicatorImageActive : indicatorImageNormal source: parent.popup.visible ? indicatorImageActive : indicatorImageNormal
width: indicatorWidth width: indicatorWidth
height: indicatorHeight height: indicatorHeight
...@@ -91,25 +142,26 @@ ComboBox { ...@@ -91,25 +142,26 @@ ComboBox {
anchors.rightMargin: popup.visible ? sidePaddingActive : sidePaddingNormal anchors.rightMargin: popup.visible ? sidePaddingActive : sidePaddingNormal
} }
///Defining the background for the main line
background: Rectangle { background: Rectangle {
anchors.fill: parent anchors.fill: parent
color: parent.popup.visible ? normalColor : "transparent" color: parent.popup.visible ? hilightTopColor : normalTopColor
radius: 2 * pt radius: 2 * pt
height: parent.height height: parent.height
} }
///Main line text settings
contentItem: Text { contentItem: Text {
anchors.fill: parent anchors.fill: parent
anchors.leftMargin: popup.visible ? sidePaddingActive : sidePaddingNormal anchors.leftMargin: popup.visible ? sidePaddingActive : sidePaddingNormal
anchors.topMargin: popup.visible ? topIndentActive : topIndentNormal
text: parent.displayText text: parent.displayText
font.family: fontRobotoRegular.name font.family: fontRobotoRegular.name
font.pixelSize: fontSizeComboBox font.pixelSize: fontSizeComboBox
color: popup.visible ? hilightColorTopText : normalColorTopText color: popup.visible ? hilightColorTopText : normalColorTopText
verticalAlignment: Text.AlignTop verticalAlignment: Text.AlignVCenter
} }
///Customize drop-down list with shadow effect
popup: Popup { popup: Popup {
y: parent.height - 1 y: parent.height - 1
width: parent.width + 1 width: parent.width + 1
...@@ -123,6 +175,7 @@ ComboBox { ...@@ -123,6 +175,7 @@ ComboBox {
background: Rectangle { background: Rectangle {
width: customComboBox.background.width width: customComboBox.background.width
color: parent.color
Rectangle { Rectangle {
id: contentCorner id: contentCorner
anchors.fill: parent anchors.fill: parent
...@@ -133,16 +186,17 @@ ComboBox { ...@@ -133,16 +186,17 @@ ComboBox {
source: contentCorner source: contentCorner
verticalOffset: 9 * pt verticalOffset: 9 * pt
samples: 13 * pt samples: 13 * pt
color: "#40000000" color: colorDropShadow
} }
} }
} }
///Shadow effect for the top element.
DropShadow { DropShadow {
anchors.fill: parent anchors.fill: if(topEffect) parent
source: background source: if(topEffect) background
verticalOffset: 9 * pt verticalOffset: if(topEffect) 9 * pt
samples: 13 * pt samples: if(topEffect) 13 * pt
color: "#40000000" color: if(topEffect) customComboBox.popup.visible ? colorDropShadow : colorTopNormalDropShadow
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment