CommitPlane.qml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import QtQuick 2.0
  2. import QtQuick.Controls 1.4
  3. Item {
  4. id: root
  5. property QtObject commit: null
  6. property QtObject diff: null
  7. onCommitChanged: {
  8. if(commit != null) {
  9. diff = commit.diff
  10. } else {
  11. diff = null
  12. }
  13. }
  14. QtObject {
  15. id: d
  16. property int viewportMargins: 20
  17. property int commitInfoWidth: 400
  18. }
  19. CommitInfo {
  20. id: commitInfo
  21. anchors.top: parent.top
  22. anchors.left: parent.left
  23. anchors.leftMargin: 20
  24. width: d.commitInfoWidth
  25. }
  26. DiffFiles {
  27. id: files
  28. files: diff ? diff.files : null
  29. anchors.top: arrow.bottom
  30. anchors.topMargin: -10
  31. anchors.bottom: parent.bottom
  32. anchors.left: parent.left
  33. anchors.leftMargin: 20
  34. width: d.commitInfoWidth
  35. onOpenDiff: {
  36. fileDiff.text = diff.unified(file)
  37. currentFileName.text = qsTr("Diff for ") + file
  38. }
  39. }
  40. FlickPagerArrow {
  41. id: arrow
  42. anchors.top: commitInfo.bottom
  43. source: commitInfo.state === "opened" ? "arrow-141-16" : "arrow-203-16"
  44. active: true
  45. anchors.left: commitInfo.left
  46. anchors.right: commitInfo.right
  47. onClicked: {
  48. commitInfo.state = commitInfo.state === "opened" ? "closed" : "opened"
  49. }
  50. gradient: Gradient {
  51. GradientStop { position: 0.0; color: "#00ffffff" }
  52. GradientStop { position: 0.2; color: "#ffffffff" }
  53. GradientStop { position: 0.8; color: "#ffffffff" }
  54. GradientStop { position: 1.0; color: "#00ffffff" }
  55. }
  56. }
  57. Text {
  58. id: currentFileName
  59. anchors.top: parent.top
  60. anchors.left: files.right
  61. anchors.leftMargin: 40
  62. font.weight: Font.Bold
  63. }
  64. ScrollView {
  65. id: diffViewport
  66. anchors.top: topDecor.bottom
  67. anchors.bottom: bottomDecor.top
  68. anchors.left: files.right
  69. anchors.leftMargin: 20
  70. anchors.right: parent.right
  71. anchors.topMargin: -10
  72. anchors.bottomMargin: -10
  73. __wheelAreaScrollSpeed:30
  74. clip: true
  75. Item {
  76. id: innerItem
  77. width: fileDiff.contentWidth
  78. height: fileDiff.contentHeight + 20
  79. Text {
  80. id: fileDiff
  81. anchors.top: parent.top
  82. anchors.topMargin: 10
  83. font.family: "Inconsolata"
  84. font.pointSize: 12
  85. }
  86. }
  87. }
  88. onDiffChanged: {
  89. fileDiff.text = ""
  90. currentFileName.text = ""
  91. }
  92. Rectangle {
  93. id: topDecor
  94. anchors.right: diffViewport.right
  95. anchors.left: diffViewport.left
  96. anchors.top: currentFileName.bottom
  97. height: d.viewportMargins
  98. gradient: Gradient {
  99. GradientStop { position: 0.0; color: "#ffffffff" }
  100. GradientStop { position: 0.7; color: "#ffffffff" }
  101. GradientStop { position: 1.0; color: "#00ffffff" }
  102. }
  103. }
  104. Rectangle {
  105. id: bottomDecor
  106. anchors.right: diffViewport.right
  107. anchors.left: diffViewport.left
  108. anchors.bottom: parent.bottom
  109. height: d.viewportMargins
  110. gradient: Gradient {
  111. GradientStop { position: 0.0; color: "#00ffffff" }
  112. GradientStop { position: 0.3; color: "#ffffffff" }
  113. GradientStop { position: 1.0; color: "#ffffffff" }
  114. }
  115. }
  116. AreaPlaceholder {
  117. anchors.fill: diffViewport
  118. active: fileDiff.text == ""
  119. visible: diff != null
  120. text: "Select file on side panel"
  121. }
  122. AreaPlaceholder {
  123. active: diff == null
  124. text: "Select commit in graph"
  125. }
  126. }