diff --git a/imports/Spectral/Panel/RoomDrawer.qml b/imports/Spectral/Panel/RoomDrawer.qml index 5136c9cbd..7c83cf861 100644 --- a/imports/Spectral/Panel/RoomDrawer.qml +++ b/imports/Spectral/Panel/RoomDrawer.qml @@ -28,8 +28,8 @@ Drawer { anchors.margins: 32 ImageItem { - Layout.preferredWidth: 64 - Layout.preferredHeight: 64 + Layout.preferredWidth: 96 + Layout.preferredHeight: 96 Layout.alignment: Qt.AlignHCenter hint: room ? room.displayName : "No name" diff --git a/imports/Spectral/Panel/RoomPanelForm.ui.qml b/imports/Spectral/Panel/RoomPanelForm.ui.qml index 185c41e14..968a7d68d 100644 --- a/imports/Spectral/Panel/RoomPanelForm.ui.qml +++ b/imports/Spectral/Panel/RoomPanelForm.ui.qml @@ -160,7 +160,7 @@ Item { id: goTopFab - visible: !(messageListView.atYEnd || messageListView.moving) + visible: !messageListView.atYEnd contentItem: MaterialIcon { anchors.fill: parent diff --git a/imports/Spectral/Panel/RoomPanelInput.qml b/imports/Spectral/Panel/RoomPanelInput.qml index 770458e31..a5524cd75 100644 --- a/imports/Spectral/Panel/RoomPanelInput.qml +++ b/imports/Spectral/Panel/RoomPanelInput.qml @@ -20,6 +20,14 @@ Rectangle { elevation: 2 } + Rectangle { + width: currentRoom && currentRoom.hasFileUploading ? parent.width * currentRoom.fileUploadingProgress / 100 : 0 + height: parent.height + + opacity: 0.2 + color: Material.accent + } + RowLayout { anchors.fill: parent @@ -40,7 +48,7 @@ Rectangle { BusyIndicator { anchors.fill: parent - running: false + running: currentRoom && currentRoom.hasFileUploading } } diff --git a/org.eu.encom.spectral.appdata.xml b/org.eu.encom.spectral.appdata.xml index 74a0215b9..b4f367afa 100644 --- a/org.eu.encom.spectral.appdata.xml +++ b/org.eu.encom.spectral.appdata.xml @@ -17,11 +17,11 @@ Overview - https://raw.githubusercontent.com/encombhat/flathub/org.eu.encom.spectral/screenshots/overview.png + https://gitlab.com/b0/spectral/raw/master/screenshots/1.png Room Config - https://raw.githubusercontent.com/encombhat/flathub/org.eu.encom.spectral/screenshots/room_config.png + https://gitlab.com/b0/spectral/raw/master/screenshots/2.png Black Hat @@ -38,6 +38,7 @@ intense + diff --git a/src/notifications/managerlinux.cpp b/src/notifications/managerlinux.cpp index 5312cc4cf..3a09b0861 100644 --- a/src/notifications/managerlinux.cpp +++ b/src/notifications/managerlinux.cpp @@ -25,7 +25,8 @@ NotificationsManager::NotificationsManager(QObject *parent) void NotificationsManager::postNotification( const QString &roomid, const QString &eventid, const QString &roomname, - const QString &sender, const QString &text, const QImage &icon, const QUrl &iconPath) { + const QString &sender, const QString &text, const QImage &icon, + const QUrl &iconPath) { uint id = showNotification(roomname, sender + ": " + text, icon); notificationIds[id] = roomEventId{roomid, eventid}; } @@ -38,10 +39,26 @@ void NotificationsManager::postNotification( uint NotificationsManager::showNotification(const QString summary, const QString text, const QImage image) { + QImage croppedImage; + QRect rect = image.rect(); + if (rect.width() != rect.height()) { + if (rect.width() > rect.height()) { + QRect crop((rect.width() - rect.height()) / 2, 0, rect.height(), + rect.height()); + croppedImage = image.copy(crop); + } else { + QRect crop(0, (rect.height() - rect.width()) / 2, rect.width(), + rect.width()); + croppedImage = image.copy(crop); + } + } else { + croppedImage = image; + } + QVariantMap hints; - hints["image-data"] = image; + hints["image-data"] = croppedImage; QList argumentList; - argumentList << "Spectral"; // app_name + argumentList << "Spectral"; // app_name argumentList << uint(0); // replace_id argumentList << ""; // app_icon argumentList << summary; // summary diff --git a/src/spectralroom.cpp b/src/spectralroom.cpp index 80329e555..16078b7da 100644 --- a/src/spectralroom.cpp +++ b/src/spectralroom.cpp @@ -3,6 +3,7 @@ #include "connection.h" #include "user.h" +#include "csapi/content-repo.h" #include "csapi/leaving.h" #include "csapi/typing.h" #include "events/typingevent.h" @@ -26,13 +27,25 @@ SpectralRoom::SpectralRoom(Connection* connection, QString roomId, void SpectralRoom::chooseAndUploadFile() { auto localFile = QFileDialog::getOpenFileUrl(Q_NULLPTR, tr("Save File as")); if (!localFile.isEmpty()) { - uploadFile(localFile.toString(), localFile, getMIME(localFile)); - QMetaObject::Connection* const connection = new QMetaObject::Connection; - *connection = connect(this, &Room::fileTransferCompleted, - [=](QString id, QUrl localFile, QUrl mxcUrl) { - disconnect(*connection); - postFile(localFile, mxcUrl); - }); + UploadContentJob* job = + connection()->uploadFile(localFile.toLocalFile(), getMIME(localFile)); + if (isJobRunning(job)) { + setHasFileUploading(true); + connect(job, &BaseJob::uploadProgress, this, + [=](qint64 bytesSent, qint64 bytesTotal) { + if (bytesTotal != 0) { + setFileUploadingProgress(bytesSent * 100 / bytesTotal); + } + }); + connect(job, &BaseJob::success, this, + [=] { postFile(localFile, job->contentUri()); }); + connect(job, &BaseJob::finished, this, [=] { + setHasFileUploading(false); + setFileUploadingProgress(0); + }); + } else { + qDebug() << "Failed transfer."; + } } } diff --git a/src/spectralroom.h b/src/spectralroom.h index 13bd7b124..955150dd7 100644 --- a/src/spectralroom.h +++ b/src/spectralroom.h @@ -15,6 +15,10 @@ class SpectralRoom : public Room { Q_PROPERTY(QString usersTyping READ getUsersTyping NOTIFY typingChanged) Q_PROPERTY(QString cachedInput READ cachedInput WRITE setCachedInput NOTIFY cachedInputChanged) + Q_PROPERTY(bool hasFileUploading READ hasFileUploading NOTIFY + hasFileUploadingChanged) + Q_PROPERTY(int fileUploadingProgress READ fileUploadingProgress NOTIFY + fileUploadingProgressChanged) Q_PROPERTY(bool busy READ busy NOTIFY busyChanged) public: @@ -47,6 +51,22 @@ class SpectralRoom : public Room { QDateTime lastActiveTime(); + bool hasFileUploading() { return m_hasFileUploading; } + void setHasFileUploading(bool value) { + if (m_hasFileUploading != value) { + m_hasFileUploading = value; + emit hasFileUploadingChanged(); + } + } + + int fileUploadingProgress() { return m_fileUploadingProgress; } + void setFileUploadingProgress(int value) { + if (m_fileUploadingProgress != value) { + m_fileUploadingProgress = value; + emit fileUploadingProgressChanged(); + } + } + Q_INVOKABLE float orderForTag(QString name); Q_INVOKABLE int savedTopVisibleIndex() const; Q_INVOKABLE int savedBottomVisibleIndex() const; @@ -58,6 +78,9 @@ class SpectralRoom : public Room { QString m_cachedInput; QSet highlights; + bool m_hasFileUploading = false; + int m_fileUploadingProgress = 0; + bool m_busy; QString getMIME(const QUrl& fileUrl) const; @@ -75,6 +98,8 @@ class SpectralRoom : public Room { void cachedInputChanged(); void busyChanged(); void inheritedAvatarChanged(); // https://bugreports.qt.io/browse/QTBUG-7684 + void hasFileUploadingChanged(); + void fileUploadingProgressChanged(); public slots: void chooseAndUploadFile();