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
|
||||
|
||||
ImageItem {
|
||||
Layout.preferredWidth: 64
|
||||
Layout.preferredHeight: 64
|
||||
Layout.preferredWidth: 96
|
||||
Layout.preferredHeight: 96
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
hint: room ? room.displayName : "No name"
|
||||
|
|
|
@ -160,7 +160,7 @@ Item {
|
|||
|
||||
id: goTopFab
|
||||
|
||||
visible: !(messageListView.atYEnd || messageListView.moving)
|
||||
visible: !messageListView.atYEnd
|
||||
|
||||
contentItem: MaterialIcon {
|
||||
anchors.fill: parent
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
<screenshots>
|
||||
<screenshot type="default">
|
||||
<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>
|
||||
<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>
|
||||
</screenshots>
|
||||
<developer_name>Black Hat</developer_name>
|
||||
|
@ -38,6 +38,7 @@
|
|||
<content_attribute id="social-audio">intense</content_attribute>
|
||||
</content_rating>
|
||||
<releases>
|
||||
<release version="436" date="2018-10-20" 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="215" date="2018-08-24" type="stable"></release>
|
||||
|
|
|
@ -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<QVariant> argumentList;
|
||||
argumentList << "Spectral"; // app_name
|
||||
argumentList << "Spectral"; // app_name
|
||||
argumentList << uint(0); // replace_id
|
||||
argumentList << ""; // app_icon
|
||||
argumentList << summary; // summary
|
||||
|
|
|
@ -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.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<const QMatrixClient::RoomEvent*> 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();
|
||||
|
|
Loading…
Reference in New Issue