Code cleanup.
This commit is contained in:
parent
076c501605
commit
df045a786f
|
@ -3,6 +3,7 @@ import QtQuick.Controls 2.4
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import QtQuick.Controls.Material 2.4
|
import QtQuick.Controls.Material 2.4
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
|
import Qt.labs.platform 1.0 as Platform
|
||||||
|
|
||||||
import Spectral 0.1
|
import Spectral 0.1
|
||||||
import Spectral.Setting 0.1
|
import Spectral.Setting 0.1
|
||||||
|
@ -14,13 +15,15 @@ ColumnLayout {
|
||||||
readonly property bool avatarVisible: !sentByMe && (aboveAuthor !== author || aboveSection !== section || aboveEventType === "state" || aboveEventType === "emote" || aboveEventType === "other")
|
readonly property bool avatarVisible: !sentByMe && (aboveAuthor !== author || aboveSection !== section || aboveEventType === "state" || aboveEventType === "emote" || aboveEventType === "other")
|
||||||
readonly property bool sentByMe: author === currentRoom.localUser
|
readonly property bool sentByMe: author === currentRoom.localUser
|
||||||
|
|
||||||
signal saveFileAs()
|
property bool openOnFinished: false
|
||||||
signal openExternally()
|
readonly property bool downloaded: progressInfo && progressInfo.completed
|
||||||
|
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
|
onDownloadedChanged: if (downloaded && openOnFinished) openSavedFile()
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
Layout.leftMargin: 48
|
Layout.leftMargin: 48
|
||||||
|
|
||||||
|
@ -72,7 +75,6 @@ ColumnLayout {
|
||||||
id: img
|
id: img
|
||||||
|
|
||||||
source: "image://mxc/" + (content.thumbnail_url ? content.thumbnail_url : content.url)
|
source: "image://mxc/" + (content.thumbnail_url ? content.thumbnail_url : content.url)
|
||||||
sourceSize.width: Math.min(256, messageListView.width)
|
|
||||||
|
|
||||||
layer.enabled: true
|
layer.enabled: true
|
||||||
layer.effect: OpacityMask {
|
layer.effect: OpacityMask {
|
||||||
|
@ -88,13 +90,65 @@ ColumnLayout {
|
||||||
|
|
||||||
id: messageMouseArea
|
id: messageMouseArea
|
||||||
|
|
||||||
onSecondaryClicked: {
|
onSecondaryClicked: messageContextMenu.popup()
|
||||||
messageContextMenu.root = root
|
|
||||||
messageContextMenu.model = model
|
Menu {
|
||||||
messageContextMenu.selectedText = ""
|
id: messageContextMenu
|
||||||
messageContextMenu.popup()
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,11 +80,37 @@ ColumnLayout {
|
||||||
|
|
||||||
id: messageMouseArea
|
id: messageMouseArea
|
||||||
|
|
||||||
onSecondaryClicked: {
|
onSecondaryClicked: messageContextMenu.popup()
|
||||||
messageContextMenu.root = root
|
|
||||||
messageContextMenu.model = model
|
Menu {
|
||||||
messageContextMenu.selectedText = contentLabel.selectedText
|
readonly property string selectedText: contentLabel.selectedText
|
||||||
messageContextMenu.popup()
|
|
||||||
|
id: messageContextMenu
|
||||||
|
|
||||||
|
MenuItem {
|
||||||
|
text: "View Source"
|
||||||
|
|
||||||
|
onTriggered: {
|
||||||
|
sourceDialog.sourceText = toolTip
|
||||||
|
sourceDialog.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MenuItem {
|
||||||
|
text: "Reply"
|
||||||
|
|
||||||
|
onTriggered: {
|
||||||
|
roomPanelInput.replyUser = author
|
||||||
|
roomPanelInput.replyEventID = eventId
|
||||||
|
roomPanelInput.replyContent = messageContextMenu.selectedText || message
|
||||||
|
roomPanelInput.isReply = true
|
||||||
|
roomPanelInput.focus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MenuItem {
|
||||||
|
text: "Redact"
|
||||||
|
|
||||||
|
onTriggered: currentRoom.redactEvent(eventId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,4 @@ pragma Singleton
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import QtQuick.Controls 2.4
|
import QtQuick.Controls 2.4
|
||||||
|
|
||||||
Item {
|
Label {}
|
||||||
property alias font: materialLabel.font
|
|
||||||
Label {
|
|
||||||
id: materialLabel
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
import QtQuick 2.12
|
|
||||||
import QtQuick.Controls 2.4
|
|
||||||
|
|
||||||
Menu {
|
|
||||||
property var root: null
|
|
||||||
property var model: null
|
|
||||||
property string selectedText
|
|
||||||
|
|
||||||
readonly property bool isFile: model && (model.eventType === "video" || model.eventType === "audio" || model.eventType === "file" || model.eventType === "image")
|
|
||||||
|
|
||||||
id: messageContextMenu
|
|
||||||
|
|
||||||
MenuItem {
|
|
||||||
text: "View Source"
|
|
||||||
|
|
||||||
onTriggered: {
|
|
||||||
sourceDialog.sourceText = model.toolTip
|
|
||||||
sourceDialog.open()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MenuItem {
|
|
||||||
visible: isFile
|
|
||||||
height: visible ? undefined : 0
|
|
||||||
text: "Open Externally"
|
|
||||||
|
|
||||||
onTriggered: root.openExternally()
|
|
||||||
}
|
|
||||||
MenuItem {
|
|
||||||
visible: isFile
|
|
||||||
height: visible ? undefined : 0
|
|
||||||
text: "Save As"
|
|
||||||
|
|
||||||
onTriggered: root.saveFileAs()
|
|
||||||
}
|
|
||||||
MenuItem {
|
|
||||||
height: visible ? undefined : 0
|
|
||||||
text: "Reply"
|
|
||||||
|
|
||||||
onTriggered: {
|
|
||||||
roomPanelInput.replyUser = model.author
|
|
||||||
roomPanelInput.replyEventID = model.eventId
|
|
||||||
roomPanelInput.replyContent = selectedText != "" ? selectedText : model.message
|
|
||||||
roomPanelInput.isReply = true
|
|
||||||
roomPanelInput.focus()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MenuItem {
|
|
||||||
visible: model && model.author === currentRoom.localUser
|
|
||||||
height: visible ? undefined : 0
|
|
||||||
text: "Redact"
|
|
||||||
|
|
||||||
onTriggered: currentRoom.redactEvent(model.eventId)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
import QtQuick 2.12
|
|
||||||
import QtQuick.Controls 2.4
|
|
||||||
import Spectral 0.1
|
|
||||||
|
|
||||||
Menu {
|
|
||||||
property var model: null
|
|
||||||
|
|
||||||
id: roomListMenu
|
|
||||||
|
|
||||||
MenuItem {
|
|
||||||
text: "Favourite"
|
|
||||||
checkable: true
|
|
||||||
checked: model && model.category === RoomType.Favorite
|
|
||||||
|
|
||||||
onTriggered: model.category === RoomType.Favorite ? model.currentRoom.removeTag("m.favourite") : model.currentRoom.addTag("m.favourite", 1.0)
|
|
||||||
}
|
|
||||||
MenuItem {
|
|
||||||
text: "Deprioritize"
|
|
||||||
checkable: true
|
|
||||||
checked: model && model.category === RoomType.Deprioritized
|
|
||||||
|
|
||||||
onTriggered: model.category === RoomType.Deprioritized ? model.currentRoom.removeTag("m.lowpriority") : model.currentRoom.addTag("m.lowpriority", 1.0)
|
|
||||||
}
|
|
||||||
MenuSeparator {}
|
|
||||||
MenuItem {
|
|
||||||
text: "Mark as Read"
|
|
||||||
|
|
||||||
onTriggered: model.currentRoom.markAllMessagesAsRead()
|
|
||||||
}
|
|
||||||
MenuItem {
|
|
||||||
text: "Leave Room"
|
|
||||||
|
|
||||||
onTriggered: model.currentRoom.forget()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
module Spectral.Menu
|
|
||||||
MessageContextMenu 2.0 MessageContextMenu.qml
|
|
||||||
RoomContextMenu 2.0 RoomContextMenu.qml
|
|
|
@ -5,7 +5,6 @@ import QtQuick.Layouts 1.3
|
||||||
import QtQuick.Controls.Material 2.4
|
import QtQuick.Controls.Material 2.4
|
||||||
|
|
||||||
import Spectral.Component 2.0
|
import Spectral.Component 2.0
|
||||||
import Spectral.Menu 2.0
|
|
||||||
import Spectral.Effect 2.0
|
import Spectral.Effect 2.0
|
||||||
|
|
||||||
import Spectral 0.1
|
import Spectral 0.1
|
||||||
|
@ -489,11 +488,8 @@ Rectangle {
|
||||||
stepSize: 25
|
stepSize: 25
|
||||||
snapMode: Slider.SnapAlways
|
snapMode: Slider.SnapAlways
|
||||||
|
|
||||||
ToolTip {
|
ToolTip.visible: pressed
|
||||||
Material.foreground: "white"
|
ToolTip.text: value
|
||||||
visible: parent.pressed
|
|
||||||
text: parent.value
|
|
||||||
}
|
|
||||||
|
|
||||||
onMoved: controller.setDpi(value)
|
onMoved: controller.setDpi(value)
|
||||||
}
|
}
|
||||||
|
@ -804,10 +800,7 @@ Rectangle {
|
||||||
RippleEffect {
|
RippleEffect {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
onSecondaryClicked: {
|
onSecondaryClicked: roomContextMenu.popup()
|
||||||
roomContextMenu.model = model
|
|
||||||
roomContextMenu.popup()
|
|
||||||
}
|
|
||||||
onPrimaryClicked: {
|
onPrimaryClicked: {
|
||||||
if (category === RoomType.Invited) {
|
if (category === RoomType.Invited) {
|
||||||
inviteDialog.currentRoom = currentRoom
|
inviteDialog.currentRoom = currentRoom
|
||||||
|
@ -823,6 +816,36 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Menu {
|
||||||
|
id: roomContextMenu
|
||||||
|
|
||||||
|
MenuItem {
|
||||||
|
text: "Favourite"
|
||||||
|
checkable: true
|
||||||
|
checked: category === RoomType.Favorite
|
||||||
|
|
||||||
|
onTriggered: category === RoomType.Favorite ? currentRoom.removeTag("m.favourite") : currentRoom.addTag("m.favourite", 1.0)
|
||||||
|
}
|
||||||
|
MenuItem {
|
||||||
|
text: "Deprioritize"
|
||||||
|
checkable: true
|
||||||
|
checked: category === RoomType.Deprioritized
|
||||||
|
|
||||||
|
onTriggered: category === RoomType.Deprioritized ? currentRoom.removeTag("m.lowpriority") : currentRoom.addTag("m.lowpriority", 1.0)
|
||||||
|
}
|
||||||
|
MenuSeparator {}
|
||||||
|
MenuItem {
|
||||||
|
text: "Mark as Read"
|
||||||
|
|
||||||
|
onTriggered: currentRoom.markAllMessagesAsRead()
|
||||||
|
}
|
||||||
|
MenuItem {
|
||||||
|
text: "Leave Room"
|
||||||
|
|
||||||
|
onTriggered: currentRoom.forget()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
section.property: "display"
|
section.property: "display"
|
||||||
|
@ -837,10 +860,6 @@ Rectangle {
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomContextMenu {
|
|
||||||
id: roomContextMenu
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ import Qt.labs.qmlmodels 1.0
|
||||||
import Spectral.Component 2.0
|
import Spectral.Component 2.0
|
||||||
import Spectral.Component.Emoji 2.0
|
import Spectral.Component.Emoji 2.0
|
||||||
import Spectral.Component.Timeline 2.0
|
import Spectral.Component.Timeline 2.0
|
||||||
import Spectral.Menu 2.0
|
|
||||||
import Spectral.Effect 2.0
|
import Spectral.Effect 2.0
|
||||||
|
|
||||||
import Spectral 0.1
|
import Spectral 0.1
|
||||||
|
@ -266,10 +265,6 @@ Item {
|
||||||
onClicked: messageListView.positionViewAtBeginning()
|
onClicked: messageListView.positionViewAtBeginning()
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageContextMenu {
|
|
||||||
id: messageContextMenu
|
|
||||||
}
|
|
||||||
|
|
||||||
Popup {
|
Popup {
|
||||||
property string sourceText
|
property string sourceText
|
||||||
|
|
||||||
|
|
|
@ -251,13 +251,8 @@ Control {
|
||||||
onTriggered: currentRoom.sendTypingNotification(true)
|
onTriggered: currentRoom.sendTypingNotification(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolTip {
|
ToolTip.visible: currentRoom && currentRoom.hasUsersTyping
|
||||||
visible: currentRoom
|
ToolTip.text: currentRoom ? currentRoom.usersTyping : ""
|
||||||
&& currentRoom.hasUsersTyping
|
|
||||||
text: currentRoom ? currentRoom.usersTyping : ""
|
|
||||||
|
|
||||||
Material.foreground: "white"
|
|
||||||
}
|
|
||||||
|
|
||||||
Keys.onReturnPressed: {
|
Keys.onReturnPressed: {
|
||||||
if (event.modifiers & Qt.ShiftModifier) {
|
if (event.modifiers & Qt.ShiftModifier) {
|
||||||
|
|
|
@ -26,9 +26,6 @@ ApplicationWindow {
|
||||||
visible: true
|
visible: true
|
||||||
title: qsTr("Spectral")
|
title: qsTr("Spectral")
|
||||||
|
|
||||||
Material.foreground: MSettings.darkTheme ? "#FFFFFF" : "#1D333E"
|
|
||||||
Material.background: MSettings.darkTheme ? "#303030" : "#FFFFFF"
|
|
||||||
|
|
||||||
Platform.SystemTrayIcon {
|
Platform.SystemTrayIcon {
|
||||||
visible: MSettings.showTray
|
visible: MSettings.showTray
|
||||||
iconSource: "qrc:/assets/img/icon.png"
|
iconSource: "qrc:/assets/img/icon.png"
|
||||||
|
@ -132,7 +129,6 @@ ApplicationWindow {
|
||||||
ToolTip {
|
ToolTip {
|
||||||
id: loginButtonTooltip
|
id: loginButtonTooltip
|
||||||
|
|
||||||
Material.foreground: "white"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,5 @@ Theme=Light
|
||||||
Variant=Dense
|
Variant=Dense
|
||||||
Primary=#344955
|
Primary=#344955
|
||||||
Accent=#673AB7
|
Accent=#673AB7
|
||||||
Foreground=#1D333E
|
|
||||||
Background=#FFFFFF
|
Background=#FFFFFF
|
||||||
Font/Family="Roboto,Noto Sans,Noto Color Emoji"
|
Font/Family="Roboto,Noto Sans,Noto Color Emoji"
|
||||||
|
|
3
res.qrc
3
res.qrc
|
@ -14,9 +14,6 @@
|
||||||
<file>imports/Spectral/Component/qmldir</file>
|
<file>imports/Spectral/Component/qmldir</file>
|
||||||
<file>imports/Spectral/Effect/ElevationEffect.qml</file>
|
<file>imports/Spectral/Effect/ElevationEffect.qml</file>
|
||||||
<file>imports/Spectral/Effect/qmldir</file>
|
<file>imports/Spectral/Effect/qmldir</file>
|
||||||
<file>imports/Spectral/Menu/MessageContextMenu.qml</file>
|
|
||||||
<file>imports/Spectral/Menu/qmldir</file>
|
|
||||||
<file>imports/Spectral/Menu/RoomContextMenu.qml</file>
|
|
||||||
<file>imports/Spectral/Page/qmldir</file>
|
<file>imports/Spectral/Page/qmldir</file>
|
||||||
<file>assets/font/material.ttf</file>
|
<file>assets/font/material.ttf</file>
|
||||||
<file>assets/img/icon.icns</file>
|
<file>assets/img/icon.icns</file>
|
||||||
|
|
Loading…
Reference in New Issue