diff --git a/imports/Spectral/Component/AutoTextField.qml b/imports/Spectral/Component/AutoTextField.qml index ec07de6..274b236 100644 --- a/imports/Spectral/Component/AutoTextField.qml +++ b/imports/Spectral/Component/AutoTextField.qml @@ -1,5 +1,5 @@ import QtQuick 2.12 -import QtQuick.Controls 2.4 +import QtQuick.Controls 2.12 TextField { selectByMouse: true diff --git a/imports/Spectral/Component/Avatar.qml b/imports/Spectral/Component/Avatar.qml index e80d213..1372525 100644 --- a/imports/Spectral/Component/Avatar.qml +++ b/imports/Spectral/Component/Avatar.qml @@ -1,5 +1,5 @@ import QtQuick 2.12 -import QtQuick.Controls 2.4 +import QtQuick.Controls 2.12 import QtGraphicalEffects 1.0 Item { diff --git a/imports/Spectral/Component/Emoji/EmojiPicker.qml b/imports/Spectral/Component/Emoji/EmojiPicker.qml index c3520f1..019357f 100644 --- a/imports/Spectral/Component/Emoji/EmojiPicker.qml +++ b/imports/Spectral/Component/Emoji/EmojiPicker.qml @@ -1,7 +1,7 @@ import QtQuick 2.12 -import QtQuick.Controls 2.4 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.Material 2.4 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Controls.Material 2.12 import Spectral.Component 2.0 diff --git a/imports/Spectral/Component/MaterialIcon.qml b/imports/Spectral/Component/MaterialIcon.qml index d0564c6..83c4d7e 100644 --- a/imports/Spectral/Component/MaterialIcon.qml +++ b/imports/Spectral/Component/MaterialIcon.qml @@ -1,6 +1,6 @@ import QtQuick 2.12 -import QtQuick.Controls 2.4 -import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 import Spectral.Setting 0.1 import Spectral.Font 0.1 diff --git a/imports/Spectral/Component/ScrollHelper.qml b/imports/Spectral/Component/ScrollHelper.qml index 7a9779a..89425d6 100644 --- a/imports/Spectral/Component/ScrollHelper.qml +++ b/imports/Spectral/Component/ScrollHelper.qml @@ -1,5 +1,5 @@ import QtQuick 2.12 -import QtQuick.Controls 2.4 +import QtQuick.Controls 2.12 MouseArea { id: root diff --git a/imports/Spectral/Component/SplitView.qml b/imports/Spectral/Component/SplitView.qml index e4302bb..a29e14e 100644 --- a/imports/Spectral/Component/SplitView.qml +++ b/imports/Spectral/Component/SplitView.qml @@ -38,8 +38,8 @@ ****************************************************************************/ import QtQuick 2.12 -import QtQuick.Controls 2.4 -import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 import QtQuick.Window 2.1 import Spectral.Setting 0.1 @@ -89,7 +89,7 @@ Item { /*! \qmlmethod void SplitView::addItem(Item item) Add an item to the end of the view. - \since QtQuick.Controls 1.3 */ + \since QtQuick.Controls 1.12 */ function addItem(item) { d.updateLayoutGuard = true d.addItem_impl(item) diff --git a/imports/Spectral/Component/Timeline/DownloadableContent.qml b/imports/Spectral/Component/Timeline/DownloadableContent.qml index 2457424..60be43e 100644 --- a/imports/Spectral/Component/Timeline/DownloadableContent.qml +++ b/imports/Spectral/Component/Timeline/DownloadableContent.qml @@ -1,6 +1,6 @@ import QtQuick 2.12 -import QtQuick.Controls 2.4 -import QtQuick.Controls.Material 2.4 +import QtQuick.Controls 2.12 +import QtQuick.Controls.Material 2.12 import Qt.labs.platform 1.0 Item { diff --git a/imports/Spectral/Component/Timeline/FileDelegate.qml b/imports/Spectral/Component/Timeline/FileDelegate.qml new file mode 100644 index 0000000..0dc52ce --- /dev/null +++ b/imports/Spectral/Component/Timeline/FileDelegate.qml @@ -0,0 +1,174 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Controls.Material 2.12 +import QtGraphicalEffects 1.0 +import Qt.labs.platform 1.0 as Platform + +import Spectral 0.1 +import Spectral.Setting 0.1 + +import Spectral.Component 2.0 +import Spectral.Font 0.1 + +ColumnLayout { + readonly property bool avatarVisible: !sentByMe && (aboveAuthor !== author || aboveSection !== section || aboveEventType === "state" || aboveEventType === "emote" || aboveEventType === "other") + readonly property bool sentByMe: author === currentRoom.localUser + + property bool openOnFinished: false + readonly property bool downloaded: progressInfo && progressInfo.completed + + id: root + + spacing: 0 + + onDownloadedChanged: if (downloaded && openOnFinished) openSavedFile() + + Label { + Layout.leftMargin: 48 + + text: author.displayName + + visible: avatarVisible + + font.pixelSize: 13 + verticalAlignment: Text.AlignVCenter + } + + RowLayout { + Layout.alignment: sentByMe ? Qt.AlignRight : Qt.AlignLeft + + z: -5 + + id: messageRow + + spacing: 4 + + Avatar { + Layout.preferredWidth: 32 + Layout.preferredHeight: 32 + Layout.alignment: Qt.AlignTop + + visible: avatarVisible + hint: author.displayName + source: author.avatarUrl + } + + Label { + Layout.preferredWidth: 32 + Layout.preferredHeight: 32 + Layout.alignment: Qt.AlignTop + + visible: !(sentByMe || avatarVisible) + + text: Qt.formatDateTime(time, "hh:mm") + color: "#5B7480" + + font.pixelSize: 10 + horizontalAlignment: Label.AlignHCenter + verticalAlignment: Label.AlignVCenter + } + + Control { + Layout.maximumWidth: messageListView.width - (!sentByMe ? 32 + messageRow.spacing : 0) - 48 + + padding: 12 + + contentItem: RowLayout { + ToolButton { + contentItem: MaterialIcon { + icon: progressInfo.completed ? "\ue5ca" : "\ue2c4" + } + + onClicked: progressInfo.completed ? openSavedFile() : saveFileAs() + } + + ColumnLayout { + Label { + Layout.alignment: Qt.AlignVCenter + + text: display + font.pixelSize: 18 + font.weight: Font.Medium + font.capitalization: Font.AllUppercase + } + + Label { + text: progressInfo.active ? (progressInfo.progress + "/" + progressInfo.total) : content.info.size + color: MPalette.lighter + } + } + } + + background: Rectangle { + color: MPalette.banner + radius: 18 + + AutoMouseArea { + anchors.fill: parent + + id: messageMouseArea + + onSecondaryClicked: messageContextMenu.popup() + + Menu { + id: messageContextMenu + + MenuItem { + text: "View Source" + + onTriggered: { + sourceDialog.sourceText = toolTip + sourceDialog.open() + } + } + MenuItem { + text: "Open Externally" + + onTriggered: downloadAndOpen() + } + MenuItem { + text: "Save As" + + onTriggered: saveFileAs() + } + MenuItem { + text: "Reply" + + onTriggered: { + roomPanelInput.replyUser = author + roomPanelInput.replyEventID = eventId + roomPanelInput.replyContent = message + roomPanelInput.isReply = true + roomPanelInput.focus() + } + } + MenuItem { + text: "Redact" + + onTriggered: currentRoom.redactEvent(eventId) + } + } + } + } + } + } + + function saveFileAs() { currentRoom.saveFileAs(eventId) } + + function downloadAndOpen() + { + if (downloaded) openSavedFile() + else + { + openOnFinished = true + currentRoom.downloadFile(eventId, Platform.StandardPaths.writableLocation(Platform.StandardPaths.CacheLocation) + "/" + eventId.replace(":", "_") + (message || ".tmp")) + } + } + + function openSavedFile() + { + if (Qt.openUrlExternally(progressInfo.localPath)) return; + if (Qt.openUrlExternally(progressInfo.localDir)) return; + } +} diff --git a/imports/Spectral/Component/Timeline/ImageDelegate.qml b/imports/Spectral/Component/Timeline/ImageDelegate.qml index 34b81b5..2b3b1d6 100644 --- a/imports/Spectral/Component/Timeline/ImageDelegate.qml +++ b/imports/Spectral/Component/Timeline/ImageDelegate.qml @@ -1,7 +1,7 @@ import QtQuick 2.12 -import QtQuick.Controls 2.4 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.Material 2.4 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Controls.Material 2.12 import QtGraphicalEffects 1.0 import Qt.labs.platform 1.0 as Platform diff --git a/imports/Spectral/Component/Timeline/MessageDelegate.qml b/imports/Spectral/Component/Timeline/MessageDelegate.qml index 05499ae..62551d7 100644 --- a/imports/Spectral/Component/Timeline/MessageDelegate.qml +++ b/imports/Spectral/Component/Timeline/MessageDelegate.qml @@ -1,7 +1,7 @@ import QtQuick 2.12 -import QtQuick.Controls 2.4 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.Material 2.4 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Controls.Material 2.12 import Spectral 0.1 import Spectral.Setting 0.1 @@ -147,6 +147,7 @@ ColumnLayout { Layout.alignment: Qt.AlignTop source: replyAuthor ? replyAuthor.avatarUrl : "" + hint: replyAuthor ? replyAuthor.displayName : "H" } ColumnLayout { diff --git a/imports/Spectral/Component/Timeline/SectionDelegate.qml b/imports/Spectral/Component/Timeline/SectionDelegate.qml index 32400dc..e84be60 100644 --- a/imports/Spectral/Component/Timeline/SectionDelegate.qml +++ b/imports/Spectral/Component/Timeline/SectionDelegate.qml @@ -1,5 +1,5 @@ import QtQuick 2.12 -import QtQuick.Controls 2.4 +import QtQuick.Controls 2.12 import Spectral.Setting 0.1 Label { diff --git a/imports/Spectral/Component/Timeline/StateDelegate.qml b/imports/Spectral/Component/Timeline/StateDelegate.qml index 2c4c20a..9e6fef7 100644 --- a/imports/Spectral/Component/Timeline/StateDelegate.qml +++ b/imports/Spectral/Component/Timeline/StateDelegate.qml @@ -1,28 +1,27 @@ import QtQuick 2.12 -import QtQuick.Controls 2.4 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.Material 2.4 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Controls.Material 2.12 import Spectral.Setting 0.1 Label { text: "" + author.displayName + " " + display - color: Material.accent + color: MPalette.foreground + font.pixelSize: 13 + font.weight: Font.Medium topPadding: 8 bottomPadding: 8 - leftPadding: 16 - rightPadding: 16 + leftPadding: 24 + rightPadding: 24 wrapMode: Label.Wrap - linkColor: Material.accent textFormat: MSettings.richText ? Text.RichText : Text.StyledText onLinkActivated: Qt.openUrlExternally(link) background: Rectangle { - color: "transparent" - border.color: Material.accent - border.width: 2 - radius: 18 + color: MPalette.banner + radius: 4 } } diff --git a/imports/Spectral/Component/Timeline/qmldir b/imports/Spectral/Component/Timeline/qmldir index aaa54ce..527b337 100644 --- a/imports/Spectral/Component/Timeline/qmldir +++ b/imports/Spectral/Component/Timeline/qmldir @@ -3,3 +3,4 @@ MessageDelegate 2.0 MessageDelegate.qml StateDelegate 2.0 StateDelegate.qml SectionDelegate 2.0 SectionDelegate.qml ImageDelegate 2.0 ImageDelegate.qml +FileDelegate 2.0 FileDelegate.qml diff --git a/imports/Spectral/Effect/RippleEffect.qml b/imports/Spectral/Effect/RippleEffect.qml index 9749aa9..33a002f 100644 --- a/imports/Spectral/Effect/RippleEffect.qml +++ b/imports/Spectral/Effect/RippleEffect.qml @@ -1,5 +1,5 @@ import QtQuick 2.12 -import QtQuick.Controls 2.4 +import QtQuick.Controls 2.12 import QtGraphicalEffects 1.0 import Spectral.Component 2.0 diff --git a/imports/Spectral/Font/CommonFont.qml b/imports/Spectral/Font/CommonFont.qml index 371004d..6205c2e 100644 --- a/imports/Spectral/Font/CommonFont.qml +++ b/imports/Spectral/Font/CommonFont.qml @@ -1,5 +1,5 @@ pragma Singleton import QtQuick 2.12 -import QtQuick.Controls 2.4 +import QtQuick.Controls 2.12 Label {} diff --git a/imports/Spectral/Panel/RoomDrawer.qml b/imports/Spectral/Panel/RoomDrawer.qml index bb6edd2..113005f 100644 --- a/imports/Spectral/Panel/RoomDrawer.qml +++ b/imports/Spectral/Panel/RoomDrawer.qml @@ -1,7 +1,7 @@ import QtQuick 2.12 -import QtQuick.Controls 2.4 -import QtQuick.Controls.Material 2.4 -import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.12 +import QtQuick.Controls.Material 2.12 +import QtQuick.Layouts 1.12 import Spectral.Component 2.0 diff --git a/imports/Spectral/Panel/RoomHeader.qml b/imports/Spectral/Panel/RoomHeader.qml index 4222787..91f04a1 100644 --- a/imports/Spectral/Panel/RoomHeader.qml +++ b/imports/Spectral/Panel/RoomHeader.qml @@ -1,7 +1,7 @@ import QtQuick 2.12 -import QtQuick.Controls 2.4 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.Material 2.4 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Controls.Material 2.12 import Spectral 0.1 import Spectral.Effect 2.0 diff --git a/imports/Spectral/Panel/RoomListPanel.qml b/imports/Spectral/Panel/RoomListPanel.qml index e0a3415..9bcd0f6 100644 --- a/imports/Spectral/Panel/RoomListPanel.qml +++ b/imports/Spectral/Panel/RoomListPanel.qml @@ -1,8 +1,8 @@ import QtQuick 2.12 -import QtQuick.Controls 2.4 +import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.Material 2.4 +import QtQuick.Layouts 1.12 +import QtQuick.Controls.Material 2.12 import Spectral.Component 2.0 import Spectral.Effect 2.0 diff --git a/imports/Spectral/Panel/RoomPanel.qml b/imports/Spectral/Panel/RoomPanel.qml index 465710f..2f0bc27 100644 --- a/imports/Spectral/Panel/RoomPanel.qml +++ b/imports/Spectral/Panel/RoomPanel.qml @@ -1,7 +1,7 @@ import QtQuick 2.12 -import QtQuick.Controls 2.4 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.Material 2.4 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Controls.Material 2.12 import Qt.labs.qmlmodels 1.0 import Spectral.Component 2.0 @@ -132,7 +132,7 @@ Item { SectionDelegate { Layout.alignment: Qt.AlignHCenter - Layout.margins: 4 + Layout.margins: 16 visible: section !== aboveSection || Math.abs(time - aboveTime) > 600000 } @@ -152,7 +152,7 @@ Item { SectionDelegate { Layout.alignment: Qt.AlignHCenter - Layout.margins: 4 + Layout.margins: 16 visible: section !== aboveSection || Math.abs(time - aboveTime) > 600000 } @@ -172,7 +172,7 @@ Item { SectionDelegate { Layout.alignment: Qt.AlignHCenter - Layout.margins: 4 + Layout.margins: 16 visible: section !== aboveSection || Math.abs(time - aboveTime) > 600000 } @@ -190,7 +190,7 @@ Item { SectionDelegate { Layout.alignment: Qt.AlignHCenter - Layout.margins: 4 + Layout.margins: 16 visible: section !== aboveSection || Math.abs(time - aboveTime) > 600000 } @@ -208,14 +208,32 @@ Item { SectionDelegate { Layout.alignment: Qt.AlignHCenter - Layout.margins: 4 + Layout.margins: 16 visible: section !== aboveSection || Math.abs(time - aboveTime) > 600000 } ImageDelegate { Layout.maximumWidth: parent.width + } + } + } + + DelegateChoice { + roleValue: "file" + delegate: ColumnLayout { + width: messageListView.width + spacing: 4 + + SectionDelegate { Layout.alignment: Qt.AlignHCenter + Layout.margins: 16 + + visible: section !== aboveSection || Math.abs(time - aboveTime) > 600000 + } + + FileDelegate { + Layout.maximumWidth: parent.width } } } diff --git a/imports/Spectral/Panel/RoomPanelInput.qml b/imports/Spectral/Panel/RoomPanelInput.qml index 112da6e..1b3a840 100644 --- a/imports/Spectral/Panel/RoomPanelInput.qml +++ b/imports/Spectral/Panel/RoomPanelInput.qml @@ -1,7 +1,7 @@ import QtQuick 2.12 -import QtQuick.Controls 2.4 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.Material 2.4 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Controls.Material 2.12 import Spectral.Component 2.0 import Spectral.Component.Emoji 2.0 diff --git a/imports/Spectral/Setting/Palette.qml b/imports/Spectral/Setting/Palette.qml index 3b040ff..b959905 100644 --- a/imports/Spectral/Setting/Palette.qml +++ b/imports/Spectral/Setting/Palette.qml @@ -1,6 +1,6 @@ pragma Singleton import QtQuick 2.12 -import QtQuick.Controls.Material 2.3 +import QtQuick.Controls.Material 2.12 QtObject { readonly property int theme: MSettings.darkTheme ? Material.Dark : Material.Light @@ -10,4 +10,5 @@ QtObject { readonly property color foreground: MSettings.darkTheme ? "#FFFFFF" : "#1D333E" readonly property color background: MSettings.darkTheme ? "#303030" : "#FFFFFF" readonly property color lighter: MSettings.darkTheme ? "#FFFFFF" : "#5B7480" + readonly property color banner: MSettings.darkTheme ? "#404040" : "#F2F3F4" } diff --git a/qml/main.qml b/qml/main.qml index 02862ec..29aa113 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -1,7 +1,7 @@ import QtQuick 2.12 -import QtQuick.Controls 2.4 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.Material 2.4 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Controls.Material 2.12 import Qt.labs.settings 1.0 import Qt.labs.platform 1.0 as Platform @@ -76,7 +76,6 @@ ApplicationWindow { property bool busy: false width: 360 - height: 300 x: (window.width - width) / 2 y: (window.height - height) / 2 @@ -86,9 +85,9 @@ ApplicationWindow { title: "Login" - contentItem: ColumnLayout { + contentItem: Column { AutoTextField { - Layout.fillWidth: true + width: parent.width id: serverField @@ -97,7 +96,7 @@ ApplicationWindow { } AutoTextField { - Layout.fillWidth: true + width: parent.width id: usernameField @@ -105,7 +104,7 @@ ApplicationWindow { } AutoTextField { - Layout.fillWidth: true + width: parent.width id: passwordField diff --git a/res.qrc b/res.qrc index 8f74d56..e5c3da8 100644 --- a/res.qrc +++ b/res.qrc @@ -43,5 +43,6 @@ imports/Spectral/Component/Timeline/ImageDelegate.qml imports/Spectral/Component/Avatar.qml imports/Spectral/Setting/Palette.qml + imports/Spectral/Component/Timeline/FileDelegate.qml