RepositoryView.qml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. import QtQuick 2.0
  2. import QtQuick.Controls 1.4
  3. import org.semlanik.cutegit 1.0
  4. FocusScope {
  5. id: root
  6. anchors.fill: parent
  7. TopBar {
  8. id: topBar
  9. onCloseClicked: {
  10. _handler.diffReset()
  11. commitPlane.commit = null
  12. commitList.state = "full"
  13. commitList.activeCommit = null
  14. }
  15. closeVisible: commitPlane.diff != null
  16. }
  17. Rectangle {
  18. id: bg
  19. color: "#eeeeee"
  20. anchors.fill: commitList
  21. }
  22. CommitList {
  23. id: commitList
  24. anchors.top: topBar.bottom
  25. anchors.bottom: consoleContol.top
  26. anchors.left: parent.left
  27. commitsModel: _handler.commits
  28. graphModel: _handler.graph
  29. onCommitClicked: {
  30. if(commit == null) {
  31. commitPlane.commit = null
  32. _handler.diff()
  33. commitList.state = "commitsOnly"
  34. return;
  35. }
  36. if(commit.diff === null) {
  37. commitPlane.commit = null
  38. _handler.diffReset()
  39. commitList.state = "full"
  40. return
  41. }
  42. commitList.state = "commitsOnly"
  43. if(!root.controlActive) {
  44. commitPlane.commit = commit
  45. root.commitsForDiff=[]
  46. } else {
  47. console.log("root.controlActive: " + root.controlActive)
  48. if(root.commitsForDiff === null) {
  49. root.commitsForDiff = new Array(0);
  50. }
  51. console.log("Length" + root.commitsForDiff.length)
  52. root.commitsForDiff.push(commit)
  53. if(root.commitsForDiff.length === 2) {
  54. commitPlane.commit = root.commitsForDiff[1]
  55. _handler.diff(root.commitsForDiff[0], root.commitsForDiff[1])
  56. root.commitsForDiff=[]
  57. }
  58. }
  59. }
  60. }
  61. CommitPlane {
  62. id: commitPlane
  63. anchors.left: commitList.right
  64. anchors.right: parent.right
  65. anchors.top: topBar.bottom
  66. anchors.bottom: consoleContol.top
  67. Binding {
  68. target: commitPlane
  69. property: "diff"
  70. value: _handler.activeDiff
  71. }
  72. }
  73. Rectangle {
  74. id: dimmingPlane
  75. anchors.fill: commitList
  76. MouseArea {
  77. anchors.fill: parent
  78. }
  79. color: "black"
  80. opacity: _handler.isBusy ? 0.4 : 0.0
  81. visible: opacity > 0
  82. Behavior on opacity {
  83. NumberAnimation {
  84. duration: 500
  85. }
  86. }
  87. }
  88. ConsoleControl {
  89. id: consoleContol
  90. anchors.left: parent.left
  91. anchors.right: parent.right
  92. anchors.bottom: parent.bottom
  93. }
  94. Connections {
  95. target: _handler
  96. onActiveRepoChanged: {
  97. commitPlane.diff = null
  98. commitPlane.commit = null
  99. }
  100. }
  101. Keys.onPressed: {
  102. event.accepted = true
  103. switch(event.key) {
  104. case Qt.Key_Control:
  105. root.controlActive = true
  106. console.log("control pressed")
  107. break
  108. case Qt.Key_F4:
  109. consoleContol.state = consoleContol.state === "closed" ? "opened" : "closed"
  110. break
  111. case Qt.Key_G://Found the G point. Let's open console using this action.
  112. //TODO: Later has to be part of Console C++ class to read settings
  113. consoleContol.state = "opened"
  114. _handler.console.requestAutocomplete("g");
  115. break
  116. default:
  117. event.accepted = false
  118. }
  119. }
  120. Keys.onReleased: {
  121. if(event.key === Qt.Key_Control) {
  122. root.controlActive = false
  123. console.log("control released");
  124. }
  125. }
  126. onActiveFocusChanged: {
  127. root.controlActive = false
  128. console.log("control released");
  129. }
  130. Tooltip {
  131. }
  132. }