<commit_before>// -*- qml -*-
import QtQuick 1.1
import com.nokia.meego 1.1
import QtCamera 1.0
import CameraPlus 1.0

// TODO: metadata creator name, gps, geotags
// TODO: resolutions and aspect ratios
// TODO: postcapture
// TODO: battery low state
// TODO: disk space
// TODO: flash not ready
// TODO: focus, caf, ...
// TODO: indicators
// TODO: portrait/landscape
// TODO: record in a hidden directory and then copy the video to avoid tracker indexing it.

PageStackWindow {
        id: root

        property alias dimmer: camDimmer

        showStatusBar: false

        Component.onCompleted: {
                theme.inverted = true;
                if (settings.mode == 0) {
                        openFile("ImagePage.qml");
                }
                else {
                        openFile("VideoPage.qml");
                }
        }

        Settings {
                id: settings
        }

        FileNaming {
                id: fileNaming
                imageSuffix: cam.imageSuffix
                videoSuffix: cam.videoSuffix
        }

        // Stolen from https://qt.gitorious.org/qt-components/qt-components/blobs/master/examples/meego/QmlComponentGallery/qml/ListPage.qml
        function replacePage(file) {
                var component = Qt.createComponent(file)

                if (component.status == Component.Ready) {
                        pageStack.replace(component, {cam: cam}, true);
                }
                else {
                        console.log("Error loading component:", component.errorString());
                }
        }

        function openFile(file) {
                var component = Qt.createComponent(file)

                if (component.status == Component.Ready) {
                        pageStack.push(component, {cam: cam});
                }
                else {
                        console.log("Error loading component:", component.errorString());
                }
        }

        platformStyle: PageStackWindowStyle {
                // TODO: Hack
                background: " "
        }

        Connections {
                target: platformWindow
                onActiveChanged: {
                        if (platformWindow.active) {
                                cam.start();
                        }
                        else {
                                // This is a noop if camera is not idle so calling it will not hurt
                                cam.stop();
                        }
                }
        }

        Camera {
                onIdleChanged: {
                        if (idle && !platformWindow.active) {
                                stop();
                        }
                }

                onDeviceIdChanged: {
                        if (platformWindow.active) {
                                cam.start();
                        }
                }

                id: cam
                anchors.fill: parent

                // TODO: hardcoding device id
                Component.onCompleted: { cam.deviceId = 0; mode = settings.mode; }

                // TODO: Hack<commit_msg>Show an error if we fail to start the camera pipeline<commit_after>// -*- qml -*-
import QtQuick 1.1
import com.nokia.meego 1.1
import com.nokia.extras 1.1
import QtCamera 1.0
import CameraPlus 1.0

// TODO: metadata creator name, gps, geotags
// TODO: resolutions and aspect ratios
// TODO: postcapture
// TODO: battery low state
// TODO: disk space
// TODO: flash not ready
// TODO: focus, caf, ...
// TODO: indicators
// TODO: portrait/landscape
// TODO: record in a hidden directory and then copy the video to avoid tracker indexing it.

PageStackWindow {
        id: root

        property alias dimmer: camDimmer

        showStatusBar: false

        Component.onCompleted: {
                theme.inverted = true;
                if (settings.mode == 0) {
                        openFile("ImagePage.qml");
                }
                else {
                        openFile("VideoPage.qml");
                }
        }

        function showError(msg) {
                error.text = msg;
                error.show();
        }

        InfoBanner {
                id: error
        }

        Settings {
                id: settings
        }

        FileNaming {
                id: fileNaming
                imageSuffix: cam.imageSuffix
                videoSuffix: cam.videoSuffix
        }

        // Stolen from https://qt.gitorious.org/qt-components/qt-components/blobs/master/examples/meego/QmlComponentGallery/qml/ListPage.qml
        function replacePage(file) {
                var component = Qt.createComponent(file)

                if (component.status == Component.Ready) {
                        pageStack.replace(component, {cam: cam}, true);
                }
                else {
                        console.log("Error loading component:", component.errorString());
                }
        }

        function openFile(file) {
                var component = Qt.createComponent(file)

                if (component.status == Component.Ready) {
                        pageStack.push(component, {cam: cam});
                }
                else {
                        console.log("Error loading component:", component.errorString());
                }
        }

        platformStyle: PageStackWindowStyle {
                // TODO: Hack
                background: " "
        }

        Connections {
                target: platformWindow
                onActiveChanged: {
                        if (platformWindow.active) {
                                if (!cam.start()) {
                                        showError("Camera failed to start. Please restart the camera.");
                                }
                        }
                        else {
                                // This is a noop if camera is not idle so calling it will not hurt
                                cam.stop();
                        }
                }
        }

        Camera {
                onIdleChanged: {
                        if (idle && !platformWindow.active) {
                                stop();
                        }
                }

                onDeviceIdChanged: {
                        if (platformWindow.active) {
                                cam.start();
                        }
                }

                id: cam
                anchors.fill: parent

                // TODO: hardcoding device id
                Component.onCompleted: { cam.deviceId = 0; mode = settings.mode; }

                // TODO: Hack
{'fraction_non_alphanumeric': 0.08506814437621686, 'fraction_numerical': 0.0032948929159802307, 'mean_word_length': 1.0403299725022914, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2791853', 'n_tokens_mistral': 1660, 'n_tokens_neox': 1485, 'n_words': 387}