Warning, /utilities/skanpage/src/qml/ContentView.qml is written in an unsupported language. File is not indexed.

0001 /**
0002  * SPDX-FileCopyrightText: 2015 by Kåre Särs <kare.sars@iki .fi>
0003  * SPDX-FileCopyrightText: 2021 by Alexander Stippich <a.stippich@gmx.net>
0004  *
0005  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006  */
0007 
0008 import QtQuick 2.15
0009 import QtQuick.Controls 2.15
0010 import QtQuick.Layouts 1.1
0011 
0012 import org.kde.kirigami 2.12 as Kirigami
0013 import org.kde.skanpage 1.0
0014 
0015 Item {
0016     id: mainContent
0017 
0018     readonly property string name: skanpage.documentModel.changed ? i18nc("Prefix for document name indicating an unsaved document", "* %1", skanpage.documentModel.name) : skanpage.documentModel.name;
0019     property int splitViewPreferredWidth: splitView.width / 4
0020     property alias splitViewItemWidth: scrollView.width
0021     property bool showOptions: true
0022     property alias optionsPanel: optionsPanel
0023     property alias activeDocument: activeDocument
0024 
0025     signal saveSinglePage(int pageNumber)
0026 
0027     focus: true
0028 
0029     RowLayout {
0030         anchors.fill: parent
0031         
0032         spacing: 0
0033 
0034         SplitView {
0035             id: splitView
0036             Layout.fillWidth: true
0037             Layout.fillHeight: true
0038             orientation: Qt.Horizontal
0039 
0040             handle: Item {
0041                 implicitWidth: Kirigami.Units.smallSpacing
0042 
0043                 Kirigami.Separator {
0044                     height: parent.height
0045                     width: Kirigami.Units.smallSpacing / 2
0046                     anchors.centerIn: parent
0047 
0048                     HoverHandler { cursorShape: Qt.SizeHorCursor }
0049                 }
0050             }
0051 
0052             DocumentList {
0053                 id: scrollView
0054 
0055                 SplitView.fillHeight: true
0056                 SplitView.preferredWidth: splitViewPreferredWidth
0057                 SplitView.minimumWidth: scrollView.minimumWidth
0058                 SplitView.maximumWidth: splitView.width - activeDocument.width - optionsSeparator.width
0059                 onSaveSinglePage: mainContent.saveSinglePage(pageNumber)
0060                 onShowScannedPage: activeDocument.showPreview = false
0061                 onMinimumWidthChanged: // Do not prefer a width lower than a minimum
0062                     if (SplitView.preferredWidth < minimumWidth) SplitView.preferredWidth = minimumWidth
0063             }
0064 
0065             onResizingChanged: if (!resizing) scrollView.minimumWidthChanged()
0066 
0067             DocumentPage {
0068                 id: activeDocument
0069 
0070                 SplitView.fillWidth: true
0071                 SplitView.minimumWidth: splitView.width / 5
0072                 SplitView.fillHeight: true
0073 
0074                 visible: skanpage.applicationState === Skanpage.ReadyForScan
0075                 onSaveSinglePage: mainContent.saveSinglePage(pageNumber)
0076             }
0077 
0078             InProgressPage {
0079                 id: inProgressImage
0080 
0081                 SplitView.fillWidth: true
0082                 SplitView.fillHeight: true
0083 
0084                 visible: skanpage.applicationState === Skanpage.ScanInProgress
0085             }
0086         }
0087 
0088         Item {
0089             id: optionsSeparator
0090             Layout.fillHeight: true
0091 
0092             Kirigami.Separator {
0093                 height: parent.height
0094                 width: Kirigami.Units.smallSpacing / 2
0095                 anchors.centerIn: parent
0096             }
0097         }
0098 
0099         OptionsPanel {
0100             id: optionsPanel
0101 
0102             Layout.fillHeight: true
0103         }
0104     }
0105 
0106     states: [
0107         State {
0108             name: "noOptions"
0109             when: mainContent.showOptions === false
0110             PropertyChanges {
0111                 target: optionsPanel
0112                 Layout.minimumWidth: 0
0113                 Layout.maximumWidth: 0
0114                 Layout.preferredWidth: 0
0115             }
0116             PropertyChanges {
0117                 target: optionsSeparator
0118                 visible: false
0119             }
0120         },
0121         State {
0122             name: "showOptions"
0123             when: mainContent.showOptions === true
0124             PropertyChanges {
0125                 target: optionsPanel
0126                 Layout.minimumWidth: optionsPanel.targetWidth
0127                 Layout.maximumWidth: optionsPanel.targetWidth
0128                 Layout.preferredWidth: optionsPanel.targetWidth
0129             }
0130             PropertyChanges {
0131                 target: optionsSeparator
0132                 visible: true
0133             }
0134         }
0135     ]
0136 
0137     transitions: Transition {
0138         NumberAnimation {
0139             target: optionsPanel
0140             properties: "Layout.minimumWidth, Layout.maximumWidth, Layout.preferredWidth"
0141             easing.type: Easing.InOutQuad
0142             duration: Kirigami.Units.longDuration
0143         }
0144     }
0145 }