<commit_before>import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.2

import nerdioscore 1.0


ApplicationWindow {
    id: root
    visible: true
    width: 490
    height: 980

    function focusChat(recipient, message) {
        if (recipient === null) {
            return;
        }

        var jid = recipient.split("/")[0]

        if (messageStack.currentItem !== null && messageStack.currentItem.recipient === jid) {
            if (message !== "") {
                messageStack.currentItem.text += jid + ": " + message + "\n"
            }
            return;
        }

        var elem = messageStack.find(function(item) {
            if (item !== null && item.recipient === jid) {
                return true;
            }
            return false;
        }, true)
        if (elem !== null) {
            elem = messageStack.pop(elem)
            if (message !== "") {
                elem.text += jid + ": " + message + "\n"
            }
            return;
        }

        // create new chat window
        var newObject = Qt.createQmlObject('import QtQuick.Controls 1.4; TextArea {property string recipient}',
            root, "dynamicSnippet1");
        if (message === "") {
            messageStack.push({item: newObject, properties: {recipient: jid}})
        } else {
            messageStack.push({item: newObject, properties: {recipient: jid, text: jid + ": " + message + "\n"}})
        }
    }

    NerdiosCore {
        id: nerdioscore
        jid: "<EMAIL>"
        password: "password"

        onMessageReceived: {
            focusChat(message.from, message.body)
        }
    }

    Dialog {
        id: addContactDialog
        title: "Add a contact"
        standardButtons: StandardButton.Ok | StandardButton.Cancel
            TextField {
                id: jidField
                text: "jid"
            }
        onAccepted: {
            console.log(jidField.text)
            nerdioscore.addContact(jidField.text)
        }
    }

    Action {
        id: addContact
        onTriggered: addContactDialog.open()
    }

    menuBar: MenuBar {
            Menu {
                title: "File"
                MenuItem {
                    text: "About"
                }
                MenuItem {
                    text: "Preferences"
                }
                MenuItem {
                    text: "Quit"
                    onTriggered: Qt.quit()
                }
            }

            Menu {
                title: "Status"
                MenuItem {
                    text: "Available"
                    onTriggered: {<commit_msg>add login dialog<commit_after>import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.2

import nerdioscore 1.0


ApplicationWindow {
    id: root
    visible: true
    width: 490
    height: 980

    function focusChat(recipient, message) {
        if (recipient === null) {
            return;
        }

        var jid = recipient.split("/")[0]

        if (messageStack.currentItem !== null && messageStack.currentItem.recipient === jid) {
            if (message !== "") {
                messageStack.currentItem.text += jid + ": " + message + "\n"
            }
            return;
        }

        var elem = messageStack.find(function(item) {
            if (item !== null && item.recipient === jid) {
                return true;
            }
            return false;
        }, true)
        if (elem !== null) {
            elem = messageStack.pop(elem)
            if (message !== "") {
                elem.text += jid + ": " + message + "\n"
            }
            return;
        }

        // create new chat window
        var newObject = Qt.createQmlObject('import QtQuick.Controls 1.4; TextArea {property string recipient}',
            root, "dynamicSnippet1");
        if (message === "") {
            messageStack.push({item: newObject, properties: {recipient: jid}})
        } else {
            messageStack.push({item: newObject, properties: {recipient: jid, text: jid + ": " + message + "\n"}})
        }
    }

    NerdiosCore {
        id: nerdioscore

        onMessageReceived: {
            focusChat(message.from, message.body)
        }
    }

    Dialog {
        id: addContactDialog
        title: "Add a contact"
        standardButtons: StandardButton.Ok | StandardButton.Cancel
            TextField {
                id: jidField
                text: "jid"
            }
        onAccepted: {
            console.log(jidField.text)
            nerdioscore.addContact(jidField.text)
        }
    }

    Dialog {
        id: loginDialog
        title: "Login"
        standardButtons: StandardButton.Ok | StandardButton.Cancel
        GridLayout {
            id: grid
            columns: 2
            rows: 2
            Label {
                text: "Username: "
            }
            TextField {
                id: loginName
            }
            Label {
                text: "Password: "
            }
            TextField {
                id: loginPassword
                echoMode: TextInput.Password
            }
        }

        onAccepted: {
            nerdioscore.jid = loginName.text
            nerdioscore.password = <PASSWORD>
            //nerdioscore.connect()
        }
    }

    Action {
        id: addContact
        onTriggered: addContactDialog.open()
    }

    menuBar: MenuBar {
            Menu {
                title: "File"
                MenuItem {
                    text: "Login"
                    onTriggered: loginDialog.open()
                }

                MenuItem {
                    text: "About"
                }
                MenuItem {
                    text: "Preferences"
                }
                MenuItem {
                    text: "Quit"
                    onTriggered: Qt.quit()
                }
            }

            Menu {
                title: "Status"
                MenuItem {
                    text: "Available"
                    onTriggered: {
{'fraction_non_alphanumeric': 0.1014920478767011, 'fraction_numerical': 0.006886374815543532, 'mean_word_length': 1.2077452044878756, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5848176', 'n_tokens_mistral': 1698, 'n_tokens_neox': 1582, 'n_words': 356}