CommitPlane.qml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. }
  38. }
  39. FlickPagerArrow {
  40. id: arrow
  41. anchors.top: commitInfo.bottom
  42. source: commitInfo.state === "opened" ? "arrow-141-16" : "arrow-203-16"
  43. active: true
  44. anchors.left: commitInfo.left
  45. anchors.right: commitInfo.right
  46. onClicked: {
  47. commitInfo.state = commitInfo.state === "opened" ? "closed" : "opened"
  48. }
  49. gradient: Gradient {
  50. GradientStop { position: 0.0; color: "#00ffffff" }
  51. GradientStop { position: 0.2; color: "#ffffffff" }
  52. GradientStop { position: 0.8; color: "#ffffffff" }
  53. GradientStop { position: 1.0; color: "#00ffffff" }
  54. }
  55. }
  56. ScrollView {
  57. id: diffViewport
  58. anchors.top: topDecor.bottom
  59. anchors.bottom: bottomDecor.top
  60. anchors.left: files.right
  61. anchors.leftMargin: 20
  62. anchors.right: parent.right
  63. anchors.topMargin: -10
  64. anchors.bottomMargin: -10
  65. __wheelAreaScrollSpeed:30
  66. clip: true
  67. Item {
  68. id: innerItem
  69. width: fileDiff.contentWidth
  70. height: fileDiff.contentHeight + 20
  71. Text {
  72. id: fileDiff
  73. anchors.top: parent.top
  74. anchors.topMargin: 10
  75. font.family: "Inconsolata"
  76. font.pointSize: 12
  77. }
  78. }
  79. }
  80. onDiffChanged: {
  81. fileDiff.text = ""
  82. }
  83. Rectangle {
  84. id: topDecor
  85. anchors.right: diffViewport.right
  86. anchors.left: diffViewport.left
  87. anchors.top: parent.top
  88. height: d.viewportMargins
  89. gradient: Gradient {
  90. GradientStop { position: 0.0; color: "#ffffffff" }
  91. GradientStop { position: 0.7; color: "#ffffffff" }
  92. GradientStop { position: 1.0; color: "#00ffffff" }
  93. }
  94. }
  95. Rectangle {
  96. id: bottomDecor
  97. anchors.right: diffViewport.right
  98. anchors.left: diffViewport.left
  99. anchors.bottom: parent.bottom
  100. height: d.viewportMargins
  101. gradient: Gradient {
  102. GradientStop { position: 0.0; color: "#00ffffff" }
  103. GradientStop { position: 0.3; color: "#ffffffff" }
  104. GradientStop { position: 1.0; color: "#ffffffff" }
  105. }
  106. }
  107. AreaPlaceholder {
  108. anchors.fill: diffViewport
  109. active: fileDiff.text == ""
  110. visible: diff != null
  111. text: "Select file on side panel"
  112. }
  113. AreaPlaceholder {
  114. active: diff == null
  115. text: "Select commit in graph"
  116. }
  117. }