2023-04-28 13:43:04 +03:00
/ *
* Copyright ( C ) 2023 by Matthieu Gallien < matthieu . gallien @ nextcloud . com >
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful , but
* WITHOUT ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE . See the GNU General Public License
* for more details .
* /
import QtQml 2.15
import QtQuick 2.15
2023-05-04 11:32:56 +03:00
import QtQuick . Window 2.15 as QtWindow
2023-04-28 13:43:04 +03:00
import QtQuick . Layouts 1.15
import QtQuick . Controls 2.15
import QtQml . Models 2.15
import Style 1.0
import com . nextcloud . desktopclient 1.0
import "./tray"
2023-05-25 05:32:20 +03:00
ApplicationWindow {
2023-05-04 11:32:56 +03:00
id: conflictsDialog
2023-04-28 13:43:04 +03:00
2023-05-03 19:09:12 +03:00
required property var allConflicts
2023-05-04 11:32:56 +03:00
flags: Qt . Window | Qt . Dialog
2023-04-28 13:43:04 +03:00
visible: true
2023-05-16 10:37:45 +03:00
width: Style . minimumWidthResolveConflictsDialog
height: Style . minimumHeightResolveConflictsDialog
minimumWidth: Style . minimumWidthResolveConflictsDialog
minimumHeight: Style . minimumHeightResolveConflictsDialog
2023-04-28 15:54:55 +03:00
title: qsTr ( 'Solve sync conflicts' )
2023-04-28 13:43:04 +03:00
2023-05-04 11:32:56 +03:00
onClosing: function ( close ) {
2023-05-04 13:29:54 +03:00
Systray . destroyDialog ( self ) ;
2023-05-04 11:32:56 +03:00
close . accepted = true
2023-04-28 13:43:04 +03:00
}
ColumnLayout {
anchors.fill: parent
anchors.leftMargin: 20
anchors.rightMargin: 20
anchors.bottomMargin: 20
anchors.topMargin: 20
spacing: 15
z: 2
EnforcedPlainTextLabel {
2023-05-16 10:54:09 +03:00
text: qsTr ( "%1 files in conflict" , 'indicate the number of conflicts to resolve' , delegateModel . count ) . arg ( delegateModel . count )
2023-04-28 13:43:04 +03:00
font.bold: true
2023-05-16 10:04:11 +03:00
font.pixelSize: Style . bigFontPixelSizeResolveConflictsDialog
2023-04-28 13:43:04 +03:00
Layout.fillWidth: true
}
EnforcedPlainTextLabel {
2023-05-02 15:53:53 +03:00
text: qsTr ( "Choose if you want to keep the local version, server version, or both. If you choose both, the local file will have a number added to its name." )
2023-04-28 15:54:55 +03:00
wrapMode: Text . WrapAtWordBoundaryOrAnywhere
2023-05-16 10:04:11 +03:00
font.pixelSize: Style . fontPixelSizeResolveConflictsDialog
2023-04-28 13:43:04 +03:00
Layout.fillWidth: true
Layout.topMargin: - 15
}
RowLayout {
Layout.fillWidth: true
Layout.topMargin: 15
CheckBox {
id: selectExisting
Layout.fillWidth: true
2023-04-28 15:54:55 +03:00
text: qsTr ( 'All local versions' )
leftPadding: 0
implicitWidth: 100
2023-04-28 13:43:04 +03:00
2023-05-16 10:04:11 +03:00
font.pixelSize: Style . fontPixelSizeResolveConflictsDialog
2023-05-12 14:17:38 +03:00
2023-09-11 17:19:42 +03:00
checked: realModel . allConflictingSelected
2023-05-12 14:17:38 +03:00
onToggled: function ( ) {
2023-09-11 17:19:42 +03:00
realModel . selectAllConflicting ( checked )
2023-05-12 14:17:38 +03:00
}
2023-04-28 13:43:04 +03:00
}
CheckBox {
id: selectConflict
Layout.fillWidth: true
2023-04-28 15:54:55 +03:00
text: qsTr ( 'All server versions' )
leftPadding: 0
implicitWidth: 100
2023-04-28 13:43:04 +03:00
2023-05-16 10:04:11 +03:00
font.pixelSize: Style . fontPixelSizeResolveConflictsDialog
2023-05-12 14:17:38 +03:00
2023-09-11 17:19:42 +03:00
checked: realModel . allExistingsSelected
2023-05-12 14:17:38 +03:00
onToggled: function ( ) {
2023-09-11 17:19:42 +03:00
realModel . selectAllExisting ( checked )
2023-05-12 14:17:38 +03:00
}
2023-04-28 13:43:04 +03:00
}
}
Rectangle {
Layout.fillWidth: true
Layout.leftMargin: 5
Layout.rightMargin: 5
2023-05-25 06:51:51 +03:00
color: palette . dark
2023-04-28 13:43:04 +03:00
height: 1
}
2023-05-02 14:55:17 +03:00
SyncConflictsModel {
id: realModel
2023-05-03 19:09:12 +03:00
2023-05-04 11:32:56 +03:00
conflictActivities: conflictsDialog . allConflicts
2023-05-02 14:55:17 +03:00
}
2023-04-28 13:43:04 +03:00
ScrollView {
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
ScrollBar.horizontal.policy: ScrollBar . AlwaysOff
ListView {
id: conflictListView
model: DelegateModel {
2023-05-03 19:40:15 +03:00
id: delegateModel
2023-05-03 19:09:12 +03:00
model: realModel
2023-04-28 13:43:04 +03:00
delegate: ConflictDelegate {
width: conflictListView . contentItem . width
height: 100
}
}
}
}
DialogButtonBox {
Layout.fillWidth: true
2023-05-03 14:59:29 +03:00
Button {
text: qsTr ( "Resolve conflicts" )
DialogButtonBox.buttonRole: DialogButtonBox . AcceptRole
}
Button {
text: qsTr ( "Cancel" )
DialogButtonBox.buttonRole: DialogButtonBox . RejectRole
}
2023-04-28 13:43:04 +03:00
onAccepted: function ( ) {
2023-05-16 11:37:40 +03:00
realModel . applySolution ( )
2023-05-04 13:30:13 +03:00
Systray . destroyDialog ( conflictsDialog )
2023-04-28 13:43:04 +03:00
}
onRejected: function ( ) {
2023-05-04 13:30:13 +03:00
Systray . destroyDialog ( conflictsDialog )
2023-04-28 13:43:04 +03:00
}
}
}
Rectangle {
2023-05-23 19:30:53 +03:00
color: Style . backgroundColor
2023-04-28 13:43:04 +03:00
anchors.fill: parent
z: 1
}
}