diff --git a/CellFrameDashboardGUI/screen/DapMainApplicationWindow.qml b/CellFrameDashboardGUI/screen/DapMainApplicationWindow.qml index f7debc1002e65b20757409a9283a0349304d5a68..73e879aae951404f95164cb8539956acc544e601 100644 --- a/CellFrameDashboardGUI/screen/DapMainApplicationWindow.qml +++ b/CellFrameDashboardGUI/screen/DapMainApplicationWindow.qml @@ -23,8 +23,8 @@ DapMainApplicationWindowForm { id: modelMenuTab - Component.onCompleted: { - + Component.onCompleted: + { append({ name: qsTr("Dashboard"), page: dashboardScreen, diff --git a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanel.qml b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanel.qml index 6bfb0620aa94be82ee809256554bca6c63c48f17..fdd8fd57c56496c4cfb46a7ad0c5015d930036b6 100644 --- a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanel.qml +++ b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanel.qml @@ -2,24 +2,64 @@ import QtQuick 2.4 DapConsoleRightPanelForm { + ///@detalis commandQuery Command for history. + property string commandQuery + ///@detalis historyQuery Text of command from the command history. + property string historyQuery + ///@detalis historySize Num of history command at right panel. + property int historySize: 10 + + dapRightPanelWidth: visible ? 300 * pt : 0 * pt + ListModel { id: modelHistoryConsole ListElement { - query: "help" + query: "help1" } ListElement { - query: "wallet list" + query: "wallet list1" } ListElement { - query: "help" + query: "help2" } ListElement { - query: "wallet list" + query: "wallet list2" + } + } + + //Returns true if item 'someElement' is already exist at list 'someModel'. + function findElement(someModel, someElement) + { + console.log("someElement.query", someElement.query) + for(var i = 0; i < someModel.count; ++i) + if(someModel.get(i).query === someElement.query) + { + modelHistoryConsole.remove(i); + return true; + } + + return false; + } + + onCommandQueryChanged: + { + console.log("commandQuery", commandQuery) + //Adding only new element + if(!findElement(modelHistoryConsole, {query: commandQuery})) + { + if(commandQuery !== "") + modelHistoryConsole.insert(0, {query: commandQuery}); } + else + modelHistoryConsole.insert(0, {query: commandQuery}); + + //History is limited by historySize and realized as FIFO + if(historySize < modelHistoryConsole.count) + modelHistoryConsole.remove(modelHistoryConsole.count-1); } } diff --git a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanelForm.ui.qml b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanelForm.ui.qml index 5a7c8c0fc6e60c4f227fca206383ae629abb2182..cf57d06c387eab53e252477aaabd5d21ba91aaab 100644 --- a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanelForm.ui.qml +++ b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanelForm.ui.qml @@ -13,6 +13,7 @@ DapAbstractRightPanel { anchors.fill: parent anchors.leftMargin: 16 * pt + anchors.rightMargin: 16 * pt text: qsTr("Last actions") verticalAlignment: Qt.AlignVCenter horizontalAlignment: Text.AlignLeft @@ -54,10 +55,23 @@ DapAbstractRightPanel id: textCommand text: query color: "#070023" + width: parent.width + wrapMode: Text.Wrap font.pixelSize: 14 * pt font.family: "Roboto" font.weight: Font.Normal + //For the automatic sending selected command from history + MouseArea + { + id: historyQueryMouseArea + anchors.fill: textCommand + onDoubleClicked: historyQuery = textCommand.text + } } + //It allows to see last element of list by default + currentIndex: count - 1 + highlightFollowsCurrentItem: true + highlightRangeMode: ListView.ApplyRange } } } diff --git a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreen.qml b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreen.qml index 60a06a8bcef5b3361cdb63d57a2da74ca3f7b7e3..79fc3e6119ed07a655a5b11850a18b70cf694454 100644 --- a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreen.qml +++ b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreen.qml @@ -4,6 +4,40 @@ import QtQuick.Layouts 1.0 DapConsoleScreenForm { + ///@detalis sendCommand Text of command from the inputCommand + property string sendCommand + ///@detalis historyCommand Text of command from the command history + property string historyCommand + ///@detalis receivedAnswer Answer for the sended command + property string receivedAnswer + + + Component.onCompleted: + { + //The start point for using history + consoleHistoryIndex = modelConsoleCommand.count + } + + QtObject + { + id: themeConsole + property font inputCommandFont: + Qt.font({ + pixelSize: 18 * pt, + family: "Roboto", + styleName: "Normal", + weight: Font.Normal + }) + + property font consoleCommandFont: + Qt.font({ + pixelSize: 18 * pt, + family: "Roboto", + styleName: "Normal", + weight: Font.Normal + }) + } + ListModel { id: modelConsoleCommand @@ -12,6 +46,18 @@ DapConsoleScreenForm query: "Command" response: "This answer" } + ListElement + { + query: "Command" + response: "This answer may be very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very long" + } + ListElement + { + query: "One little query" + response: "One little response" + } + + } Component @@ -19,18 +65,59 @@ DapConsoleScreenForm id: delegateConsoleCommand Column { + width: parent.width Text { id: textQuery text: "> " + query - font.pixelSize: 14 * pt + font: themeConsole.consoleCommandFont } Text { id: textResponse text: response - font.pixelSize: 14 * pt + width: parent.width + wrapMode: Text.Wrap + font: themeConsole.consoleCommandFont + } + } + } + + //Send command from inputCommand TextArea + onSendedCommandChanged: + { + if(sendedCommand != "") + { + sendCommand = sendedCommand; + modelConsoleCommand.append({query: sendedCommand, response: receivedAnswer}); + consoleHistoryIndex = modelConsoleCommand.count; + sendedCommand = ""; + } + } + + //Send command fron right history panel + onHistoryCommandChanged: + { + sendCommand = historyCommand; + modelConsoleCommand.append({query: sendCommand, response: receivedAnswer}); + consoleHistoryIndex = modelConsoleCommand.count; + } + + //Using KeyUp and KeyDown to serf on console history + onConsoleHistoryIndexChanged: + { + if(consoleHistoryIndex >= 0) + { + if(consoleHistoryIndex >= modelConsoleCommand.count) + { + consoleHistoryIndex = modelConsoleCommand.count; + currentCommand = ""; + return; } } + else + consoleHistoryIndex = 0; + currentCommand = modelConsoleCommand.get(consoleHistoryIndex).query; + return; } } diff --git a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreenForm.ui.qml b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreenForm.ui.qml index 52a42384bbdd62fbe96d604bdb7714de443d227b..f2bf41aae63ddd92cb8102d541ab2368648bc66a 100644 --- a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreenForm.ui.qml +++ b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreenForm.ui.qml @@ -1,16 +1,31 @@ import QtQuick 2.4 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.0 +import "qrc:/widgets" import "../../" DapAbstractScreen { + id: consoleScreen + + ///@detalis sendedCommand Text of command from the inputCommand. + property string sendedCommand + ///@detalis isCommandSended Sing of sending. + property bool isCommandSended + ///@detalis currentCommand Current text in consoleCmd. + property alias currentCommand: consoleCmd.text + ///@detalis consoleHistoryIndex Index for using KeyUp and KeyDown to the navigation in console history. + property int consoleHistoryIndex + Rectangle { + id: consoleRectangle anchors.fill: parent anchors.topMargin: 24 * pt anchors.leftMargin: 20 * pt anchors.rightMargin: 20 * pt + anchors.bottomMargin: 20 * pt + ListView { @@ -18,21 +33,29 @@ DapAbstractScreen anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right - anchors.bottom: inputCommand.top + height: (contentHeight < consoleRectangle.height - inputCommand.height) ? contentHeight : consoleRectangle.height - inputCommand.height clip: true model: modelConsoleCommand delegate: delegateConsoleCommand + currentIndex: count - 1 + highlightFollowsCurrentItem: true + highlightRangeMode: ListView.ApplyRange + DapScrollViewHandling + { + id: scrollHandler + viewData: listViewConsoleCommand + scrollMouseAtArrow: consoleScroll.mouseAtArrow + } } RowLayout { id: inputCommand - spacing: 0 - - anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right + anchors.top: listViewConsoleCommand.bottom + height: consoleCmd.contentHeight Text { @@ -40,9 +63,7 @@ DapAbstractScreen verticalAlignment: Qt.AlignVCenter text: ">" color: "#070023" - font.pixelSize: 18 * pt - font.family: "Roboto" - font.weight: Font.Normal + font: themeConsole.inputCommandFont } TextArea @@ -53,10 +74,31 @@ DapAbstractScreen placeholderText: qsTr("Type here...") selectByMouse: true focus: true - font.pixelSize: 18 * pt - font.family: "Roboto" - font.weight: Font.Normal - } + font: themeConsole.inputCommandFont + Keys.onReturnPressed: text.length > 0 ? sendedCommand = text : sendedCommand = "" + Keys.onEnterPressed: text.length > 0 ? sendedCommand = text : sendedCommand = "" + Keys.onUpPressed: consoleHistoryIndex -= 1 + Keys.onDownPressed: consoleHistoryIndex += 1 + } } + + } + + DapScrollView + { + id: consoleScroll + scrollDownButtonImageSource: "qrc:/res/icons/ic_scroll-down.png" + scrollDownButtonHoveredImageSource: "qrc:/res/icons/ic_scroll-down_hover.png" + scrollUpButtonImageSource: "qrc:/res/icons/ic_scroll-up.png" + scrollUpButtonHoveredImageSource: "qrc:/res/icons/ic_scroll-up_hover.png" + viewData: listViewConsoleCommand + //Assign DapScrollView with DapScrollViewHandling which must have no parent-child relationship + onClicked: scrollHandler.scrollDirectionUp = !scrollHandler.scrollDirectionUp + scrollButtonVisible: scrollHandler.scrollVisible + scrollButtonArrowUp: scrollHandler.scrollDirectionUp + scrollButtonTopMargin: 10 * pt + scrollButtonBottomMargin: 10 * pt + scrollButtonLeftMargin: 10 * pt + scrollButtonRightMargin: 10 * pt } } diff --git a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleTab.qml b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleTab.qml index f50b551a97ff7f2ef96fb0255aca79abd7a7a0b1..aa7a4b51a1823613013094cb20dfe2a763fe0a95 100644 --- a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleTab.qml +++ b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleTab.qml @@ -1,6 +1,8 @@ import QtQuick 2.4 +import "qrc:/" DapConsoleTabForm { - + //The console interface need in command handler + // Handler answer must be set to rAnswer } diff --git a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleTabForm.ui.qml b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleTabForm.ui.qml index 4576be55a74972450548bff0658f9f908dac14f7..c27d9ef11e4c997c7022dce9a9bfa5cde0068e56 100644 --- a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleTabForm.ui.qml +++ b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleTabForm.ui.qml @@ -6,9 +6,24 @@ DapAbstractTab { id: consoleTab + ///@detalis rAnswer Answer for the sended command + property string rAnswer + dapTopPanel: DapConsoleTopPanel { } - dapScreen: DapConsoleScreen { } + dapScreen: + DapConsoleScreen + { + //Set receivedAnswer of dapScreen to the external variable rAnswer for the displaying it in console + receivedAnswer: rAnswer + //Assign historyCommand of dapScreen with dapRightPanel.historyQuery for ability to use right history panel to send command to the console + historyCommand: dapRightPanel.historyQuery + } - dapRightPanel: DapConsoleRightPanel { } + dapRightPanel: + DapConsoleRightPanel + { + //Assign commandQuery of dapRightPanel with dapScreen.sendCommand for set it to right history panelfrome console + commandQuery: dapScreen.sendCommand + } } diff --git a/libdap-qt-ui-qml b/libdap-qt-ui-qml index a86e079efd20140004ed48a36bba6c46b8efd628..5b93902e0b1197f5e1fffbb0881091341322b541 160000 --- a/libdap-qt-ui-qml +++ b/libdap-qt-ui-qml @@ -1 +1 @@ -Subproject commit a86e079efd20140004ed48a36bba6c46b8efd628 +Subproject commit 5b93902e0b1197f5e1fffbb0881091341322b541