Merge branch 'qt-512' into 'material'

Qt 512

See merge request b0/spectral!33
This commit is contained in:
Black Hat 2018-12-15 02:56:10 +00:00
commit 076c501605
38 changed files with 172 additions and 186 deletions

View File

@ -1,4 +1,4 @@
import QtQuick 2.9
import QtQuick 2.12
ListView {
ScrollHelper {

View File

@ -1,4 +1,4 @@
import QtQuick 2.9
import QtQuick 2.12
import Spectral.Setting 0.1

View File

@ -1,5 +1,5 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
TextField {
selectByMouse: true

View File

@ -1,5 +1,5 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
import QtGraphicalEffects 1.0
Item {

View File

@ -1,7 +1,7 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.2
import QtQuick.Controls.Material 2.4
import Spectral.Component 2.0

View File

@ -1,7 +1,7 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.2
import QtQuick.Controls.Material 2.4
import Spectral.Setting 0.1
import Spectral.Font 0.1

View File

@ -1,5 +1,5 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
MouseArea {
id: root

View File

@ -37,8 +37,8 @@
**
****************************************************************************/
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3
import QtQuick.Window 2.1
import Spectral.Setting 0.1

View File

@ -1,6 +1,6 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
import QtQuick.Controls.Material 2.4
import Qt.labs.platform 1.0
Item {

View File

@ -1,7 +1,7 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.2
import QtQuick.Controls.Material 2.4
import QtGraphicalEffects 1.0
import Spectral 0.1
@ -11,8 +11,6 @@ import Spectral.Component 2.0
import Spectral.Font 0.1
ColumnLayout {
readonly property int alignment: sentByMe ? Qt.AlignRight : Qt.AlignLeft
readonly property bool avatarVisible: !sentByMe && (aboveAuthor !== author || aboveSection !== section || aboveEventType === "state" || aboveEventType === "emote" || aboveEventType === "other")
readonly property bool sentByMe: author === currentRoom.localUser
@ -75,7 +73,6 @@ ColumnLayout {
source: "image://mxc/" + (content.thumbnail_url ? content.thumbnail_url : content.url)
sourceSize.width: Math.min(256, messageListView.width)
sourceSize.height: 256
layer.enabled: true
layer.effect: OpacityMask {

View File

@ -1,7 +1,7 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.2
import QtQuick.Controls.Material 2.4
import Spectral 0.1
import Spectral.Setting 0.1
@ -10,14 +10,14 @@ import Spectral.Component 2.0
import Spectral.Font 0.1
ColumnLayout {
readonly property int alignment: sentByMe ? Qt.AlignRight : Qt.AlignLeft
readonly property bool avatarVisible: !sentByMe && (aboveAuthor !== author || aboveSection !== section || aboveEventType === "state" || aboveEventType === "emote" || aboveEventType === "other")
readonly property bool sentByMe: author === currentRoom.localUser
signal saveFileAs()
signal openExternally()
Layout.alignment: sentByMe ? Qt.AlignRight : Qt.AlignLeft
id: root
spacing: 0
@ -34,8 +34,6 @@ ColumnLayout {
}
RowLayout {
Layout.alignment: sentByMe ? Qt.AlignRight : Qt.AlignLeft
z: -5
id: messageRow
@ -70,10 +68,8 @@ ColumnLayout {
Control {
Layout.maximumWidth: messageListView.width - (!sentByMe ? 32 + messageRow.spacing : 0) - 48
topPadding: 8
bottomPadding: 8
leftPadding: 16
rightPadding: 16
verticalPadding: 8
horizontalPadding: 16
background: Rectangle {
color: sentByMe ? "#009DC2" : eventType === "notice" ? "#4285F4" : "#673AB7"

View File

@ -1,5 +1,5 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
Label {
text: section + " • " + Qt.formatTime(time, "hh:mm")

View File

@ -1,13 +1,11 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.2
import QtQuick.Controls.Material 2.4
import Spectral.Setting 0.1
Label {
readonly property int alignment: Qt.AlignHCenter
text: "<b>" + author.displayName + "</b> " + display
color: Material.accent

View File

@ -1,34 +0,0 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
Item {
property alias source: baseImage.source
property alias sourceSize: baseImage.sourceSize.width
readonly property bool loading: baseImage.status == Image.Loading
signal clicked()
width: loading ? 128 : baseImage.implicitWidth
height: loading ? progressBar.height : baseImage.implicitHeight
id: rekt
Image { id: baseImage }
ProgressBar {
width: parent.width
visible: loading
id: progressBar
indeterminate: true
}
MouseArea {
anchors.fill: parent
propagateComposedEvents: true
onClicked: rekt.clicked()
}
}

View File

@ -1,17 +0,0 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.2
import Spectral.Setting 0.1
Label {
property bool coloredBackground
color: coloredBackground ? "white": Material.foreground
wrapMode: Label.Wrap
linkColor: coloredBackground ? "white" : Material.accent
textFormat: Text.RichText
onLinkActivated: Qt.openUrlExternally(link)
}

View File

@ -2,3 +2,4 @@ module Spectral.Component.Timeline
MessageDelegate 2.0 MessageDelegate.qml
StateDelegate 2.0 StateDelegate.qml
SectionDelegate 2.0 SectionDelegate.qml
ImageDelegate 2.0 ImageDelegate.qml

View File

@ -1,4 +1,4 @@
import QtQuick 2.9
import QtQuick 2.12
import QtGraphicalEffects 1.0
Item {

View File

@ -1,4 +1,4 @@
import QtQuick 2.9
import QtQuick 2.12
import QtGraphicalEffects 1.0
/*!

View File

@ -1,5 +1,5 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
import QtGraphicalEffects 1.0
import Spectral.Component 2.0

View File

@ -1,6 +1,6 @@
pragma Singleton
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
Item {
property alias font: materialLabel.font

View File

@ -1,5 +1,5 @@
pragma Singleton
import QtQuick 2.9
import QtQuick 2.12
FontLoader {
source: "qrc:/assets/font/material.ttf"

View File

@ -1,5 +1,5 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
Menu {
property var root: null

View File

@ -1,5 +1,5 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
import Spectral 0.1
Menu {

View File

@ -1,6 +1,6 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
import QtQuick.Controls.Material 2.4
import QtQuick.Layouts 1.3
import Spectral.Component 2.0
@ -48,7 +48,7 @@ Drawer {
wrapMode: Label.Wrap
horizontalAlignment: Text.AlignHCenter
text: room ? room.memberCount + " Members" : "No Member Count"
text: room ? room.totalMemberCount + " Members" : "No Member Count"
}
RowLayout {

View File

@ -1,7 +1,7 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.2
import QtQuick.Controls.Material 2.4
import Spectral 0.1
import Spectral.Effect 2.0

View File

@ -1,8 +1,8 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.2
import QtQuick.Controls.Material 2.4
import Spectral.Component 2.0
import Spectral.Menu 2.0
@ -813,7 +813,11 @@ Rectangle {
inviteDialog.currentRoom = currentRoom
inviteDialog.open()
} else {
if (enteredRoom) {
enteredRoom.displayed = false
leaveRoom(enteredRoom)
}
currentRoom.displayed = true
enterRoom(currentRoom)
enteredRoom = currentRoom
}

View File

@ -1,7 +1,8 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.2
import QtQuick.Controls.Material 2.4
import Qt.labs.qmlmodels 1.0
import Spectral.Component 2.0
import Spectral.Component.Emoji 2.0
@ -121,12 +122,13 @@ Item {
}
}
delegate: DelegateChooser {
role: "eventType"
DelegateChoice {
roleValue: "state"
delegate: ColumnLayout {
width: parent.width
implicitHeight: 32
id: delegateColumn
width: messageListView.width
spacing: 4
SectionDelegate {
@ -136,51 +138,86 @@ Item {
visible: section !== aboveSection || Math.abs(time - aboveTime) > 600000
}
Loader {
Layout.maximumWidth: delegateColumn.width
Layout.alignment: item ? item.alignment : 0
source: {
switch (eventType) {
case "message":
case "notice":
return "qrc:/imports/Spectral/Component/Timeline/MessageDelegate.qml"
case "emote":
case "state":
return "qrc:/imports/Spectral/Component/Timeline/StateDelegate.qml"
case "image":
return "qrc:/imports/Spectral/Component/Timeline/ImageDelegate.qml"
default:
return ""
}
}
}
// Read marker
RowLayout {
Layout.fillWidth: true
StateDelegate {
Layout.maximumWidth: parent.width
Layout.alignment: Qt.AlignHCenter
visible: readMarker === true
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 2
color: Material.accent
}
}
}
Label {
text: "And Now"
color: Material.accent
verticalAlignment: Text.AlignVCenter
DelegateChoice {
roleValue: "emote"
delegate: ColumnLayout {
width: messageListView.width
spacing: 4
SectionDelegate {
Layout.alignment: Qt.AlignHCenter
Layout.margins: 4
visible: section !== aboveSection || Math.abs(time - aboveTime) > 600000
}
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 2
StateDelegate {
Layout.maximumWidth: parent.width
Layout.alignment: Qt.AlignHCenter
}
}
}
color: Material.accent
DelegateChoice {
roleValue: "message"
delegate: ColumnLayout {
width: messageListView.width
spacing: 4
SectionDelegate {
Layout.alignment: Qt.AlignHCenter
Layout.margins: 4
visible: section !== aboveSection || Math.abs(time - aboveTime) > 600000
}
MessageDelegate {
}
}
}
DelegateChoice {
roleValue: "notice"
delegate: ColumnLayout {
width: messageListView.width
spacing: 4
SectionDelegate {
Layout.alignment: Qt.AlignHCenter
Layout.margins: 4
visible: section !== aboveSection || Math.abs(time - aboveTime) > 600000
}
MessageDelegate {
}
}
}
DelegateChoice {
roleValue: "image"
delegate: ColumnLayout {
width: messageListView.width
spacing: 4
SectionDelegate {
Layout.alignment: Qt.AlignHCenter
Layout.margins: 4
visible: section !== aboveSection || Math.abs(time - aboveTime) > 600000
}
ImageDelegate {
Layout.maximumWidth: parent.width
Layout.alignment: Qt.AlignHCenter
}
}
}
}
@ -236,21 +273,19 @@ Item {
Popup {
property string sourceText
x: (window.width - width) / 2
y: (window.height - height) / 2
anchors.centerIn: parent
width: 480
id: sourceDialog
parent: ApplicationWindow.overlay
modal: true
padding: 16
closePolicy: Dialog.CloseOnEscape | Dialog.CloseOnPressOutside
contentItem: ScrollView {
clip: true
TextArea {
readOnly: true
selectByMouse: true

View File

@ -1,7 +1,7 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.2
import QtQuick.Controls.Material 2.4
import Spectral.Component 2.0
import Spectral.Component.Emoji 2.0
@ -167,6 +167,8 @@ Control {
spacing: 0
ToolButton {
Layout.preferredWidth: 48
Layout.preferredHeight: 48
Layout.alignment: Qt.AlignBottom
id: uploadButton
@ -186,6 +188,8 @@ Control {
}
ToolButton {
Layout.preferredWidth: 48
Layout.preferredHeight: 48
Layout.alignment: Qt.AlignBottom
id: cancelReplyButton
@ -364,6 +368,8 @@ Control {
}
ToolButton {
Layout.preferredWidth: 48
Layout.preferredHeight: 48
Layout.alignment: Qt.AlignBottom
id: emojiButton

View File

@ -1,5 +1,5 @@
pragma Singleton
import QtQuick 2.9
import QtQuick 2.12
import Qt.labs.settings 1.0
Settings {

@ -1 +1 @@
Subproject commit 52081fe91724e5f2a82c55f0e6230d8841dd859a
Subproject commit fcc8d2ca615fce6e42bf1cf6585d60f94a2db926

View File

@ -1,7 +1,7 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.2
import QtQuick.Controls.Material 2.4
import Qt.labs.settings 1.0
import Qt.labs.platform 1.0 as Platform

View File

@ -7,6 +7,7 @@ Style=Material
[Material]
Theme=Light
Variant=Dense
Primary=#344955
Accent=#673AB7
Foreground=#1D333E

View File

@ -33,8 +33,6 @@
<file>imports/Spectral/Panel/RoomHeader.qml</file>
<file>imports/Spectral/Component/ScrollHelper.qml</file>
<file>imports/Spectral/Component/AutoListView.qml</file>
<file>imports/Spectral/Component/Timeline/TimelineImage.qml</file>
<file>imports/Spectral/Component/Timeline/TimelineLabel.qml</file>
<file>imports/Spectral/Component/AutoTextField.qml</file>
<file>imports/Spectral/Panel/RoomPanelInput.qml</file>
<file>imports/Spectral/Component/SplitView.qml</file>

View File

@ -42,7 +42,12 @@ Controller::Controller(QObject* parent)
QTimer::singleShot(0, this, SLOT(invokeLogin()));
}
Controller::~Controller() {}
Controller::~Controller() {
for (Connection* c : m_connections) {
c->stopSync();
c->saveState();
}
}
inline QString accessTokenFileName(const AccountSettings& account) {
QString fileName = account.userId();
@ -107,6 +112,8 @@ void Controller::addConnection(Connection* c) {
m_connections.push_back(c);
c->setLazyLoading(true);
connect(c, &Connection::syncDone, this, [=] {
emit syncDone();
c->sync(30000);

View File

@ -29,6 +29,7 @@ QImage ImageProvider::requestImage(const QString& id, QSize* pSize,
QUrl mxcUri{id};
QImage result = image(mxcUri, requestedSize);
if (result.isNull()) return {};
if (!requestedSize.isEmpty() && result.size() != requestedSize) {
QImage scaled = result.scaled(requestedSize, Qt::KeepAspectRatio,
Qt::SmoothTransformation);

View File

@ -195,8 +195,6 @@ QDateTime SpectralRoom::lastActiveTime() {
return messageEvents().rbegin()->get()->timestamp();
}
float SpectralRoom::orderForTag(QString name) { return tag(name).order; }
int SpectralRoom::savedTopVisibleIndex() const {
return firstDisplayedMarker() == timelineEdge()
? 0

View File

@ -66,7 +66,6 @@ class SpectralRoom : public Room {
}
}
Q_INVOKABLE float orderForTag(QString name);
Q_INVOKABLE int savedTopVisibleIndex() const;
Q_INVOKABLE int savedBottomVisibleIndex() const;
Q_INVOKABLE void saveViewport(int topIndex, int bottomIndex);

View File

@ -34,12 +34,8 @@ void UserListModel::setRoom(QMatrixClient::Room* room) {
connect(m_currentRoom, &Room::memberRenamed, this,
&UserListModel::userAdded);
{
QElapsedTimer et;
et.start();
m_users = m_currentRoom->users();
std::sort(m_users.begin(), m_users.end(), room->memberSorter());
qDebug() << "Sorting" << m_users.size() << "user(s) in"
<< m_currentRoom->displayName() << "took" << et;
}
for (User* user : m_users) {
connect(user, &User::avatarChanged, this, &UserListModel::avatarChanged);