diff --git a/libdap-qt-ui-qml.qrc b/libdap-qt-ui-qml.qrc index ee0c2a1e768eee5bad5d3e11fe1fef786814a388..5b942bf72ea281de47c05e1b39f32fbedc551d52 100644 --- a/libdap-qt-ui-qml.qrc +++ b/libdap-qt-ui-qml.qrc @@ -25,5 +25,7 @@ <file>widgets/DapText.qml</file> <file>widgets/DapTextForm.ui.qml</file> <file>widgets/DapScrollViewHandling.qml</file> + <file>widgets/DapMessageBox.qml</file> + <file>widgets/DapMessageBoxForm.ui.qml</file> </qresource> </RCC> diff --git a/widgets/DapComboBox.qml b/widgets/DapComboBox.qml index 1aa258e39ec6ce29d2a533c79ea39315e71d6a72..ee809d5ea2bd8dd9614d5a48123e4b9d0ea559ee 100644 --- a/widgets/DapComboBox.qml +++ b/widgets/DapComboBox.qml @@ -29,70 +29,104 @@ DapComboBoxForm //Text item contentItem: - Text + Rectangle { - id:textDelegateComboBox + id: rectangleTextComboBox anchors.fill: parent anchors.topMargin: paddingTopItemDelegate anchors.leftMargin: popup.visible ? sidePaddingActive : sidePaddingNormal anchors.rightMargin: popup.visible ? sidePaddingActive : sidePaddingNormal - font: fontComboBox + color: "transparent" + + property int comboBoxIndex: index + property int comboBoxCurrentIndex: currentIndex - //Calculates various properties of a given string of text for a particular font - TextMetrics - { - id: tm - font: fontComboBox - elide: Text.ElideRight - text: model[comboBoxTextRole] - elideWidth: - { - if(index != currentIndex) - return widthPopupComboBoxActive - 2*sidePaddingActive; - else - return widthPopupComboBoxNormal - indicatorWidth - indicatorLeftInterval; - } - } FontMetrics { - id: fm - font: fontComboBox + id: comboBoxFontMetric } - text: + + Row + { + id: textRow + width: rectangleTextComboBox.width - ((index != currentIndex) ? + endRowPadding : + (indicatorWidth + indicatorLeftInterval) + ) + height: rectangleTextComboBox.height + spacing: roleInterval + property var elTextArray: [] + + Repeater { - 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 + id: textRepeater + model: comboBoxTextRole.length + + DapText { - 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: textComboBoxDelegate + width: (textRow.width - roleInterval * (comboBoxTextRole.length - 1)) / comboBoxTextRole.length + enabled: false + fontDapText: (fontComboBox.length > index) ? + fontComboBox[index] : + fontComboBox[0]; + textColor: hovered ? colorTextComboBox[index][1] : colorTextComboBox[index][0] + fullText: getModelData(rectangleTextComboBox.comboBoxIndex, comboBoxTextRole[index]) + textElide: (elideTextComboBox.length > index) ? + elideTextComboBox[index] : + elideTextComboBox[0]; + horizontalAlignment: (alignTextComboBox.length > index) ? + alignTextComboBox[index] : + alignTextComboBox[0]; + onElTextChanged: textRow.elTextArray[index] = elText + + Component.onCompleted: + { + if(rectangleTextComboBox.comboBoxIndex == rectangleTextComboBox.comboBoxCurrentIndex) + { + + var tmp = mainRow; + tmp[index] = elText; + mainRow = tmp; + + if(index == 0) + { + comboBoxFontMetric.font = (fontComboBox.length > index) ? + fontComboBox[index] : + fontComboBox[0]; + mainLineText = comboBoxFontMetric.elidedText(fullText, Text.ElideRight, rectangleTextComboBox.width, Qt.TextShowMnemonic); + } + } + } + } + } - color: hovered ? hilightColorText : normalColorText + + } + Component.onCompleted: + { + if(rectangleTextComboBox.comboBoxCurrentIndex !== -1) + updateMainRow(comboBoxFontMetric, rectangleTextComboBox.comboBoxIndex, rectangleTextComboBox.comboBoxCurrentIndex, textRow.elTextArray, (widthPopupComboBoxNormal - indicatorWidth - indicatorLeftInterval)); + + } + onComboBoxCurrentIndexChanged: + { + if(rectangleTextComboBox.comboBoxCurrentIndex !== -1) + updateMainRow(comboBoxFontMetric, rectangleTextComboBox.comboBoxIndex, rectangleTextComboBox.comboBoxCurrentIndex, textRow.elTextArray, rectangleTextComboBox.width); + + } } + //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: { + anchors.bottomMargin: + { if(index == count - 2) { if(index+1 == currentIndex) @@ -108,4 +142,31 @@ DapComboBoxForm } highlighted: parent.highlightedIndex === index } + + + function getModelData(rowIndex, modelRole) + { + return model.get(rowIndex)[modelRole]; + } + + function updateMainRow(fm, cbIndex, cbCurrentIndex, elTextArray, width) + { + if(cbIndex === cbCurrentIndex) + { + for(var i = 0; i < comboBoxTextRole.length; i++) + { + fm.font = (fontComboBox.length > i) ? + fontComboBox[i] : + fontComboBox[0]; + + var tmp = mainRow; + tmp[i] = elTextArray[i]; + mainRow = tmp; + + if(i == 0) + mainLineText = fm.elidedText(getModelData(cbCurrentIndex, comboBoxTextRole[0]), Text.ElideRight, width, Qt.TextShowMnemonic); + } + } + } + } diff --git a/widgets/DapComboBoxForm.ui.qml b/widgets/DapComboBoxForm.ui.qml index 8df56df1ef7bd57c1922db3bfb3736d670353d74..80ca3731f79ef23ab51076fd61f4c3a64ae8eba7 100644 --- a/widgets/DapComboBoxForm.ui.qml +++ b/widgets/DapComboBoxForm.ui.qml @@ -1,5 +1,5 @@ import QtQuick 2.0 -import QtQuick.Controls 2.2 +import QtQuick.Controls 2.0 import QtQuick.Controls.Styles 1.4 import QtGraphicalEffects 1.0 @@ -7,7 +7,6 @@ ComboBox { id: dapComboBox - property string comboBoxTextRole ///@detalis normalColorText Text color in normal state. property string normalColorText ///@detalis hilightColorText Text color in selected state. @@ -60,12 +59,32 @@ ComboBox property string colorTopNormalDropShadow ///@detalis colorDropShadow Unboxed shadow color in expanded state. property string colorDropShadow + ///@detalis fontComboBox Font setting combobox. - property alias fontComboBox: dapComboBox.font - ///@detalis mainLineText Text without unneccesary part. + property var fontComboBox: [] + ///@detalis colorTextComboBox Color text setting combobox: array [normalColorText, hilightColorText] for every role + property var colorTextComboBox: [] + ///@detalis colorMainTextComboBox Color mainline text setting combobox: array [normalTopColorText, hilightTopColorText] for every role + property var colorMainTextComboBox: [] + ///@detalis elideTextComboBox Elide setting combobox. + property var elideTextComboBox: [Text.ElideRight] + ///@detalis alignTextComboBox Align setting combobox. + property var alignTextComboBox: [Text.AlignLeft] + + ///@detalis comboBoxTextRole The model roles used for the ComboBox. + property var comboBoxTextRole: ["text"] + ///@detalis comboBoxTextRoleWidth The model roles width used for the ComboBox. + property var comboBoxTextRoleWidth: [100] + ///@detalis roleInterval The width between text of model roles used for the ComboBox. + property int roleInterval: 10 + ///@detalis endRowPadding The width of padding at the end of one row at ComboBox where it is need. + property int endRowPadding: 10 + + ///@detalis mainRow The model role for the main line of cloded ComboBox. + property var mainRow: [""] + //@detalis mainLineText Text without unneccesary part. property string mainLineText - textRole: comboBoxTextRole width: popup.visible ? widthPopupComboBoxActive : widthPopupComboBoxNormal height: popup.visible ? heightComboBoxActive : heightComboBoxNormal anchors.verticalCenter: parent.verticalCenter @@ -93,16 +112,51 @@ ComboBox //Main line text settings contentItem: - Text + Rectangle { + id: mainRectangle anchors.fill: parent + anchors.verticalCenter: parent.verticalCenter anchors.leftMargin: popup.visible ? sidePaddingActive : sidePaddingNormal - text: mainLineText - font: parent.font - color: popup.visible ? hilightColorTopText : normalColorTopText - verticalAlignment: Text.AlignVCenter + color: "transparent" + + Row + { + id: topComboBoxRow + width: widthPopupComboBoxNormal - indicatorWidth - indicatorLeftInterval + height: mainRectangle.height + spacing: roleInterval + Repeater + { + id: textCurrentRepeater + model: (popup.visible) ? comboBoxTextRole.length : 1 + Text + { + anchors.verticalCenter: parent.verticalCenter + text: (popup.visible) ? + (index < mainRow.length ? mainRow[index] : ""): + mainLineText + font: popup.visible ? + ((fontComboBox.length > index) ? + fontComboBox[index] : + fontComboBox[0] + ) : + fontComboBox[0]; + width: popup.visible ? + (topComboBoxRow.width - roleInterval * (comboBoxTextRole.length - 1)) / comboBoxTextRole.length : + contentWidth + color: popup.visible ? + colorMainTextComboBox[index][1] : + colorMainTextComboBox[index][0] + horizontalAlignment: popup.visible ? + alignTextComboBox[index] : + Text.AlignLeft + } + } + } } + //Customize drop-down list with shadow effect popup: Popup @@ -113,6 +167,7 @@ ComboBox contentItem: ListView { + id: popupList clip: true implicitHeight: contentHeight model: dapComboBox.popup.visible ? dapComboBox.delegateModel : null @@ -149,5 +204,6 @@ ComboBox verticalOffset: topEffect ? 9 * pt : 0 samples: topEffect ? 13 * pt : 0 color: topEffect ? (dapComboBox.popup.visible ? colorDropShadow : colorTopNormalDropShadow) : "#000000" + z: -1 } } diff --git a/widgets/DapMessageBox.qml b/widgets/DapMessageBox.qml new file mode 100644 index 0000000000000000000000000000000000000000..46220cec3996b6662a6eb8ddcafc2f000cc66efa --- /dev/null +++ b/widgets/DapMessageBox.qml @@ -0,0 +1,6 @@ +import QtQuick 2.4 + +DapMessageBoxForm +{ + +} diff --git a/widgets/DapMessageBoxForm.ui.qml b/widgets/DapMessageBoxForm.ui.qml new file mode 100644 index 0000000000000000000000000000000000000000..c16711ade7a9ee49ceed2064505f88fffdc88fb7 --- /dev/null +++ b/widgets/DapMessageBoxForm.ui.qml @@ -0,0 +1,99 @@ +import QtQuick 2.4 +import QtQuick.Controls 2.0 +import QtGraphicalEffects 1.0 + +Rectangle +{ + id: dapMessageBox + + property alias dapTitleText: titleText + property alias dapContentText: contentText + property alias dapButtonOk: buttonOk + + layer.enabled: true + layer.effect: + DropShadow + { + horizontalOffset: 3 + verticalOffset: 3 + radius: 13 + samples: 17 + color: "#ababab" + } + + Rectangle + { + id: frameTitle + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + height: 44 * pt + color: "#908D9D" + + Text + { + id: titleText + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.right: parent.right + anchors.leftMargin: 30 * pt + anchors.rightMargin: 30 * pt + font.pixelSize: 16 * pt + font.family: "Roboto" + font.styleName: "Normal" + font.weight: Font.Normal + color: "#FFFFFF" + } + } + + Rectangle + { + id: frameContent + anchors.top: frameTitle.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.topMargin: 30 * pt + anchors.leftMargin: 30 * pt + anchors.rightMargin: 30 * pt + anchors.bottomMargin: 32 * pt + height: 172 * pt + color: "#FFFFFF" + + Text + { + id: contentText + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: buttonOk.top + font.pixelSize: 16 * pt + font.family: "Roboto" + font.styleName: "Normal" + font.weight: Font.Normal + color: "#070023" + wrapMode: Text.WordWrap + } + + DapButton + { + id: buttonOk + widthButton: 78 * pt + heightButton: 36 * pt + anchors.right: parent.right + anchors.bottom: parent.bottom + textButton: qsTr("OK") + colorBackgroundNormal:"#3E3853" + colorBackgroundHover: "#D51F5D" + colorButtonTextNormal: "#FFFFFF" + colorButtonTextHover: "#FFFFFF" + fontButton.pixelSize: 14 * pt + borderColorButton: "#FFFFFF" + borderWidthButton: 0 + fontButton.family: "Roboto" + fontButton.weight: Font.Normal + horizontalAligmentText:Qt.AlignCenter + colorTextButton: "#FFFFFF" + } + } +} diff --git a/widgets/DapScrollViewHandling.qml b/widgets/DapScrollViewHandling.qml index 5da84b5dcc54ab61aa103ad3025e192868ad1ba7..8e4ffc53d0fe2b743b4cd0110424eca3973dfc1b 100644 --- a/widgets/DapScrollViewHandling.qml +++ b/widgets/DapScrollViewHandling.qml @@ -21,14 +21,17 @@ MouseArea //If mouse pointer go to parent area onEntered: { - //ScrollButton is needed to be visible only if list lenght more than its height - scrollVisible = viewData.contentHeight > viewData.height; - //If user see the first element - if(viewData.atYBeginning) - scrollDirectionUp = false; - //If user see the last element - if(viewData.atYEnd) - scrollDirectionUp = true; + if(containsMouse) + { + //ScrollButton is needed to be visible only if list lenght more than its height + scrollVisible = viewData.contentHeight > viewData.height; + //If user see the first element + if(viewData.atYBeginning) + scrollDirectionUp = false; + //If user see the last element + if(viewData.atYEnd) + scrollDirectionUp = true; + } } //If mouse pointer go out the parent area diff --git a/widgets/DapTabForm.ui.qml b/widgets/DapTabForm.ui.qml index 778f4fe592095d077f020acdf96075691a7dde20..a5d6ee609a43b4d2569c57d5bcc8ca2292267196 100644 --- a/widgets/DapTabForm.ui.qml +++ b/widgets/DapTabForm.ui.qml @@ -1,4 +1,4 @@ -//**************************************************************************** +//**************************************************************************** // Implements a general view of the tab. //**************************************************************************** @@ -20,6 +20,8 @@ Rectangle ///@detalis Tab frame. property alias dapFrame: frameTab + property alias rightPanel: rightPanel + anchors.fill: parent // Install the top panel widget diff --git a/widgets/DapText.qml b/widgets/DapText.qml index 3ca718a4455e20c0a2660b515989f20561105e7f..3718df584dd48088c6a29b4ed8cb95ccf40c89a5 100644 --- a/widgets/DapText.qml +++ b/widgets/DapText.qml @@ -2,60 +2,69 @@ import QtQuick 2.4 DapTextForm { - onTextChanged: - { - elidedText = (width > 2) ? elideByWidth(width) : (maxSymbolCapacity > 2) ? elideByCapacity(maxSymbolCapacity) : text - width = _metrics.boundingRect(elidedText).width - height = _metrics.boundingRect(elidedText).height - } + textMetric.elideWidth: width - // "Copy Button" handler - function copy() + //Text eliding is available only after full item boot + //with all metrics - to delete binding loop + Component.onCompleted: { - _fullText.selectAll() - _fullText.copy() + checkTextElide(); } + //If it needed the dynamic width change + onWidthChanged: checkTextElide() - // Elides text by number of symbols - function elideByCapacity(maxSymbols) + //Function to elide text and check result + function checkTextElide() { - var res = "" - if (text.length > maxSymbols) + if(textMetric.elideWidth < fontMetric.tightBoundingRect(textMetric.text).width) { - switch (elide) + switch(textElide) { - case Qt.ElideLeft: - res = ".." + text.slice(-maxSymbols, text.length-1) - break - case Qt.ElideMiddle: - res = text.slice(0, Math.floor(maxSymbols/2)) + ".." + text.slice(Math.floor(maxSymbols/2) + 1, text.length-1) - break - case Qt.ElideRight: - res = text.slice(0, maxSymbols) + ".." - break - default: - res = text - break + case Text.ElideRight: + elText = textMetric.elidedText.substring(0, textMetric.elidedText.length - 1) + + ((fontMetric.tightBoundingRect(textMetric.elidedText.substring(0, textMetric.elidedText.length - 1)).width + + fontMetric.tightBoundingRect(textMetric.text.charAt(textMetric.elidedText.length - 1) + '..').width) < textMetric.elideWidth ? + (textMetric.text.charAt(textMetric.elidedText.length - 1) + '..'): + '..'); + break; + + case Text.ElideLeft: + elText = '..' + ((fontMetric.tightBoundingRect(textMetric.elidedText.substring(1, textMetric.elidedText.length - 1)).width + + fontMetric.tightBoundingRect('..' + textMetric.text.charAt(textMetric.text.length - textMetric.elidedText.length)).width) < textMetric.elideWidth ? + (textMetric.text.charAt(textMetric.text.length - textMetric.elidedText.length)): + '') + textMetric.elidedText.substring(1, textMetric.elidedText.length - 1); + + break; + + case Text.ElideMiddle: + elText = textMetric.elidedText.substring(0, textMetric.elidedText.indexOf('…')) + + ((fontMetric.tightBoundingRect(textMetric.elidedText.substring(0, textMetric.elidedText.indexOf('…'))).width + + fontMetric.tightBoundingRect(textMetric.text.charAt(textMetric.elidedText.indexOf('…')) + '..').width + + fontMetric.tightBoundingRect(textMetric.elidedText.substring(textMetric.elidedText.indexOf('…') + 1, textMetric.elidedText.length)).width) < textMetric.elideWidth ? + (textMetric.text.charAt(textMetric.elidedText.indexOf('…')) + '..'): + '..') + + textMetric.elidedText.substring(textMetric.elidedText.indexOf('…') + 1, textMetric.elidedText.length); + break; + + case Text.ElideNone: + elText = fullText; } + } else - { - res = text - } - return res + elText = textMetric.elidedText.replace('…', '..'); } - // Elides text by width - function elideByWidth(maxWidth) + //Function to copy full text to the clipboard + function copyFullText() { - if (_metrics.advanceWidth(text) > maxWidth) - { - var symbolsNum = (maxWidth / _metrics.averageCharacterWidth) - return elideByCapacity(Math.floor(symbolsNum)) - } - else - { - return text - } + //Replace elide text by full text and select it + text = fullText; + selectAll(); + //Because this method can copy only selected text + copy(); + // User should not see it! + deselect(); + text = elText; } } diff --git a/widgets/DapTextForm.ui.qml b/widgets/DapTextForm.ui.qml index ea18b880fe65f5aa5e653b224fab502804a531fe..875b42725e609a361490cd296b55206616fb8dbb 100644 --- a/widgets/DapTextForm.ui.qml +++ b/widgets/DapTextForm.ui.qml @@ -1,43 +1,41 @@ import QtQuick 2.4 -import QtQuick.Controls 2.2 +import QtQuick.Controls 2.0 -Item +TextInput { id: dapText - ///@details Text. - property alias text: fullText.text - ///@details Text color. - property alias color: elidedText.color - ///@details Font. - property alias font: elidedText.font - ///@details Elide style. - property int elide: Qt.ElideRight - ///@details The number of symbols to display. - property int maxSymbolCapacity: 0 - ///@details Text to display. - property alias elidedText: elidedText.text + ///@detalis fullText Full text string + property string fullText + ///@detalis elText Elided text string + property string elText + ////@detalis fontDapText Font setting combobox. + property font fontDapText + ///@details elide Elide style. + property int textElide: Text.ElideRight + ///@detalis textMetric Text Metric to elide text + property alias textMetric: dapTextInputTextMetric + ///@detalis fontMetric Font Metric to check elided text + property alias fontMetric: dapTextInputFontMetric + ///@detalis textColor Color of text + property color textColor - property alias _fullText: fullText - property alias _metrics: metrics - - // Displays the text - Text - { - id: elidedText - } - - // Calculates elide - FontMetrics + font: fontDapText + color: textColor + //To do elide + TextMetrics { - id: metrics - font: parent.font + id: dapTextInputTextMetric + font: fontDapText + elide: textElide + text: fullText } - // Stores full string to copy - TextInput + // To check elide + FontMetrics { - id: fullText - visible: false + id: dapTextInputFontMetric + font: fontDapText } + text: elText }