<commit_before>import QtQuick 2.5
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.3
import DepthView 2.0

Dialog {
    id: root
    modal: true

    function reset() {
        for (var i = 0; i < swipe.contentModel.count; ++i)
            if (swipe.contentModel.get(i).reset !== undefined)
                swipe.contentModel.get(i).reset();
    }

    onRejected: reset()

    onAccepted: {
        for (var i = 0; i < swipe.contentModel.count; ++i)
            if (swipe.contentModel.get(i).apply !== undefined)
                swipe.contentModel.get(i).apply();
    }

    footer: DialogButtonBox {
        standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel | DialogButtonBox.Apply | DialogButtonBox.Reset

        onClicked: {
            if (button === standardButton(DialogButtonBox.Apply))
                swipe.currentItem.apply()
            else if (button === standardButton(DialogButtonBox.Reset))
                swipe.currentItem.reset()
        }

        Component.onCompleted: {
            /* Disable the buttons if there is no function for them to call. */
            standardButton(DialogButtonBox.Apply).enabled = Qt.binding(function() { return swipe.currentItem !== null && swipe.currentItem.apply !== undefined })
            standardButton(DialogButtonBox.Reset).enabled = Qt.binding(function() { return swipe.currentItem !== null && swipe.currentItem.reset !== undefined })
        }
    }

    /* Use the reset function to init values. */
    Component.onCompleted: reset()

    clip: true

    header: TabBar {
        id: bar
        currentIndex: swipe.currentIndex

        Repeater {
            model: swipe.contentChildren

            TabButton { text: modelData.title }
        }
    }

    Item {
        anchors.fill: parent
        clip: true

        SwipeView {
            id: swipe
            anchors.fill: parent
            currentIndex: bar.currentIndex

            Flickable {
                function reset() {
                    saveWindowStateCheckBox.checked = DepthView.saveWindowState
                    startupFileBrowserCheckBox.checked = DepthView.startupFileBrowser
                    uiThemeComboBox.currentIndex = uiThemeComboBox.find(DepthView.uiTheme)

                    /* If the selection is invalid, use "Default", as that's what QML uses when none is set. */
                    if (uiThemeComboBox.currentIndex < 0)
                        uiThemeComboBox.currentIndex = 0
                }

                function apply() {
                    DepthView.saveWindowState = saveWindowStateCheckBox.checked
                    DepthView.startupFileBrowser = startupFileBrowserCheckBox.checked
                    DepthView.uiTheme = uiThemeComboBox.currentText
                }

                readonly property string title: qsTr("General Settings")

                ScrollBar.vertical: ScrollBar { }
                contentHeight: generalSettingsContent.childrenRect.height

                /* Only enable panning when the item is tall enough. */
                interactive: contentHeight > height

                Column {
                    id: generalSettingsContent
                    width: parent.width

                    CheckBox {
                        id: saveWindowStateCheckBox
                        text: qsTr("Remember Window State")
                    }

                    CheckBox {
                        id: startupFileBrowserCheckBox
                        text: qsTr("Show File Browser at Startup")
                    }

                    Row {
                        Label {
                            anchors.verticalCenter: parent.verticalCenter
                            text: qsTr("UI Theme: ")
                        }

                        ComboBox {
                            id: uiThemeComboBox

                            model: DepthView.uiThemes
                        }
                    }
                    Button {
                        /* If the function is undefined this build doesn't support file association. */
                        visible: DepthView.registerFileTypes !== undefined

                        /* TODO - It would be nice to have a more configurable "register these types" setup... */
                        text: qsTr("Register stereo image files with DepthView.")

                        onClicked: DepthView.registerFileTypes()
                    }
                    Button {
                        text: qsTr("Reset File Database")

                        /* TODO - Confirm. */
                        onClicked: FolderListing.resetFileDatabase()
                    }
                    Button {
                        text: qsTr("Reset Plugin Database")

                        /* TODO - Confirm. */
                        onClicked: PluginManager.resetPluginDatabase()
                    }
                }
            }

            Flickable {
                function reset() {
                    greyFacSlider.value = DepthView.greyFac
                    mirrorLeftCheckBox.checked = DepthView.mirrorLeft
                    mirrorRightCheckBox.checked = DepthView.mirrorRight
                    anamorphicCheckBox.checked = DepthView.anamorphicDualView
                    swapEyesCheckBox.checked = DepthView.swapEyes
                }

                function apply() {
                    DepthView.greyFac = greyFacSlider.value
                    DepthView.mirrorLeft = mirrorLeftCheckBox.checked
                    DepthView.mirrorRight = mirrorRightCheckBox.checked
                    DepthView.anamorphicDualView = anamorphicCheckBox.checked
                    DepthView.swapEyes = swapEyesCheckBox.checked
                }

                readonly property string title: qsTr("Render Settings")

                ScrollBar.vertical: ScrollBar { }
                contentHeight: renderSettingsContent.childrenRect.height

                /* Only enable panning when the item is tall enough. */
                interactive: contentHeight > height

                Column {
                    id: renderSettingsContent
                    width: parent.width

                    GroupBox {
                        width: parent.width
                        title: qsTr("Anaglyph")

                        LabeledSlider {
                            text: qsTr("Grey Factor")

                            id: greyFacSlider
                            Layout.fillWidth: true
                        }
                    }

                    GroupBox {
                        width: parent.width
                        title: qsTr("Side-by-Side/Top-Bottom")

                        Column {
                            anchors.fill: parent

                            CheckBox {
                                id: mirrorLeftCheckBox
                                text: qsTr("Mirror Left")
                            }
<commit_msg>Show confirmation dialog before resetting database.<commit_after>import QtQuick 2.5
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.3
import DepthView 2.0

Dialog {
    id: root
    modal: true

    function reset() {
        for (var i = 0; i < swipe.contentModel.count; ++i)
            if (swipe.contentModel.get(i).reset !== undefined)
                swipe.contentModel.get(i).reset();
    }

    onRejected: reset()

    onAccepted: {
        for (var i = 0; i < swipe.contentModel.count; ++i)
            if (swipe.contentModel.get(i).apply !== undefined)
                swipe.contentModel.get(i).apply();
    }

    footer: DialogButtonBox {
        standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel | DialogButtonBox.Apply | DialogButtonBox.Reset

        onClicked: {
            if (button === standardButton(DialogButtonBox.Apply))
                swipe.currentItem.apply()
            else if (button === standardButton(DialogButtonBox.Reset))
                swipe.currentItem.reset()
        }

        Component.onCompleted: {
            /* Disable the buttons if there is no function for them to call. */
            standardButton(DialogButtonBox.Apply).enabled = Qt.binding(function() { return swipe.currentItem !== null && swipe.currentItem.apply !== undefined })
            standardButton(DialogButtonBox.Reset).enabled = Qt.binding(function() { return swipe.currentItem !== null && swipe.currentItem.reset !== undefined })
        }
    }

    /* Use the reset function to init values. */
    Component.onCompleted: reset()

    clip: true

    header: TabBar {
        id: bar
        currentIndex: swipe.currentIndex

        Repeater {
            model: swipe.contentChildren

            TabButton { text: modelData.title }
        }
    }

    Item {
        anchors.fill: parent
        clip: true

        SwipeView {
            id: swipe
            anchors.fill: parent
            currentIndex: bar.currentIndex

            Flickable {
                function reset() {
                    saveWindowStateCheckBox.checked = DepthView.saveWindowState
                    startupFileBrowserCheckBox.checked = DepthView.startupFileBrowser
                    uiThemeComboBox.currentIndex = uiThemeComboBox.find(DepthView.uiTheme)

                    /* If the selection is invalid, use "Default", as that's what QML uses when none is set. */
                    if (uiThemeComboBox.currentIndex < 0)
                        uiThemeComboBox.currentIndex = 0
                }

                function apply() {
                    DepthView.saveWindowState = saveWindowStateCheckBox.checked
                    DepthView.startupFileBrowser = startupFileBrowserCheckBox.checked
                    DepthView.uiTheme = uiThemeComboBox.currentText
                }

                readonly property string title: qsTr("General Settings")

                ScrollBar.vertical: ScrollBar { }
                contentHeight: generalSettingsContent.childrenRect.height

                /* Only enable panning when the item is tall enough. */
                interactive: contentHeight > height

                Column {
                    id: generalSettingsContent
                    width: parent.width

                    CheckBox {
                        id: saveWindowStateCheckBox
                        text: qsTr("Remember Window State")
                    }

                    CheckBox {
                        id: startupFileBrowserCheckBox
                        text: qsTr("Show File Browser at Startup")
                    }

                    Row {
                        Label {
                            anchors.verticalCenter: parent.verticalCenter
                            text: qsTr("UI Theme: ")
                        }

                        ComboBox {
                            id: uiThemeComboBox

                            model: DepthView.uiThemes
                        }
                    }
                    Button {
                        /* If the function is undefined this build doesn't support file association. */
                        visible: DepthView.registerFileTypes !== undefined

                        /* TODO - It would be nice to have a more configurable "register these types" setup... */
                        text: qsTr("Register stereo image files with DepthView.")

                        onClicked: DepthView.registerFileTypes()
                    }

                    RowLayout {
                        Button {
                            text: qsTr("Reset File Database")

                            onClicked: resetFileDB.open()

                        }
                        Button {
                            text: qsTr("Reset Plugin Database")

                            onClicked: resetPluginDB.open()

                        }
                    }
                }
                Dialog {
                    id: resetFileDB
                    title: "Are you sure?"
                    modal: true

                    Label {
                        text: "All stored file information will be lost..."
                    }

                    standardButtons: Dialog.Ok | Dialog.Cancel

                    onAccepted: FolderListing.resetFileDatabase()
                }
                Dialog {
                    id: resetPluginDB
                    title: "Are you sure?"
                    modal: true

                    Label {
                        text: "All currently enabled plugins will be reset..."
                    }

                    standardButtons: Dialog.Ok | Dialog.Cancel

                    onAccepted: PluginManager.resetPluginDatabase()
                }
            }

            Flickable {
                function reset() {
                    greyFacSlider.value = DepthView.greyFac
                    mirrorLeftCheckBox.checked = DepthView.mirrorLeft
                    mirrorRightCheckBox.checked = DepthView.mirrorRight
                    anamorphicCheckBox.checked = DepthView.anamorphicDualView
                    swapEyesCheckBox.checked = DepthView.swapEyes
                }

                function apply() {
                    DepthView.greyFac = greyFacSlider.value
                    DepthView.mirrorLeft = mirrorLeftCheckBox.checked
                    DepthView.mirrorRight = mirrorRightCheckBox.checked
                    DepthView.anamorphicDualView = anamorphicCheckBox.checked
                    DepthView.swapEyes = swapEyesCheckBox.checked
                }

                readonly property string title: qsTr("Render Settings")

                ScrollBar.vertical: ScrollBar { }
                contentHeight: renderSettingsContent.childrenRect.height

                /* Only enable panning when the item is tall enough. */
                interactive: contentHeight > height

                ColumnLayout {
                    id: renderSettingsContent
                    width: parent.width

                    GroupBox {
                        Layout.fillWidth: true
                        title: qsTr("Anaglyph")

                        LabeledSlider {
                            text: qsTr("Grey Factor")

                            id: greyFacSlider
                            Layout.fillWidth: true
                        }
                    }

                    GroupBox {
                        Layout.fillWidth: true
                        title: qsTr("Side-by-Side/Top-Bottom")

                        Column {
                            anchors.fill: parent

                            CheckBox {
                                id: mirrorLeftCheckBox
                                text: qsTr("Mirror Left")
                            }

{'fraction_non_alphanumeric': 0.06775416271828888, 'fraction_numerical': 0.001624475429809124, 'mean_word_length': 1.1795250036878595, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4019726', 'n_tokens_mistral': 3505, 'n_tokens_neox': 3171, 'n_words': 750}