main.qml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. This file is part of PyPass
  3. PyPass is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. import QtQuick 2.5
  15. import QtQuick.Controls 1.0
  16. import QtQuick.Layouts 1.0
  17. import QtQuick.Window 2.0
  18. ApplicationWindow {
  19. id: applicationWindow
  20. title: 'PyPass'
  21. property int margin: 10
  22. width: Screen.width
  23. height: 0.3 * Screen.height
  24. maximumHeight: 0.3 * Screen.height
  25. flags: Qt.FramelessWindowHint | Qt.Window
  26. function moveUp() {
  27. if (resultList.currentIndex > 0)
  28. resultList.currentIndex -= 1
  29. }
  30. function moveDown() {
  31. if (resultList.currentIndex < resultList.maximumIndex)
  32. resultList.currentIndex += 1
  33. }
  34. Shortcut {
  35. objectName: "escapeShortcut"
  36. sequence: "Escape"
  37. }
  38. Shortcut {
  39. objectName: "tabShortcut"
  40. sequence: "Tab"
  41. }
  42. Shortcut {
  43. sequence: "Up"
  44. onActivated: moveUp()
  45. }
  46. Shortcut {
  47. sequence: "Ctrl+K"
  48. onActivated: moveUp()
  49. }
  50. Shortcut {
  51. sequence: "Down"
  52. onActivated: moveDown()
  53. }
  54. Shortcut {
  55. sequence: "Ctrl+J"
  56. onActivated: moveDown()
  57. }
  58. ColumnLayout {
  59. anchors.fill: parent
  60. anchors.margins: margin
  61. TextField {
  62. id: searchInput
  63. objectName: "searchInputModel"
  64. font.pixelSize: 24
  65. focus: true
  66. onFocusChanged: {
  67. focus = true
  68. }
  69. Layout.fillWidth: true
  70. }
  71. ScrollView {
  72. Layout.fillHeight: true
  73. Layout.fillWidth: true
  74. ListView {
  75. id: resultList
  76. objectName: "resultListModel"
  77. property int maximumIndex: resultListModelMaxIndex
  78. property bool makeItalic: resultListModelMakeItalic
  79. model: resultListModel
  80. delegate: Component {
  81. Item {
  82. property variant itemData: model.modelData
  83. width: parent.width
  84. height: 23
  85. Column {
  86. Text {
  87. text: display
  88. textFormat: Text.PlainText
  89. font.pixelSize: 18
  90. font.italic: resultList.makeItalic && text.indexOf(' ') >= 0 ? true : false
  91. color: resultList.currentIndex === index ? "red" : "steelblue"
  92. Behavior on color { PropertyAnimation {} }
  93. }
  94. }
  95. MouseArea {
  96. objectName: "resultListMouseModel"
  97. anchors.fill: parent
  98. hoverEnabled: true
  99. onPositionChanged: {
  100. if (index <= resultListModelMaxIndex)
  101. resultList.currentIndex = index
  102. }
  103. onClicked: {
  104. if (index <= resultListModelMaxIndex)
  105. searchInput.accepted()
  106. }
  107. }
  108. }
  109. }
  110. }
  111. }
  112. ListView {
  113. id: messageListModel
  114. model: messageListModelList
  115. delegate: Text {
  116. text: display
  117. textFormat: Text.StyledText
  118. }
  119. Timer {
  120. objectName: "clearOldMessagesTimer"
  121. interval: 1000
  122. running: true
  123. repeat: true
  124. }
  125. Layout.fillWidth: true
  126. Layout.minimumHeight: contentHeight
  127. }
  128. }
  129. }