CommitPlane.qml 3.9 KB

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