Replace icons with text for image resolution indicator
[harmattan/cameraplus] / qml / ImageResolutionSettings.qml
1 // -*- qml -*-
2
3 /*!
4  * This file is part of CameraPlus.
5  *
6  * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22
23 import QtQuick 2.0
24 import QtCamera 1.0
25
26 Column {
27     property Camera camera: null
28
29     spacing: 10
30
31     property string __aspectRatio: settings.device == 1 ?
32         settings.secondaryImageAspectRatio : settings.primaryImageAspectRatio
33     property string __resolution: settings.device == 1 ?
34         settings.secondaryImageResolution : settings.primaryImageResolution
35
36     SectionHeader {
37         text: qsTr("Aspect ratio")
38         visible: aspectRatioRow.visible
39     }
40
41     CameraButtonRow {
42         id: aspectRatioRow
43         width: parent.width
44         enabled: camera ? camera.idle : false
45         exclusive: false
46         visible: imageSettings.aspectRatioCount > 1
47
48         Repeater {
49             model: imageSettings.aspectRatios
50             delegate: CameraButton {
51                 text: qsTr(modelData)
52                 checked: __aspectRatio == modelData
53                 onClicked: {
54                     if (settings.device == 1) {
55                         settings.secondaryImageAspectRatio = modelData
56                     } else {
57                         settings.primaryImageAspectRatio = modelData
58                     }
59                 }
60             }
61         }
62     }
63
64     SectionHeader {
65         text: qsTr("Resolution")
66         visible: resolutionsRow.visible
67     }
68
69     CameraButtonRow {
70         id: resolutionsRow
71         width: parent.width
72         enabled: camera ? camera.idle : false
73         exclusive: false
74         visible: imageSettings.resolutions.count > 1
75
76         Binding {
77             target: imageSettings.resolutions
78             property: "aspectRatio"
79             value: settings.primaryImageAspectRatio
80             when: settings.device == 0
81         }
82
83         Binding {
84             target: imageSettings.resolutions
85             property: "aspectRatio"
86             value: settings.secondaryImageAspectRatio
87             when: settings.device == 1
88         }
89
90         Repeater {
91             id: resolutions
92
93             model: imageSettings.resolutions.aspectRatio == __aspectRatio ?
94                 imageSettings.resolutions : undefined
95
96             delegate: CameraButton {
97                 capitalize: true
98                 text: qsTr("%1 %2 Mpx").arg(resolutionName).arg(megaPixels)
99                 checked: __resolution == resolutionName
100                 onClicked: {
101                     if (settings.device == 1) {
102                         settings.secondaryImageResolution = resolutionName
103                     } else {
104                         settings.primaryImageResolution = resolutionName
105                     }
106                 }
107             }
108         }
109     }
110 }