<commit_before>/****************************************************************************
**
** Copyright (C) 2013-2015 <NAME>
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**
****************************************************************************/

import QtQuick 2.4
import QtQuick.Controls.Styles 1.3
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import Qt.labs.settings 1.0
import "palettes"

ApplicationWindow {
    id: cApplicationWindow
    width: 420
    height: 640
    visible: true
    title: "QML Creator"
    visibility: settings.debugMode ? "FullScreen" : "Maximized"

    style: ApplicationWindowStyle {
        background: Rectangle {
            color: palette.background
        }
    }

    // Loading
    signal loaded()

    Component.onCompleted:
        loaded()

    onLoaded: {
        // http://doc.qt.io/qt-5/qml-qtquick-window-screen.html
        // The Screen attached object is valid inside Item or Item derived types, after component completion
        settings.pixelDensity = settings.debugMode ? 6.0 : Screen.logicalPixelDensity

        if (settings.firstRun)
        {
            projectManager.restoreExamples()
            settings.firstRun = false
        }
    }

    // Settings
    QtObject {
        id: settings

        // configurable
        property string font: "Ubuntu Mono"
        property int fontSize: 40
        property string palette: "Cute"
        property int indentSize: 4

        // internal
        property bool debugMode: false
        property double pixelDensity
        property bool firstRun: true
        property bool desktopPlatform: Qt.platform.os === "windows" ||
                                       Qt.platform.os === "linux" ||
                                       Qt.platform.os === "osx" ||
                                       Qt.platform.os === "unix"
    }

    Settings {
        category: "Editor"
        property alias font: settings.font
        property alias fontSize: settings.fontSize
        property alias palette: settings.palette
        property alias indentSize: settings.indentSize
        property alias firstRun: settings.firstRun
    }

    property alias settings: settings

    // Palettes

    PaletteLoader {
        id: paletteLoader
        name: settings.palette
    }

    property alias palette: paletteLoader.palette

    // Focus Management

    property var focusItem: null
    signal backPressed()

    onActiveFocusItemChanged: {
        if (focusItem !== null && focusItem.Keys !== undefined)
            focusItem.Keys.onReleased.disconnect(onKeyReleased)

        if (activeFocusItem !== null)
        {
            activeFocusItem.Keys.onReleased.connect(onKeyReleased)
            focusItem = activeFocusItem
        }
    }

    function onKeyReleased(event) {
        if (event.key === Qt.Key_Back || event.key === Qt.Key_Escape) {<commit_msg>Implemented mechanism of examples update<commit_after>/****************************************************************************
**
** Copyright (C) 2013-2015 <NAME>
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**
****************************************************************************/

import QtQuick 2.4
import QtQuick.Controls.Styles 1.3
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import Qt.labs.settings 1.0
import "palettes"

ApplicationWindow {
    id: cApplicationWindow
    width: 420
    height: 640
    visible: true
    title: "QML Creator"
    visibility: settings.debugMode ? "FullScreen" : "Maximized"

    style: ApplicationWindowStyle {
        background: Rectangle {
            color: palette.background
        }
    }

    // Loading
    signal loaded()

    Component.onCompleted:
        loaded()

    onLoaded: {
        // http://doc.qt.io/qt-5/qml-qtquick-window-screen.html
        // The Screen attached object is valid inside Item or Item derived types, after component completion
        settings.pixelDensity = settings.debugMode ? 6.0 : Screen.logicalPixelDensity

        var previousVersion = parseInt(settings.previousVersion.split(".").join(""))
        if (previousVersion === 0)
        { // first run
            projectManager.restoreExamples()
            settings.previousVersion = Qt.application.version
        }
        else
        {
            var currentVersion = parseInt(Qt.application.version.split(".").join(""))
            if (currentVersion > previousVersion)
            {
                var parameters = {
                    title: qsTr("New examples"),
                    text: qsTr("We detected that you had recently updated QML Creator on your device.") + "\n" +
                          qsTr("We are constantly working on QML Creator improvement, and we may have added some new sample projects in the current release.") + "\n" +
                          qsTr("Press OK if you would like to get them now (notice that all the changes you have made in the \"Examples\" section will be removed)") + "\n" +
                          qsTr("Alternatively, you can do it later by pressing the \"Restore examples\" button in the \"Examples\" screen.")
                }

                var callback = function(value)
                {
                    if (value)
                        projectManager.restoreExamples()

                    settings.previousVersion = Qt.application.version
                }

                dialog.open(dialog.types.confirmation, parameters, callback)
            }
        }
    }

    // Settings
    QtObject {
        id: settings

        // configurable
        property string font: "Ubuntu Mono"
        property int fontSize: 40
        property string palette: "Cute"
        property int indentSize: 4

        // internal
        property bool debugMode: false
        property double pixelDensity
        property string previousVersion: "0.0.0"
        property bool desktopPlatform: Qt.platform.os === "windows" ||
                                       Qt.platform.os === "linux" ||
                                       Qt.platform.os === "osx" ||
                                       Qt.platform.os === "unix"
    }

    Settings {
        category: "Editor"
        property alias font: settings.font
        property alias fontSize: settings.fontSize
        property alias palette: settings.palette
        property alias indentSize: settings.indentSize
    }

    Settings {
        category: "Version"
        property alias previousVersion: settings.previousVersion
    }

    property alias settings: settings

    // Palettes

    PaletteLoader {
        id: paletteLoader
        name: settings.palette
    }

    property alias palette: paletteLoader.palette

    // Focus Management

    property var focusItem: null
    signal backPressed()

    onActiveFocusItemChanged: {
        if (focusItem !== null && focusItem.Keys !== undefined)
            focusItem.Keys.onReleased.disconnect(onKeyReleased)

        if (activeFocusItem !== null)
        {
            activeFocusItem.Keys.onReleased.connect(onKeyReleased)
            focusItem = activeFocusItem
        }
    }

    function onKeyReleased(event) {
        if (event.key === Qt.Key_Back || event.key === Qt.Key_Escape) {
{'fraction_non_alphanumeric': 0.12116061672939177, 'fraction_numerical': 0.008741046497511229, 'mean_word_length': 2.2154566744730677, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '655774', 'n_tokens_mistral': 2113, 'n_tokens_neox': 1960, 'n_words': 640}