diff --git a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanel.qml b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanel.qml index 45975e5335c1e71ee552574fd758b31579d71760..993d7af309dc753147e87f79036fb9260c9cf9bf 100644 --- a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanel.qml +++ b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanel.qml @@ -7,6 +7,8 @@ DapConsoleRightPanelForm property string commandQuery ///@detalis historyQuery Text of command from the command history. property string historyQuery + ///@detalis historyQueryIndex Index of command from the command history. + property string historyQueryIndex ///@detalis historySize Num of history command at right panel. property int historySize: 10 @@ -23,7 +25,6 @@ DapConsoleRightPanelForm //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) { @@ -36,22 +37,28 @@ DapConsoleRightPanelForm 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); + } + + //Handler for the doubleClick on right history panel + onHistoryQueryIndexChanged: + { + if(historyQueryIndex > -1) + { + historyQuery = modelHistoryConsole.get(historyQueryIndex).query; + historyQueryIndex = -1; + historyQuery = "" } } } diff --git a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanelForm.ui.qml b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanelForm.ui.qml index cf57d06c387eab53e252477aaabd5d21ba91aaab..734e06a8f1b2a6860fdf10fb8eeeeb8a89f092f0 100644 --- a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanelForm.ui.qml +++ b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanelForm.ui.qml @@ -65,7 +65,7 @@ DapAbstractRightPanel { id: historyQueryMouseArea anchors.fill: textCommand - onDoubleClicked: historyQuery = textCommand.text + onDoubleClicked: historyQueryIndex = index } } //It allows to see last element of list by default diff --git a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreen.qml b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreen.qml index c62d0bc1dbe8445d1716ef72b425b331285996b6..1668bffec46718a46e031a9e584f0c59df7b1d18 100644 --- a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreen.qml +++ b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreen.qml @@ -19,6 +19,8 @@ DapConsoleScreenForm { //The start point for using history consoleHistoryIndex = modelConsoleCommand.count + //Set focus to console input + consoleInput.forceActiveFocus() } QtObject @@ -75,19 +77,21 @@ DapConsoleScreenForm if(sendedCommand != "") { sendCommand = sendedCommand; - consoleHistoryIndex = modelConsoleCommand.count; + consoleHistoryIndex = modelConsoleCommand.count + 1; runCommand(sendCommand) sendedCommand = ""; currentCommand = sendedCommand; } + } //Send command fron right history panel onHistoryCommandChanged: { sendCommand = historyCommand; - runCommand(sendCommand) - consoleHistoryIndex = modelConsoleCommand.count; + runCommand(sendCommand); + consoleHistoryIndex = modelConsoleCommand.count + 1; + consoleInput.forceActiveFocus(); } //Using KeyUp and KeyDown to serf on console history @@ -97,7 +101,6 @@ DapConsoleScreenForm { if(consoleHistoryIndex >= modelConsoleCommand.count) { - consoleHistoryIndex = modelConsoleCommand.count; currentCommand = ""; return; } @@ -107,4 +110,5 @@ DapConsoleScreenForm 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 f2bf41aae63ddd92cb8102d541ab2368648bc66a..8a11636f97ace1130ce3a0a5a70707a67ea0df47 100644 --- a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreenForm.ui.qml +++ b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreenForm.ui.qml @@ -16,6 +16,8 @@ DapAbstractScreen property alias currentCommand: consoleCmd.text ///@detalis consoleHistoryIndex Index for using KeyUp and KeyDown to the navigation in console history. property int consoleHistoryIndex + ///@detalis consoleInput Reference to console input area + property alias consoleInput: consoleCmd Rectangle { @@ -26,20 +28,22 @@ DapAbstractScreen anchors.rightMargin: 20 * pt anchors.bottomMargin: 20 * pt - ListView { id: listViewConsoleCommand anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right - height: (contentHeight < consoleRectangle.height - inputCommand.height) ? contentHeight : consoleRectangle.height - inputCommand.height + 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 @@ -75,13 +79,20 @@ DapAbstractScreen selectByMouse: true focus: true 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 - } + Keys.onReturnPressed: text.length > 0 ? + sendedCommand = text : + sendedCommand = "" + Keys.onEnterPressed: text.length > 0 ? + sendedCommand = text : + sendedCommand = "" + Keys.onUpPressed: (consoleHistoryIndex > 0) ? + consoleHistoryIndex -= 1 : + null + Keys.onDownPressed: (consoleHistoryIndex < modelConsoleCommand.count) ? + consoleHistoryIndex += 1 : + null + } } - } DapScrollView