/*
 * Copyright (C) 2022-2026 Savoir-faire Linux Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import net.jami.Models 1.1
import net.jami.Adapters 1.1
import net.jami.Constants 1.1
import Qt5Compat.GraphicalEffects
import "../../commoncomponents"

BaseModalDialog {
    id: root

    titleText: JamiStrings.chooseAUsername
    closeButtonVisible: false

    signal joinClicked

    modal: true
    padding: 0

    visible: false
    focus: true
    closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside

    button1.text: JamiStrings.chooseAUsername
    button1Role: DialogButtonBox.NoRole
    button1.onClicked: root.close()

    button2.text: JamiStrings.joinJami
    button2Role: DialogButtonBox.YesRole
    button2.objectName: "joinButton"
    button2.onClicked: {
        root.joinClicked();
        WizardViewStepModel.nextStep();
        root.close();
    }
    button2.Accessible.name: JamiStrings.chooseAUsername
    button2.Accessible.description: JamiStrings.joinJamiNoPassword

    popupContent: ColumnLayout {
        width: 400
        Text {
            Layout.fillWidth: true
            Layout.fillHeight: true
            Layout.leftMargin: popupMargins
            Layout.rightMargin: popupMargins

            text: JamiStrings.joinJamiNoPassword
            color: JamiTheme.textColor
            horizontalAlignment: Text.AlignLeft
            verticalAlignment: Text.AlignVCenter
            wrapMode: Text.WordWrap
            font.pixelSize: JamiTheme.popuptextSize

            lineHeight: JamiTheme.wizardViewTextLineHeight

            Accessible.role: Accessible.Dialog
            Accessible.name: titleText
            Accessible.description: JamiStrings.joinJamiNoPassword
        }
    }
}
