Use dialogs for image and video settings.
authorMohammed Sameer <msameer@foolab.org>
Mon, 7 Jan 2013 10:58:18 +0000 (12:58 +0200)
committerMohammed Sameer <msameer@foolab.org>
Mon, 7 Jan 2013 10:58:18 +0000 (12:58 +0200)
qml/ImagePage.qml
qml/ImageSettingsDialog.js [new file with mode: 0644]
qml/ImageSettingsDialog.qml [new file with mode: 0644]
qml/ImageSettingsPage.qml [deleted file]
qml/VideoPage.qml
qml/VideoSettingsDialog.js [new file with mode: 0644]
qml/VideoSettingsDialog.qml [new file with mode: 0644]
qml/VideoSettingsPage.qml [deleted file]
qml/qml.qrc

index a719808..cd6ba72 100644 (file)
@@ -220,8 +220,12 @@ CameraPage {
                 },
                 ToolIcon {
                         iconSource: "image://theme/icon-m-toolbar-view-menu-white"
-                        onClicked: openFile("ImageSettingsPage.qml");
+                        onClicked: imageSettingsDialog.open();
                 }
                 ]
         }
+
+        ImageSettingsDialog {
+                id: imageSettingsDialog
+        }
 }
diff --git a/qml/ImageSettingsDialog.js b/qml/ImageSettingsDialog.js
new file mode 100644 (file)
index 0000000..14f85d7
--- /dev/null
@@ -0,0 +1,45 @@
+// -*- js -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+function resetAspectRatio(row) {
+    imageSettings.resolutions.aspectRatio = row.checkedButton.aspect;
+    settings.imageAspectRatio = imageSettings.resolutions.aspectRatio;
+}
+
+function setAspectRatio(data) {
+    if (!cam.idle) {
+        showError(qsTr("Camera is busy saving."));
+        return;
+    }
+
+    settings.imageAspectRatio = data;
+    imageSettings.resolutions.aspectRatio = data;
+}
+
+function setResolution(resolution) {
+    if (!cam.idle) {
+        showError(qsTr("Camera is busy saving."));
+        return;
+    }
+
+    settings.imageResolution = resolution;
+}
diff --git a/qml/ImageSettingsDialog.qml b/qml/ImageSettingsDialog.qml
new file mode 100644 (file)
index 0000000..1b7fe97
--- /dev/null
@@ -0,0 +1,134 @@
+// -*- qml -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+import QtQuick 1.1
+import com.nokia.meego 1.1
+import QtCamera 1.0
+import "ImageSettingsDialog.js" as Util
+
+Dialog {
+        id: dialog
+
+        content: item
+
+        Connections {
+                target: Qt.application
+                onActiveChanged: {
+                        if (!Qt.application.active) {
+                                dialog.close();
+                        }
+                }
+        }
+
+        onStatusChanged: {
+                if (status == DialogStatus.Open) {
+                        cam.renderingEnabled = false;
+                }
+                else if (status == DialogStatus.Closing) {
+                        cam.renderingEnabled = true;
+                }
+        }
+
+        Item {
+                id: item
+                width: parent.width
+                height: root.height
+
+                Flickable {
+                        id: flickable
+                        anchors.fill: parent
+                        anchors.margins: 10
+                        contentHeight: col.height
+
+                        Column {
+                                id: col
+
+                                width: parent.width
+                                spacing: 10
+
+                                Label {
+                                        font.pixelSize: 36
+                                        text: qsTr("Image settings");
+                                }
+
+                                SectionHeader {
+                                        text: qsTr("Aspect ratio");
+                                }
+
+                                ButtonRow {
+                                        id: aspectRatioRow
+                                        width: parent.width
+
+                                        exclusive: false
+                                        onCheckedButtonChanged: {
+                                                // This is needed to initially setup the
+                                                // resolutions buttons
+                                                Util.resetAspectRatio(aspectRatioRow);
+                                        }
+
+                                        Repeater {
+                                                model: imageSettings.aspectRatios
+                                                delegate: Button {
+                                                        property string aspect: modelData;
+                                                        text: qsTr(modelData);
+                                                        checked: settings.imageAspectRatio == modelData;
+                                                        onClicked: Util.setAspectRatio(modelData);
+                                                }
+                                        }
+                                }
+
+                                SectionHeader {
+                                        text: qsTr("Resolution");
+                                }
+
+                                ButtonRow {
+                                        id: resolutionsRow
+                                        width: parent.width
+
+                                        exclusive: false
+
+                                        Repeater {
+                                                id: resolutions
+                                                model: imageSettings.resolutions
+
+                                                // http://stackoverflow.com/questions/1026069/capitalize-the-first-letter-of-string-in-javascript
+                                                function name(name, mp) {
+                                                        return name.charAt(0).toUpperCase() + name.slice(1) + " " + mp + " Mpx";
+                                                }
+
+                                                delegate: Button {
+                                                        property string resolution: resolutionName
+                                                        property string aspectRatio: resolutionAspectRatio
+                                                        text: resolutions.name(resolutionName, megaPixels);
+                                                        checked: settings.imageResolution == resolutionName
+                                                        onClicked: Util.setResolution(resolutionName);
+                                                }
+                                        }
+                                }
+
+                                CameraSettings {
+                                        anchors.horizontalCenter: parent.horizontalCenter
+                                }
+                        }
+                }
+        }
+}
diff --git a/qml/ImageSettingsPage.qml b/qml/ImageSettingsPage.qml
deleted file mode 100644 (file)
index 0a97118..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-// -*- qml -*-
-
-/*!
- * This file is part of CameraPlus.
- *
- * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-import QtQuick 1.1
-import com.nokia.meego 1.1
-import QtCamera 1.0
-import CameraPlus 1.0
-
-import "data.js" as Data
-
-CameraPage {
-        id: page
-        controlsVisible: false
-        policyMode: CameraResources.Image
-        enableViewfinder: false
-        standbyVisible: !Qt.application.active
-
-        Rectangle {
-                color: "black"
-                anchors.fill: parent
-        }
-
-        Flickable {
-                id: flickable
-                anchors.top: parent.top
-                anchors.left: parent.left
-                anchors.right: parent.right
-                anchors.bottom: toolBar.top
-                anchors.margins: 10
-                contentHeight: col.height
-
-                Column {
-                        id: col
-
-                        width: parent.width
-                        spacing: 10
-
-                        Label {
-                                font.pixelSize: 36
-                                text: qsTr("Image settings");
-                        }
-
-                        SectionHeader {
-                                text: qsTr("Aspect ratio");
-                        }
-
-                        ButtonRow {
-                                anchors.horizontalCenter: parent.horizontalCenter
-                                exclusive: false
-                                onCheckedButtonChanged: {
-                                        // This is needed to initially setup the
-                                        // resolutions buttons
-                                        imageSettings.resolutions.aspectRatio = checkedButton.aspect;
-                                        settings.imageAspectRatio = imageSettings.resolutions.aspectRatio;
-                                }
-
-                                Repeater {
-                                        model: imageSettings.aspectRatios
-                                        delegate: Button {
-                                                property string aspect: modelData;
-                                                text: qsTr(modelData);
-                                                checked: settings.imageAspectRatio == modelData;
-                                                onClicked: {
-                                                        if (!cam.idle) {
-                                                                showError(qsTr("Camera is busy saving."));
-                                                                return;
-                                                        }
-
-                                                        settings.imageAspectRatio = modelData;
-                                                        imageSettings.resolutions.aspectRatio = modelData;
-                                                }
-                                        }
-                                }
-                        }
-
-                        SectionHeader {
-                                text: qsTr("Resolution");
-                        }
-
-                        ButtonRow {
-                                id: resolutionsRow
-                                anchors.horizontalCenter: parent.horizontalCenter
-                                exclusive: false
-
-                                Repeater {
-                                        id: resolutions
-                                        model: imageSettings.resolutions
-
-                                        // http://stackoverflow.com/questions/1026069/capitalize-the-first-letter-of-string-in-javascript
-                                        function name(name, mp) {
-                                                return name.charAt(0).toUpperCase() + name.slice(1) + " " + mp + " Mpx";
-                                        }
-
-                                        delegate: Button {
-                                                property string resolution: resolutionName
-                                                property string aspectRatio: resolutionAspectRatio
-                                                text: resolutions.name(resolutionName, megaPixels);
-                                                checked: settings.imageResolution == resolutionName
-                                                onClicked: {
-                                                        if (!cam.idle) {
-                                                                showError(qsTr("Camera is busy saving."));
-                                                                return;
-                                                        }
-
-                                                        settings.imageResolution = resolutionName;
-                                                }
-                                        }
-                                }
-                        }
-
-                        CameraSettings {
-                                anchors.horizontalCenter: parent.horizontalCenter
-                        }
-                }
-        }
-
-        ToolBar {
-                id: toolBar
-                anchors.bottom: parent.bottom
-                tools: ToolBarLayout {
-                        id: layout
-                        ToolIcon { iconId: "icon-m-toolbar-back-white"; onClicked: pageStack.pop(); }
-                }
-        }
-}
index dbb3d44..a2be950 100644 (file)
@@ -176,8 +176,12 @@ CameraPage {
                 },
                 ToolIcon {
                         iconSource: "image://theme/icon-m-toolbar-view-menu-white"
-                        onClicked: openFile("VideoSettingsPage.qml");
+                        onClicked: videoSettingsDialog.open();
                 }
                 ]
         }
+
+        VideoSettingsDialog {
+                id: videoSettingsDialog
+        }
 }
diff --git a/qml/VideoSettingsDialog.js b/qml/VideoSettingsDialog.js
new file mode 100644 (file)
index 0000000..b578345
--- /dev/null
@@ -0,0 +1,30 @@
+// -*- js -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+function setResolution(resolution) {
+    if (!cam.idle) {
+        showError(qsTr("Camera is busy saving."));
+        return;
+    }
+
+    settings.videoResolution = resolution;
+}
diff --git a/qml/VideoSettingsDialog.qml b/qml/VideoSettingsDialog.qml
new file mode 100644 (file)
index 0000000..aa81bf5
--- /dev/null
@@ -0,0 +1,106 @@
+// -*- qml -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+import QtQuick 1.1
+import com.nokia.meego 1.1
+import QtCamera 1.0
+import "VideoSettingsDialog.js" as Util
+
+Dialog {
+        id: dialog
+
+        content: item
+
+        Connections {
+                target: Qt.application
+                onActiveChanged: {
+                        if (!Qt.application.active) {
+                                dialog.close();
+                        }
+                }
+        }
+
+        onStatusChanged: {
+                if (status == DialogStatus.Open) {
+                        cam.renderingEnabled = false;
+                }
+                else if (status == DialogStatus.Closing) {
+                        cam.renderingEnabled = true;
+                }
+        }
+
+        Item {
+                id: item
+                width: parent.width
+                height: root.height
+
+
+                Flickable {
+                        id: flickable
+                        anchors.fill: parent
+                        anchors.margins: 10
+                        contentHeight: col.height
+
+                        Column {
+                                id: col
+
+                                width: parent.width
+                                spacing: 10
+
+                                Label {
+                                        font.pixelSize: 36
+                                        text: qsTr("Video settings");
+                                }
+
+                                SectionHeader {
+                                        text: qsTr("Resolution");
+                                }
+
+                                ButtonRow {
+                                        width: parent.width
+
+                                        exclusive: false
+
+                                        Repeater {
+                                                id: resolutions
+
+                                                model: videoSettings.resolutions
+
+                                                function name(name, res) {
+                                                        return name.charAt(0).toUpperCase() + name.slice(1) + " " + res;
+                                                }
+
+                                                delegate: Button {
+                                                        text: resolutions.name(resolutionName, resolution);
+                                                        checked: settings.videoResolution == resolutionName;
+                                                        onClicked: Util.setResolution(resolutionName);
+                                                }
+                                        }
+                                }
+
+                                CameraSettings {
+                                        anchors.horizontalCenter: parent.horizontalCenter
+                                }
+                        }
+                }
+        }
+}
diff --git a/qml/VideoSettingsPage.qml b/qml/VideoSettingsPage.qml
deleted file mode 100644 (file)
index 9fb1d84..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-// -*- qml -*-
-
-/*!
- * This file is part of CameraPlus.
- *
- * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-import QtQuick 1.1
-import com.nokia.meego 1.1
-import QtCamera 1.0
-import CameraPlus 1.0
-
-import "data.js" as Data
-
-CameraPage {
-        id: page
-        controlsVisible: false
-        policyMode: CameraResources.Video
-        enableViewfinder: false
-        standbyVisible: !Qt.application.active
-
-        Rectangle {
-                color: "black"
-                anchors.fill: parent
-        }
-
-        Flickable {
-                id: flickable
-                anchors.top: parent.top
-                anchors.left: parent.left
-                anchors.right: parent.right
-                anchors.bottom: toolBar.top
-                anchors.margins: 10
-                contentHeight: col.height
-
-                Column {
-                        id: col
-
-                        width: parent.width
-                        spacing: 10
-
-                        Label {
-                                font.pixelSize: 36
-                                text: qsTr("Video settings");
-                        }
-
-                        SectionHeader {
-                                text: qsTr("Resolution");
-                        }
-
-                        ButtonRow {
-                                anchors.horizontalCenter: parent.horizontalCenter
-                                exclusive: false
-
-                                Repeater {
-                                        id: resolutions
-
-                                        model: videoSettings.resolutions
-
-                                        function name(name, res) {
-                                                return name.charAt(0).toUpperCase() + name.slice(1) + " " + res;
-                                        }
-
-                                        delegate: Button {
-                                                text: resolutions.name(resolutionName, resolution);
-                                                checked: settings.videoResolution == resolutionName;
-                                                onClicked: {
-                                                        if (!cam.idle) {
-                                                                showError(qsTr("Camera is busy saving."));
-                                                                return;
-                                                        }
-
-                                                        settings.videoResolution = resolutionName;
-                                                }
-                                        }
-                                }
-                        }
-
-                        CameraSettings {
-                                anchors.horizontalCenter: parent.horizontalCenter
-                        }
-                }
-        }
-
-        ToolBar {
-                id: toolBar
-                anchors.bottom: parent.bottom
-                tools: ToolBarLayout {
-                        id: layout
-                        ToolIcon { iconId: "icon-m-toolbar-back-white"; onClicked: pageStack.pop(); }
-                }
-        }
-}
index 3dcc025..fa4029d 100644 (file)
@@ -5,7 +5,6 @@
        <file>PipelineManager.qml</file>
        <file>FocusReticle.qml</file>
        <file>CameraPage.qml</file>
-       <file>ImageSettingsPage.qml</file>
        <file>Standby.qml</file>
        <file>CameraSettings.qml</file>
        <file>VideoPage.qml</file>
@@ -30,7 +29,6 @@
        <file>VideoTorchButton.qml</file>
        <file>PostCaptureItem.qml</file>
        <file>PostCapturePage.qml</file>
-       <file>VideoSettingsPage.qml</file>
        <file>VideoSceneButton.qml</file>
        <file>VideoEvCompButton.qml</file>
        <file>VideoWhiteBalanceButton.qml</file>
@@ -38,5 +36,9 @@
        <file>VideoMuteButton.qml</file>
        <file>VideoPlayerPage.qml</file>
        <file>SectionHeader.qml</file>
+       <file>ImageSettingsDialog.qml</file>
+       <file>ImageSettingsDialog.js</file>
+       <file>VideoSettingsDialog.qml</file>
+       <file>VideoSettingsDialog.js</file>
     </qresource>
 </RCC>