diff --git a/widgets/DapButtonForm.ui.qml b/widgets/DapButtonForm.ui.qml index 6f2ac48f3c2c95bb0c2e1569807e7c3c7e28c5fd..b826ebc63f8c8970237d9c24ab0098f00d881e45 100644 --- a/widgets/DapButtonForm.ui.qml +++ b/widgets/DapButtonForm.ui.qml @@ -12,9 +12,9 @@ Button ///@detalis hoverImageButton The image on the Button is in the mouseover state. property string hoverImageButton ///@detalis widthImageButton Image width. - property int widthImageButton + property int widthImageButton: 0 * pt ///@detalis heightImageButton Image height. - property int heightImageButton + property int heightImageButton: 0 * pt ///@detalis indentImageLeftButton: Indentation of the image from the left edge. property int indentImageLeftButton ///@detalis colorBackgroundNormal Button background color in normal state. @@ -31,8 +31,6 @@ Button property int indentTextRight ///@detalis fontButton Font setting. property alias fontButton:buttonText.font - ///@detalis existenceImage Indicates the presence of an image. - property bool existenceImage: true ///@detalis horizontalAligmentText Horizontal alignment. property alias horizontalAligmentText:buttonText.horizontalAlignment ///@detalis colorBackgroundButton This property overrides the background color. @@ -72,12 +70,12 @@ Button Image { id: iconNewWallet - anchors.verticalCenter: if(existenceImage)parent.verticalCenter - anchors.left: if(existenceImage)parent.left - anchors.leftMargin:if(existenceImage) indentImageLeftButton - source: if(existenceImage) dapButton.hovered ? hoverImageButton : normalImageButton - width: if(existenceImage)widthImageButton - height:if(existenceImage) heightImageButton + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: indentImageLeftButton + source: dapButton.hovered ? hoverImageButton : normalImageButton + width: widthImageButton + height: heightImageButton } } } diff --git a/widgets/DapComboBox.qml b/widgets/DapComboBox.qml index ecc68f9ecbc1e631e166708dc82ee2bd3896a649..3698dd704e05b57b625c5be5dd3762211e12358a 100644 --- a/widgets/DapComboBox.qml +++ b/widgets/DapComboBox.qml @@ -3,96 +3,109 @@ import QtQuick.Controls 2.0 DapComboBoxForm { - id:dapComboBox + delegate: + ItemDelegate + { + width: parent.width - delegate:ItemDelegate - { - - width: parent.width - - //Adjusting the height of the line, taking into account that the second element from the end may be the last - height:{ - if(index != currentIndex) - { - if(index == (count - 2)) - { - if(index+1 == currentIndex) return heightListElement + bottomIntervalListElement - else return heightListElement + intervalListElement - } - if (index == count - 1) return heightListElement + bottomIntervalListElement - return heightListElement + intervalListElement - } - else return 0 - } - //Text item - contentItem: Text { - id:textDelegateComboBox - anchors.fill: parent - anchors.topMargin: paddingTopItemDelegate - anchors.leftMargin: popup.visible ? sidePaddingActive : sidePaddingNormal - anchors.rightMargin: popup.visible ? sidePaddingActive : sidePaddingNormal - font:dapComboBox.font - //Calculates various properties of a given string of text for a particular font - TextMetrics - { - id: tm - font: dapComboBox.font - elide: Text.ElideRight - text: modelData - elideWidth: + //Adjusting the height of the line, taking into account that the second element from the end may be the last + height: { if(index != currentIndex) - return widthPopupComboBoxActive - 2*sidePaddingActive; - else - return widthPopupComboBoxNormal - indicatorWidth - indicatorLeftInterval; + { + if(index == (count - 2)) + { + if(index+1 == currentIndex) + return heightListElement + bottomIntervalListElement + else + return heightListElement + intervalListElement + } + if (index == count - 1) + return heightListElement + bottomIntervalListElement + return heightListElement + intervalListElement + } + else return 0 } - } - FontMetrics - { - id: fm - font: dapComboBox.font - } - text: - { - if(index != currentIndex) - { - if(tm.elidedText.length < tm.text.length) - return tm.elidedText.substring(0, tm.elidedText.length-1) + - ((fm.tightBoundingRect(tm.elidedText.substring(0, tm.elidedText.length-1)).width + fm.tightBoundingRect(tm.text.charAt(tm.elidedText.length-1) + '..').width) < tm.elideWidth ? - (tm.text.charAt(tm.elidedText.length-1) + '..') - : '..'); - return tm.elidedText.replace('…', '..'); - } - else + + //Text item + contentItem: + Text { - if(tm.elidedText.length < tm.text.length) - mainLineText = tm.elidedText.substring(0, tm.elidedText.length-1) + - ((fm.tightBoundingRect(tm.elidedText.substring(0, tm.elidedText.length-1)).width + fm.tightBoundingRect(tm.text.charAt(tm.elidedText.length-1) + '..').width) < tm.elideWidth ? - (tm.text.charAt(tm.elidedText.length-1) + '..') - : '..'); - else - mainLineText = tm.elidedText.replace('…', '..'); - return ""; + id:textDelegateComboBox + anchors.fill: parent + anchors.topMargin: paddingTopItemDelegate + anchors.leftMargin: popup.visible ? sidePaddingActive : sidePaddingNormal + anchors.rightMargin: popup.visible ? sidePaddingActive : sidePaddingNormal + font: fontComboBox + + //Calculates various properties of a given string of text for a particular font + TextMetrics + { + id: tm + font: fontComboBox + elide: Text.ElideRight + text: modelData + elideWidth: + { + if(index != currentIndex) + return widthPopupComboBoxActive - 2*sidePaddingActive; + else + return widthPopupComboBoxNormal - indicatorWidth - indicatorLeftInterval; + } + } + FontMetrics + { + id: fm + font: fontComboBox + } + text: + { + if(index != currentIndex) + { + if(tm.elidedText.length < tm.text.length) + return tm.elidedText.substring(0, tm.elidedText.length-1) + + ((fm.tightBoundingRect(tm.elidedText.substring(0, tm.elidedText.length-1)).width + + fm.tightBoundingRect(tm.text.charAt(tm.elidedText.length-1) + '..').width) < tm.elideWidth ? + (tm.text.charAt(tm.elidedText.length-1) + '..') + : '..'); + return tm.elidedText.replace('…', '..'); + } + else + { + if(tm.elidedText.length < tm.text.length) + mainLineText = tm.elidedText.substring(0, tm.elidedText.length-1) + + ((fm.tightBoundingRect(tm.elidedText.substring(0, tm.elidedText.length-1)).width + + fm.tightBoundingRect(tm.text.charAt(tm.elidedText.length-1) + '..').width) < tm.elideWidth ? + (tm.text.charAt(tm.elidedText.length-1) + '..') + : '..'); + else + mainLineText = tm.elidedText.replace('…', '..'); + return ""; + } + } + 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 { - anchors.fill: parent - anchors.bottomMargin: { - if(index == count - 2) + //Indent from the bottom edge or the next line that will not stand out when you hover over the mouse + background: + Rectangle { - if(index+1 == currentIndex) return bottomIntervalListElement - else return intervalListElement + anchors.fill: parent + anchors.bottomMargin: { + if(index == count - 2) + { + if(index+1 == currentIndex) + return bottomIntervalListElement + else + return intervalListElement + } + if (index == count - 1) + return bottomIntervalListElement + return intervalListElement + } + color: hovered ? hilightColor : normalColor } - if (index == count - 1) return bottomIntervalListElement - return intervalListElement - } - color: hovered ? hilightColor : normalColor + highlighted: parent.highlightedIndex === index } - highlighted: parent.highlightedIndex === index - } } diff --git a/widgets/DapComboBoxForm.ui.qml b/widgets/DapComboBoxForm.ui.qml index 273913a2170d364ad1966cfcc652992b11b5c2b5..19cb3a1139994f6ab6a40670932e06a0befb4804 100644 --- a/widgets/DapComboBoxForm.ui.qml +++ b/widgets/DapComboBoxForm.ui.qml @@ -5,6 +5,8 @@ import QtGraphicalEffects 1.0 ComboBox { + id: dapComboBox + ///@detalis normalColorText Text color in normal state. property string normalColorText ///@detalis hilightColorText Text color in selected state. @@ -51,18 +53,17 @@ ComboBox property int indicatorWidth ///@detalis indicatorHeight Indicator height. property int indicatorHeight - ///@detalis indicatorLeftInterval Space between indicator border and text border + ///@detalis indicatorLeftInterval Space between indicator border and text border. property int indicatorLeftInterval /// colorTopNormalDropShadow Color of the shadow effect of the combo box when minimized. property string colorTopNormalDropShadow ///@detalis colorDropShadow Unboxed shadow color in expanded state. property string colorDropShadow ///@detalis fontComboBox Font setting combobox. - property alias fontComboBox:customComboBox.font - ///@detalis mainLineText Text without unneccesary part + property alias fontComboBox: dapComboBox.font + ///@detalis mainLineText Text without unneccesary part. property string mainLineText - id: customComboBox width: popup.visible ? widthPopupComboBoxActive : widthPopupComboBoxNormal height: popup.visible ? heightComboBoxActive : heightComboBoxNormal anchors.verticalCenter: parent.verticalCenter @@ -88,6 +89,7 @@ ComboBox radius: 2 * pt height: parent.height } + //Main line text settings contentItem: Text @@ -113,14 +115,14 @@ ComboBox { clip: true implicitHeight: contentHeight - model: customComboBox.popup.visible ? customComboBox.delegateModel : null + model: dapComboBox.popup.visible ? dapComboBox.delegateModel : null ScrollIndicator.vertical: ScrollIndicator {} } background: Rectangle { - width: customComboBox.background.width + width: dapComboBox.background.width color: normalColor Rectangle { @@ -153,7 +155,7 @@ ComboBox 13 * pt else 0 color: if (topEffect) - customComboBox.popup.visible ? colorDropShadow : colorTopNormalDropShadow - else "#00000000" + dapComboBox.popup.visible ? colorDropShadow : colorTopNormalDropShadow + else "#000000" } }