From 6e43a456fd94780e07dcf1143dc19829fd9000bf Mon Sep 17 00:00:00 2001 From: ababi <albert.babi@savoirfairelinux.com> Date: Mon, 7 Sep 2020 17:44:57 +0200 Subject: [PATCH] dialogs: migrate dialogs to native-style Gitlab: #20 Change-Id: I05358244ad9cae5d335934a2947c18de6d79683e --- qml.qrc | 1 + .../AccountMigrationDialog.qml | 784 +++++------------- src/commoncomponents/BaseDialog.qml | 28 + src/commoncomponents/DeleteAccountDialog.qml | 137 ++- src/commoncomponents/ElidedTextLabel.qml | 3 +- src/commoncomponents/HoverableButton.qml | 3 +- src/commoncomponents/PasswordDialog.qml | 267 +++--- src/constant/JamiStrings.qml | 9 +- src/constant/JamiTheme.qml | 3 + src/mainview/MainView.qml | 23 +- src/mainview/components/AboutPopUp.qml | 92 +- src/mainview/components/UserProfile.qml | 238 +++--- src/mainview/components/WelcomePage.qml | 17 +- .../components/WelcomePageQrDialog.qml | 74 +- .../components/CurrentAccountSettings.qml | 30 +- .../components/KeyBoardShortcutTable.qml | 148 ++-- .../components/LinkDeviceDialog.qml | 245 +++--- src/settingsview/components/LinkedDevices.qml | 6 +- .../components/NameRegistrationDialog.qml | 518 +++--------- .../components/RevokeDevicePasswordDialog.qml | 125 +-- src/wizardview/WizardView.qml | 4 - .../components/ImportFromBackupPage.qml | 6 +- 22 files changed, 1041 insertions(+), 1720 deletions(-) create mode 100644 src/commoncomponents/BaseDialog.qml diff --git a/qml.qrc b/qml.qrc index 7d367269b..0bb8fc3b0 100644 --- a/qml.qrc +++ b/qml.qrc @@ -138,5 +138,6 @@ <file>src/commoncomponents/SpinnerButton.qml</file> <file>src/commoncomponents/UsernameLineEdit.qml</file> <file>src/mainview/components/UserInfoCallPage.qml</file> + <file>src/commoncomponents/BaseDialog.qml</file> </qresource> </RCC> diff --git a/src/commoncomponents/AccountMigrationDialog.qml b/src/commoncomponents/AccountMigrationDialog.qml index 07c7f3e88..ea5f95085 100644 --- a/src/commoncomponents/AccountMigrationDialog.qml +++ b/src/commoncomponents/AccountMigrationDialog.qml @@ -46,11 +46,11 @@ Window{ signal accountMigrationFinished - function startAccountMigrationOfTopStack(){ + function startAccountMigrationOfTopStack() { passwordInputLineEdit.clear() accountsToMigrateListModel.reset() - if(accountsToMigrateListModel.rowCount() <= 0){ + if (accountsToMigrateListModel.rowCount() <= 0) { closeWithoutOperation() return false @@ -65,21 +65,21 @@ Window{ var alias = accountsToMigrateListModel.data(accountsToMigrateListModel.index( 0, 0), AccountsToMigrateListModel.Alias) - if(managerUri.length !== 0){ + if (managerUri.length !== 0) { managerUriInputLabel.text = managerUri } else { managerUriInputLabel.text = "N/A" } - if(username.length !== 0){ + if (username.length !== 0) { usernameInputLabel.text = username - } else if(managerUsername.length !== 0){ + } else if (managerUsername.length !== 0) { usernameInputLabel.text = managerUsername } else { usernameInputLabel.text = "N/A" } - if(alias.length !== 0){ + if (alias.length !== 0) { aliasInputLabel.text = alias } else { aliasInputLabel.text = "N/A" @@ -102,20 +102,20 @@ Window{ return true } - function checkIfAccountMigrationFinishedAndClose(){ + function checkIfAccountMigrationFinishedAndClose() { accountsToMigrateListModel.reset() - if(accountsToMigrateListModel.rowCount() > 0){ + if (accountsToMigrateListModel.rowCount() > 0) { startAccountMigrationOfTopStack() } else { accountMigrationFinished() - if(!nonOperationClosing){ + if (!nonOperationClosing) { nonOperationClosing = true accountMigrationDialog.close() } } } - function acceptMigration(){ + function acceptMigration() { nonOperationClosing = false accountsToMigrateListModel.dataChanged(accountsToMigrateListModel.index(0, 0), accountsToMigrateListModel.index( @@ -123,17 +123,17 @@ Window{ checkIfAccountMigrationFinishedAndClose() } - function refuseMigrationAndDeleteAccount(){ + function refuseMigrationAndDeleteAccount() { AccountAdapter.model.removeAccount(accountID) acceptMigration() } - function closeWithoutOperation(){ + function closeWithoutOperation() { nonOperationClosing = false accountMigrationDialog.close() } - Timer{ + Timer { id: timerFailureReturn interval: 1000 @@ -145,27 +145,27 @@ Window{ } } - Connections{ + Connections { id: connectionMigrationEnded enabled: false target: AccountAdapter.model - function onMigrationEnded(accountIdIn, ok){ + function onMigrationEnded(accountIdIn, ok) { nonOperationClosing = true connectionMigrationEnded.enabled = false - if(accountID !== accountIdIn){ + if (accountID !== accountIdIn) { return } - if(!ok){ + if (ok) { + acceptMigration() + } else { successState = false timerFailureReturn.restart() - } else { - acceptMigration() } } } - function slotMigrationButtonClicked(){ + function slotMigrationButtonClicked() { successState = true stackedWidget.currentIndex = 1 @@ -173,7 +173,7 @@ Window{ AccountAdapter.setArchivePasswordAsync(accountID,password) } - function slotDeleteButtonClicked(){ + function slotDeleteButtonClicked() { nonOperationClosing = false refuseMigrationAndDeleteAccount() } @@ -188,7 +188,7 @@ Window{ usernameInputLabel.text = "" aliasInputLabel.text = "" - if(nonOperationClosing){ + if (nonOperationClosing) { checkIfAccountMigrationFinishedAndClose() } nonOperationClosing = true @@ -196,8 +196,14 @@ Window{ visible: false - width: 455 - height: 594 + title: JamiStrings.authenticate + modality: Qt.WindowModal + flags: Qt.WindowStaysOnTopHint + + width: 600 + height: 600 + minimumWidth: 600 + minimumHeight: 600 Component.onCompleted: { setX(Screen.width / 2 - width / 2) @@ -205,10 +211,10 @@ Window{ } ColumnLayout { - anchors.fill: parent - Layout.alignment: Qt.AlignHCenter + anchors.fill: parent + Layout.alignment: Qt.AlignHCenter - StackLayout{ + StackLayout { id: stackedWidget Layout.fillWidth: true @@ -217,499 +223,220 @@ Window{ currentIndex: 0 - Rectangle{ + // Index = 0 + Rectangle { id: accountMigrationPage Layout.fillWidth: true Layout.fillHeight: true Layout.alignment: Qt.AlignHCenter - Layout.leftMargin: 11 - Layout.rightMargin: 11 - Layout.topMargin: 11 - Layout.bottomMargin: 11 - - x: (parent.width - width) /2 - y: (parent.height - height) /2 - - ScrollView { - id: accountMigrationPageScroll - anchors.fill: parent - - clip: true - - ScrollBar.horizontal.policy: ScrollBar.AsNeeded - ScrollBar.vertical.policy: ScrollBar.AsNeeded - ColumnLayout { - spacing: 7 + spacing: 8 width: stackedWidget.width height: stackedWidget.height Layout.alignment: Qt.AlignHCenter - RowLayout { - Layout.fillWidth: true - - Item{ - Layout.fillWidth: true - - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 - } - - Label { - id: accountMigrationLabel - - Layout.alignment: Qt.AlignHCenter - Layout.preferredHeight: 27 - - font.pointSize: 13 - font.kerning: true - wrapMode:Text.Wrap + Label { + id: accountMigrationLabel - text: JamiStrings.authenticationRequired + Layout.alignment: Qt.AlignHCenter + Layout.preferredHeight: JamiTheme.preferredFieldHeight - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter - } + font.pointSize: JamiTheme.headerFontSize + font.kerning: true + wrapMode:Text.Wrap - Item{ - Layout.fillWidth: true + text: JamiStrings.authenticationRequired - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 - } + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter } - RowLayout{ - spacing: 7 - - Item{ - Layout.fillWidth: true - - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 - } - - Label{ - id: migrationReasonLabel - - Layout.alignment: Qt.AlignHCenter - Layout.preferredHeight: 21 - - font.pointSize: 10 - font.kerning: true - wrapMode:Text.Wrap - - text: JamiStrings.migrationReason - - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter - } + Label { + id: migrationReasonLabel - Item{ - Layout.fillWidth: true + Layout.alignment: Qt.AlignHCenter + Layout.preferredHeight: JamiTheme.preferredFieldHeight - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 - } - } + font.pointSize: JamiTheme.textFontSize + font.kerning: true + wrapMode:Text.Wrap - Item{ - Layout.minimumWidth: 20 - Layout.preferredWidth: 20 - Layout.maximumWidth: 20 + text: JamiStrings.migrationReason - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter } - ColumnLayout{ - spacing: 7 - - Layout.fillWidth: true - - RowLayout{ - Layout.fillWidth: true - Layout.alignment: Qt.AlignCenter - - Item{ - Layout.fillWidth: true + Label { + id: avatarLabel - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 - } - - Label{ - id: avatarLabel - - Layout.maximumWidth: 200 - Layout.preferredWidth: 200 - Layout.minimumWidth: 200 + Layout.preferredWidth: 200 + Layout.preferredHeight: 200 - Layout.maximumHeight: 200 - Layout.preferredHeight: 200 - Layout.minimumHeight: 200 - - Layout.alignment: Qt.AlignHCenter + Layout.alignment: Qt.AlignHCenter - background: Rectangle { - id: avatarLabelBackground + background: Rectangle { + id: avatarLabelBackground - anchors.fill: parent - color: "transparent" + anchors.fill: parent + color: "transparent" - Image{ - id: avatarImg + Image { + id: avatarImg - anchors.fill: parent - source: { - if(imgBase64.length === 0){ - return "" - } else { - return "data:image/png;base64," + imgBase64 - } - } - fillMode: Image.PreserveAspectCrop - layer.enabled: true - layer.effect: OpacityMask { - maskSource: Rectangle{ - width: avatarImg.width - height: avatarImg.height - radius: { - var size = ((avatarImg.width <= avatarImg.height)? avatarImg.width:avatarImg.height) - return size /2 - } - } + anchors.fill: parent + source: { + if (imgBase64.length === 0) { + return "" + } else { + return "data:image/png;base64," + imgBase64 + } + } + fillMode: Image.PreserveAspectCrop + layer.enabled: true + layer.effect: OpacityMask { + maskSource: Rectangle { + width: avatarImg.width + height: avatarImg.height + radius: { + var size = ((avatarImg.width <= avatarImg.height)? avatarImg.width:avatarImg.height) + return size / 2 } } } } - - Item{ - Layout.fillWidth: true - - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 - } } } - Item{ - Layout.minimumWidth: 20 - Layout.preferredWidth: 20 - Layout.maximumWidth: 20 - - Layout.minimumHeight: 30 - Layout.preferredHeight: 30 - Layout.maximumHeight: 30 - } - - GridLayout{ + GridLayout { rows: 4 - columns: 5 - rowSpacing: 7 - columnSpacing: 7 + columns: 2 + rowSpacing: 8 + columnSpacing: 8 Layout.fillWidth: true + Layout.alignment: Qt.AlignHCenter + Layout.leftMargin: JamiTheme.preferredMarginSize + Layout.rightMargin: JamiTheme.preferredMarginSize // 1st Row - Item{ - Layout.row: 0 - Layout.column: 0 - - Layout.fillWidth: true - Layout.preferredWidth:40 - - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 - } - - Label{ + Label { id: aliasLabel - Layout.row: 0 - Layout.column: 1 - - Layout.preferredWidth: 92 - Layout.preferredHeight: 30 + Layout.preferredWidth: JamiTheme.preferredFieldWidth + Layout.preferredHeight: JamiTheme.preferredFieldHeight text: JamiStrings.alias - font.pointSize: 10 + font.pointSize: JamiTheme.textFontSize font.kerning: true horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } - Item{ - Layout.row: 0 - Layout.column: 2 - - Layout.fillWidth: true - Layout.preferredWidth:40 - Layout.maximumWidth: 40 - - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 - } - - Label{ + Label { id: aliasInputLabel - Layout.row: 0 - Layout.column: 3 - - Layout.preferredWidth: 142 + Layout.preferredWidth: JamiTheme.preferredFieldWidth + Layout.preferredHeight: JamiTheme.preferredFieldHeight - Layout.minimumHeight: 30 - Layout.preferredHeight: 30 - - font.pointSize: 10 + font.pointSize: JamiTheme.textFontSize font.kerning: true horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } - Item{ - Layout.row: 0 - Layout.column: 4 - - Layout.fillWidth: true - Layout.preferredWidth:40 - - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 - } - // 2nd Row - Item{ - Layout.row: 1 - Layout.column: 0 - - Layout.fillWidth: true - Layout.preferredWidth:40 - - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 - } - - Label{ + Label { id: usernameLabel - Layout.row: 1 - Layout.column: 1 - - Layout.preferredWidth: 92 - Layout.preferredHeight: 30 + Layout.preferredWidth: JamiTheme.preferredFieldWidth + Layout.preferredHeight: JamiTheme.preferredFieldHeight text: JamiStrings.username - font.pointSize: 10 + font.pointSize: JamiTheme.textFontSize font.kerning: true horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } - Item{ - Layout.row: 1 - Layout.column: 2 - - Layout.fillWidth: true - Layout.preferredWidth:40 - Layout.maximumWidth: 40 - - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 - } - - Label{ + Label { id: usernameInputLabel - Layout.row: 1 - Layout.column: 3 - - Layout.preferredWidth: 142 - - Layout.minimumHeight: 30 - Layout.preferredHeight: 30 + Layout.preferredWidth: JamiTheme.preferredFieldWidth + Layout.preferredHeight: JamiTheme.preferredFieldHeight - font.pointSize: 10 + font.pointSize: JamiTheme.textFontSize font.kerning: true horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } - Item{ - Layout.row: 1 - Layout.column: 4 - - Layout.fillWidth: true - Layout.preferredWidth:40 - - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 - } - // 3rd Row - Item{ - Layout.row: 2 - Layout.column: 0 - - Layout.fillWidth: true - Layout.preferredWidth:40 - - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 - } - - Label{ + Label { id: managerUriLabel - Layout.row: 2 - Layout.column: 1 - - Layout.preferredWidth: 92 - Layout.preferredHeight: 30 + Layout.preferredWidth: JamiTheme.preferredFieldWidth + Layout.preferredHeight: JamiTheme.preferredFieldHeight text: JamiStrings.jamsServer - font.pointSize: 10 + font.pointSize: JamiTheme.textFontSize font.kerning: true horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } - Item{ - Layout.row: 2 - Layout.column: 2 - - Layout.fillWidth: true - Layout.preferredWidth:40 - Layout.maximumWidth: 40 - - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 - } - - Label{ + Label { id: managerUriInputLabel - Layout.row: 2 - Layout.column: 3 + Layout.preferredWidth: JamiTheme.preferredFieldWidth + Layout.preferredHeight: JamiTheme.preferredFieldHeight - Layout.preferredWidth: 142 - - Layout.minimumHeight: 30 - Layout.preferredHeight: 30 - - font.pointSize: 10 + font.pointSize: JamiTheme.textFontSize font.kerning: true horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } - Item{ - Layout.row: 2 - Layout.column: 4 - - Layout.fillWidth: true - Layout.preferredWidth:40 - - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 - } - // 4th Row - Item{ - Layout.row: 3 - Layout.column: 0 - - Layout.fillWidth: true - Layout.preferredWidth:40 - - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 - } - - Label{ + Label { id: passwordLabel - Layout.row: 3 - Layout.column: 1 - - Layout.preferredWidth: 92 - Layout.preferredHeight: 30 + Layout.preferredWidth: JamiTheme.preferredFieldWidth + Layout.preferredHeight: JamiTheme.preferredFieldHeight text: JamiStrings.password - font.pointSize: 10 + font.pointSize: JamiTheme.textFontSize font.kerning: true horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } - Item{ - Layout.row: 3 - Layout.column: 2 - - Layout.fillWidth: true - Layout.preferredWidth:40 - Layout.maximumWidth: 40 - - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 - } - - InfoLineEdit{ + MaterialLineEdit { id: passwordInputLineEdit - Layout.row: 3 - Layout.column: 3 - - Layout.preferredWidth: 142 - - Layout.minimumHeight: 30 - Layout.preferredHeight: 30 - - font.pointSize: 10 - font.kerning: true - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth + Layout.preferredHeight: 48 + echoMode: TextInput.Password placeholderText: JamiStrings.password onTextChanged: { - if(text.length === 0){ - migrationPushButton.enabled = false - } else { - migrationPushButton.enabled = true - } + migrationPushButton.enabled = text.length > 0 password = text } @@ -717,250 +444,125 @@ Window{ password = text } } - - Item{ - Layout.row: 3 - Layout.column: 4 - - Layout.fillWidth: true - Layout.preferredWidth:40 - - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 - } - } - - Item{ - Layout.minimumWidth: 20 - Layout.preferredWidth: 20 - Layout.maximumWidth: 20 - - Layout.minimumHeight: 40 - Layout.preferredHeight: 40 - Layout.maximumHeight: 40 } - RowLayout{ - spacing: 0 + RowLayout { + spacing: 80 Layout.fillWidth: true + Layout.alignment: Qt.AlignHCenter + Layout.bottomMargin: JamiTheme.preferredMarginSize - Item { - Layout.minimumWidth: 20 - Layout.preferredWidth: 20 - Layout.maximumWidth: 20 - - Layout.minimumHeight: 40 - Layout.preferredHeight: 40 - Layout.maximumHeight: 40 - } - - HoverableGradientButton { + MaterialButton { id: migrationPushButton Layout.alignment: Qt.AlignLeft - Layout.maximumWidth: 100 - Layout.preferredWidth: 100 + Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 + Layout.preferredHeight: JamiTheme.preferredFieldHeight - Layout.maximumHeight: 30 - Layout.preferredHeight: 30 - Layout.minimumHeight: 30 + color: enabled? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true text: JamiStrings.authenticate - font.pointSize: 10 - font.kerning: true - - radius: height / 2 - backgroundColor: JamiTheme.releaseColor onClicked: { slotMigrationButtonClicked() } } - Item { - Layout.fillWidth: true - - Layout.minimumHeight: 40 - Layout.preferredHeight: 40 - Layout.maximumHeight: 40 - } - - HoverableButtonTextItem { + MaterialButton { id: deleteAccountPushButton - backgroundColor: "red" - onEnterColor: Qt.rgba(150 / 256, 0, 0, 0.7) - onDisabledBackgroundColor: Qt.rgba( - 255 / 256, - 0, 0, 0.8) - onPressColor: backgroundColor - textColor: "white" - Layout.alignment: Qt.AlignRight - Layout.maximumWidth: 100 - Layout.preferredWidth: 100 + Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 + Layout.preferredHeight: JamiTheme.preferredFieldHeight - Layout.maximumHeight: 30 - Layout.preferredHeight: 30 - Layout.minimumHeight: 30 + color: JamiTheme.buttonTintedRed + hoveredColor: JamiTheme.buttonTintedRedHovered + pressedColor: JamiTheme.buttonTintedRedPressed + outlined: true text: JamiStrings.deleteAccount - font.pointSize: 10 - font.kerning: true - - radius: height / 2 - onClicked: { slotDeleteButtonClicked() } } - - Item { - Layout.minimumWidth: 20 - Layout.preferredWidth: 20 - Layout.maximumWidth: 20 - - Layout.minimumHeight: 40 - Layout.preferredHeight: 40 - Layout.maximumHeight: 40 - } } } - - } } - Rectangle{ + // Index = 1 + Rectangle { id: migrationWaitingPage Layout.fillWidth: true Layout.fillHeight: true Layout.alignment: Qt.AlignHCenter - Layout.leftMargin: 11 - Layout.rightMargin: 11 - Layout.topMargin: 11 - Layout.bottomMargin: 11 - - x: (parent.width - width) /2 - y: (parent.height - height) /2 - - ScrollView { - id: migrationWaitingPageScroll - anchors.fill: parent - - clip: true + ColumnLayout { + spacing: 8 - ScrollBar.horizontal.policy: ScrollBar.AsNeeded - ScrollBar.vertical.policy: ScrollBar.AsNeeded + width: stackedWidget.width + height: stackedWidget.height + Layout.alignment: Qt.AlignHCenter - ColumnLayout{ - spacing: 7 + RowLayout{ + spacing: 8 - width: stackedWidget.width - height: stackedWidget.height Layout.alignment: Qt.AlignHCenter + Layout.fillWidth: true - Item{ - Layout.fillWidth: true - Layout.fillHeight: true - - Layout.preferredHeight: 211 - } - - RowLayout{ - spacing: 7 + Label { + id: spinnerLabel Layout.alignment: Qt.AlignHCenter - Layout.fillWidth: true - - Item{ - Layout.alignment: Qt.AlignLeft - Layout.fillWidth: true - Layout.fillHeight: true - - Layout.minimumWidth: 20 - } - Label{ - id: spinnerLabel - - Layout.alignment: Qt.AlignHCenter - - Layout.maximumWidth: 200 - Layout.preferredWidth: 200 - Layout.minimumWidth: 200 - - Layout.maximumHeight: 200 - Layout.preferredHeight: 200 - Layout.minimumHeight: 200 - - property string spinnerDisplyState: successState ? "spinnerLabel_Regular" : "spinnerLabel_Failure" - onSpinnerDisplyStateChanged: { - switch (spinnerDisplyState) { - case "spinnerLabel_Regular": - background = Qt.createQmlObject("import QtQuick 2.14; - AnimatedImage { - source: \"qrc:/images/jami_eclipse_spinner.gif\" - - playing: true - paused: false - fillMode: Image.PreserveAspectFit - mipmap: true - }", spinnerLabel) - break - case "spinnerLabel_Failure": - background = Qt.createQmlObject("import QtQuick 2.14; - import \"qrc:/src/constant/\"; - Image { - anchors.fill: parent; - source:\"image://tintedPixmap/\" + (\"qrc:/images/icons/baseline-error_outline-24px.svg\").replace(\"qrc:/images/icons/\", \"\") + \"+\" + JamiTheme.urgentOrange_; - mipmap: true;}", spinnerLabel) - break - } + Layout.preferredWidth: 200 + Layout.preferredHeight: 200 + + property string spinnerDisplyState: successState ? "spinnerLabel_Regular" : "spinnerLabel_Failure" + onSpinnerDisplyStateChanged: { + switch (spinnerDisplyState) { + case "spinnerLabel_Regular": + background = Qt.createQmlObject("import QtQuick 2.14; + AnimatedImage { + source: \"qrc:/images/jami_eclipse_spinner.gif\" + + playing: true + paused: false + fillMode: Image.PreserveAspectFit + mipmap: true + }", spinnerLabel) + break + case "spinnerLabel_Failure": + background = Qt.createQmlObject("import QtQuick 2.14; + import \"qrc:/src/constant/\"; + Image { + anchors.fill: parent; + source:\"image://tintedPixmap/\" + (\"qrc:/images/icons/baseline-error_outline-24px.svg\").replace(\"qrc:/images/icons/\", \"\") + \"+\" + JamiTheme.urgentOrange_; + mipmap: true;}", spinnerLabel) + break } } - - Item { - Layout.alignment: Qt.AlignRight - Layout.fillWidth: true - Layout.fillHeight: true - - Layout.minimumWidth: 20 - } - } - - Item{ - Layout.fillWidth: true - Layout.fillHeight: true - - Layout.preferredHeight: 211 } + } - Label{ - id: progressLabel - - Layout.alignment: Qt.AlignHCenter - Layout.fillWidth: true - - color: successState? "black" : "red" - text: successState? JamiStrings.inProgress : JamiStrings.authenticationFailed - font.pointSize: 11 - font.kerning: true + Label { + id: progressLabel - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - wrapMode: Label.WordWrap - } + Layout.alignment: Qt.AlignHCenter + Layout.fillWidth: true + Layout.bottomMargin: 80 - Item{ - Layout.fillWidth: true + color: successState? "black" : "red" + text: successState? JamiStrings.inProgress : JamiStrings.authenticationFailed + font.pointSize: JamiTheme.textFontSize + font.kerning: true - Layout.minimumHeight: 20 - Layout.preferredHeight: 20 - Layout.maximumHeight: 20 - } + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Label.WordWrap } } } diff --git a/src/commoncomponents/BaseDialog.qml b/src/commoncomponents/BaseDialog.qml new file mode 100644 index 000000000..8036a5942 --- /dev/null +++ b/src/commoncomponents/BaseDialog.qml @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 by Savoir-faire Linux + * Author: Albert Babà <albert.babi@savoirfairelinux.com> + * + * 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 2.15 +import QtQuick.Dialogs 1.2 + +import "../constant" + +Dialog { + id: root + + visible: false +} diff --git a/src/commoncomponents/DeleteAccountDialog.qml b/src/commoncomponents/DeleteAccountDialog.qml index f44959c04..552d9813d 100644 --- a/src/commoncomponents/DeleteAccountDialog.qml +++ b/src/commoncomponents/DeleteAccountDialog.qml @@ -22,9 +22,11 @@ import QtQuick.Layouts 1.14 import QtQuick.Controls.Styles 1.4 import net.jami.Models 1.0 import net.jami.Adapters 1.0 + import "../constant" +import "../commoncomponents" -Dialog { +BaseDialog { id: root property int profileType: SettingsAdapter.getCurrentAccount_Profile_Info_Type() @@ -38,156 +40,139 @@ Dialog { } } - onOpened: { + signal accepted + + function openDialog() { profileType = SettingsAdapter.getCurrentAccount_Profile_Info_Type() labelBestId.text = SettingsAdapter.getAccountBestName() labelAccountHash.text = SettingsAdapter.getCurrentAccount_Profile_Info_Uri() + open() } - onVisibleChanged: { - if(!visible){ - reject() - } - } - - header : Rectangle { - width: parent.width - height: 64 - color: "transparent" - Text { - anchors.fill: parent - anchors.leftMargin: JamiTheme.preferredMarginSize - anchors.topMargin: JamiTheme.preferredMarginSize - - text: qsTr("Account deletion") - font.pointSize: JamiTheme.headerFontSize - wrapMode: Text.Wrap - } - } - - visible: false - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 + title: JamiStrings.deleteAccount contentItem: Rectangle { - implicitHeight: contentLayout.implicitHeight + 64 + JamiTheme.preferredMarginSize - implicitWidth: 350 + id: deleteAccountContentRect - ColumnLayout{ - id: contentLayout - anchors.fill: parent + implicitWidth: JamiTheme.preferredDialogWidth + implicitHeight: JamiTheme.preferredDialogHeight + + ColumnLayout { anchors.centerIn: parent + anchors.fill: parent + anchors.margins: JamiTheme.preferredMarginSize Label { id: labelDeletion - Layout.fillWidth: true - Layout.preferredHeight: 30 Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: deleteAccountContentRect.width - JamiTheme.preferredMarginSize * 2 + + text: JamiStrings.confirmDeleteQuestion font.pointSize: JamiTheme.textFontSize font.kerning: true + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter wrapMode: Text.Wrap - text: JamiStrings.confirmDeleteQuestion } Label { id: labelBestId - Layout.topMargin: 5 - Layout.fillWidth: true - Layout.preferredHeight: 30 Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: deleteAccountContentRect.width - JamiTheme.preferredMarginSize * 2 + + text: SettingsAdapter.getAccountBestName() font.pointSize: JamiTheme.textFontSize font.kerning: true font.bold: true + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter wrapMode: Text.Wrap - - text: SettingsAdapter.getAccountBestName() } Label { id: labelAccountHash Layout.alignment: Qt.AlignHCenter - Layout.preferredHeight: 30 + Layout.preferredWidth: deleteAccountContentRect.width - JamiTheme.preferredMarginSize * 2 + + text: SettingsAdapter.getCurrentAccount_Profile_Info_Uri() font.pointSize: JamiTheme.textFontSize font.kerning: true + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter wrapMode: Text.Wrap - text: SettingsAdapter.getCurrentAccount_Profile_Info_Uri() } Label { id: labelWarning - Layout.topMargin: 5 - Layout.preferredHeight: 30 - Layout.fillWidth: true - Layout.alignment: Qt.AlignHCenter + visible: !isSIP - visible: ! isSIP + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: deleteAccountContentRect.width - JamiTheme.preferredMarginSize * 2 - wrapMode: Text.Wrap text: JamiStrings.deleteAccountInfos + font.pointSize: JamiTheme.textFontSize font.kerning: true + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.Wrap + color: "red" } RowLayout { - Layout.topMargin: JamiTheme.preferredMarginSize / 2 - Layout.bottomMargin: 5 - Layout.preferredHeight: 30 + spacing: 16 Layout.fillWidth: true - Layout.alignment: Qt.AlignHCenter + Layout.alignment: Qt.AlignCenter - HoverableRadiusButton { - id: btnDeleteAccept + MaterialButton { + id: btnDelete - Layout.fillWidth: true - Layout.maximumWidth: 130 + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + Layout.preferredHeight: JamiTheme.preferredFieldHeight - radius: height / 2 + color: JamiTheme.buttonTintedRed + hoveredColor: JamiTheme.buttonTintedRedHovered + pressedColor: JamiTheme.buttonTintedRedPressed + outlined: true text: qsTr("Delete") - font.pointSize: JamiTheme.buttonFontSize - font.kerning: true onClicked: { AccountAdapter.deleteCurrentAccount() - accept() + accepted() + close() } } - HoverableButtonTextItem { - id: btnDeleteCancel - - Layout.leftMargin: 20 - Layout.fillWidth: true - Layout.maximumWidth: 130 + MaterialButton { + id: btnCancel - backgroundColor: "red" - onEnterColor: Qt.rgba(150 / 256, 0, 0, 0.7) - onDisabledBackgroundColor: Qt.rgba( - 255 / 256, - 0, 0, 0.8) - onPressColor: backgroundColor - textColor: "white" + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + Layout.preferredHeight: JamiTheme.preferredFieldHeight - radius: height / 2 + color: JamiTheme.buttonTintedBlack + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true text: qsTr("Cancel") - font.pointSize: JamiTheme.buttonFontSize - font.kerning: true onClicked: { - reject() + close() } } } diff --git a/src/commoncomponents/ElidedTextLabel.qml b/src/commoncomponents/ElidedTextLabel.qml index e448ceb29..9b1fd9e69 100644 --- a/src/commoncomponents/ElidedTextLabel.qml +++ b/src/commoncomponents/ElidedTextLabel.qml @@ -18,7 +18,8 @@ import QtQuick 2.14 import QtQuick.Controls 1.4 -import net.jami.Models 1.0 + +import "../constant" Label { id: root diff --git a/src/commoncomponents/HoverableButton.qml b/src/commoncomponents/HoverableButton.qml index 39b9ac672..a3056bb14 100644 --- a/src/commoncomponents/HoverableButton.qml +++ b/src/commoncomponents/HoverableButton.qml @@ -18,9 +18,8 @@ */ import QtQuick 2.14 import QtQuick.Controls 2.14 -import net.jami.Models 1.0 import QtGraphicalEffects 1.15 - +import "../constant" // HoverableButton contains the following configurable properties: // 1. Color changes on different button state diff --git a/src/commoncomponents/PasswordDialog.qml b/src/commoncomponents/PasswordDialog.qml index 6373cdea0..73027c741 100644 --- a/src/commoncomponents/PasswordDialog.qml +++ b/src/commoncomponents/PasswordDialog.qml @@ -26,8 +26,7 @@ import net.jami.Adapters 1.0 import "../constant" // PasswordDialog for changing password and exporting account - -Dialog { +BaseDialog { id: root enum PasswordEnteringPurpose { @@ -35,38 +34,13 @@ Dialog { ExportAccount, SetPassword } - readonly property int successCode: 200 - signal doneSignal(int code, int currentPurpose) property string path: "" property int purpose: PasswordDialog.ChangePassword - header : Rectangle { - id: dialogHeader - width: parent.width - height: 64 - color: "transparent" - Text { - anchors.fill: parent - anchors.leftMargin: JamiTheme.preferredMarginSize - anchors.topMargin: JamiTheme.preferredMarginSize - - text: { - switch(purpose){ - case PasswordDialog.ExportAccount: - return JamiStrings.enterPassword - case PasswordDialog.ChangePassword: - return qsTr("Changing password") - case PasswordDialog.SetPassword: - return qsTr("Set password") - } - } - font.pointSize: JamiTheme.headerFontSize - wrapMode: Text.Wrap - } - } + signal doneSignal(bool success, int currentPurpose) - function openDialog(purposeIn, exportPathIn = ""){ + function openDialog(purposeIn, exportPathIn = "") { purpose = purposeIn path = exportPathIn currentPasswordEdit.clear() @@ -74,40 +48,22 @@ Dialog { confirmPasswordEdit.borderColorMode = InfoLineEdit.NORMAL passwordEdit.clear() confirmPasswordEdit.clear() - root.open() - } - - function haveDone(code, currentPurpose) { - done(code) - doneSignal(code, currentPurpose) + validatePassword() + open() } function validatePassword() { - var acceptablePassword = (passwordEdit.text === confirmPasswordEdit.text) - btnChangePasswordConfirm.enabled = acceptablePassword - - if (acceptablePassword) { - passwordEdit.borderColorMode = InfoLineEdit.RIGHT - confirmPasswordEdit.borderColorMode = InfoLineEdit.RIGHT - return - } - - passwordEdit.borderColorMode = InfoLineEdit.ERROR - confirmPasswordEdit.borderColorMode = InfoLineEdit.ERROR - } - - Timer{ - id: timerToOperate - - interval: 200 - repeat: false - - onTriggered: { - if ((purpose === PasswordDialog.ChangePassword) || (purpose === PasswordDialog.SetPassword)) { - savePasswordQML() - } else if(purpose === PasswordDialog.ExportAccount) { - exportAccountQML() - } + switch (purpose) { + case PasswordDialog.ExportAccount: + btnConfirm.enabled = currentPasswordEdit.length > 0 + break + case PasswordDialog.SetPassword: + btnConfirm.enabled = passwordEdit.length > 0 && + passwordEdit.text === confirmPasswordEdit.text + break + default: + btnConfirm.enabled = currentPasswordEdit.length > 0 && + passwordEdit.text === confirmPasswordEdit.text } } @@ -119,13 +75,8 @@ Dialog { path, currentPasswordEdit.text) } - - if (success) { - haveDone(successCode, root.purpose) - } else { - btnChangePasswordConfirm.enabled = false - currentPasswordEdit.borderColorMode = InfoLineEdit.ERROR - } + doneSignal(success, purpose) + close() } function savePasswordQML() { @@ -136,134 +87,144 @@ Dialog { passwordEdit.text) if (success) { AccountAdapter.setArchiveHasPassword(passwordEdit.text.length !== 0) - haveDone(successCode, passwordDialog.purpose) - } else { - currentPasswordEdit.borderColorMode = InfoLineEdit.ERROR - btnChangePasswordConfirm.enabled = false } + doneSignal(success, purpose) + close() } - visible: false - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 + title: { + switch(purpose){ + case PasswordDialog.ExportAccount: + return JamiStrings.enterPassword + case PasswordDialog.ChangePassword: + return JamiStrings.changePassword + case PasswordDialog.SetPassword: + return JamiStrings.setPassword + } + } - contentItem: Rectangle { - implicitHeight: contentLayout.implicitHeight + dialogHeader.height + JamiTheme.preferredMarginSize - implicitWidth: 350 + Timer { + id: timerToOperate - ColumnLayout { - id: contentLayout - anchors.fill: parent + interval: 200 + repeat: false - ColumnLayout { - Layout.alignment: Qt.AlignHCenter + onTriggered: { + if (purpose === PasswordDialog.ExportAccount) { + exportAccountQML() + } else { + savePasswordQML() + } + } + } - MaterialLineEdit { - id: currentPasswordEdit + contentItem: Rectangle { + id: passwordDialogContentRect + + implicitWidth: JamiTheme.preferredDialogWidth + implicitHeight: JamiTheme.preferredDialogHeight - Layout.maximumHeight: visible ? - 48 : - 0 - Layout.fillWidth: true + ColumnLayout { + anchors.centerIn: parent + anchors.fill: parent + anchors.margins: JamiTheme.preferredMarginSize - visible: purpose === PasswordDialog.ChangePassword || purpose === PasswordDialog.ExportAccount - echoMode: TextInput.Password - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter + MaterialLineEdit { + id: currentPasswordEdit - placeholderText: JamiStrings.enterCurrentPassword + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth + Layout.preferredHeight: visible ? 48 : 0 - onTextChanged: { - if (purpose === PasswordDialog.ChangePassword) { - validatePassword() - } + visible: purpose === PasswordDialog.ChangePassword || + purpose === PasswordDialog.ExportAccount + echoMode: TextInput.Password + placeholderText: JamiStrings.enterCurrentPassword - if (currentPasswordEdit.text.length == 0) { - btnChangePasswordConfirm.enabled = false - } else { - btnChangePasswordConfirm.enabled = true - } - } + onTextChanged: { + validatePassword() } + } - MaterialLineEdit { - id: passwordEdit + MaterialLineEdit { + id: passwordEdit - Layout.fillWidth: true - Layout.topMargin: JamiTheme.preferredMarginSize / 2 - fieldLayoutHeight: 48 + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth + Layout.preferredHeight: visible ? 48 : 0 - visible: purpose === PasswordDialog.ChangePassword || purpose === PasswordDialog.SetPassword - echoMode: TextInput.Password - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter + visible: purpose === PasswordDialog.ChangePassword || + purpose === PasswordDialog.SetPassword + echoMode: TextInput.Password - placeholderText: JamiStrings.enterNewPassword + placeholderText: JamiStrings.enterNewPassword - onTextChanged: { - validatePassword() - } + onTextChanged: { + validatePassword() } + } - MaterialLineEdit { - id: confirmPasswordEdit + MaterialLineEdit { + id: confirmPasswordEdit - Layout.fillWidth: true - Layout.topMargin: JamiTheme.preferredMarginSize / 2 - fieldLayoutHeight: 48 - layoutFillwidth: true + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth + Layout.preferredHeight: visible ? 48 : 0 - visible: purpose === PasswordDialog.ChangePassword || purpose === PasswordDialog.SetPassword - echoMode: TextInput.Password - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter + visible: purpose === PasswordDialog.ChangePassword || + purpose === PasswordDialog.SetPassword + echoMode: TextInput.Password - placeholderText: JamiStrings.confirmNewPassword + placeholderText: JamiStrings.confirmNewPassword - onTextChanged: { - validatePassword() - } + onTextChanged: { + validatePassword() } } RowLayout { - Layout.topMargin: JamiTheme.preferredMarginSize / 2 - Layout.alignment: Qt.AlignRight + spacing: 16 + Layout.fillWidth: true + Layout.alignment: Qt.AlignCenter - Button { - id: btnChangePasswordConfirm + MaterialButton { + id: btnConfirm - contentItem: Text { - text: JamiStrings.confirm - color: JamiTheme.buttonTintedBlue - font.capitalization: Font.AllUppercase - } + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + Layout.preferredHeight: JamiTheme.preferredFieldHeight - background: Rectangle { - color: "transparent" - } + color: enabled? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true + enabled: purpose === PasswordDialog.SetPassword + + text: (purpose === PasswordDialog.ExportAccount) ? JamiStrings.exportAccount : + JamiStrings.change onClicked: { + btnConfirm.enabled = false timerToOperate.restart() } } + MaterialButton { + id: btnCancel - Button { - id: btnChangePasswordCancel - Layout.leftMargin: JamiTheme.preferredMarginSize / 2 + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + Layout.preferredHeight: JamiTheme.preferredFieldHeight - contentItem: Text { - text: qsTr("CANCEL") - color: JamiTheme.buttonTintedBlue - } + color: JamiTheme.buttonTintedBlack + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true - background: Rectangle { - color: "transparent" - } + text: qsTr("Cancel") onClicked: { - root.reject() + close() } } } diff --git a/src/constant/JamiStrings.qml b/src/constant/JamiStrings.qml index b58ad865d..50eec7a4d 100644 --- a/src/constant/JamiStrings.qml +++ b/src/constant/JamiStrings.qml @@ -289,18 +289,22 @@ Item { property string connectFromAnotherDevice: qsTr("Create account from an another device") // KeyBoardShortcutTable - property string conversations: ("Conversations") + property string conversations: qsTr("Conversations") // LinkDevicesDialog property string pinTimerInfos: qsTr("The PIN and the account password should be entered in your device within 10 minutes.") property string close: qsTr("Close") + property string enterAccountPassword: qsTr("Enter your account password") + property string addDevice: qsTr("Add Device") // PasswordDialog property string enterPassword: qsTr("Enter the password") property string enterCurrentPassword: qsTr("Enter current password") property string enterNewPassword: qsTr("Enter new password") property string confirmNewPassword: qsTr("Confirm new password") + property string change: qsTr("Change") property string confirm: qsTr("Confirm") + property string exportAccount: qsTr("Export") // PhotoBoothView property string chooseAvatarImage: qsTr("Choose a picture as avatar") @@ -328,6 +332,9 @@ Item { // UserProfile property string qrCode: qsTr("QR code") + // Account QR + property string accountQr: qsTr("Account QR") + // WelcomePage property string shareInvite: qsTr("This is your Jami username.\nCopy and share it with your friends!") property string linkFromAnotherDevice: qsTr("Link this device to an existing account") diff --git a/src/constant/JamiTheme.qml b/src/constant/JamiTheme.qml index 526bf9006..b4b7bf290 100644 --- a/src/constant/JamiTheme.qml +++ b/src/constant/JamiTheme.qml @@ -83,6 +83,7 @@ Item { property int splitViewHandlePreferredWidth: 4 property int textFontSize: 9 + property int tinyFontSize: 7 property int settingsFontSize: 9 property int buttonFontSize: 9 property int headerFontSize: 13 @@ -93,6 +94,8 @@ Item { property int preferredFieldWidth: 256 property int preferredFieldHeight: 32 property int preferredMarginSize: 16 + property int preferredDialogWidth: 400 + property int preferredDialogHeight: 300 // Jami theme colors function rgb256(r, g, b) { diff --git a/src/mainview/MainView.qml b/src/mainview/MainView.qml index 09ac2421e..47e6ecc5f 100644 --- a/src/mainview/MainView.qml +++ b/src/mainview/MainView.qml @@ -34,13 +34,12 @@ Window { id: mainViewWindow property int minWidth: settingsViewPreferredWidth - property int minHeight: aboutPopUpDialog.contentHeight + property int minHeight: 400 property int mainViewWindowPreferredWidth: 650 property int mainViewWindowPreferredHeight: 600 property int sidePanelViewStackPreferredWidth: 250 property int mainViewStackPreferredWidth: 250 - property int aboutPopUpPreferredWidth: 400 property int settingsViewPreferredWidth: 445 property int onWidthChangedTriggerDistance: 5 @@ -461,7 +460,7 @@ Window { callStackView.showIncomingCallPage(AccountAdapter.currentAccountId, currentUID) } else { - callStackView.showOutgoingCallPage() + callStackView.showOutgoingCallPage(callState) } } @@ -649,20 +648,10 @@ Window { AboutPopUp { id: aboutPopUpDialog - - x: Math.round((mainViewWindow.width - width) / 2) - y: Math.round((mainViewWindow.height - height) / 2) - width: aboutPopUpPreferredWidth - height: aboutPopUpDialog.contentHeight } WelcomePageQrDialog { id: qrDialog - - x: Math.round((mainViewWindow.width - width) / 2) - y: Math.round((mainViewWindow.height - height) / 2) - width: qrDialog.contentHeight - height: qrDialog.contentHeight } RecordBox{ @@ -672,11 +661,6 @@ Window { UserProfile { id: userProfile - - x: Math.round((mainViewWindow.width - width) / 2) - y: Math.round((mainViewWindow.height - height) / 2) - width: Math.max(mainViewWindow.width / 2, aboutPopUpPreferredWidth) - height: userProfile.contentHeight } onClosing: { @@ -771,8 +755,5 @@ Window { KeyBoardShortcutTable { id: shortcutsTable - - x: Math.round((mainViewWindow.width - width) / 2) - y: Math.round((mainViewWindow.height - height) / 2) } } diff --git a/src/mainview/components/AboutPopUp.qml b/src/mainview/components/AboutPopUp.qml index 31d922610..83e1cb33f 100644 --- a/src/mainview/components/AboutPopUp.qml +++ b/src/mainview/components/AboutPopUp.qml @@ -17,23 +17,17 @@ */ import QtQuick 2.14 -import QtQuick.Controls 2.14 +import QtQuick.Controls 2.15 import QtQuick.Layouts 1.14 import net.jami.Models 1.0 import net.jami.Adapters 1.0 -import "../../commoncomponents" import "../../constant" +import "../../commoncomponents" -Dialog { - id: aboutPopUp - - - // When dialog is opened, trigger mainViewWindow overlay which is defined in overlay.model (model : true is necessary). - modal: true - - // Content height + margin. - contentHeight: aboutPopUpContentRectColumnLayout.height + 5 * 7 +BaseDialog { + id: root + title: qsTr("About") ProjectCreditsScrollView { id: projectCreditsScrollView @@ -47,18 +41,22 @@ Dialog { visible: false } - Rectangle { + contentItem: Rectangle { id: aboutPopUpContentRect - anchors.fill: parent + implicitWidth: 400 + implicitHeight: 600 ColumnLayout { id: aboutPopUpContentRectColumnLayout + anchors.centerIn: parent + anchors.fill: parent Image { id: aboutPopUPJamiLogoImage Layout.alignment: Qt.AlignCenter + Layout.topMargin: JamiTheme.preferredMarginSize Layout.preferredWidth: aboutPopUpContentRect.width Layout.preferredHeight: 100 @@ -74,7 +72,7 @@ Dialog { Layout.preferredWidth: aboutPopUpContentRect.width Layout.preferredHeight: textMetricsjamiVersionText.boundingRect.height - font.pointSize: JamiTheme.textFontSize - 2 + font.pointSize: JamiTheme.textFontSize horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter @@ -97,7 +95,7 @@ Dialog { Layout.topMargin: 5 wrapMode: Text.WordWrap - font.pointSize: JamiTheme.textFontSize - 2 + font.pointSize: JamiTheme.textFontSize horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter @@ -120,7 +118,7 @@ Dialog { Layout.topMargin: 5 wrapMode: Text.WordWrap - font.pointSize: JamiTheme.textFontSize - 2 + font.pointSize: JamiTheme.textFontSize horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter @@ -135,15 +133,13 @@ Dialog { Layout.alignment: Qt.AlignCenter - // Strangely, hoveredLink works badly when width grows too large Layout.preferredWidth: 50 Layout.preferredHeight: textMetricsjamiDeclarationHyperText.boundingRect.height Layout.topMargin: 5 Layout.bottomMargin: 5 - font.pointSize: JamiTheme.textFontSize - 2 - + font.pointSize: JamiTheme.textFontSize horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter @@ -159,7 +155,6 @@ Dialog { MouseArea { anchors.fill: parent - // We don't want to eat clicks on the Text. acceptedButtons: Qt.NoButton cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor @@ -174,7 +169,7 @@ Dialog { Layout.preferredHeight: textMetricsjamiDeclarationYearText.boundingRect.height Layout.bottomMargin: 5 - font.pointSize: JamiTheme.textFontSize - 2 + font.pointSize: JamiTheme.textFontSize horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter @@ -192,13 +187,12 @@ Dialog { id: jamiNoneWarrantyHyperText Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: Math.min(300, - aboutPopUpContentRect.width) + Layout.preferredWidth: Math.min(300, aboutPopUpContentRect.width) Layout.preferredHeight: textMetricsjamiNoneWarrantyHyperText.boundingRect.height * 2 Layout.bottomMargin: 10 wrapMode: Text.WordWrap - font.pointSize: JamiTheme.textFontSize - 3 + font.pointSize: JamiTheme.tinyFontSize horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter @@ -224,8 +218,7 @@ Dialog { Layout.alignment: Qt.AlignCenter Layout.preferredWidth: aboutPopUpContentRect.width - Layout.preferredHeight: JamiTheme.preferredFieldHeight - Layout.bottomMargin: 10 + Layout.preferredHeight: 32 RowLayout { id: buttonGroupChangeLogAndCreditsRowLayout @@ -234,12 +227,15 @@ Dialog { MaterialButton { id: changeLogButton - Layout.preferredHeight: JamiTheme.preferredFieldHeight text: JamiStrings.changelog - color: projectCreditsScrollView.visible? JamiTheme.buttonTintedGreyInactive : JamiTheme.buttonTintedGrey + color: projectCreditsScrollView.visible? JamiTheme.buttonTintedGreyInactive : + JamiTheme.buttonTintedGrey hoveredColor: JamiTheme.buttonTintedGreyHovered pressedColor: JamiTheme.buttonTintedGreyPressed - Layout.preferredWidth: 100 + + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 + Layout.preferredHeight: JamiTheme.preferredFieldHeight onClicked: { if (changeLogOrCreditsStack.depth > 1) { @@ -250,12 +246,14 @@ Dialog { MaterialButton { id: creditsButton - Layout.preferredHeight: JamiTheme.preferredFieldHeight text: JamiStrings.credits - color: projectCreditsScrollView.visible? JamiTheme.buttonTintedGrey : JamiTheme.buttonTintedGreyInactive + color: projectCreditsScrollView.visible? JamiTheme.buttonTintedGrey : + JamiTheme.buttonTintedGreyInactive hoveredColor: JamiTheme.buttonTintedGreyHovered pressedColor: JamiTheme.buttonTintedGreyPressed - Layout.preferredWidth: 100 + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 + Layout.preferredHeight: JamiTheme.preferredFieldHeight onClicked: { if (changeLogOrCreditsStack.depth == 1) { @@ -271,19 +269,33 @@ Dialog { id: changeLogOrCreditsStack Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: aboutPopUpContentRect.width - Layout.preferredHeight: 150 - Layout.bottomMargin: 5 + Layout.preferredWidth: aboutPopUpContentRect.width - JamiTheme.preferredMarginSize*2 + Layout.preferredHeight: aboutPopUpContentRect.height - 460 + Layout.margins: JamiTheme.preferredMarginSize initialItem: changeLogScrollView clip: true } - } - } - background: Rectangle { - border.width: 0 - radius: 10 + MaterialButton { + id: btnClose + + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 + Layout.preferredHeight: JamiTheme.preferredFieldHeight + Layout.bottomMargin: JamiTheme.preferredMarginSize + + text: qsTr("Close") + color: enabled? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true + + onClicked: { + close() + } + } + } } } diff --git a/src/mainview/components/UserProfile.qml b/src/mainview/components/UserProfile.qml index 4bb5c60d1..4914d7eb0 100644 --- a/src/mainview/components/UserProfile.qml +++ b/src/mainview/components/UserProfile.qml @@ -1,7 +1,7 @@ - /* * Copyright (C) 2020 by Savoir-faire Linux * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> + * Author: Albert Babà <albert.babi@savoirfairelinux.com> * * 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 @@ -16,15 +16,16 @@ * 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 2.14 import QtQuick.Controls 2.14 import QtQuick.Layouts 1.14 -import net.jami.Models 1.0 +import "../../constant" import "../../commoncomponents" -Dialog { - id: userProfileDialog +BaseDialog { + id: root property string responsibleConvUid: "" property string contactPicBase64: "" @@ -33,152 +34,161 @@ Dialog { property string idText: "" property int preferredImgSize: 80 - modal: true - // Content height + margin. - contentHeight: userProfileDialogLayout.implicitHeight + 60 - contentWidth: userProfileDialogLayout.implicitWidth + 60 + contentItem: Rectangle { + id: userProfileContentRect - // Fake focus to make sure that text edit lose focus on close. - FocusScope { - id: fakeFocusTextEdit - } + implicitWidth: 480 + implicitHeight: 400 - contentItem: GridLayout { + GridLayout { + id: userProfileDialogLayout - id: userProfileDialogLayout - columns: 2 - rowSpacing: 10 - columnSpacing: 10 + anchors.centerIn: parent + anchors.fill: parent + anchors.margins: JamiTheme.preferredMarginSize - Image { - id: contactImage + columns: 2 + rows: 6 + rowSpacing: 16 + columnSpacing: 24 - Layout.alignment: Qt.AlignRight - Layout.preferredWidth: 130 + Image { + id: contactImage - sourceSize.width: preferredImgSize - sourceSize.height: preferredImgSize + Layout.alignment: Qt.AlignRight + Layout.preferredWidth: 130 - fillMode: Image.PreserveAspectFit - mipmap: true - } + sourceSize.width: preferredImgSize + sourceSize.height: preferredImgSize - // Visible when user alias is not empty or equals to id. - Text { - id: contactAlias + fillMode: Image.PreserveAspectFit + mipmap: true + } + + // Visible when user alias is not empty or equals to id. + Text { + id: contactAlias - Layout.alignment: Qt.AlignLeft + Layout.alignment: Qt.AlignLeft - font.pointSize: JamiTheme.titleFontSize - text: textMetricsContactAliasText.elidedText - visible: aliasText ? (aliasText === idText ? false : true) : false + font.pointSize: JamiTheme.titleFontSize + text: textMetricsContactAliasText.elidedText + visible: aliasText ? (aliasText === idText ? false : true) : false - TextMetrics { - id: textMetricsContactAliasText - font: contactAlias.font - text: aliasText - elideWidth: userProfileDialog.width-160 - elide: Qt.ElideMiddle + TextMetrics { + id: textMetricsContactAliasText + font: contactAlias.font + text: aliasText + elideWidth: userProfileContentRect.width-200 + elide: Qt.ElideMiddle + } } - } - Item { - Layout.columnSpan: 2 - height: 20 - } + Item { + Layout.columnSpan: 2 + height: 8 + } - Text { - Layout.alignment: Qt.AlignRight - font.pointSize: JamiTheme.menuFontSize - text: qsTr("Informations") - } + Text { + Layout.alignment: Qt.AlignRight + font.pointSize: JamiTheme.menuFontSize + text: qsTr("Information") + } - Item { Layout.fillWidth: true } + Item { Layout.fillWidth: true } - Text { - Layout.alignment: Qt.AlignRight - font.pointSize: JamiTheme.textFontSize - text: qsTr("Username") - visible: registeredNameText ? (registeredNameText === idText ? false : true) : false - color: JamiTheme.faddedFontColor - } + Text { + Layout.alignment: Qt.AlignRight + font.pointSize: JamiTheme.textFontSize + text: JamiStrings.username + visible: registeredNameText ? (registeredNameText === idText ? false : true) : false + color: JamiTheme.faddedFontColor + } - // Visible when user name is not empty or equals to alias. - Text { - id: contactDisplayName + // Visible when user name is not empty or equals to alias. + Text { + id: contactDisplayName - Layout.alignment: Qt.AlignLeft + Layout.alignment: Qt.AlignLeft - font.pointSize: JamiTheme.textFontSize - text: textMetricsContactDisplayNameText.elidedText - visible: registeredNameText ? (registeredNameText === idText ? false : true) : false + font.pointSize: JamiTheme.textFontSize + text: textMetricsContactDisplayNameText.elidedText + visible: registeredNameText ? (registeredNameText === idText ? false : true) : false - TextMetrics { - id: textMetricsContactDisplayNameText - font: contactDisplayName.font - text: registeredNameText - elideWidth: userProfileDialog.width-160 - elide: Qt.ElideMiddle + TextMetrics { + id: textMetricsContactDisplayNameText + font: contactDisplayName.font + text: registeredNameText + elideWidth: userProfileContentRect.width-200 + elide: Qt.ElideMiddle + } } - } - Text { - Layout.alignment: Qt.AlignRight - font.pointSize: JamiTheme.textFontSize - text: JamiStrings.identifier - color: JamiTheme.faddedFontColor - } + Text { + Layout.alignment: Qt.AlignRight + font.pointSize: JamiTheme.textFontSize + text: JamiStrings.identifier + color: JamiTheme.faddedFontColor + } - TextEdit { - id: contactId + TextEdit { + id: contactId - Layout.alignment: Qt.AlignLeft + Layout.alignment: Qt.AlignLeft - selectByMouse: true - readOnly: true - font.pointSize: JamiTheme.textFontSize - text: textMetricsContactIdText.elidedText + selectByMouse: true + readOnly: true + font.pointSize: JamiTheme.textFontSize + text: textMetricsContactIdText.elidedText - TextMetrics { - id: textMetricsContactIdText - font: contactId.font - text: idText - elideWidth: userProfileDialog.width-160 - elide: Qt.ElideMiddle + TextMetrics { + id: textMetricsContactIdText + font: contactId.font + text: idText + elideWidth: userProfileContentRect.width-200 + elide: Qt.ElideMiddle + } } - } - Text { - Layout.alignment: Qt.AlignRight - font.pointSize: JamiTheme.textFontSize - text: JamiStrings.qrCode - color: JamiTheme.faddedFontColor - } + Text { + Layout.alignment: Qt.AlignRight + font.pointSize: JamiTheme.textFontSize + text: JamiStrings.qrCode + color: JamiTheme.faddedFontColor + } - Image { - id: contactQrImage + Image { + id: contactQrImage - Layout.alignment: Qt.AlignBottom | Qt.AlignLeft + Layout.alignment: Qt.AlignLeft - fillMode: Image.PreserveAspectFit - sourceSize.width: preferredImgSize - sourceSize.height: preferredImgSize - mipmap: true - } + fillMode: Image.PreserveAspectFit + sourceSize.width: preferredImgSize + sourceSize.height: preferredImgSize + mipmap: true + } - Item { height: 20 } + MaterialButton { + id: btnClose - } + Layout.columnSpan: 2 + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 + Layout.preferredHeight: JamiTheme.preferredFieldHeight - background: Rectangle { - border.width: 0 - radius: 10 - } + color: JamiTheme.buttonTintedBlack + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true - onClosed: { - contactId.deselect() - fakeFocusTextEdit.focus = true + text: JamiStrings.close + + onClicked: { + close() + } + } + } } onResponsibleConvUidChanged: { diff --git a/src/mainview/components/WelcomePage.qml b/src/mainview/components/WelcomePage.qml index 90e974003..e012efb76 100644 --- a/src/mainview/components/WelcomePage.qml +++ b/src/mainview/components/WelcomePage.qml @@ -1,3 +1,4 @@ + /* * Copyright (C) 2020 by Savoir-faire Linux * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> @@ -26,10 +27,8 @@ import "../../commoncomponents" Rectangle { id: welcomeRect - - anchors.fill: parent - property int buttonPreferredSize: 30 + anchors.fill: parent Rectangle { id: welcomeRectComponentsGroup @@ -48,7 +47,7 @@ Rectangle { Layout.alignment: Qt.AlignCenter Layout.preferredWidth: welcomeRectComponentsGroup.width Layout.preferredHeight: 100 - Layout.topMargin: 50 + Layout.topMargin: 32 Layout.bottomMargin: 10 fillMode: Image.PreserveAspectFit @@ -61,7 +60,7 @@ Rectangle { Layout.alignment: Qt.AlignCenter Layout.preferredWidth: welcomeRectComponentsGroup.width - Layout.preferredHeight: 100 + Layout.preferredHeight: 80 Layout.bottomMargin: 5 wrapMode: Text.WordWrap @@ -122,6 +121,7 @@ Rectangle { elide: Qt.ElideMiddle } } + HoverableButton { id: copyRegisterednameButton Layout.alignment: Qt.AlignCenter @@ -139,14 +139,17 @@ Rectangle { } } - Button { + id: btnAbout + anchors.bottom: parent.bottom + anchors.bottomMargin: 10 anchors.horizontalCenter: parent.horizontalCenter + background: Rectangle { color: "transparent" } - anchors.bottomMargin: 12 + contentItem: Text { text: qsTr("About Jami") color: "grey" diff --git a/src/mainview/components/WelcomePageQrDialog.qml b/src/mainview/components/WelcomePageQrDialog.qml index 9c6bb790b..a4a9e2515 100644 --- a/src/mainview/components/WelcomePageQrDialog.qml +++ b/src/mainview/components/WelcomePageQrDialog.qml @@ -17,41 +17,65 @@ */ import QtQuick 2.14 -import QtQuick.Controls 2.14 +import QtQuick.Controls 2.15 import QtQuick.Layouts 1.14 import net.jami.Models 1.0 import net.jami.Adapters 1.0 -Dialog { - id: userQrImageDialog +import "../../constant" +import "../../commoncomponents" - // When dialog is opened, trigger mainViewWindow overlay which is defined in overlay.model. - // (model : true is necessary) - modal: true +BaseDialog { + id: root - //Content height + margin. - contentHeight: userQrImage.height + 30 + title: JamiStrings.accountQr - Image { - id: userQrImage + contentItem: Rectangle { + id: content - anchors.centerIn: parent + implicitWidth: userQrImage.width + JamiTheme.preferredMarginSize * 2 + implicitHeight: 352 // Qr + btn + margins - width: 256 - height: 256 - smooth: false + ColumnLayout { - fillMode: Image.PreserveAspectFit - source: { - if (AccountAdapter.currentAccountId && - AccountAdapter.currentAccountType === Profile.Type.RING) - return "image://qrImage/account_" + AccountAdapter.currentAccountId - return "" - } - } + anchors.centerIn: parent + anchors.fill: parent + + Image { + id: userQrImage + + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: 256 + Layout.preferredHeight: 256 + + smooth: false - background: Rectangle { - border.width: 0 - radius: 10 + fillMode: Image.PreserveAspectFit + source: { + if (AccountAdapter.currentAccountId) + return "image://qrImage/account_" + AccountAdapter.currentAccountId + return "" + } + } + + MaterialButton { + id: btnClose + + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 + Layout.preferredHeight: JamiTheme.preferredFieldHeight + Layout.bottomMargin: JamiTheme.preferredMarginSize + + text: JamiStrings.close + color: enabled? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true + + onClicked: { + close() + } + } + } } } diff --git a/src/settingsview/components/CurrentAccountSettings.qml b/src/settingsview/components/CurrentAccountSettings.qml index 56eb29e88..a286317a2 100644 --- a/src/settingsview/components/CurrentAccountSettings.qml +++ b/src/settingsview/components/CurrentAccountSettings.qml @@ -55,6 +55,7 @@ Rectangle { linkedDevices.updateAndShowDevicesSlot() bannedContacts.setVisibility() advancedSettings.updateAdvancedAccountInfos() + setPasswordButtonText() } function passwordClicked() { @@ -85,11 +86,29 @@ Rectangle { bannedContacts.connectCurrentAccount(false) } + + function setPasswordButtonText() { + var hasPassword = AccountAdapter.hasPassword() + passwdPushButton.toolTipText = hasPassword ? + JamiStrings.changeCurrentPassword : + JamiStrings.setAPassword + + passwdPushButton.text = hasPassword ? + JamiStrings.changePassword : + JamiStrings.setPassword + } + + MessageBox { + id: msgDialog + + onAccepted: { + setPasswordButtonText() + } + } + DeleteAccountDialog { id: deleteAccountDialog - anchors.centerIn: parent.Center - onAccepted: { AccountAdapter.setSelectedConvId() @@ -104,10 +123,7 @@ Rectangle { PasswordDialog { id: passwordDialog - anchors.centerIn: parent.Center - onDoneSignal: { - var success = (code === successCode) var title = success ? qsTr("Success") : qsTr("Error") var iconMode = success ? StandardIcon.Information : StandardIcon.Critical @@ -125,7 +141,7 @@ Rectangle { break } - MessageBox.openWithParameters(title,info, iconMode, StandardButton.Ok) + msgDialog.openWithParameters(title,info, iconMode, StandardButton.Ok) } } @@ -152,7 +168,7 @@ Rectangle { var title = isSuccessful ? qsTr("Success") : qsTr("Error") var iconMode = isSuccessful ? StandardIcon.Information : StandardIcon.Critical var info = isSuccessful ? JamiStrings.backupSuccessful : JamiStrings.backupFailed - MessageBox.openWithParameters(title,info, iconMode, StandardButton.Ok) + msgDialog.openWithParameters(title,info, iconMode, StandardButton.Ok) } } } diff --git a/src/settingsview/components/KeyBoardShortcutTable.qml b/src/settingsview/components/KeyBoardShortcutTable.qml index f62fb672c..b959229c9 100644 --- a/src/settingsview/components/KeyBoardShortcutTable.qml +++ b/src/settingsview/components/KeyBoardShortcutTable.qml @@ -15,56 +15,28 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 import QtQuick.Layouts 1.3 +import net.jami.Models 1.0 import "../../constant" +import "../../commoncomponents" -Dialog { +BaseDialog { id: root - modal: true - - width: rectangle.width + 24 - height: rectangle.height + 24 - Rectangle { - id: rectangle + visible: false + title: qsTr("Shortcuts") - property int minWidth: 1200 - property int minHeight: 500 + contentItem: Rectangle { + id: shortcutsTableContentRect - implicitWidth: minWidth - implicitHeight: minHeight - color: "white" - radius: 30 - - Rectangle { - width: 500 - height: t_metrics_title.tightBoundingRect.height + 15 - color: "#e0e0e0" - radius: 8 - anchors.top: parent.top - anchors.topMargin: 10 - anchors.horizontalCenter: parent.horizontalCenter - Text { - id : titleText - anchors.centerIn: parent - anchors.leftMargin: 10 - font.family: "Arial" - font.pointSize: 12 - font.bold: true - text: "Shortcuts" - color: "black" - } - TextMetrics { - id: t_metrics_title - font: titleText.font - text: titleText.text - } - } + implicitWidth: 800 + implicitHeight: 600 ListModel { id: keyboardGeneralShortcutsModel @@ -80,27 +52,27 @@ Dialog { } ListElement { Shortcut: "Ctrl+R" - Description: "Requests list" + Description: qsTr("Requests list") KeyLength: 2 } ListElement { Shortcut: "Ctrl+↑" - Description: "Previous conversation" + Description: qsTr("Previous conversation") KeyLength: 2 } ListElement { Shortcut: "Ctrl+↓" - Description: "Next conversation" + Description: qsTr("Next conversation") KeyLength: 2 } ListElement { Shortcut: "Ctrl+F" - Description: "Search bar" + Description: qsTr("Search bar") KeyLength: 2 } ListElement { Shortcut: "F11" - Description: "Fullscreen" + Description: qsTr("Fullscreen") KeyLength: 1 } } @@ -108,12 +80,12 @@ Dialog { id: keyboardConversationShortcutsModel ListElement { Shortcut: "Shift+Ctrl+C" - Description: "Start an audio call" + Description: qsTr("Start an audio call") KeyLength: 3 } ListElement { Shortcut: "Shift+Ctrl+X" - Description: "Start a video call" + Description: qsTr("Start a video call") KeyLength: 3 } ListElement { @@ -136,27 +108,27 @@ Dialog { id: keyboardSettingsShortcutsModel ListElement { Shortcut: "Ctrl+M" - Description: "Media settings" + Description: qsTr("Media settings") KeyLength: 2 } ListElement { Shortcut: "Ctrl+G" - Description: "General Settings" + Description: qsTr("General settings") KeyLength: 2 } ListElement { Shortcut: "Ctrl+I" - Description: "Account Settings" + Description: qsTr("Account settings") KeyLength: 2 } ListElement { Shortcut: "Ctrl+Shift+N" - Description: "Open account creation wizard" + Description: qsTr("Open account creation wizard") KeyLength: 3 } ListElement { Shortcut: "F10" - Description: "Open window" + Description: qsTr("Open window") KeyLength: 1 } } @@ -184,17 +156,19 @@ Dialog { Rectangle { id: cellRectWithThreeKeys - implicitWidth: minWidth /2 + implicitWidth: minWidth / 2 implicitHeight: 50 anchors.left: parent.left - anchors.leftMargin: 50 + anchors.leftMargin: 20 color: "white" border.color: "white" + Rectangle { id: containerRectWithThreeKeys implicitWidth: parent.width - 10 implicitHeight: 50 + anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter @@ -257,7 +231,7 @@ Dialog { id: descriptionDelegate Rectangle { - implicitWidth: minWidth /2 + implicitWidth: root.width / 2 implicitHeight: 50 color: "white" @@ -268,7 +242,7 @@ Dialog { anchors.left: parent.left anchors.leftMargin: 10 font.family: "Arial" - font.pointSize: 10 + font.pointSize: JamiTheme.textFontSize text: styleData.value } } @@ -313,6 +287,7 @@ Dialog { Loader { property variant modelData: model sourceComponent: shortcutDelegateWithThreeKeys + asynchronous: true } } } @@ -333,7 +308,7 @@ Dialog { height: [t_metrics_general.tightBoundingRect.height + 10, 0][styleData.column % 2] width: [parent.width, 0][styleData.column % 2] color: "white" - radius: 10 + radius: 4 anchors.top: parent.top anchors.topMargin: 5 Text { @@ -342,7 +317,7 @@ Dialog { anchors.left: parent.left anchors.leftMargin: 10 font.family: "Arial" - font.pointSize: 12 + font.pointSize: JamiTheme.headerFontSize text: styleData.column % 2 ? "" : "General" color: "black" } @@ -376,6 +351,7 @@ Dialog { Loader { property variant modelData: model sourceComponent: shortcutDelegateWithThreeKeys + asynchronous: true } } } @@ -396,7 +372,7 @@ Dialog { height: [t_metrics_conversations.tightBoundingRect.height + 10, 0][styleData.column % 2] width: [parent.width, 0][styleData.column % 2] color: "white" - radius: 10 + radius: 4 anchors.top: parent.top anchors.topMargin: 5 Text { @@ -405,7 +381,7 @@ Dialog { anchors.left: parent.left anchors.leftMargin: 10 font.family: "Arial" - font.pointSize: 12 + font.pointSize: JamiTheme.headerFontSize text: styleData.column % 2 ? "" : JamiStrings.conversations color: "black" } @@ -441,6 +417,7 @@ Dialog { Loader { property variant modelData: model sourceComponent: shortcutDelegateWithThreeKeys + asynchronous: true } } } @@ -461,7 +438,7 @@ Dialog { height: [t_metrics_calls.tightBoundingRect.height + 10, 0][styleData.column % 2] width: [parent.width, 0][styleData.column % 2] color: "white" - radius: 10 + radius: 4 anchors.top: parent.top anchors.topMargin: 5 Text { @@ -504,6 +481,7 @@ Dialog { Loader { property variant modelData: model sourceComponent: shortcutDelegateWithThreeKeys + asynchronous: true } } } @@ -524,7 +502,7 @@ Dialog { height: [t_metrics_settings.tightBoundingRect.height + 10, 0][styleData.column % 2] width: [parent.width, 0][styleData.column % 2] color: "white" - radius: 10 + radius: 4 anchors.top: parent.top anchors.topMargin: 5 Text { @@ -549,19 +527,21 @@ Dialog { } } } + TabBar { id: tabBar anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom - anchors.bottomMargin: 15 - width: 240 + anchors.bottomMargin: parent.height - 500 // Forced postion below table + + width: JamiTheme.preferredFieldWidth * 2 + height: JamiTheme.preferredFieldHeight + currentIndex: 0 TabButton { id: pageOne - - width: tabBar.width / 2 - height: 30 - + width: JamiTheme.preferredFieldWidth text: "1" down: true // customize tab button @@ -576,8 +556,9 @@ Dialog { // customize tab button background: Rectangle { id: buttonRectOne - - radius: 10 + implicitWidth: JamiTheme.preferredFieldWidth + implicitHeight: JamiTheme.preferredFieldHeight + radius: 4 color: pageOne.down ? "#e0e0e0" :"#fdfdfd" MouseArea { anchors.fill: parent @@ -591,11 +572,8 @@ Dialog { } TabButton { id: pageTwo - - width: tabBar.width / 2 - height: 30 - text: "2" + width: JamiTheme.preferredFieldWidth contentItem: Text { text: pageTwo.text font: pageTwo.font @@ -607,8 +585,10 @@ Dialog { background: Rectangle { id: buttonRectTwo + implicitWidth: JamiTheme.preferredFieldWidth + implicitHeight: JamiTheme.preferredFieldHeight - radius: 10 + radius: 4 color: pageTwo.down ? "#e0e0e0" :"#fdfdfd" MouseArea { anchors.fill: parent @@ -621,5 +601,27 @@ Dialog { } } } + + MaterialButton { + id: btnClose + + anchors.bottom: parent.bottom + anchors.bottomMargin: JamiTheme.preferredMarginSize + anchors.horizontalCenter: parent.horizontalCenter + + width: JamiTheme.preferredFieldWidth / 2 + height: JamiTheme.preferredFieldHeight + + color: JamiTheme.buttonTintedBlack + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true + + text: JamiStrings.close + + onClicked: { + close() + } + } } } diff --git a/src/settingsview/components/LinkDeviceDialog.qml b/src/settingsview/components/LinkDeviceDialog.qml index da10fc551..56581d975 100644 --- a/src/settingsview/components/LinkDeviceDialog.qml +++ b/src/settingsview/components/LinkDeviceDialog.qml @@ -1,6 +1,7 @@ /* * Copyright (C) 2020 by Savoir-faire Linux * Author: Yang Wang <yang.wang@savoirfairelinux.com> + * Author: Albert Babà <albert.babi@savoirfairelinux.com> * * 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 @@ -23,20 +24,21 @@ import QtQuick.Controls.Styles 1.4 import net.jami.Models 1.0 import net.jami.Adapters 1.0 +import "../../constant" import "../../commoncomponents" -Dialog { +BaseDialog { id: root function openLinkDeviceDialog() { infoLabel.text = JamiStrings.pinTimerInfos passwordEdit.clear() - root.open() if(AccountAdapter.hasPassword()) { stackedWidget.currentIndex = 0 } else { setGeneratingPage() } + open() } function setGeneratingPage() { @@ -67,7 +69,7 @@ Dialog { } } - Timer{ + Timer { id: timeOut repeat: false @@ -78,17 +80,17 @@ Dialog { } } - function setExportPage(status, pin){ + function setExportPage(status, pin) { timeOut.stop() - if(status === NameDirectory.ExportOnRingStatus.SUCCESS) { - infoLabel.isSucessState = true + if (status === NameDirectory.ExportOnRingStatus.SUCCESS) { + infoLabel.success = true yourPinLabel.visible = true exportedPIN.visible = true infoLabel.text = JamiStrings.pinTimerInfos exportedPIN.text = pin } else { - infoLabel.isSucessState = false + infoLabel.success = false yourPinLabel.visible = false exportedPIN.visible = false @@ -110,8 +112,12 @@ Dialog { stackedWidget.currentIndex = 2 } + signal accepted + property int exportTimeout : 20000 + title: JamiStrings.addDevice + Connections { target: NameDirectory @@ -120,63 +126,31 @@ Dialog { } } - visible: false - - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 - - header : Rectangle { - width: parent.width - height: 64 - color: "transparent" - Text { - anchors.fill: parent - anchors.leftMargin: JamiTheme.preferredMarginSize - anchors.topMargin: JamiTheme.preferredMarginSize - - text: JamiStrings.linkAnotherDevice - font.pointSize: JamiTheme.headerFontSize - wrapMode: Text.Wrap - } - } - - onClosed: { - if(infoLabel.isSucessState) { - accept() - } else { - reject() - } - } - contentItem: Rectangle { - implicitWidth: 350 - implicitHeight: 210 + id: linkDeviceContentRect + + implicitWidth: JamiTheme.preferredDialogWidth + implicitHeight: JamiTheme.preferredDialogHeight StackLayout { id: stackedWidget + anchors.centerIn: parent anchors.fill: parent - currentIndex: 2 + anchors.margins: JamiTheme.preferredMarginSize + // Index = 0 Rectangle { - id: passwordConfirmPage - Layout.fillWidth: true Layout.fillHeight: true - Layout.alignment: Qt.AlignCenter - Layout.leftMargin: JamiTheme.preferredMarginSize - Layout.rightMargin: JamiTheme.preferredMarginSize - Layout.bottomMargin: JamiTheme.preferredMarginSize - ColumnLayout { - anchors.fill: parent + anchors.centerIn: parent + spacing: 16 Label { - Layout.topMargin: JamiTheme.preferredMarginSize - Layout.fillWidth: true Layout.alignment: Qt.AlignHCenter - wrapMode: Text.Wrap - text: qsTr("Enter your account password") + text: JamiStrings.enterAccountPassword + font.pointSize: JamiTheme.textFontSize font.kerning: true horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter @@ -185,84 +159,85 @@ Dialog { MaterialLineEdit { id: passwordEdit + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth Layout.preferredHeight: 48 - Layout.fillWidth: true - Layout.alignment: Qt.AlignHCenter - Layout.maximumWidth: 300 echoMode: TextInput.Password horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter - placeholderText: qsTr("Password") + placeholderText: JamiStrings.enterCurrentPassword + + borderColorMode: InfoLineEdit.NORMAL + + onTextChanged: { + btnConfirm.enabled = text.length > 0 + } } RowLayout { - Layout.topMargin: JamiTheme.preferredMarginSize - Layout.preferredHeight: 30 + Layout.alignment: Qt.AlignCenter Layout.fillWidth: true - Layout.alignment: Qt.AlignHCenter + spacing: 16 - HoverableRadiusButton { - id: btnPasswordOk + MaterialButton { + id: btnConfirm - Layout.preferredWidth: 130 + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + Layout.preferredHeight: JamiTheme.preferredFieldHeight - radius: height / 2 + color: enabled? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true + enabled: false text: qsTr("Register") - font.pointSize: 10 - font.kerning: true onClicked: { setGeneratingPage() } } - HoverableButtonTextItem { + MaterialButton { id: btnCancel - Layout.leftMargin: 20 - Layout.preferredWidth: 130 + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + Layout.preferredHeight: JamiTheme.preferredFieldHeight - backgroundColor: "red" - onEnterColor: Qt.rgba(150 / 256, 0, 0, 0.7) - onDisabledBackgroundColor: Qt.rgba( - 255 / 256, - 0, 0, 0.8) - onPressColor: backgroundColor - textColor: "white" - - radius: height / 2 + color: JamiTheme.buttonTintedBlack + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true + enabled: true text: qsTr("Cancel") - font.pointSize: 10 - font.kerning: true onClicked: { - reject() + close() } } } } } + // Index = 1 Rectangle { - id: exportingPage - Layout.fillWidth: true Layout.fillHeight: true ColumnLayout { - anchors.fill: parent anchors.centerIn: parent + spacing: 16 Label { - Layout.alignment: Qt.AlignLeft - Layout.leftMargin: JamiTheme.preferredMarginSize - - wrapMode: Text.Wrap - text: qsTr("Exporting Account") + Layout.alignment: Qt.AlignCenter + text: JamiStrings.backupAccount + font.pointSize: JamiTheme.headerFontSize + font.kerning: true horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } @@ -270,18 +245,16 @@ Dialog { Label { id: exportingSpinner - Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: parent.width - JamiTheme.preferredMarginSize * 2 + Layout.alignment: Qt.AlignCenter + + Layout.preferredWidth: 96 + Layout.preferredHeight: 96 background: Rectangle { - anchors.fill: parent AnimatedImage { id: spinnerMovie - anchors.fill: parent - source: "qrc:/images/jami_eclipse_spinner.gif" - playing: exportingSpinner.visible paused: false fillMode: Image.PreserveAspectFit @@ -292,28 +265,27 @@ Dialog { } } + // Index = 2 Rectangle { - id: exportedPage - Layout.fillWidth: true Layout.fillHeight: true ColumnLayout { - anchors.fill: parent anchors.centerIn: parent + spacing: 16 RowLayout { - Layout.alignment: Qt.AlignLeft - Layout.preferredWidth: parent.width - JamiTheme.preferredMarginSize * 2 - Layout.leftMargin: JamiTheme.preferredMarginSize + Layout.alignment: Qt.AlignCenter + Layout.fillWidth: true + Layout.margins: JamiTheme.preferredMarginSize + spacing: 16 Label { id: yourPinLabel - Layout.alignment: Qt.AlignLeft - - wrapMode: Text.Wrap - text: "Your PIN is:" + Layout.alignment: Qt.AlignHCenter + text: qsTr("Your PIN is:") + font.pointSize: JamiTheme.headerFontSize font.kerning: true horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter @@ -321,12 +293,9 @@ Dialog { Label { id: exportedPIN - - Layout.leftMargin: JamiTheme.preferredMarginSize / 2 - - wrapMode: Text.Wrap - text: "PIN" - font.pointSize: JamiTheme.menuFontSize + Layout.alignment: Qt.AlignHCenter + text: qsTr("PIN") + font.pointSize: JamiTheme.headerFontSize font.kerning: true horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter @@ -336,29 +305,27 @@ Dialog { Label { id: infoLabel - property bool isSucessState: false - property int borderWidth : isSucessState? 1 : 0 - property int borderRadius : isSucessState? 15 : 0 - property string backgroundColor : isSucessState? "whitesmoke" : "transparent" - property string borderColor : isSucessState? "lightgray" : "transparent" - color: isSucessState ? "#2b5084" : "black" - padding: isSucessState ? 8 : 0 - - Layout.alignment: Qt.AlignLeft - Layout.leftMargin: JamiTheme.preferredMarginSize - Layout.preferredWidth: parent.width - JamiTheme.preferredMarginSize * 2 + property bool success: false + property int borderWidth : success? 1 : 0 + property int borderRadius : success? 15 : 0 + property string backgroundColor : success? "whitesmoke" : "transparent" + property string borderColor : success? "lightgray" : "transparent" + color: success ? "#2b5084" : "black" + padding: success ? 8 : 0 wrapMode: Text.Wrap - text: JamiStrings.pinTimerInfos - font.pointSize: 8 + text: qsTr("This pin and the account password should be entered in your device within 10 minutes.") + font.pointSize: JamiTheme.textFontSize font.kerning: true + Layout.maximumWidth: linkDeviceContentRect.width - JamiTheme.preferredMarginSize * 2 + + Layout.alignment: Qt.AlignCenter horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter background: Rectangle{ id: infoLabelBackground - anchors.fill: parent border.width: infoLabel.borderWidth border.color: infoLabel.borderColor @@ -367,29 +334,26 @@ Dialog { } } - RowLayout { - Layout.alignment: Qt.AlignRight - Layout.fillWidth: true + MaterialButton { + id: btnCloseExportDialog - Button { - id: btnCloseExportDialog + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + Layout.preferredHeight: JamiTheme.preferredFieldHeight - contentItem: Text { - text: JamiStrings.close - color: JamiTheme.buttonTintedBlue - } + color: enabled? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true + enabled: true - background: Rectangle { - color: "transparent" - } + text: JamiStrings.close - onClicked: { - if(infoLabel.isSucessState) { - accept() - } else { - reject() - } + onClicked: { + if (infoLabel.success) { + accepted() } + close() } } } @@ -397,3 +361,4 @@ Dialog { } } } + diff --git a/src/settingsview/components/LinkedDevices.qml b/src/settingsview/components/LinkedDevices.qml index ed0292150..76e4127ce 100644 --- a/src/settingsview/components/LinkedDevices.qml +++ b/src/settingsview/components/LinkedDevices.qml @@ -79,16 +79,12 @@ ColumnLayout { LinkDeviceDialog { id: linkDeviceDialog - anchors.centerIn: parent.Center - onAccepted: updateAndShowDevicesSlot() } RevokeDevicePasswordDialog{ id: revokeDevicePasswordDialog - anchors.centerIn: parent.Center - onRevokeDeviceWithPassword: revokeDeviceWithIDAndPassword(idOfDevice, password) } @@ -160,4 +156,4 @@ ColumnLayout { onClicked: linkDeviceDialog.openLinkDeviceDialog() } -} \ No newline at end of file +} diff --git a/src/settingsview/components/NameRegistrationDialog.qml b/src/settingsview/components/NameRegistrationDialog.qml index c66806218..48d095bb4 100644 --- a/src/settingsview/components/NameRegistrationDialog.qml +++ b/src/settingsview/components/NameRegistrationDialog.qml @@ -1,6 +1,7 @@ /* * Copyright (C) 2020 by Savoir-faire Linux * Author: Yang Wang <yang.wang@savoirfairelinux.com> + * Author: Albert Babà <yang.wang@savoirfairelinux.com> * * 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 @@ -23,14 +24,17 @@ import QtQuick.Controls.Styles 1.4 import net.jami.Models 1.0 import net.jami.Adapters 1.0 +import "../../constant" import "../../commoncomponents" -Dialog { +BaseDialog { id: root property string registerdName : "" - function openNameRegistrationDialog(registerNameIn){ + signal accepted + + function openNameRegistrationDialog(registerNameIn) { registerdName = registerNameIn lblRegistrationError.text = qsTr("Something went wrong") passwordEdit.clear() @@ -39,27 +43,26 @@ Dialog { } else { startRegistration() } - - root.open() + open() } - function startRegistration(){ + function startRegistration() { startSpinner() timerForStartRegistration.restart() } - function slotStartNameRegistration(){ + function slotStartNameRegistration() { var password = passwordEdit.text AccountAdapter.model.registerName(UtilsAdapter.getCurrAccId(), password, registerdName) } - function startSpinner(){ + function startSpinner() { stackedWidget.currentIndex = 1 spinnerLabel.visible = true spinnerMovie.playing = true } - Timer{ + Timer { id: timerForStartRegistration interval: 100 @@ -73,482 +76,201 @@ Dialog { Connections{ target: NameDirectory - function onNameRegistrationEnded(status, name){ - if(status === NameDirectory.RegisterNameStatus.SUCCESS){ - accept() - } else { - switch(status){ - case NameDirectory.RegisterNameStatus.WRONG_PASSWORD: - lblRegistrationError.text = qsTr("Incorrect password") - break - - case NameDirectory.RegisterNameStatus.NETWORK_ERROR: - lblRegistrationError.text = qsTr("Network error") - break - default: - break - } - stackedWidget.currentIndex = 2 + function onNameRegistrationEnded(status, name) { + switch(status) { + case NameDirectory.RegisterNameStatus.SUCCESS: + accepted() + close() + return + case NameDirectory.RegisterNameStatus.WRONG_PASSWORD: + lblRegistrationError.text = qsTr("Incorrect password") + break + case NameDirectory.RegisterNameStatus.NETWORK_ERROR: + lblRegistrationError.text = qsTr("Network error") + break + default: + break } + stackedWidget.currentIndex = 2 } } - visible: false - - anchors.centerIn: parent.Center - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 - title: JamiStrings.setUsername - onClosed: { - reject() - } + contentItem: Rectangle { + id: nameRegistrationContentRect - contentItem: Rectangle{ - implicitWidth: 350 - implicitHeight: 208 + implicitWidth: JamiTheme.preferredDialogWidth + implicitHeight: JamiTheme.preferredDialogHeight - StackLayout{ - id: stackedWidget - anchors.fill: parent + color: "transparent" - currentIndex: 0 + StackLayout { + id: stackedWidget - Rectangle{ - id: passwordConfirmPage + anchors.centerIn: parent + anchors.fill: parent + anchors.margins: JamiTheme.preferredMarginSize + // Index = 0 + Rectangle { Layout.fillWidth: true Layout.fillHeight: true - Layout.leftMargin: 11 - Layout.rightMargin: 11 - Layout.topMargin: 11 - Layout.bottomMargin: 11 - - ColumnLayout{ - anchors.fill: parent - spacing: 7 - - Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter - - Item{ - Layout.alignment: Qt.AlignHCenter - - Layout.fillHeight: true - Layout.maximumHeight: 20 - Layout.preferredHeight: 20 - Layout.minimumHeight: 20 - } + ColumnLayout { + anchors.centerIn: parent + spacing: 16 - Label{ - Layout.preferredWidth: 219 - Layout.alignment: Qt.AlignHCenter - wrapMode: Text.Wrap - text: qsTr("Enter your account password") - font.pointSize: 8 + Label { + Layout.alignment: Qt.AlignCenter + text: JamiStrings.enterAccountPassword + font.pointSize: JamiTheme.textFontSize font.kerning: true horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } - Item{ - Layout.alignment: Qt.AlignHCenter - - Layout.fillHeight: true - - Layout.maximumHeight: 20 - Layout.preferredHeight: 20 - Layout.minimumHeight: 20 - } - - InfoLineEdit{ + MaterialLineEdit { id: passwordEdit - Layout.alignment: Qt.AlignHCenter - - Layout.minimumWidth: 294 - Layout.preferredWidth: 294 - - Layout.preferredHeight: 30 - Layout.minimumHeight: 30 + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth + Layout.preferredHeight: 48 echoMode: TextInput.Password placeholderText: qsTr("Password") - } - Item{ - Layout.alignment: Qt.AlignHCenter - - Layout.fillHeight: true - - Layout.maximumHeight: 20 - Layout.preferredHeight: 20 - Layout.minimumHeight: 20 + onTextChanged: btnRegister.enabled = (text.length > 0) } - RowLayout{ - spacing: 7 - + RowLayout { + spacing: 16 Layout.alignment: Qt.AlignHCenter - Layout.fillWidth: true - Item{ - Layout.fillWidth: true - - Layout.maximumHeight: 20 - Layout.preferredHeight: 20 - Layout.minimumHeight: 20 - } - - HoverableRadiusButton{ + MaterialButton { id: btnRegister - Layout.maximumWidth: 130 - Layout.preferredWidth: 130 - Layout.minimumWidth: 130 - - Layout.maximumHeight: 30 - Layout.preferredHeight: 30 - Layout.minimumHeight: 30 + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + Layout.preferredHeight: JamiTheme.preferredFieldHeight - radius: height /2 + color: enabled? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true + enabled: false text: qsTr("Register") - font.pointSize: 10 - font.kerning: true onClicked: { startRegistration() } } - Item{ - Layout.fillWidth: true - Layout.minimumWidth: 40 - - Layout.maximumHeight: 20 - Layout.preferredHeight: 20 - Layout.minimumHeight: 20 - } - - HoverableButtonTextItem { + MaterialButton { id: btnCancel - Layout.maximumWidth: 130 - Layout.preferredWidth: 130 - Layout.minimumWidth: 130 - - Layout.maximumHeight: 30 - Layout.preferredHeight: 30 - Layout.minimumHeight: 30 - - backgroundColor: "red" - onEnterColor: Qt.rgba(150 / 256, 0, 0, 0.7) - onDisabledBackgroundColor: Qt.rgba( - 255 / 256, - 0, 0, 0.8) - onPressColor: backgroundColor - textColor: "white" + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + Layout.preferredHeight: JamiTheme.preferredFieldHeight - radius: height /2 + color: JamiTheme.buttonTintedBlack + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true text: qsTr("Cancel") - font.pointSize: 10 - font.kerning: true onClicked: { - reject() + close() } } - - Item{ - Layout.fillWidth: true - Layout.minimumWidth: 40 - - Layout.maximumHeight: 20 - Layout.preferredHeight: 20 - Layout.minimumHeight: 20 - } - } - - Item{ - Layout.alignment: Qt.AlignHCenter - - Layout.fillHeight: true - - Layout.maximumHeight: 20 - Layout.preferredHeight: 20 - Layout.minimumHeight: 20 } } } - Rectangle{ - id: registeringPage - + // Index = 1 + Rectangle { Layout.fillWidth: true Layout.fillHeight: true - Layout.leftMargin: 11 - Layout.rightMargin: 11 - Layout.topMargin: 11 - Layout.bottomMargin: 11 + ColumnLayout { + anchors.centerIn: parent + spacing: 16 - ColumnLayout{ - anchors.fill: parent - spacing: 7 - - Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter - - Item{ - Layout.alignment: Qt.AlignHCenter - - Layout.fillHeight: true - Layout.minimumHeight: 40 - - Layout.maximumWidth: 20 - Layout.preferredWidth: 20 - Layout.minimumWidth: 20 + Label { + Layout.alignment: Qt.AlignCenter + text: JamiStrings.registeringName + font.pointSize: JamiTheme.textFontSize + font.kerning: true + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter } - RowLayout{ - Layout.fillWidth: true - spacing: 0 - - Layout.maximumHeight: 30 - - Item{ - Layout.fillWidth: true - - Layout.maximumHeight: 20 - Layout.preferredHeight: 20 - Layout.minimumHeight: 20 - } - - Label{ - Layout.alignment: Qt.AlignHCenter - - Layout.maximumWidth: 0 - Layout.preferredWidth: 341 - - Layout.minimumHeight: 0 - Layout.preferredHeight: 30 - Layout.maximumHeight: 30 + Label { + id: spinnerLabel - wrapMode: Text.Wrap - text: JamiStrings.registeringName - font.pointSize: 8 - font.kerning: true - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - - Item{ - Layout.fillWidth: true - - Layout.maximumHeight: 20 - Layout.preferredHeight: 20 - Layout.minimumHeight: 20 - } - } - - Item{ Layout.alignment: Qt.AlignHCenter - Layout.fillHeight: true - - Layout.maximumWidth: 20 - Layout.preferredWidth: 20 - Layout.minimumWidth: 20 - } - - RowLayout{ - spacing: 7 - - Item{ - Layout.fillWidth: true - - Layout.maximumHeight: 20 - Layout.preferredHeight: 20 - Layout.minimumHeight: 20 - } - - Label{ - id: spinnerLabel - - Layout.alignment: Qt.AlignHCenter - - Layout.maximumWidth: 96 - Layout.preferredWidth: 96 - Layout.minimumWidth: 96 - - Layout.maximumHeight: 96 - Layout.preferredHeight: 96 - Layout.minimumHeight: 96 + Layout.preferredWidth: 96 + Layout.preferredHeight: 96 - background: Rectangle { + background: Rectangle { + AnimatedImage { + id: spinnerMovie anchors.fill: parent - AnimatedImage { - id: spinnerMovie - - anchors.fill: parent - - source: "qrc:/images/jami_eclipse_spinner.gif" - - playing: spinnerLabel.visible - paused: false - fillMode: Image.PreserveAspectFit - mipmap: true - } + source: "qrc:/images/jami_eclipse_spinner.gif" + playing: spinnerLabel.visible + paused: false + fillMode: Image.PreserveAspectFit + mipmap: true } } - - Item{ - Layout.fillWidth: true - - Layout.maximumHeight: 20 - Layout.preferredHeight: 20 - Layout.minimumHeight: 20 - } - - } - - Item{ - Layout.alignment: Qt.AlignHCenter - - Layout.fillHeight: true - Layout.minimumHeight: 40 - - Layout.maximumWidth: 20 - Layout.preferredWidth: 20 - Layout.minimumWidth: 20 } } } - Rectangle{ - id: nameNotRegisteredPage - + // Index = 2 + Rectangle { Layout.fillWidth: true Layout.fillHeight: true - ColumnLayout{ - anchors.fill: parent + ColumnLayout { + anchors.centerIn: parent + spacing: 16 - Item{ - Layout.fillHeight: true - Layout.minimumHeight: 40 - - Layout.maximumWidth: 20 - Layout.preferredWidth: 20 - Layout.minimumWidth: 20 - } - - RowLayout{ - spacing: 7 - Layout.fillWidth: true + Label { + id: lblRegistrationError - Item{ - Layout.fillWidth: true - - Layout.maximumHeight: 20 - Layout.preferredHeight: 20 - Layout.minimumHeight: 20 - } - - Label{ - id: lblRegistrationError - - Layout.alignment: Qt.AlignHCenter - - Layout.maximumWidth: 0 - Layout.preferredWidth: 341 - - Layout.minimumHeight: 0 - Layout.preferredHeight: 30 - Layout.maximumHeight: 30 - - wrapMode: Text.Wrap - text: qsTr("Something went wrong") - font.pointSize: 8 - font.kerning: true - color: "red" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - - Item{ - Layout.fillWidth: true - - Layout.maximumHeight: 20 - Layout.preferredHeight: 20 - Layout.minimumHeight: 20 - } - } - - Item{ - Layout.fillHeight: true - Layout.minimumHeight: 40 - - Layout.maximumWidth: 20 - Layout.preferredWidth: 20 - Layout.minimumWidth: 20 + Layout.alignment: Qt.AlignCenter + text: qsTr("Something went wrong") + font.pointSize: JamiTheme.textFontSize + font.kerning: true + color: "red" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter } - RowLayout{ - spacing: 7 - Layout.fillWidth: true - - Item{ - Layout.fillWidth: true - - Layout.maximumHeight: 20 - Layout.preferredHeight: 20 - Layout.minimumHeight: 20 - } - - HoverableRadiusButton{ - id: btnCloseRegisterDialog - - Layout.maximumWidth: 130 - Layout.preferredWidth: 130 - Layout.minimumWidth: 130 - - Layout.maximumHeight: 30 - Layout.preferredHeight: 30 - Layout.minimumHeight: 30 + MaterialButton { + id: btnClose - radius: height /2 - - text: JamiStrings.close - font.pointSize: 10 - font.kerning: true + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 + Layout.preferredHeight: JamiTheme.preferredFieldHeight - onClicked: { - reject() - } - } + color: JamiTheme.buttonTintedBlack + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true - Item{ - Layout.fillWidth: true + text: JamiStrings.close - Layout.maximumHeight: 20 - Layout.preferredHeight: 20 - Layout.minimumHeight: 20 + onClicked: { + close() } } - - Item{ - Layout.fillHeight: true - Layout.minimumHeight: 40 - - Layout.maximumWidth: 20 - Layout.preferredWidth: 20 - Layout.minimumWidth: 20 - } } } } diff --git a/src/settingsview/components/RevokeDevicePasswordDialog.qml b/src/settingsview/components/RevokeDevicePasswordDialog.qml index 6d14aba9b..7a4180436 100644 --- a/src/settingsview/components/RevokeDevicePasswordDialog.qml +++ b/src/settingsview/components/RevokeDevicePasswordDialog.qml @@ -1,6 +1,7 @@ /* * Copyright (C) 2020 by Savoir-faire Linux * Author: Yang Wang <yang.wang@savoirfairelinux.com> + * Author: Albert Babà <albert.babi@savoirfairelinux.com> * * 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 @@ -20,109 +21,115 @@ import QtQuick 2.15 import QtQuick.Controls 2.14 import QtQuick.Layouts 1.14 import QtQuick.Controls.Styles 1.4 + import "../../constant" import "../../commoncomponents" -Dialog { +BaseDialog { id: root property string deviceId : "" signal revokeDeviceWithPassword(string idOfDevice, string password) - function openRevokeDeviceDialog(deviceIdIn){ + function openRevokeDeviceDialog(deviceIdIn) { deviceId = deviceIdIn passwordEdit.clear() - root.open() - } - - header : Rectangle { - width: parent.width - height: 64 - color: "transparent" - Text { - anchors.fill: parent - anchors.leftMargin: JamiTheme.preferredMarginSize - anchors.topMargin: JamiTheme.preferredMarginSize - - text: JamiStrings.confirmRemovalRequest - wrapMode: Text.Wrap - font.pointSize: JamiTheme.headerFontSize - } + open() } - visible: false - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 - - onAccepted: { - revokeDeviceWithPassword(deviceId,passwordEdit.text) - } + title: qsTr("Remove device") contentItem: Rectangle { - implicitWidth: 350 - implicitHeight: contentLayout.implicitHeight + 64 + JamiTheme.preferredMarginSize + id: revokeDeviceContentRect + + implicitWidth: JamiTheme.preferredDialogWidth + implicitHeight: JamiTheme.preferredDialogHeight ColumnLayout { - id: contentLayout - anchors.fill: parent anchors.centerIn: parent + anchors.fill: parent + anchors.margins: JamiTheme.preferredMarginSize + spacing: 16 + + Label { + id: labelDeletion + + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: revokeDeviceContentRect.width - JamiTheme.preferredMarginSize * 2 + + text: qsTr("Enter this account's password to confirm the removal of this device") + font.pointSize: JamiTheme.textFontSize + font.kerning: true + wrapMode: Text.Wrap + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } MaterialLineEdit { id: passwordEdit - Layout.preferredHeight: 48 - Layout.fillWidth: true Layout.alignment: Qt.AlignHCenter - Layout.maximumWidth: 300 + Layout.preferredWidth: JamiTheme.preferredFieldWidth + Layout.preferredHeight: visible ? 48 : 0 echoMode: TextInput.Password - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter + placeholderText: JamiStrings.enterCurrentPassword + borderColorMode: InfoLineEdit.NORMAL - placeholderText: qsTr("Password") + onTextChanged: { + btnRemove.enabled = text.length > 0 + } } RowLayout { - Layout.topMargin: JamiTheme.preferredMarginSize / 2 - Layout.alignment: Qt.AlignRight + spacing: 16 + Layout.alignment: Qt.AlignHCenter - Button { - id: btnChangePasswordConfirm + Layout.fillWidth: true - contentItem: Text { - text: qsTr("CONFIRM") - color: JamiTheme.buttonTintedBlue - } + MaterialButton { + id: btnRemove - background: Rectangle { - color: "transparent" - } + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + Layout.preferredHeight: JamiTheme.preferredFieldHeight + + color: enabled? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true + enabled: false + + text: qsTr("Remove") onClicked: { - timerToOperate.restart() + revokeDeviceWithPassword(deviceId, passwordEdit.text) + close() } } + MaterialButton { + id: btnCancel - Button { - id: btnChangePasswordCancel - Layout.leftMargin: JamiTheme.preferredMarginSize / 2 + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + Layout.preferredHeight: JamiTheme.preferredFieldHeight - contentItem: Text { - text: qsTr("CANCEL") - color: JamiTheme.buttonTintedBlue - } + color: JamiTheme.buttonTintedBlack + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true + enabled: true - background: Rectangle { - color: "transparent" - } + text: qsTr("Cancel") onClicked: { - root.reject() + close() } } - } + } } } } diff --git a/src/wizardview/WizardView.qml b/src/wizardview/WizardView.qml index 6f6d5d4d8..cb272a185 100644 --- a/src/wizardview/WizardView.qml +++ b/src/wizardview/WizardView.qml @@ -146,15 +146,11 @@ Rectangle { PasswordDialog { id: passwordDialog - anchors.centerIn: parent.Center - visible: false purpose: PasswordDialog.ExportAccount onDoneSignal: { if (currentPurpose === passwordDialog.ExportAccount) { - var success = (code === successCode) - var title = success ? qsTr("Success") : qsTr("Error") var info = success ? JamiStrings.backupSuccessful : JamiStrings.backupFailed diff --git a/src/wizardview/components/ImportFromBackupPage.qml b/src/wizardview/components/ImportFromBackupPage.qml index dc35b436f..787a3c3ed 100644 --- a/src/wizardview/components/ImportFromBackupPage.qml +++ b/src/wizardview/components/ImportFromBackupPage.qml @@ -42,7 +42,7 @@ Rectangle { connectBtn.spinnerTriggered = false passwordFromBackupEdit.clear() errorText = "" - fileImportBtnText = JamiString.archive + fileImportBtnText = JamiStrings.archive } function errorOccured(errorMessage) { @@ -63,10 +63,10 @@ Rectangle { onAccepted: { filePath = file - if (file.length != 0) { + if (file.length !== "") { fileImportBtnText = UtilsAdapter.toFileInfoName(file) } else { - fileImportBtnText = JamiString.archive + fileImportBtnText = JamiStrings.archive } } } -- GitLab