Add upload progress && fix icon proportion of DBus.
This commit is contained in:
parent
129a83d91f
commit
73ce9c2bf1
|
@ -28,8 +28,8 @@ Drawer {
|
||||||
anchors.margins: 32
|
anchors.margins: 32
|
||||||
|
|
||||||
ImageItem {
|
ImageItem {
|
||||||
Layout.preferredWidth: 64
|
Layout.preferredWidth: 96
|
||||||
Layout.preferredHeight: 64
|
Layout.preferredHeight: 96
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
|
||||||
hint: room ? room.displayName : "No name"
|
hint: room ? room.displayName : "No name"
|
||||||
|
|
|
@ -160,7 +160,7 @@ Item {
|
||||||
|
|
||||||
id: goTopFab
|
id: goTopFab
|
||||||
|
|
||||||
visible: !(messageListView.atYEnd || messageListView.moving)
|
visible: !messageListView.atYEnd
|
||||||
|
|
||||||
contentItem: MaterialIcon {
|
contentItem: MaterialIcon {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
|
@ -20,6 +20,14 @@ Rectangle {
|
||||||
elevation: 2
|
elevation: 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width: currentRoom && currentRoom.hasFileUploading ? parent.width * currentRoom.fileUploadingProgress / 100 : 0
|
||||||
|
height: parent.height
|
||||||
|
|
||||||
|
opacity: 0.2
|
||||||
|
color: Material.accent
|
||||||
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
|
@ -40,7 +48,7 @@ Rectangle {
|
||||||
BusyIndicator {
|
BusyIndicator {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
running: false
|
running: currentRoom && currentRoom.hasFileUploading
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
<screenshots>
|
<screenshots>
|
||||||
<screenshot type="default">
|
<screenshot type="default">
|
||||||
<caption>Overview</caption>
|
<caption>Overview</caption>
|
||||||
<image>https://raw.githubusercontent.com/encombhat/flathub/org.eu.encom.spectral/screenshots/overview.png</image>
|
<image>https://gitlab.com/b0/spectral/raw/master/screenshots/1.png</image>
|
||||||
</screenshot>
|
</screenshot>
|
||||||
<screenshot>
|
<screenshot>
|
||||||
<caption>Room Config</caption>
|
<caption>Room Config</caption>
|
||||||
<image>https://raw.githubusercontent.com/encombhat/flathub/org.eu.encom.spectral/screenshots/room_config.png</image>
|
<image>https://gitlab.com/b0/spectral/raw/master/screenshots/2.png</image>
|
||||||
</screenshot>
|
</screenshot>
|
||||||
</screenshots>
|
</screenshots>
|
||||||
<developer_name>Black Hat</developer_name>
|
<developer_name>Black Hat</developer_name>
|
||||||
|
@ -38,6 +38,7 @@
|
||||||
<content_attribute id="social-audio">intense</content_attribute>
|
<content_attribute id="social-audio">intense</content_attribute>
|
||||||
</content_rating>
|
</content_rating>
|
||||||
<releases>
|
<releases>
|
||||||
|
<release version="436" date="2018-10-20" type="stable"></release>
|
||||||
<release version="250" date="2018-09-05" type="stable"></release>
|
<release version="250" date="2018-09-05" type="stable"></release>
|
||||||
<release version="218" date="2018-08-24" type="stable"></release>
|
<release version="218" date="2018-08-24" type="stable"></release>
|
||||||
<release version="215" date="2018-08-24" type="stable"></release>
|
<release version="215" date="2018-08-24" type="stable"></release>
|
||||||
|
|
|
@ -25,7 +25,8 @@ NotificationsManager::NotificationsManager(QObject *parent)
|
||||||
|
|
||||||
void NotificationsManager::postNotification(
|
void NotificationsManager::postNotification(
|
||||||
const QString &roomid, const QString &eventid, const QString &roomname,
|
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);
|
uint id = showNotification(roomname, sender + ": " + text, icon);
|
||||||
notificationIds[id] = roomEventId{roomid, eventid};
|
notificationIds[id] = roomEventId{roomid, eventid};
|
||||||
}
|
}
|
||||||
|
@ -38,10 +39,26 @@ void NotificationsManager::postNotification(
|
||||||
uint NotificationsManager::showNotification(const QString summary,
|
uint NotificationsManager::showNotification(const QString summary,
|
||||||
const QString text,
|
const QString text,
|
||||||
const QImage image) {
|
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;
|
QVariantMap hints;
|
||||||
hints["image-data"] = image;
|
hints["image-data"] = croppedImage;
|
||||||
QList<QVariant> argumentList;
|
QList<QVariant> argumentList;
|
||||||
argumentList << "Spectral"; // app_name
|
argumentList << "Spectral"; // app_name
|
||||||
argumentList << uint(0); // replace_id
|
argumentList << uint(0); // replace_id
|
||||||
argumentList << ""; // app_icon
|
argumentList << ""; // app_icon
|
||||||
argumentList << summary; // summary
|
argumentList << summary; // summary
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "user.h"
|
#include "user.h"
|
||||||
|
|
||||||
|
#include "csapi/content-repo.h"
|
||||||
#include "csapi/leaving.h"
|
#include "csapi/leaving.h"
|
||||||
#include "csapi/typing.h"
|
#include "csapi/typing.h"
|
||||||
#include "events/typingevent.h"
|
#include "events/typingevent.h"
|
||||||
|
@ -26,13 +27,25 @@ SpectralRoom::SpectralRoom(Connection* connection, QString roomId,
|
||||||
void SpectralRoom::chooseAndUploadFile() {
|
void SpectralRoom::chooseAndUploadFile() {
|
||||||
auto localFile = QFileDialog::getOpenFileUrl(Q_NULLPTR, tr("Save File as"));
|
auto localFile = QFileDialog::getOpenFileUrl(Q_NULLPTR, tr("Save File as"));
|
||||||
if (!localFile.isEmpty()) {
|
if (!localFile.isEmpty()) {
|
||||||
uploadFile(localFile.toString(), localFile, getMIME(localFile));
|
UploadContentJob* job =
|
||||||
QMetaObject::Connection* const connection = new QMetaObject::Connection;
|
connection()->uploadFile(localFile.toLocalFile(), getMIME(localFile));
|
||||||
*connection = connect(this, &Room::fileTransferCompleted,
|
if (isJobRunning(job)) {
|
||||||
[=](QString id, QUrl localFile, QUrl mxcUrl) {
|
setHasFileUploading(true);
|
||||||
disconnect(*connection);
|
connect(job, &BaseJob::uploadProgress, this,
|
||||||
postFile(localFile, mxcUrl);
|
[=](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.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,10 @@ class SpectralRoom : public Room {
|
||||||
Q_PROPERTY(QString usersTyping READ getUsersTyping NOTIFY typingChanged)
|
Q_PROPERTY(QString usersTyping READ getUsersTyping NOTIFY typingChanged)
|
||||||
Q_PROPERTY(QString cachedInput READ cachedInput WRITE setCachedInput NOTIFY
|
Q_PROPERTY(QString cachedInput READ cachedInput WRITE setCachedInput NOTIFY
|
||||||
cachedInputChanged)
|
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)
|
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -47,6 +51,22 @@ class SpectralRoom : public Room {
|
||||||
|
|
||||||
QDateTime lastActiveTime();
|
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 float orderForTag(QString name);
|
||||||
Q_INVOKABLE int savedTopVisibleIndex() const;
|
Q_INVOKABLE int savedTopVisibleIndex() const;
|
||||||
Q_INVOKABLE int savedBottomVisibleIndex() const;
|
Q_INVOKABLE int savedBottomVisibleIndex() const;
|
||||||
|
@ -58,6 +78,9 @@ class SpectralRoom : public Room {
|
||||||
QString m_cachedInput;
|
QString m_cachedInput;
|
||||||
QSet<const QMatrixClient::RoomEvent*> highlights;
|
QSet<const QMatrixClient::RoomEvent*> highlights;
|
||||||
|
|
||||||
|
bool m_hasFileUploading = false;
|
||||||
|
int m_fileUploadingProgress = 0;
|
||||||
|
|
||||||
bool m_busy;
|
bool m_busy;
|
||||||
|
|
||||||
QString getMIME(const QUrl& fileUrl) const;
|
QString getMIME(const QUrl& fileUrl) const;
|
||||||
|
@ -75,6 +98,8 @@ class SpectralRoom : public Room {
|
||||||
void cachedInputChanged();
|
void cachedInputChanged();
|
||||||
void busyChanged();
|
void busyChanged();
|
||||||
void inheritedAvatarChanged(); // https://bugreports.qt.io/browse/QTBUG-7684
|
void inheritedAvatarChanged(); // https://bugreports.qt.io/browse/QTBUG-7684
|
||||||
|
void hasFileUploadingChanged();
|
||||||
|
void fileUploadingProgressChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void chooseAndUploadFile();
|
void chooseAndUploadFile();
|
||||||
|
|
Loading…
Reference in New Issue