diff --git a/src/apps/qml/ChannelInfoDialog.qml b/src/apps/qml/ChannelInfoDialog.qml index 9d81855c..39cd0e1e 100644 --- a/src/apps/qml/ChannelInfoDialog.qml +++ b/src/apps/qml/ChannelInfoDialog.qml @@ -1,203 +1,216 @@ /* Copyright (c) 2017-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.9 import QtQuick.Layouts 1.12 import QtQuick.Controls 1.4 import QtQuick.Controls 2.5 as QQC2 import QtQuick.Window 2.0 import KDE.Ruqola.DebugCategory 1.0 import KDE.Ruqola.RocketChatAccount 1.0 import KDE.Ruqola.RoomWrapper 1.0 import "common" QQC2.Dialog { id: channelInfoDialog title: i18n("Info about this channel") standardButtons: QQC2.Dialog.Close modal: true focus: true x: parent.width / 2 - width / 2 y: parent.height / 2 - height / 2 property string channelName: "" property QtObject roomInfo signal modifyChannelSetting(string roomId, int type, var newVal, string channelType) signal deleteRoom(string roomId) function initializeAndOpen() { var enabledField = !roomInfo.canBeModify; channelNameField.setReadOnly(enabledField); channelCommentField.setReadOnly(enabledField); channelAnnouncementField.setReadOnly(enabledField); channelDescriptionField.setReadOnly(enabledField); labelReadOnlyRoom.visible = !enabledField readOnlyRoom.visible = !enabledField labelArchiveRoom.visible = !enabledField archiveRoom.visible = !enabledField labelDeleteButton.visible = !enabledField deleteButton.visible = !enabledField labelRoomType.visible = !enabledField roomType.visible = !enabledField labelEncrypted.visible = !enabledField && roomInfo.encryptedEnabled encrypted.visible = !enabledField && roomInfo.encryptedEnabled + labelPassword.visible = !enabledField + password.visible = !enabledField open(); } GridLayout { columns: 2 QQC2.Label { text: i18n("Name:"); } TextFieldEditor { id: channelNameField textField: roomInfo === null ? "" : roomInfo.name onUpdateValue: { if (newVal != "") { if (roomInfo.name !== newVal) { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.Name, newVal, roomInfo.channelType) } } else { //see https://doc.qt.io/qt-5/qml-qtqml-loggingcategory.html console.log(RuqolaDebugCategorySingleton.category, "New name is empty. We can't rename room name to empty name.") } } } QQC2.Label { text: i18n("Comment:"); } TextFieldEditor { id: channelCommentField textField: roomInfo === null ? "" : roomInfo.topic onUpdateValue: { if (roomInfo.topic !== newVal) { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.Topic, newVal, roomInfo.channelType) } } } QQC2.Label { text: i18n("Announcement:"); } TextFieldEditor { id: channelAnnouncementField textField: roomInfo === null ? "" : roomInfo.announcement; onUpdateValue: { if (roomInfo.announcement !== newVal) { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.Announcement, newVal, roomInfo.channelType) } } } QQC2.Label { text: i18n("Description:"); } TextFieldEditor { id: channelDescriptionField textField: roomInfo === null ? "" : roomInfo.description; onUpdateValue: { if (roomInfo.description !== newVal) { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.Description, newVal, roomInfo.channelType) } } } + QQC2.Label { + id: labelPassword + text: i18n("Password:"); + } + PasswordLineEdit { + id: password + selectByMouse: true + //Add i18n context ? + placeholderText: i18n("Add password") + } + QQC2.Label { id: labelReadOnlyRoom text: i18n("Read-Only:"); } QQC2.Switch { id: readOnlyRoom checked: roomInfo === null ? false : roomInfo.readOnly onClicked: { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.ReadOnly, checked, roomInfo.channelType) } } QQC2.Label { id: labelArchiveRoom text: i18n("Archive:"); } QQC2.Switch { id: archiveRoom checked: roomInfo === null ? false : roomInfo.archived onClicked: { archiveRoomDialog.open() } } QQC2.Label { id: labelRoomType text: i18n("Private:") } QQC2.Switch { id: roomType checked: roomInfo === null ? false : roomInfo.channelType === "p" onClicked: { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.RoomType, checked, roomInfo.channelType) } } //TODO hide it if we don't have this support QQC2.Label { id: labelEncrypted text: i18n("Encrypted:") } QQC2.Switch { id: encrypted //checked: roomInfo === null ? false : roomInfo.channelType === "p" onClicked: { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.Encrypted, checked, roomInfo.channelType) } } QQC2.Label { id: labelDeleteButton text: i18n("Delete Room:"); } DeleteButton { id: deleteButton onDeleteButtonClicked: { deleteRoomDialog.rId = roomInfo.rid deleteRoomDialog.open(); } } } ArchiveRoomDialog { id: archiveRoomDialog onAccepted: { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.Archive, true) } onRejected: { archiveRoom.checked = false } } DeleteRoomDialog { id: deleteRoomDialog rId: channelName onDeleteRoom: { channelInfoDialog.deleteRoom(roomId) } } } diff --git a/src/apps/qml/CreateNewChannelDialog.qml b/src/apps/qml/CreateNewChannelDialog.qml index c3297ccd..392a897f 100644 --- a/src/apps/qml/CreateNewChannelDialog.qml +++ b/src/apps/qml/CreateNewChannelDialog.qml @@ -1,117 +1,116 @@ /* Copyright (c) 2017-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.9 import QtQuick.Layouts 1.12 import QtQuick.Controls 2.5 as QQC2 import QtQuick.Window 2.0 import KDE.Ruqola.DebugCategory 1.0 QQC2.Dialog { id: createNewChannelDialog signal createNewChannel(string name, bool readOnly, bool privateRoom, string usernames, bool encryptedRoom, string password) title: i18n("Create Channel") standardButtons: QQC2.Dialog.Ok | QQC2.Dialog.Cancel x: parent.width / 2 - width / 2 y: parent.height / 2 - height / 2 modal: true focus: true property bool encryptedRoomEnabled function initializeAndOpen() { channelName.text = ""; userList.text = ""; password.text = ""; readOnlyRoom.checked = false privateRoom.checked = false encryptedRoom.checked = false encryptedRoom.visible = encryptedRoomEnabled encryptedLabelRoom.visible = encryptedRoomEnabled open() } GridLayout { columns: 2 QQC2.Label { text: i18n("Name:"); } QQC2.TextField { id: channelName selectByMouse: true placeholderText: i18n("Channel Name") } QQC2.Label { text: i18n("Users:"); } QQC2.TextField { id: userList selectByMouse: true //Add i18n context ? placeholderText: i18n("User separate with ','") } QQC2.Label { text: i18n("Read-Only:"); } QQC2.Switch { id: readOnlyRoom checked: false } QQC2.Label { text: i18n("Private:"); } QQC2.Switch { id: privateRoom checked: false } QQC2.Label { id: encryptedLabelRoom text: i18n("Encrypted:"); } QQC2.Switch { id: encryptedRoom checked: false } QQC2.Label { text: i18n("Password:"); } PasswordLineEdit { id: password selectByMouse: true //Add i18n context ? placeholderText: i18n("Add password") } - } onAccepted: { if (channelName !== "") { createNewChannelDialog.createNewChannel(channelName.text, readOnlyRoom.checked, privateRoom.checked, userList.text, encryptedRoom.checked, password.text) } else { console.log(RuqolaDebugCategorySingleton.category, "Channel name is empty!") } } }