CommitPlane.qml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. import QtQuick 2.0
  2. import QtQuick.Controls 1.4
  3. import org.semlanik.cutegit 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. model: root.commit
  24. anchors.top: parent.top
  25. anchors.left: parent.left
  26. anchors.leftMargin: 20
  27. width: d.commitInfoWidth
  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. activeFocusOnPress: false
  94. }
  95. }
  96. }
  97. onDiffChanged: {
  98. d.diffModel = null
  99. }
  100. Rectangle {
  101. id: topDecor
  102. anchors.right: diffViewport.right
  103. anchors.left: diffViewport.left
  104. anchors.top: currentFileName.bottom
  105. height: d.viewportMargins
  106. gradient: Gradient {
  107. GradientStop { position: 0.0; color: "#ffffffff" }
  108. GradientStop { position: 0.7; color: "#ffffffff" }
  109. GradientStop { position: 1.0; color: "#00ffffff" }
  110. }
  111. }
  112. Rectangle {
  113. id: bottomDecor
  114. anchors.right: diffViewport.right
  115. anchors.left: diffViewport.left
  116. anchors.bottom: parent.bottom
  117. height: d.viewportMargins
  118. gradient: Gradient {
  119. GradientStop { position: 0.0; color: "#00ffffff" }
  120. GradientStop { position: 0.3; color: "#ffffffff" }
  121. GradientStop { position: 1.0; color: "#ffffffff" }
  122. }
  123. }
  124. AreaPlaceholder {
  125. anchors.fill: diffViewport
  126. active: fileDiff.text == ""
  127. visible: diff != null
  128. text: qsTr("Select file on side panel")
  129. }
  130. AreaPlaceholder {
  131. active: diff == null
  132. text: qsTr("Select commit in graph")
  133. }
  134. }