Changeset View
Changeset View
Standalone View
Standalone View
lookandfeel/contents/runcommand/RunCommand.qml
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | 61 | PlasmaComponents.TextField { | |||
---|---|---|---|---|---|
66 | Layout.minimumWidth: units.gridUnit * 25 | 66 | Layout.minimumWidth: units.gridUnit * 25 | ||
67 | 67 | | |||
68 | activeFocusOnPress: true | 68 | activeFocusOnPress: true | ||
69 | 69 | | |||
70 | onTextChanged: { | 70 | onTextChanged: { | ||
71 | root.query = queryField.text | 71 | root.query = queryField.text | ||
72 | if (allowCompletion && length > 0) { | 72 | if (allowCompletion && length > 0) { | ||
73 | var history = runnerWindow.history | 73 | var history = runnerWindow.history | ||
74 | var candidate = "" | | |||
75 | var shortest = "" | | |||
76 | 74 | | |||
75 | // search the first item in the history rather than the shortest matching one | ||||
76 | // this way more recently used entries take precedence over older ones (Bug 358985) | ||||
77 | for (var i = 0, j = history.length; i < j; ++i) { | 77 | for (var i = 0, j = history.length; i < j; ++i) { | ||
78 | var item = history[i] | 78 | var item = history[i] | ||
79 | 79 | | |||
80 | if (item.toLowerCase().indexOf(text.toLowerCase()) === 0) { | 80 | if (item.toLowerCase().indexOf(text.toLowerCase()) === 0) { | ||
81 | if (candidate.length > 0) { | | |||
82 | if (item.length < candidate.length) { | | |||
83 | candidate = item | | |||
84 | } | | |||
85 | | ||||
86 | shortest = shortest.substring(0, item.length, shortest.length) | | |||
87 | } else { | | |||
88 | candidate = item | | |||
89 | shortest = item | | |||
90 | } | | |||
91 | } | | |||
92 | } | | |||
93 | | ||||
94 | if (candidate.length > 0) { | | |||
95 | var oldText = text | 81 | var oldText = text | ||
96 | text = candidate | 82 | text = item | ||
97 | select(text.length, oldText.length) | 83 | select(text.length, oldText.length) | ||
84 | break | ||||
85 | } | ||||
98 | } | 86 | } | ||
99 | } | 87 | } | ||
100 | } | 88 | } | ||
101 | Keys.onPressed: allowCompletion = (event.key !== Qt.Key_Backspace && event.key !== Qt.Key_Delete) | 89 | Keys.onPressed: allowCompletion = (event.key !== Qt.Key_Backspace && event.key !== Qt.Key_Delete) | ||
102 | Keys.onUpPressed: { | 90 | Keys.onUpPressed: { | ||
103 | if (length === 0) { | 91 | if (length === 0) { | ||
104 | root.showHistory = true | 92 | root.showHistory = true | ||
105 | } | 93 | } | ||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |