123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- import QtQuick 2.0
- import QtQuick.Controls 1.4
- import org.semlanik.nicegit 1.0
- Item {
- id: root
- property QtObject commit: null
- property QtObject diff: null
- onCommitChanged: {
- if(commit != null) {
- diff = commit.diff
- } else {
- diff = null
- }
- }
- QtObject {
- id: d
- property int viewportMargins: 20
- property int commitInfoWidth: 400
- property QtObject diffModel: null
- }
- CommitInfo {
- id: commitInfo
- anchors.top: parent.top
- anchors.left: parent.left
- anchors.leftMargin: 20
- width: d.commitInfoWidth
- visible: commit != null
- }
- DiffFiles {
- id: files
- diff: root.diff
- anchors.top: arrow.bottom
- anchors.topMargin: -10
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- anchors.leftMargin: 20
- width: d.commitInfoWidth
- onOpenDiff: {
- d.diffModel = diff.model(file)
- }
- }
- FlickPagerArrow {
- id: arrow
- enabled: commit != null
- anchors.top: commitInfo.bottom
- source: commitInfo.state === "opened" ? "arrow-141-16" : "arrow-203-16"
- active: true
- anchors.left: commitInfo.left
- anchors.right: commitInfo.right
- onClicked: {
- commitInfo.state = commitInfo.state === "opened" ? "closed" : "opened"
- }
- gradient: Gradient {
- GradientStop { position: 0.0; color: "#00ffffff" }
- GradientStop { position: 0.2; color: "#ffffffff" }
- GradientStop { position: 0.8; color: "#ffffffff" }
- GradientStop { position: 1.0; color: "#00ffffff" }
- }
- }
- Text {
- id: currentFileName
- text: qsTr("Diff for ") + (d.diffModel ? d.diffModel.path : "")
- anchors.top: parent.top
- anchors.left: files.right
- anchors.leftMargin: 40
- font.weight: Font.Bold
- }
- ScrollView {
- id: diffViewport
- anchors.top: topDecor.bottom
- anchors.bottom: bottomDecor.top
- anchors.left: files.right
- anchors.leftMargin: 20
- anchors.right: parent.right
- anchors.topMargin: -10
- anchors.bottomMargin: -10
- __wheelAreaScrollSpeed:30
- clip: true
- Item {
- id: innerItem
- width: fileDiff.contentWidth
- height: fileDiff.contentHeight + 20
- TextEdit {
- id: fileDiff
- text: d.diffModel ? d.diffModel.data : ""
- anchors.top: parent.top
- anchors.topMargin: 10
- textFormat: TextEdit.RichText
- font.family: "Inconsolata"
- font.pointSize: 12
- selectByMouse: true
- readOnly: true
- }
- }
- }
- onDiffChanged: {
- d.diffModel = null
- }
- Rectangle {
- id: topDecor
- anchors.right: diffViewport.right
- anchors.left: diffViewport.left
- anchors.top: currentFileName.bottom
- height: d.viewportMargins
- gradient: Gradient {
- GradientStop { position: 0.0; color: "#ffffffff" }
- GradientStop { position: 0.7; color: "#ffffffff" }
- GradientStop { position: 1.0; color: "#00ffffff" }
- }
- }
- Rectangle {
- id: bottomDecor
- anchors.right: diffViewport.right
- anchors.left: diffViewport.left
- anchors.bottom: parent.bottom
- height: d.viewportMargins
- gradient: Gradient {
- GradientStop { position: 0.0; color: "#00ffffff" }
- GradientStop { position: 0.3; color: "#ffffffff" }
- GradientStop { position: 1.0; color: "#ffffffff" }
- }
- }
- AreaPlaceholder {
- anchors.fill: diffViewport
- active: fileDiff.text == ""
- visible: diff != null
- text: "Select file on side panel"
- }
- AreaPlaceholder {
- active: diff == null
- text: "Select commit in graph"
- }
- }
|