diff --git a/src/apps/qml/ChannelInfoDialog.qml b/src/apps/qml/ChannelInfoDialog.qml index b5dc8379..995162eb 100644 --- a/src/apps/qml/ChannelInfoDialog.qml +++ b/src/apps/qml/ChannelInfoDialog.qml @@ -1,243 +1,253 @@ /* 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.2 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 + + width: parent.width * 9 / 10 + height: parent.height * 9 / 10 + anchors.centerIn: parent 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 labelBroadcast.visible = !enabledField broadcast.visible = !enabledField //TODO fix me! Readd password password.text = ""; open(); } - GridLayout { + contentItem: GridLayout { columns: 2 QQC2.Label { text: i18n("Name:"); } TextFieldEditor { id: channelNameField + Layout.fillWidth: true 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 + Layout.fillWidth: true 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 + Layout.fillWidth: true 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 + Layout.fillWidth: true 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 + Layout.fillWidth: true selectByMouse: true //Add i18n context ? placeholderText: roomInfo === null ? i18n("Add password") : (roomInfo.joinCodeRequired ? i18n("This Room has a password") : i18n("Add password")) } QQC2.Label { id: labelReadOnlyRoom text: i18n("Read-Only:"); MouseArea { anchors.fill: parent acceptedButtons: Qt.RightButton | Qt.LeftButton hoverEnabled: true QQC2.ToolTip { id: tooltipReact text: i18n("Only Authorized people can write.") } } } QQC2.Switch { id: readOnlyRoom checked: roomInfo === null ? false : roomInfo.readOnly onClicked: { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.ReadOnly, checked, roomInfo.channelType) } } QQC2.Label { id: labelBroadcast text: i18n("Broadcast:"); } QQC2.Switch { id: broadcast checked: roomInfo === null ? false : roomInfo.broadcast onClicked: { console.log(RuqolaDebugCategorySingleton.category, "Broadcast not implemented yet") //TODO } } QQC2.Label { id: labelArchiveRoom text: i18n("Archive:"); } QQC2.Switch { id: archiveRoom checked: roomInfo === null ? false : roomInfo.archived onClicked: { archiveRoomDialog.archive = checked 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.encrypted 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(); } } + Item { + Layout.fillHeight: true + } } ArchiveRoomDialog { id: archiveRoomDialog onAccepted: { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.Archive, archiveRoomDialog.archive, roomInfo.channelType) } onRejected: { archiveRoom.checked = false } } DeleteRoomDialog { id: deleteRoomDialog rId: channelName onDeleteRoom: { channelInfoDialog.deleteRoom(roomId) channelInfoDialog.close() } } } diff --git a/src/apps/qml/CreateDiscussionDialog.qml b/src/apps/qml/CreateDiscussionDialog.qml index e570a43c..7392de9c 100644 --- a/src/apps/qml/CreateDiscussionDialog.qml +++ b/src/apps/qml/CreateDiscussionDialog.qml @@ -1,87 +1,108 @@ /* Copyright (c) 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.2 import KDE.Ruqola.DebugCategory 1.0 QQC2.Dialog { id: createDiscussionDialog title: i18n("Create Discussion") property string roomId property string messageId property string roomName property string originalMessage signal createNewDiscussion(string parentRoomName, string discussionTitle, string replyMessage, string msgId) standardButtons: QQC2.Dialog.Ok | QQC2.Dialog.Cancel - x: parent.width / 2 - width / 2 - y: parent.height / 2 - height / 2 + width: parent.width * 9 / 10 + height: parent.height * 9 / 10 + anchors.centerIn: parent modal: true focus: true function clearAndOpen() { //discussionName.text = "" + //TODO search how implement it without call it all the time. + standardButton(QQC2.Dialog.Ok).text = i18n("Create"); answer.text = "" open(); } - ColumnLayout { + contentItem: ColumnLayout { QQC2.Label { text: i18n("Parent Channel or Group:"); } QQC2.TextField { id: parentRoom text: roomName + Layout.fillWidth: true selectByMouse: true readOnly: true } QQC2.Label { text: i18n("Discussion Name:"); } QQC2.TextField { id: discussionName selectByMouse: true + Layout.fillWidth: true text: originalMessage } + +// //TODO implement it. +// QQC2.Label { +// text: i18n("Invite Users:"); +// } +// QQC2.TextField { +// id: inviteUser +// selectByMouse: true +// Layout.fillWidth: true +// } + QQC2.Label { text: i18n("Your answer:"); } QQC2.TextField { id: answer + Layout.fillWidth: true + Layout.fillHeight: true selectByMouse: true + verticalAlignment: TextInput.AlignTop + wrapMode: TextInput.Wrap } + //Add message + users } onAccepted: { createDiscussionDialog.createNewDiscussion(roomId, discussionName.text, answer.text, messageId) } } diff --git a/src/apps/qml/TextFieldEditor.qml b/src/apps/qml/TextFieldEditor.qml index 5c5fd828..3b0ffe70 100644 --- a/src/apps/qml/TextFieldEditor.qml +++ b/src/apps/qml/TextFieldEditor.qml @@ -1,65 +1,66 @@ /* 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.2 import org.kde.kirigami 2.7 as Kirigami RowLayout { id: textFieldEditor signal updateValue(string newVal) property alias textField: channelNameField.text function setReadOnly(ro) { channelNameField.readOnly = ro; channelIcon.visible = !ro; } function clear() { channelNameField.clear() } QQC2.TextField { id: channelNameField selectByMouse: true + Layout.fillWidth: true onAccepted: { if (enabled) { textFieldEditor.updateValue(text) } } onFocusChanged: { if (enabled) { textFieldEditor.updateValue(channelNameField.text) } } } Kirigami.Icon { id: channelIcon source: "document-edit" height: Kirigami.Units.iconSizes.medium width: height } } diff --git a/src/rocketchatrestapi-qt5/downloadfilejob.cpp b/src/rocketchatrestapi-qt5/downloadfilejob.cpp index 2b373b06..e6c1c7bd 100644 --- a/src/rocketchatrestapi-qt5/downloadfilejob.cpp +++ b/src/rocketchatrestapi-qt5/downloadfilejob.cpp @@ -1,137 +1,137 @@ /* Copyright (c) 2018-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. */ #include "downloadfilejob.h" #include "rocketchatqtrestapi_debug.h" #include "restapimethod.h" #include using namespace RocketChatRestApi; DownloadFileJob::DownloadFileJob(QObject *parent) : RestApiAbstractJob(parent) { } DownloadFileJob::~DownloadFileJob() { } bool DownloadFileJob::start() { if (!canStart()) { deleteLater(); return false; } QNetworkReply *reply = mNetworkAccessManager->get(request()); addLoggerInfo("ChannelListJob: url:" +mUrl.toEncoded() +" mimetype " + mMimeType.toLatin1() +" saveAs " + mLocalFileUrl.toEncoded() +" store in cache " + (mStoreInCache ? "true" : "false")); connect(reply, &QNetworkReply::finished, this, &DownloadFileJob::slotDownloadDone); return true; } void DownloadFileJob::slotDownloadDone() { QNetworkReply *reply = qobject_cast(sender()); if (reply) { const QByteArray data = reply->readAll(); const int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); if (status == 200) { addLoggerInfo("DownloadFileJob::slotDownloadDone finished"); Q_EMIT downloadFileDone(data, reply->url(), mStoreInCache, mLocalFileUrl); } else { //FIXME //emitFailedMessage(replyObject); - addLoggerWarning(QByteArrayLiteral("DownloadFileJob problem: ") + data); + addLoggerWarning(QByteArrayLiteral("DownloadFileJob problem data: [") + data + "] :END"); } reply->deleteLater(); } deleteLater(); } QNetworkRequest DownloadFileJob::request() const { QNetworkRequest req(mUrl); addAuthRawHeader(req); req.setHeader(QNetworkRequest::ContentTypeHeader, mMimeType); req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); req.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, true); return req; } bool DownloadFileJob::storeInCache() const { return mStoreInCache; } void DownloadFileJob::setStoreInCache(bool storeInCache) { mStoreInCache = storeInCache; } QUrl DownloadFileJob::localFileUrl() const { return mLocalFileUrl; } void DownloadFileJob::setLocalFileUrl(const QUrl &localFileUrl) { mLocalFileUrl = localFileUrl; } bool DownloadFileJob::requireHttpAuthentication() const { return true; } bool DownloadFileJob::canStart() const { if (!RestApiAbstractJob::canStart()) { qCWarning(ROCKETCHATQTRESTAPI_LOG) << "Impossible to start DownloadFileJob"; return false; } if (!mUrl.isValid()) { qCWarning(ROCKETCHATQTRESTAPI_LOG) << "DownloadFileJob: url is not valid"; return false; } return true; } QUrl DownloadFileJob::url() const { return mUrl; } void DownloadFileJob::setUrl(const QUrl &url) { mUrl = url; } QString DownloadFileJob::mimeType() const { return mMimeType; } void DownloadFileJob::setMimeType(const QString &mimeType) { mMimeType = mimeType; }