Reformat code.

This commit is contained in:
Black Hat 2018-09-04 21:13:14 +08:00
parent 412b5201bf
commit aa29f5252d
17 changed files with 139 additions and 90 deletions

View File

@ -57,17 +57,19 @@ Page {
Pane {
width: parent.width / 2
height: parent.height
padding: 64
ColumnLayout {
id: mainCol
width: parent.width
TextField {
id: serverField
id: mainCol
TextField {
Layout.fillWidth: true
id: serverField
leftPadding: 16
topPadding: 0
bottomPadding: 0
@ -85,10 +87,10 @@ Page {
}
TextField {
id: usernameField
Layout.fillWidth: true
id: usernameField
leftPadding: 16
topPadding: 0
bottomPadding: 0
@ -105,10 +107,10 @@ Page {
}
TextField {
id: passwordField
Layout.fillWidth: true
id: passwordField
leftPadding: 16
topPadding: 0
bottomPadding: 0
@ -126,10 +128,10 @@ Page {
}
Button {
id: loginButton
Layout.fillWidth: true
id: loginButton
text: "LOGIN"
highlighted: true

View File

@ -29,28 +29,29 @@ Page {
spacing: 0
RoomListForm {
id: roomListForm
Layout.fillHeight: true
Layout.preferredWidth: MSettings.miniMode ? 64 : page.width * 0.35
Layout.minimumWidth: 64
Layout.maximumWidth: 360
id: roomListForm
listModel: roomListModel
}
Rectangle {
Layout.preferredWidth: 1
Layout.fillHeight: true
color: MSettings.darkTheme ? "#363636" : "#ececec"
}
RoomForm {
id: roomForm
Layout.fillWidth: true
Layout.fillHeight: true
id: roomForm
currentRoom: roomListForm.enteredRoom
}
}

View File

@ -58,23 +58,28 @@ Page {
Page {
id: generalForm
parent: null
Column {
Switch {
text: "Lazy load at initial sync"
checked: MSettings.lazyLoad
onCheckedChanged: MSettings.lazyLoad = checked
}
Switch {
text: "Use RichText instead of StyledText"
checked: MSettings.richText
onCheckedChanged: MSettings.richText = checked
}
Switch {
text: "Use press and hold instead of right click"
checked: MSettings.pressAndHold
onCheckedChanged: MSettings.pressAndHold = checked
}
}
@ -82,23 +87,28 @@ Page {
Page {
id: appearanceForm
parent: null
Column {
Switch {
text: "Dark theme"
checked: MSettings.darkTheme
onCheckedChanged: MSettings.darkTheme = checked
}
Switch {
text: "Mini Room List"
checked: MSettings.miniMode
onCheckedChanged: MSettings.miniMode = checked
}
Switch {
text: "Rearrange rooms by activity"
checked: MSettings.rearrangeByActivity
onCheckedChanged: MSettings.rearrangeByActivity = checked
}
}
@ -118,12 +128,8 @@ Page {
source: "qrc:/asset/img/icon.png"
}
Label {
text: "Matrique, an IM client for the Matrix protocol."
}
Label {
text: "Released under GNU General Public License, version 3."
}
Label { text: "Matrique, an IM client for the Matrix protocol." }
Label { text: "Released under GNU General Public License, version 3." }
}
}

View File

@ -6,22 +6,22 @@ Item {
property alias sourceSize: baseImage.sourceSize.width
readonly property bool loading: baseImage.status == Image.Loading
signal clicked()
id: rekt
signal clicked()
width: loading ? 128 : baseImage.implicitWidth
height: loading ? progressBar.height : baseImage.implicitHeight
Image {
id: baseImage
}
id: rekt
Image { id: baseImage }
ProgressBar {
id: progressBar
width: parent.width
visible: loading
id: progressBar
indeterminate: true
}

View File

@ -11,5 +11,6 @@ Label {
wrapMode: Label.Wrap
linkColor: coloredBackground ? "white" : Material.accent
textFormat: MSettings.richText ? Text.RichText : Text.StyledText
onLinkActivated: Qt.openUrlExternally(link)
}

View File

@ -6,6 +6,7 @@ MouseArea {
signal secondaryClicked()
acceptedButtons: MSettings.pressAndHold ? Qt.LeftButton : (Qt.LeftButton | Qt.RightButton)
onClicked: mouse.button == Qt.RightButton ? secondaryClicked() : primaryClicked()
onPressAndHold: MSettings.pressAndHold ? secondaryClicked() : {}
}

View File

@ -11,20 +11,18 @@ Item {
z: -2
height: parent.height
width: progressInfo.active && !progressInfo.completed ? progressInfo.progress / progressInfo.total * parent.width : 0
color: Material.accent
opacity: 0.4
}
onDownloadedChanged: downloaded && openOnFinished ? openSavedFile() : {}
onDownloadedChanged: if (downloaded && openOnFinished) openSavedFile()
function saveFileAs() {
currentRoom.saveFileAs(eventId)
}
function saveFileAs() { currentRoom.saveFileAs(eventId) }
function downloadAndOpen()
{
if (downloaded)
openSavedFile()
if (downloaded) openSavedFile()
else
{
openOnFinished = true
@ -34,10 +32,7 @@ Item {
function openSavedFile()
{
if (Qt.openUrlExternally(progressInfo.localPath))
return;
if (Qt.openUrlExternally(progressInfo.localDir))
return;
if (Qt.openUrlExternally(progressInfo.localPath)) return;
if (Qt.openUrlExternally(progressInfo.localDir)) return;
}
}

View File

@ -52,6 +52,7 @@ Popup {
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 2
color: Material.accent
}

View File

@ -12,13 +12,11 @@ Control {
padding: 12
background: Rectangle {
color: colored ? Material.accent : highlighted ? Material.primary : backgroundColor
}
AutoMouseArea {
anchors.fill: parent
onSecondaryClicked: Qt.createComponent("qrc:/qml/menu/MessageContextMenu.qml").createObject(this)
}
background: Rectangle { color: colored ? Material.accent : highlighted ? Material.primary : backgroundColor }
}

View File

@ -13,9 +13,11 @@ Item {
id: item
Image {
id: avatar
width: item.width
height: item.width
id: avatar
visible: showImage
source: item.source
@ -40,6 +42,7 @@ Item {
Label {
anchors.fill: parent
color: "white"
visible: showInitial
text: showInitial ? getInitials(displayText)[0] : ""

View File

@ -10,8 +10,9 @@ Item {
id: item
Text {
id: iconText
anchors.fill: parent
id: iconText
font.pointSize: 16
font.family: materialFont.name
color: item.color

View File

@ -14,10 +14,10 @@ RowLayout {
signal saveFileAs()
signal openExternally()
id: messageRow
z: -5
id: messageRow
Layout.alignment: sentByMe ? Qt.AlignRight : Qt.AlignLeft
spacing: 6
@ -100,14 +100,16 @@ RowLayout {
id: imageComponent
DownloadableContent {
id: downloadable
width: messageImage.width
height: messageImage.height
id: downloadable
AutoImage {
id: messageImage
z: -4
id: messageImage
sourceSize: 128
source: "image://mxc/" + (content.thumbnail_url ? content.thumbnail_url : content.url)

View File

@ -22,11 +22,11 @@ Item {
}
Drawer {
id: roomDrawer
width: Math.min(item.width * 0.7, 480)
height: item.height
id: roomDrawer
edge: Qt.RightEdge
interactive: false
@ -51,12 +51,14 @@ Item {
Label {
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
text: currentRoom && currentRoom.id ? currentRoom.id : ""
}
Label {
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
text: currentRoom && currentRoom.canonicalAlias ? currentRoom.canonicalAlias : "No Canonical Alias"
}
@ -65,8 +67,9 @@ Item {
Layout.fillWidth: true
TextField {
id: roomNameField
Layout.fillWidth: true
id: roomNameField
text: currentRoom && currentRoom.name ? currentRoom.name : ""
}
@ -84,9 +87,10 @@ Item {
Layout.fillWidth: true
TextField {
Layout.fillWidth: true
id: roomTopicField
Layout.fillWidth: true
text: currentRoom && currentRoom.topic ? currentRoom.topic : ""
}
@ -176,6 +180,7 @@ Item {
ImageStatus {
Layout.preferredWidth: height
Layout.fillHeight: true
source: currentRoom && currentRoom.avatarUrl != "" ? "image://mxc/" + currentRoom.avatarUrl : null
displayText: currentRoom ? currentRoom.displayName : ""
}
@ -222,10 +227,11 @@ Item {
spacing: 0
ListView {
id: messageListView
Layout.fillWidth: true
Layout.fillHeight: true
id: messageListView
clip: true
displayMarginBeginning: 40
displayMarginEnd: 40
@ -243,13 +249,12 @@ Item {
delegate: ColumnLayout {
readonly property bool hidden: marks === EventStatus.Redacted || marks === EventStatus.Hidden
id: delegateColumn
width: parent.width
height: hidden ? -8 : undefined
clip: true
id: delegateColumn
clip: true
spacing: 8
Label {
@ -283,9 +288,7 @@ Item {
topPadding: 4
bottomPadding: 4
background: Rectangle {
color: MSettings.darkTheme ? "#484848" : "grey"
}
background: Rectangle { color: MSettings.darkTheme ? "#484848" : "grey" }
}
MessageDelegate {
@ -294,6 +297,7 @@ Item {
StateDelegate {
Layout.maximumWidth: messageListView.width * 0.8
visible: eventType === "emote" || eventType === "state"
}
}
@ -304,9 +308,11 @@ Item {
onAtYEndChanged: atYEnd && currentRoom ? currentRoom.markAllMessagesAsRead() : {}
RoundButton {
id: goTopFab
width: 64
height: 64
id: goTopFab
visible: !parent.atYEnd
anchors.right: parent.right
@ -328,10 +334,10 @@ Item {
}
ScrollBar {
id: messageListViewScrollBar
Layout.preferredWidth: 16
Layout.fillHeight: true
id: messageListViewScrollBar
}
}
@ -354,9 +360,11 @@ Item {
TextField {
property real progress: 0
id: inputField
Layout.fillWidth: true
Layout.preferredHeight: 48
id: inputField
placeholderText: "Send a Message"
leftPadding: 16
topPadding: 0
@ -455,11 +463,11 @@ Item {
}
ItemDelegate {
id: emojiButton
Layout.preferredWidth: 48
Layout.preferredHeight: 48
id: emojiButton
contentItem: MaterialIcon { icon: "\ue24e" }
background: Rectangle { color: MSettings.darkTheme ? "#282828" : "#eaeaea" }
@ -467,16 +475,16 @@ Item {
onClicked: emojiPicker.visible ? emojiPicker.close() : emojiPicker.open()
EmojiPicker {
id: emojiPicker
parent: ApplicationWindow.overlay
x: window.width - 370
y: window.height - 440
width: 360
height: 360
id: emojiPicker
parent: ApplicationWindow.overlay
textArea: inputField
}
}

View File

@ -16,6 +16,7 @@ Item {
Label {
z: 10
text: MSettings.miniMode ? "Empty" : "Here? No, not here."
anchors.centerIn: parent
visible: listView.count === 0
@ -26,18 +27,18 @@ Item {
spacing: 0
TextField {
id: searchField
Layout.fillWidth: true
Layout.preferredHeight: 40
Layout.margins: 12
id: searchField
leftPadding: MSettings.miniMode ? 4 : 32
topPadding: 0
bottomPadding: 0
placeholderText: "Search..."
background: Rectangle {
color: MSettings.darkTheme ? "#282828" : "#fafafa"
}
background: Rectangle { color: MSettings.darkTheme ? "#282828" : "#fafafa" }
Shortcut {
sequence: StandardKey.Find
@ -47,6 +48,7 @@ Item {
SortFilterProxyModel {
id: roomListProxyModel
filters: RegExpFilter {
roleName: "name"
pattern: searchField.text
@ -120,6 +122,7 @@ Item {
Rectangle {
anchors.fill: parent
visible: highlighted
color: Material.accent
opacity: 0.1
@ -128,6 +131,7 @@ Item {
Rectangle {
width: 4
height: parent.height
color: Material.accent
visible: unreadCount > 0 || highlighted
}
@ -135,6 +139,7 @@ Item {
RowLayout {
anchors.fill: parent
anchors.margins: 12
spacing: 12
ImageStatus {
@ -179,6 +184,7 @@ Item {
section.delegate: Label {
width: parent.width
height: 24
text: section
color: "grey"
leftPadding: MSettings.miniMode ? undefined : 16

View File

@ -13,12 +13,14 @@ import "form"
ApplicationWindow {
readonly property var connection: matriqueController.connection
id: window
visible: true
width: 960
height: 640
minimumWidth: 800
minimumHeight: 480
id: window
visible: true
title: qsTr("Matrique")
Material.theme: MSettings.darkTheme ? Material.Dark : Material.Light
@ -40,10 +42,11 @@ ApplicationWindow {
Popup {
property bool busy: matriqueController.busy
id: busyPopup
x: (window.width - width) / 2
y: (window.height - height) / 2
id: busyPopup
modal: true
focus: true
@ -81,9 +84,11 @@ ApplicationWindow {
spacing: 0
Rectangle {
id: sideNav
Layout.preferredWidth: 64
Layout.fillHeight: true
id: sideNav
color: Material.primary
ColumnLayout {
@ -106,8 +111,9 @@ ApplicationWindow {
}
Rectangle {
color: "transparent"
Layout.fillHeight: true
color: "transparent"
}
SideNavButton {
@ -125,6 +131,7 @@ ApplicationWindow {
Menu {
id: addRoomMenu
MenuItem {
text:"New Room"
onTriggered: addRoomDialog.open()
@ -143,14 +150,17 @@ ApplicationWindow {
contentItem: Column {
TextField {
id: addRoomDialogNameTextField
width: parent.width
id: addRoomDialogNameTextField
placeholderText: "Name"
}
TextField {
id: addRoomDialogTopicTextField
width: parent.width
id: addRoomDialogTopicTextField
placeholderText: "Topic"
}
}
@ -160,16 +170,18 @@ ApplicationWindow {
}
MenuItem {
text: "Join Room"
onTriggered: joinRoomDialog.open()
Dialog {
id: joinRoomDialog
parent: ApplicationWindow.overlay
x: (window.width - width) / 2
y: (window.height - height) / 2
width: 360
id: joinRoomDialog
parent: ApplicationWindow.overlay
title: "Input Room Alias or ID"
modal: true
standardButtons: Dialog.Ok | Dialog.Cancel
@ -185,16 +197,18 @@ ApplicationWindow {
MenuItem {
text: "Direct Chat"
onTriggered: directChatDialog.open()
Dialog {
id: directChatDialog
parent: ApplicationWindow.overlay
x: (window.width - width) / 2
y: (window.height - height) / 2
width: 360
id: directChatDialog
parent: ApplicationWindow.overlay
title: "Input User ID"
modal: true
standardButtons: Dialog.Ok | Dialog.Cancel
@ -240,11 +254,12 @@ ApplicationWindow {
}
StackView {
id: stackView
initialItem: roomPage
Layout.fillWidth: true
Layout.fillHeight: true
id: stackView
initialItem: roomPage
}
}

View File

@ -8,28 +8,33 @@ Menu {
MenuItem {
text: "Copy"
onTriggered: matriqueController.copyToClipboard(plainText)
}
MenuItem {
text: "Copy Source"
onTriggered: matriqueController.copyToClipboard(toolTip)
}
MenuItem {
visible: isFile
height: visible ? undefined : 0
text: "Open Externally"
onTriggered: messageRow.openExternally()
}
MenuItem {
visible: isFile
height: visible ? undefined : 0
text: "Save As"
onTriggered: messageRow.saveFileAs()
}
MenuItem {
visible: sentByMe
height: visible ? undefined : 0
text: "Redact"
onTriggered: currentRoom.redactEvent(eventId)
}

View File

@ -8,21 +8,25 @@ Menu {
text: "Favourite"
checkable: true
checked: currentRoom && currentRoom.isFavourite
onTriggered: currentRoom.isFavourite ? currentRoom.removeTag("m.favourite") : currentRoom.addTag("m.favourite", "1")
}
MenuItem {
text: "Deprioritize"
checkable: true
checked: currentRoom && currentRoom.isLowPriority
onTriggered: currentRoom.isLowPriority ? currentRoom.removeTag("m.lowpriority") : currentRoom.addTag("m.lowpriority", "1")
}
MenuSeparator {}
MenuItem {
text: "Mark as Read"
onTriggered: currentRoom.markAllMessagesAsRead()
}
MenuItem {
text: "Leave Room"
onTriggered: currentRoom.forget()
}