MainView.qml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import QtQuick 2.0
  2. import QtQuick.Controls 1.4
  3. import org.semlanik.nicegit 1.0
  4. Item {
  5. id: root
  6. property var commitsForDiff: null
  7. property bool controlActive: false
  8. TopBar {
  9. id: topBar
  10. onCloseClicked: {
  11. commitPlane.diff = null
  12. commitPlane.commit = null
  13. commitList.state = "full"
  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: parent.bottom
  26. anchors.left: parent.left
  27. commitsModel: _handler.commits
  28. graphModel: _handler.graph
  29. onCommitClicked: {
  30. if(commit.diff == null) {
  31. commitPlane.commit = null
  32. commitPlane.diff = null
  33. commitList.state = "full"
  34. return
  35. }
  36. commitList.state = "commitsOnly"
  37. if(!root.controlActive) {
  38. commitPlane.commit = commit
  39. root.commitsForDiff=[]
  40. } else {
  41. console.log("root.controlActive: " + root.controlActive)
  42. if(root.commitsForDiff === null) {
  43. root.commitsForDiff = new Array(0);
  44. }
  45. console.log("Length" + root.commitsForDiff.length)
  46. root.commitsForDiff.push(commit)
  47. if(root.commitsForDiff.length === 2) {
  48. commitPlane.commit = root.commitsForDiff[1]
  49. commitPlane.diff = _handler.diff(root.commitsForDiff[0], root.commitsForDiff[1])
  50. root.commitsForDiff=[]
  51. }
  52. }
  53. }
  54. }
  55. CommitPlane {
  56. id: commitPlane
  57. anchors.left: commitList.right
  58. anchors.right: parent.right
  59. anchors.top: topBar.bottom
  60. anchors.bottom: parent.bottom
  61. // visible: diff != null
  62. // opacity: diff != null ? 1.0 : 0.0
  63. }
  64. Keys.onPressed: {
  65. if(event.key === Qt.Key_Control) {
  66. root.controlActive = true
  67. console.log("control pressed");
  68. }
  69. }
  70. Keys.onReleased: {
  71. if(event.key === Qt.Key_Control) {
  72. root.controlActive = false
  73. console.log("control released");
  74. }
  75. }
  76. Tooltip {
  77. }
  78. }