diff --git a/cmd/qmlfmt/main.go b/cmd/qmlfmt/main.go new file mode 100644 index 00000000..5dae4f82 --- /dev/null +++ b/cmd/qmlfmt/main.go @@ -0,0 +1,86 @@ +package main + +import ( + "bufio" + "log" + "os" + "strings" +) + +const ( + indent = " " +) + +func main() { + if len(os.Args) < 2 { + log.Fatal("Required argument(s): filename(s)") + } + + for _, filename := range os.Args[1:] { + processFile(filename) + } + +} + +func processFile(filename string) { + file, err := os.Open(filename) + if err != nil { + log.Fatalf("Could not read file %v: %v\n", filename, err) + } + + scanner := bufio.NewScanner(file) + var lines []string + + for scanner.Scan() { + lines = append(lines, scanner.Text()) + } + + file.Close() + + file, err = os.Create(filename) + defer file.Close() + if err != nil { + log.Fatalf("Could not write to file %v: %v\n", filename, err) + } + + indentCount := 0 + inMultiLineComment := false + + for _, line := range lines { + + singleCommentPos := strings.Index(line, "//") + multiLineCommentStartPos := strings.Index(line, "/*") + multiLineCommentEndPos := strings.Index(line, "*/") + + closePos := strings.Index(line, "}") + if !inMultiLineComment && closePos > -1 && (singleCommentPos == -1 || closePos < singleCommentPos) && + (multiLineCommentStartPos == -1 || closePos < multiLineCommentStartPos) && + (multiLineCommentEndPos == -1 || closePos > multiLineCommentEndPos) { + indentCount-- + } + + trimedLine := strings.Trim(line, " \t") + if trimedLine == "" { + file.Write([]byte("\n")) + } else { + file.Write([]byte(strings.Repeat(indent, indentCount) + trimedLine + "\n")) + } + + openPos := strings.Index(line, "{") + if !inMultiLineComment && openPos > -1 && (singleCommentPos == -1 || openPos < singleCommentPos) && + (multiLineCommentStartPos == -1 || openPos < multiLineCommentStartPos) && + (multiLineCommentEndPos == -1 || openPos > multiLineCommentEndPos) { + indentCount++ + } + + if multiLineCommentStartPos > -1 { + inMultiLineComment = true + } + + if multiLineCommentEndPos > -1 { + inMultiLineComment = false + } + + } + +} diff --git a/qml/fonts/Fonts.qml b/qml/fonts/Fonts.qml index 5afd4e18..40d135de 100644 --- a/qml/fonts/Fonts.qml +++ b/qml/fonts/Fonts.qml @@ -1,6 +1,6 @@ pragma Singleton - import QtQuick 2.5 +import QtQuick 2.5 QtObject { @@ -24,4 +24,4 @@ QtObject { source: "qrc:/qml/fonts/opensans/OpenSans-Light.ttf" } -} \ No newline at end of file +} diff --git a/qml/main.qml b/qml/main.qml index 447ba0c2..b6302b91 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -17,61 +17,61 @@ import "utils.js" as Utils ApplicationWindow { - id: windowItem - width: 1200 - height: 800 - visible: true - title: "cwtch" + "" + id: windowItem + width: 1200 + height: 800 + visible: true + title: "cwtch" + "" font.family: Fonts.applicationFontRegular.name font.styleName: "Light" - readonly property real ratio: height / width + readonly property real ratio: height / width - readonly property string cwtch_background_color: '#FF0000' - readonly property string cwtch_color: '#00FF00' - readonly property string cwtch_dark_color: '#0000FF' + readonly property string cwtch_background_color: '#FF0000' + readonly property string cwtch_color: '#00FF00' + readonly property string cwtch_dark_color: '#0000FF' - FontAwesome { // PRETTY BUTTON ICONS - id: awesome - resource: "qrc:/qml/fonts/fontawesome.ttf" - } + FontAwesome { // PRETTY BUTTON ICONS + id: awesome + resource: "qrc:/qml/fonts/fontawesome.ttf" + } - FontLoader { - source: "qrc:/qml/fonts/AdobeBlank.ttf" - } + FontLoader { + source: "qrc:/qml/fonts/AdobeBlank.ttf" + } - function parse(text, size, isntEditable) { // REPLACE EMOJI WITH TAGS - T.twemoji.base = gcd.assetPath + "twemoji/" - T.twemoji.ext = ".png" - T.twemoji.size = "72x72" - T.twemoji.className = "\" height=\""+size+"\" width=\""+size - var retText = T.twemoji.parse(Utils.htmlEscaped(text)) - retText = retText.replace(/\n/g,"
") + function parse(text, size, isntEditable) { // REPLACE EMOJI WITH TAGS + T.twemoji.base = gcd.assetPath + "twemoji/" + T.twemoji.ext = ".png" + T.twemoji.size = "72x72" + T.twemoji.className = "\" height=\""+size+"\" width=\""+size + var retText = T.twemoji.parse(Utils.htmlEscaped(text)) + retText = retText.replace(/\n/g,"
") - // mutant standard stickers - if (isntEditable) retText = Mutant.standard.parse(retText) + // mutant standard stickers + if (isntEditable) retText = Mutant.standard.parse(retText) - return retText - } + return retText + } - function restoreEmoji(text) { // REPLACE TAGS WITH EMOJI - var re = RegExp('', 'g') - var arr - var newtext = text - while (arr = re.exec(text)) { - var pieces = arr[1].split("-") - var replacement = "" - for (var i = 0; i < pieces.length; i++) { - replacement += T.twemoji.convert.fromCodePoint(pieces[i]) - } - newtext = newtext.replace(arr[0], replacement) - } - return newtext - } + function restoreEmoji(text) { // REPLACE TAGS WITH EMOJI + var re = RegExp('', 'g') + var arr + var newtext = text + while (arr = re.exec(text)) { + var pieces = arr[1].split("-") + var replacement = "" + for (var i = 0; i < pieces.length; i++) { + replacement += T.twemoji.convert.fromCodePoint(pieces[i]) + } + newtext = newtext.replace(arr[0], replacement) + } + return newtext + } function ptToPx(pt) { return Screen.pixelDensity * 25.4 * pt / 72 @@ -109,14 +109,14 @@ ApplicationWindow { } Rectangle { // Profile login/management pane - anchors.fill: parent - visible: false - color: Theme.backgroundMainColor + anchors.fill: parent + visible: false + color: Theme.backgroundMainColor - ProfileManagerPane { - id: profilesPane - anchors.fill: parent - } + ProfileManagerPane { + id: profilesPane + anchors.fill: parent + } } Rectangle { // Profile login/management pane @@ -171,20 +171,20 @@ ApplicationWindow { property string title - Item { anchors.fill: parent } // empty + Item { anchors.fill: parent } // empty OverlayPane { // messagePane title: theStack.title anchors.fill: parent } - SettingsPane{ anchors.fill: parent } + SettingsPane{ anchors.fill: parent } - PeerSettingsPane { anchors.fill: parent } + PeerSettingsPane { anchors.fill: parent } - GroupSettingsPane{ anchors.fill: parent } + GroupSettingsPane{ anchors.fill: parent } - AddGroupPane { anchors.fill: parent } + AddGroupPane { anchors.fill: parent } } } } @@ -202,56 +202,56 @@ ApplicationWindow { } } } - } + } - PropertyAnimation { id: anmPopup; easing.type: Easing.InQuart; duration: 7000; target: popup; property: "opacity"; to: 0; } +PropertyAnimation { id: anmPopup; easing.type: Easing.InQuart; duration: 7000; target: popup; property: "opacity"; to: 0; } - Rectangle { // THE ERROR MESSAGE POPUP - id: popup - anchors.top: parent.top - anchors.horizontalCenter: parent.horizontalCenter - anchors.topMargin: 20 - width: lblPopup.width + 30 - height: lblPopup.height + 8 * gcd.themeScale - color: "#000000" - opacity: 0.5 - radius: 15 - visible: false + Rectangle { // THE ERROR MESSAGE POPUP + id: popup + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + anchors.topMargin: 20 + width: lblPopup.width + 30 + height: lblPopup.height + 8 * gcd.themeScale + color: "#000000" + opacity: 0.5 + radius: 15 + visible: false - Label { - id: lblPopup - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - font.pixelSize: 18 * gcd.themeScale - color: "#FFFFFF" - } - } + Label { + id: lblPopup + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + font.pixelSize: 18 * gcd.themeScale + color: "#FFFFFF" + } + } - Connections { // POPUPS ARE INVOKED BY GO FUNCS - target: gcd + Connections { // POPUPS ARE INVOKED BY GO FUNCS + target: gcd - onInvokePopup: function(str) { - lblPopup.text = str - popup.opacity = 0.5 - popup.visible = true - anmPopup.restart() - } + onInvokePopup: function(str) { + lblPopup.text = str + popup.opacity = 0.5 + popup.visible = true + anmPopup.restart() + } - onSetToolbarTitle: function(str) { - theStack.title = str - } + onSetToolbarTitle: function(str) { + theStack.title = str + } - onLoaded: function() { - parentStack.pane = parentStack.managementPane + onLoaded: function() { + parentStack.pane = parentStack.managementPane splashPane.running = false } - } + } - Component.onCompleted: Mutant.standard.imagePath = gcd.assetPath; + Component.onCompleted: Mutant.standard.imagePath = gcd.assetPath; - Connections { + Connections { target: Qt.application onStateChanged: function() { // https://doc.qt.io/qt-5/qt.html#ApplicationState-enum diff --git a/qml/overlays/BulletinOverlay.qml b/qml/overlays/BulletinOverlay.qml index da8668c4..fd8c4fdc 100644 --- a/qml/overlays/BulletinOverlay.qml +++ b/qml/overlays/BulletinOverlay.qml @@ -12,51 +12,51 @@ import "../utils.js" as Utils import "../styles" ColumnLayout { - Layout.fillWidth: true - width:parent.width + Layout.fillWidth: true + width:parent.width - Text { - Layout.fillWidth: true - } + Text { + Layout.fillWidth: true + } - TextField { - id: filter + TextField { + id: filter - placeholderText: "Search.." + placeholderText: "Search.." - style: CwtchTextFieldStyle{} + style: CwtchTextFieldStyle{} - anchors.left: parent.left - anchors.right: parent.right + anchors.left: parent.left + anchors.right: parent.right - anchors.margins: 10 + anchors.margins: 10 - onTextChanged: { - bulletinView.filter = text - if (bulletinView.model.get(bulletinView.currentIndex).title.indexOf(text) == -1) { - bulletinView.currentIndex = -1 - } - } - } + onTextChanged: { + bulletinView.filter = text + if (bulletinView.model.get(bulletinView.currentIndex).title.indexOf(text) == -1) { + bulletinView.currentIndex = -1 + } + } + } - Flickable { // THE MESSAGE LIST ITSELF - id: sv - clip: true - Layout.alignment: Qt.AlignLeft | Qt.AlignTop - Layout.fillHeight: true - Layout.fillWidth: true - contentWidth: parent.width - contentHeight: parent.height - boundsBehavior: Flickable.StopAtBounds - maximumFlickVelocity: 800 + Flickable { // THE MESSAGE LIST ITSELF + id: sv + clip: true + Layout.alignment: Qt.AlignLeft | Qt.AlignTop + Layout.fillHeight: true + Layout.fillWidth: true + contentWidth: parent.width + contentHeight: parent.height + boundsBehavior: Flickable.StopAtBounds + maximumFlickVelocity: 800 - Connections { - target: gcd + Connections { + target: gcd - onClearMessages: function() { - jsonModel4.clear() - } + onClearMessages: function() { + jsonModel4.clear() + } onAppendMessage: function(handle, from, displayName, message, image, mid, fromMe, ts, ack, error) { handler(handle, from, displayName, message, image, mid, fromMe, ts, ack, error) @@ -67,29 +67,29 @@ ColumnLayout { } function handler(handle, from, displayName, message, image, mid, fromMe, ts, ack, error) { - var msg - try { - msg = JSON.parse(message) - } catch (e) { - return - } - if (msg.o != 2) return + var msg + try { + msg = JSON.parse(message) + } catch (e) { + return + } + if (msg.o != 2) return - if (msg.t != undefined && msg.b != undefined) { - jsonModel4.insert(0,{ - "title":msg.t, - "body": msg.b, - "selected":false, - "from": from, - "displayName": displayName, - "timestamp": ts - }) - } + if (msg.t != undefined && msg.b != undefined) { + jsonModel4.insert(0,{ + "title":msg.t, + "body": msg.b, + "selected":false, + "from": from, + "displayName": displayName, + "timestamp": ts + }) + } - /*if (sv.contentY + sv.height >= sv.contentHeight - colMessages.height && sv.contentHeight > sv.height) { - sv.contentY = sv.contentHeight - sv.height - }*/ - } + /*if (sv.contentY + sv.height >= sv.contentHeight - colMessages.height && sv.contentHeight > sv.height) { + sv.contentY = sv.contentHeight - sv.height + }*/ + } onUpdateContactStatus: function(_handle, _status, _loading) { if (gcd.selectedConversation == _handle) { @@ -105,153 +105,153 @@ ColumnLayout { } } - } + } - ScrollBar.vertical: ScrollBar{ - policy: ScrollBar.AlwaysOn - } + ScrollBar.vertical: ScrollBar{ + policy: ScrollBar.AlwaysOn + } - ListView { - id: bulletinView - anchors.left: parent.left - anchors.leftMargin: 10 - anchors.topMargin: 10 + ListView { + id: bulletinView + anchors.left: parent.left + anchors.leftMargin: 10 + anchors.topMargin: 10 - width: parent.width - 50 - height: parent.height - 20 - orientation: Qt.Vertical - spacing: 10 - model: jsonModel4 - property string filter: "" - delegate: + width: parent.width - 50 + height: parent.height - 20 + orientation: Qt.Vertical + spacing: 10 + model: jsonModel4 + property string filter: "" + delegate: - Item { - width: parent.width - height: title.indexOf(bulletinView.filter) >= 0 ? (selected ? texttitle.height + textbody.height + replybtn.height + 8 : texttitle.height * 2) : 0 - visible: title.indexOf(bulletinView.filter) >= 0 + Item { + width: parent.width + height: title.indexOf(bulletinView.filter) >= 0 ? (selected ? texttitle.height + textbody.height + replybtn.height + 8 : texttitle.height * 2) : 0 + visible: title.indexOf(bulletinView.filter) >= 0 - Column { - width: parent.width + Column { + width: parent.width - RowLayout { - Button { - text: selected ? "-" : "+" - style: CwtchExpandingButton{} - } - Text { - id: texttitle - text: '' + Utils.htmlEscaped(title) + ' by ' + from + "
" + timestamp - leftPadding: 10 - topPadding: 5 - bottomPadding:5 - color: windowItem.cwtch_dark_color - } - MouseArea { - anchors.fill: parent - onClicked: { - selected = !selected - bulletinView.currentIndex = index - } + RowLayout { + Button { + text: selected ? "-" : "+" + style: CwtchExpandingButton{} + } + Text { + id: texttitle + text: '' + Utils.htmlEscaped(title) + ' by ' + from + "
" + timestamp + leftPadding: 10 + topPadding: 5 + bottomPadding:5 + color: windowItem.cwtch_dark_color + } + MouseArea { + anchors.fill: parent + onClicked: { + selected = !selected + bulletinView.currentIndex = index + } - } - } + } + } - Rectangle { - height: 1 - color: windowItem.cwtch_color - anchors { - left: parent.left - right: parent.right - } - } + Rectangle { + height: 1 + color: windowItem.cwtch_color + anchors { + left: parent.left + right: parent.right + } + } - Text { - id: textbody - visible: selected - text: Utils.htmlEscaped(body) - wrapMode: TextEdit.Wrap - leftPadding: 10 - topPadding: 10 - width: parent.width - 50 - } + Text { + id: textbody + visible: selected + text: Utils.htmlEscaped(body) + wrapMode: TextEdit.Wrap + leftPadding: 10 + topPadding: 10 + width: parent.width - 50 + } - Widgets.Button { - id: replybtn - visible: selected - text: "reply" - anchors.right: parent.right - anchors.rightMargin:10 - onClicked: { - gcd.broadcast("ResetMessagePane") - theStack.pane = theStack.messagePane - gcd.loadMessagesPane(from) - overlayStack.overlay = overlayStack.chatOverlay - } - } - } + Widgets.Button { + id: replybtn + visible: selected + text: "reply" + anchors.right: parent.right + anchors.rightMargin:10 + onClicked: { + gcd.broadcast("ResetMessagePane") + theStack.pane = theStack.messagePane + gcd.loadMessagesPane(from) + overlayStack.overlay = overlayStack.chatOverlay + } + } + } - } + } - focus: true - ListModel { - id: jsonModel4 - } - } - } + focus: true + ListModel { + id: jsonModel4 + } + } + } - GroupBox { - title: qsTr("new-bulletin-label") - Layout.fillWidth: true + GroupBox { + title: qsTr("new-bulletin-label") + Layout.fillWidth: true - RowLayout { - Layout.fillWidth: true - width: parent.width - ColumnLayout { - Layout.fillWidth: true + RowLayout { + Layout.fillWidth: true + width: parent.width + ColumnLayout { + Layout.fillWidth: true - Text { - //: Post a new Bulletin Post - text: qsTr("post-new-bulletin-label") - } + Text { + //: Post a new Bulletin Post + text: qsTr("post-new-bulletin-label") + } - TextField { - id: newposttitle - //: title place holder text - placeholderText: qsTr("title-placeholder") - Layout.fillWidth: true - style: CwtchTextFieldStyle{} - } + TextField { + id: newposttitle + //: title place holder text + placeholderText: qsTr("title-placeholder") + Layout.fillWidth: true + style: CwtchTextFieldStyle{} + } - TextArea { - id: newpostbody - Layout.fillWidth: true - style: CwtchTextAreaStyle{} - } + TextArea { + id: newpostbody + Layout.fillWidth: true + style: CwtchTextAreaStyle{} + } - Widgets.Button { // SEND MESSAGE BUTTON - id: btnSend - icon: "regular/paper-plane" - text: "post" - anchors.right: parent.right - anchors.rightMargin: 2 + Widgets.Button { // SEND MESSAGE BUTTON + id: btnSend + icon: "regular/paper-plane" + text: "post" + anchors.right: parent.right + anchors.rightMargin: 2 - property int nextMessageID: 1 + property int nextMessageID: 1 - onClicked: { - if (newposttitle.text != "" && newpostbody.text != "") { - var msg = JSON.stringify({"o":2, "t":newposttitle.text, "b":newpostbody.text}) - gcd.sendMessage(msg, nextMessageID++) - } - newposttitle.text = "" - newpostbody.text = "" - } - } - } - } + onClicked: { + if (newposttitle.text != "" && newpostbody.text != "") { + var msg = JSON.stringify({"o":2, "t":newposttitle.text, "b":newpostbody.text}) + gcd.sendMessage(msg, nextMessageID++) + } + newposttitle.text = "" + newpostbody.text = "" + } + } + } + } - } + } diff --git a/qml/overlays/ChatOverlay.qml b/qml/overlays/ChatOverlay.qml index 12dbd680..a2efeaab 100644 --- a/qml/overlays/ChatOverlay.qml +++ b/qml/overlays/ChatOverlay.qml @@ -10,7 +10,7 @@ import "../fonts/Twemoji.js" as T import "../utils.js" as Utils Item { - width: parent.width + width: parent.width property bool loading ListModel { // MESSAGE OBJECTS ARE STORED HERE ... @@ -26,7 +26,7 @@ Item { model: messagesModel spacing: 6 clip: true - ScrollBar.vertical: ScrollBar {} + ScrollBar.vertical: ScrollBar {} maximumFlickVelocity: 1250 delegate: Widgets.Message { @@ -57,7 +57,7 @@ Item { try { msg = JSON.parse(message) } catch (e) { - msg = {"o": 1, "d": "(legacy message type) " + message} + msg = {"o": 1, "d": "(legacy message type) " + message} } if (msg.o != 1) return @@ -90,7 +90,7 @@ Item { try { msg = JSON.parse(message) } catch (e) { - msg = {"o": 1, "d": "(legacy message type) " + message} + msg = {"o": 1, "d": "(legacy message type) " + message} } if (msg.o != 1) return @@ -128,199 +128,199 @@ Item { } } - Widgets.EmojiDrawer { - id: emojiDrawer - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: rowDrawer.top - size: 24 * gcd.themeScale + Widgets.EmojiDrawer { + id: emojiDrawer + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: rowDrawer.top + size: 24 * gcd.themeScale - onPicked: function(shortcode) { - if (!txtMessage.enabled) return - txtMessage.insert(txtMessage.cursorPosition, ":" + shortcode + ":") - } - } + onPicked: function(shortcode) { + if (!txtMessage.enabled) return + txtMessage.insert(txtMessage.cursorPosition, ":" + shortcode + ":") + } + } - RowLayout { // THE BOTTOM DRAWER - id: rowDrawer - anchors.left: parent.left - anchors.bottom: parent.bottom - anchors.right: parent.right + RowLayout { // THE BOTTOM DRAWER + id: rowDrawer + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.right: parent.right - Rectangle { // MESSAGE ENTRY TEXTFIELD - id: rectMessage - Layout.fillWidth: true - Layout.minimumHeight: 40 * gcd.themeScale - Layout.maximumHeight: 40 * gcd.themeScale - color: txtMessage.isEnabled ? "#EDEDED" : "#CCCCCC" - border.color: "#AAAAAA" - radius: 10 + Rectangle { // MESSAGE ENTRY TEXTFIELD + id: rectMessage + Layout.fillWidth: true + Layout.minimumHeight: 40 * gcd.themeScale + Layout.maximumHeight: 40 * gcd.themeScale + color: txtMessage.isEnabled ? "#EDEDED" : "#CCCCCC" + border.color: "#AAAAAA" + radius: 10 - MouseArea { - anchors.fill: parent - onClicked: txtMessage.focus = true - } + MouseArea { + anchors.fill: parent + onClicked: txtMessage.focus = true + } - Flickable { - id: flkMessage - anchors.fill: parent//this does nothing! bug in qt - Layout.minimumWidth: parent.width - Layout.maximumWidth: parent.width - Layout.minimumHeight: rectMessage.height - Layout.maximumHeight: rectMessage.height - contentWidth: txtMessage.width - contentHeight: txtMessage.height - boundsBehavior: Flickable.StopAtBounds - clip:true - maximumFlickVelocity: 300 + Flickable { + id: flkMessage + anchors.fill: parent//this does nothing! bug in qt + Layout.minimumWidth: parent.width + Layout.maximumWidth: parent.width + Layout.minimumHeight: rectMessage.height + Layout.maximumHeight: rectMessage.height + contentWidth: txtMessage.width + contentHeight: txtMessage.height + boundsBehavior: Flickable.StopAtBounds + clip:true + maximumFlickVelocity: 300 - ScrollBar.vertical: ScrollBar{} + ScrollBar.vertical: ScrollBar{} - TextEdit { - id: txtMessage - font.pixelSize: 10 * gcd.themeScale - text: "" - padding: 6 - wrapMode: TextEdit.Wrap - textFormat: Text.RichText - width: rectMessage.width + TextEdit { + id: txtMessage + font.pixelSize: 10 * gcd.themeScale + text: "" + padding: 6 + wrapMode: TextEdit.Wrap + textFormat: Text.RichText + width: rectMessage.width - property bool skipOneUpdate: false - property int previousCursor + property bool skipOneUpdate: false + property int previousCursor - Keys.onReturnPressed: { // CTRL+ENTER = LINEBREAK + Keys.onReturnPressed: { // CTRL+ENTER = LINEBREAK if ((event.modifiers & Qt.ControlModifier) && gcd.os != "android") { - txtMessage.insert(txtMessage.cursorPosition, "
") - } else if (event.modifiers == Qt.NoModifier) { - btnSend.clicked() - } - } + txtMessage.insert(txtMessage.cursorPosition, "
") + } else if (event.modifiers == Qt.NoModifier) { + btnSend.clicked() + } + } - // welcome to the emoji parser! it is horrifying code that needs to leave in - // while also stripping any other tag, including other images. - // TODO: this probably breaks if people actually do want to paste html - onTextChanged: { + // welcome to the emoji parser! it is horrifying code that needs to leave in + // while also stripping any other tag, including other images. + // TODO: this probably breaks if people actually do want to paste html + onTextChanged: { if (gcd.os == "android") { return } - // we're taking advantage of TextEdit.getText()'s parsing capability, which means occasionally - // passing text into it to be filtered. this prevents recursive calls putting us into an - // infinite loop - if (skipOneUpdate) { - skipOneUpdate = false - return - } + // we're taking advantage of TextEdit.getText()'s parsing capability, which means occasionally + // passing text into it to be filtered. this prevents recursive calls putting us into an + // infinite loop + if (skipOneUpdate) { + skipOneUpdate = false + return + } - previousCursor = cursorPosition - //console.log("onTextChanged() at position " + previousCursor) + previousCursor = cursorPosition + //console.log("onTextChanged() at position " + previousCursor) - //console.log("1: " + txtMessage.getText(0, txtMessage.text.length)) + //console.log("1: " + txtMessage.getText(0, txtMessage.text.length)) - // convert tags back to their emoji form - // Then parse out the rest of the HTML - var nt = restoreEmoji(txtMessage.text) - if (nt != txtMessage.text) { - skipOneUpdate = true - txtMessage.text = nt - } + // convert tags back to their emoji form + // Then parse out the rest of the HTML + var nt = restoreEmoji(txtMessage.text) + if (nt != txtMessage.text) { + skipOneUpdate = true + txtMessage.text = nt + } - //console.log("2: " + txtMessage.getText(0, txtMessage.text.length)) - var preserveSpaces = txtMessage.text.replace(/
/g,"[:newline:]"); - if (preserveSpaces != txtMessage.text) { - skipOneUpdate = true - txtMessage.text = preserveSpaces - } - // strip all HTML tags - var theText = Utils.htmlEscaped(txtMessage.getText(0, txtMessage.text.length)) - //console.log("3: " + theText) + //console.log("2: " + txtMessage.getText(0, txtMessage.text.length)) + var preserveSpaces = txtMessage.text.replace(/
/g,"[:newline:]"); + if (preserveSpaces != txtMessage.text) { + skipOneUpdate = true + txtMessage.text = preserveSpaces + } + // strip all HTML tags + var theText = Utils.htmlEscaped(txtMessage.getText(0, txtMessage.text.length)) + //console.log("3: " + theText) - // convert emoji back to tags - nt = parse(theText, 10) - //console.log("4: " + nt) + // convert emoji back to tags + nt = parse(theText, 10) + //console.log("4: " + nt) - // preserve double spacing - nt = nt.replace(/\s\s/g, "  "); - nt = nt.replace(/\[\:newline\:\]/g, "
"); + // preserve double spacing + nt = nt.replace(/\s\s/g, "  "); + nt = nt.replace(/\[\:newline\:\]/g, "
"); - // then we actually put the updated text in - skipOneUpdate = true - txtMessage.text = nt + // then we actually put the updated text in + skipOneUpdate = true + txtMessage.text = nt - txtMessage.cursorPosition = previousCursor + txtMessage.cursorPosition = previousCursor - // autoscroll down only when the scrollbar is already all the way down - if (flkMessage.contentY + flkMessage.height >= flkMessage.contentHeight - txtMessage.height && flkMessage.contentHeight > flkMessage.height) { - flkMessage.contentY = flkMessage.contentHeight - flkMessage.height - } - } - } - } - } + // autoscroll down only when the scrollbar is already all the way down + if (flkMessage.contentY + flkMessage.height >= flkMessage.contentHeight - txtMessage.height && flkMessage.contentHeight > flkMessage.height) { + flkMessage.contentY = flkMessage.contentHeight - flkMessage.height + } + } + } + } + } - ColumnLayout { - id: colRight - spacing: 1 + ColumnLayout { + id: colRight + spacing: 1 - Widgets.Button { // SEND MESSAGE BUTTON - id: btnSend - icon: "regular/paper-plane" - text: "send" - Layout.minimumWidth: btnEmoji.width + btnAttach.width + 2 - Layout.maximumWidth: btnEmoji.width + btnAttach.width + 2 - anchors.right: parent.right - anchors.rightMargin: 2 + Widgets.Button { // SEND MESSAGE BUTTON + id: btnSend + icon: "regular/paper-plane" + text: "send" + Layout.minimumWidth: btnEmoji.width + btnAttach.width + 2 + Layout.maximumWidth: btnEmoji.width + btnAttach.width + 2 + anchors.right: parent.right + anchors.rightMargin: 2 - property int nextMessageID: 1 + property int nextMessageID: 1 - TextEdit { - id: txtHidden - visible: false - textFormat: Text.RichText - } + TextEdit { + id: txtHidden + visible: false + textFormat: Text.RichText + } - onClicked: { - if (txtMessage.text != "") { - txtHidden.text = restoreEmoji(txtMessage.text) - txtHidden.text = txtHidden.text.replace(/
/g,"[:newline:]"); - var txt = txtHidden.text.trim() - if (txt.length > 0) { - var rawText = txtHidden.getText(0, txtHidden.text.length) - var msg = JSON.stringify({"o":1, "d":rawText.replace(/\[\:newline\:\]/g,"\n")}) - gcd.sendMessage(msg, nextMessageID++) - } - } - txtMessage.text = "" - } - } + onClicked: { + if (txtMessage.text != "") { + txtHidden.text = restoreEmoji(txtMessage.text) + txtHidden.text = txtHidden.text.replace(/
/g,"[:newline:]"); + var txt = txtHidden.text.trim() + if (txt.length > 0) { + var rawText = txtHidden.getText(0, txtHidden.text.length) + var msg = JSON.stringify({"o":1, "d":rawText.replace(/\[\:newline\:\]/g,"\n")}) + gcd.sendMessage(msg, nextMessageID++) + } + } + txtMessage.text = "" + } + } - RowLayout { - spacing: 1 + RowLayout { + spacing: 1 - Widgets.Button { // EMOJI DRAWER BUTTON - id: btnEmoji - icon: "regular/smile" - anchors.right: btnAttach.left - anchors.rightMargin: 2 + Widgets.Button { // EMOJI DRAWER BUTTON + id: btnEmoji + icon: "regular/smile" + anchors.right: btnAttach.left + anchors.rightMargin: 2 - onClicked: emojiDrawer.visible ? emojiDrawer.slideclosed() : emojiDrawer.slideopen() - } + onClicked: emojiDrawer.visible ? emojiDrawer.slideclosed() : emojiDrawer.slideopen() + } - Widgets.Button { - id: btnAttach - icon: "solid/paperclip" - anchors.right: parent.right - anchors.rightMargin: 2 + Widgets.Button { + id: btnAttach + icon: "solid/paperclip" + anchors.right: parent.right + anchors.rightMargin: 2 - onClicked: { - gcd.popup("attachments not yet implemented, sorry") - } - } - } - } - } + onClicked: { + gcd.popup("attachments not yet implemented, sorry") + } + } + } + } + } } diff --git a/qml/overlays/ListOverlay.qml b/qml/overlays/ListOverlay.qml index 9e4dabf5..0072ccdc 100644 --- a/qml/overlays/ListOverlay.qml +++ b/qml/overlays/ListOverlay.qml @@ -12,51 +12,51 @@ import "../utils.js" as Utils import "../styles" ColumnLayout { - Layout.fillWidth: true - width:parent.width + Layout.fillWidth: true + width:parent.width - Text { - Layout.fillWidth: true - } + Text { + Layout.fillWidth: true + } - TextField { - id: filter + TextField { + id: filter - placeholderText: "Search.." + placeholderText: "Search.." - style: CwtchTextFieldStyle{} + style: CwtchTextFieldStyle{} - anchors.left: parent.left - anchors.right: parent.right + anchors.left: parent.left + anchors.right: parent.right - anchors.margins: 10 + anchors.margins: 10 - onTextChanged: { - bulletinView.filter = text - if (bulletinView.model.get(bulletinView.currentIndex).title.indexOf(text) == -1) { - bulletinView.currentIndex = -1 - } - } - } + onTextChanged: { + bulletinView.filter = text + if (bulletinView.model.get(bulletinView.currentIndex).title.indexOf(text) == -1) { + bulletinView.currentIndex = -1 + } + } + } - Flickable { // THE MESSAGE LIST ITSELF - id: sv - clip: true - Layout.alignment: Qt.AlignLeft | Qt.AlignTop - Layout.fillHeight: true - Layout.fillWidth: true - contentWidth: parent.width - contentHeight: parent.height - boundsBehavior: Flickable.StopAtBounds - maximumFlickVelocity: 800 + Flickable { // THE MESSAGE LIST ITSELF + id: sv + clip: true + Layout.alignment: Qt.AlignLeft | Qt.AlignTop + Layout.fillHeight: true + Layout.fillWidth: true + contentWidth: parent.width + contentHeight: parent.height + boundsBehavior: Flickable.StopAtBounds + maximumFlickVelocity: 800 - Connections { - target: gcd + Connections { + target: gcd - onClearMessages: function() { - jsonModel4.clear() - } + onClearMessages: function() { + jsonModel4.clear() + } onAppendMessage: function(handle, from, displayName, message, image, mid, fromMe, ts, ack, error) { handler(handle, from, displayName, message, image, mid, fromMe, ts, ack, error) @@ -68,33 +68,33 @@ ColumnLayout { function handler(handle, from, displayName, message, image, mid, fromMe, ts, ack, error) { - var msg - try { - msg = JSON.parse(message) - } catch (e) { - return - } - if (msg.o != 4) return + var msg + try { + msg = JSON.parse(message) + } catch (e) { + return + } + if (msg.o != 4) return - if (msg.t != undefined) { - jsonModel4.insert(0,{ - "title":msg.t, - "selected":false, - "from": from, - "displayName": displayName, - "timestamp": ts, - "complete": false - }) - } + if (msg.t != undefined) { + jsonModel4.insert(0,{ + "title":msg.t, + "selected":false, + "from": from, + "displayName": displayName, + "timestamp": ts, + "complete": false + }) + } - /*if(msg.c != undefined) { - jsonModel4.get(msg.c).complete = true - } + /*if(msg.c != undefined) { + jsonModel4.get(msg.c).complete = true + } - if (sv.contentY + sv.height >= sv.contentHeight - colMessages.height && sv.contentHeight > sv.height) { - sv.contentY = sv.contentHeight - sv.height - }*/ - } + if (sv.contentY + sv.height >= sv.contentHeight - colMessages.height && sv.contentHeight > sv.height) { + sv.contentY = sv.contentHeight - sv.height + }*/ + } onUpdateContactStatus: function(_handle, _status, _loading) { if (gcd.selectedConversation == _handle) { @@ -108,123 +108,123 @@ ColumnLayout { } } - } + } - ScrollBar.vertical: ScrollBar{ - policy: ScrollBar.AlwaysOn - } + ScrollBar.vertical: ScrollBar{ + policy: ScrollBar.AlwaysOn + } - ListView { - id: bulletinView - anchors.left: parent.left - anchors.leftMargin: 10 - anchors.topMargin: 10 + ListView { + id: bulletinView + anchors.left: parent.left + anchors.leftMargin: 10 + anchors.topMargin: 10 - width: parent.width - 50 - height: parent.height - 20 - orientation: Qt.Vertical - spacing: 10 - model: jsonModel4 - property string filter: "" - delegate: + width: parent.width - 50 + height: parent.height - 20 + orientation: Qt.Vertical + spacing: 10 + model: jsonModel4 + property string filter: "" + delegate: - Item { - width: parent.width - height: title.indexOf(bulletinView.filter) >= 0 ? texttitle.height : 0 - visible: title.indexOf(bulletinView.filter) >= 0 + Item { + width: parent.width + height: title.indexOf(bulletinView.filter) >= 0 ? texttitle.height : 0 + visible: title.indexOf(bulletinView.filter) >= 0 - Column { - width: parent.width + Column { + width: parent.width - RowLayout { - CheckBox { - checked: complete - onClicked: { - var msg = JSON.stringify({"o":4, "c":index}) - gcd.sendMessage(msg, btnSend.nextMessageID++) - } - } + RowLayout { + CheckBox { + checked: complete + onClicked: { + var msg = JSON.stringify({"o":4, "c":index}) + gcd.sendMessage(msg, btnSend.nextMessageID++) + } + } - RowLayout { - Text { - id: texttitle - text: '' + Utils.htmlEscaped(title) + ' by ' + from + "
" + timestamp - leftPadding: 10 - topPadding: 5 - bottomPadding:5 - color: windowItem.cwtch_dark_color - } - } - } + RowLayout { + Text { + id: texttitle + text: '' + Utils.htmlEscaped(title) + ' by ' + from + "
" + timestamp + leftPadding: 10 + topPadding: 5 + bottomPadding:5 + color: windowItem.cwtch_dark_color + } + } + } - Rectangle { - height: 1 - color: windowItem.cwtch_color - anchors { - left: parent.left - right: parent.right - } - } + Rectangle { + height: 1 + color: windowItem.cwtch_color + anchors { + left: parent.left + right: parent.right + } + } - } + } - } + } - focus: true - ListModel { - id: jsonModel4 - } - } - } + focus: true + ListModel { + id: jsonModel4 + } + } + } - GroupBox { - //: Add a New List Item - title: qsTr("add-list-item") - Layout.fillWidth: true + GroupBox { + //: Add a New List Item + title: qsTr("add-list-item") + Layout.fillWidth: true - RowLayout { - Layout.fillWidth: true - width: parent.width - ColumnLayout { - Layout.fillWidth: true + RowLayout { + Layout.fillWidth: true + width: parent.width + ColumnLayout { + Layout.fillWidth: true - Text { - //: Add a new item to the list - text: qsTr("add-new-item") - } + Text { + //: Add a new item to the list + text: qsTr("add-new-item") + } - TextField { - id: newposttitle - //: Todo... placeholder text - placeholderText: qsTr("todo-placeholder") - Layout.fillWidth: true - style: CwtchTextFieldStyle{} - } + TextField { + id: newposttitle + //: Todo... placeholder text + placeholderText: qsTr("todo-placeholder") + Layout.fillWidth: true + style: CwtchTextFieldStyle{} + } - Widgets.Button { // SEND MESSAGE BUTTON - id: btnSend - icon: "regular/paper-plane" - text: "add" - anchors.right: parent.right - anchors.rightMargin: 2 + Widgets.Button { // SEND MESSAGE BUTTON + id: btnSend + icon: "regular/paper-plane" + text: "add" + anchors.right: parent.right + anchors.rightMargin: 2 - property int nextMessageID: 1 + property int nextMessageID: 1 - onClicked: { - if (newposttitle.text != "") { - var msg = JSON.stringify({"o":4, "t":newposttitle.text}) - gcd.sendMessage(msg, nextMessageID++) - } - newposttitle.text = "" - } - } - } - } + onClicked: { + if (newposttitle.text != "") { + var msg = JSON.stringify({"o":4, "t":newposttitle.text}) + gcd.sendMessage(msg, nextMessageID++) + } + newposttitle.text = "" + } + } + } + } - } + } diff --git a/qml/overlays/MembershipOverlay.qml b/qml/overlays/MembershipOverlay.qml index 586b2d6f..04a79e7e 100644 --- a/qml/overlays/MembershipOverlay.qml +++ b/qml/overlays/MembershipOverlay.qml @@ -12,45 +12,45 @@ import "../utils.js" as Utils import "../styles" ColumnLayout { - Text { - wrapMode: Text.Wrap - Layout.maximumWidth: parent.width - horizontalAlignment: Text.AlignHCenter - padding: 1 - //: Below is a list of users who have sent messages to the group. This list may not reflect all users who have access to the group. - text: qsTr("membership-description") - } + Text { + wrapMode: Text.Wrap + Layout.maximumWidth: parent.width + horizontalAlignment: Text.AlignHCenter + padding: 1 + //: Below is a list of users who have sent messages to the group. This list may not reflect all users who have access to the group. + text: qsTr("membership-description") + } - Flickable { // THE ACTUAL CONTACT LIST - id: sv - //Layout.alignment: Qt.AlignLeft | Qt.AlignTop - clip: true - Layout.minimumHeight: 100 - //Layout.maximumHeight: parent.height - 30 - Layout.fillHeight: true - Layout.minimumWidth: parent.width - Layout.maximumWidth: parent.width - contentWidth: colContacts.width - contentHeight: colContacts.height - boundsBehavior: Flickable.StopAtBounds - maximumFlickVelocity: 400 + Flickable { // THE ACTUAL CONTACT LIST + id: sv + //Layout.alignment: Qt.AlignLeft | Qt.AlignTop + clip: true + Layout.minimumHeight: 100 + //Layout.maximumHeight: parent.height - 30 + Layout.fillHeight: true + Layout.minimumWidth: parent.width + Layout.maximumWidth: parent.width + contentWidth: colContacts.width + contentHeight: colContacts.height + boundsBehavior: Flickable.StopAtBounds + maximumFlickVelocity: 400 - ScrollBar.vertical: ScrollBar { - policy: ScrollBar.AlwaysOn - } + ScrollBar.vertical: ScrollBar { + policy: ScrollBar.AlwaysOn + } ColumnLayout { - id: colContacts - width: sv.width - spacing: 0 + id: colContacts + width: sv.width + spacing: 0 - Connections { // ADD/REMOVE CONTACT ENTRIES - target: gcd + Connections { // ADD/REMOVE CONTACT ENTRIES + target: gcd - onClearMessages: function() { - contactsModel.clear() - } + onClearMessages: function() { + contactsModel.clear() + } onAppendMessage: function(handle, from, displayName, message, image, mid, fromMe, ts, ack, error) { handler(handle, from, displayName, message, image, mid, fromMe, ts, ack, error) @@ -63,51 +63,51 @@ ColumnLayout { function handler(handle, from, displayName, message, image, mid, fromMe, ts, ack, error) { var msg - try { - msg = JSON.parse(message) - } catch (e) { - return - } + try { + msg = JSON.parse(message) + } catch (e) { + return + } - if (from == "me") { - return - } + if (from == "me") { + return + } - for(var i = 0; i 12 ? displayName.substr(0,12) + "..." : displayName - visible: !fromMe - ToolTip.text: from - ToolTip.visible: ma2.containsMouse - ToolTip.delay: 200 + Label { // DISPLAY NAME FOR GROUPS + color: "#FFFFFF" + font.pixelSize: 10 * gcd.themeScale + anchors.right: parent.right + text: displayName.length > 12 ? displayName.substr(0,12) + "..." : displayName + visible: !fromMe + ToolTip.text: from + ToolTip.visible: ma2.containsMouse + ToolTip.delay: 200 - MouseArea { - id: ma2 - anchors.fill: parent - hoverEnabled: true - } - } + MouseArea { + id: ma2 + anchors.fill: parent + hoverEnabled: true + } + } - Image { // ACKNOWLEDGEMENT ICON - id: ack - anchors.right: parent.right - source: root.error != "" ? gcd.assetPath + "fontawesome/regular/window-close.svg" : (root.ackd ? gcd.assetPath + "fontawesome/regular/check-circle.svg" : gcd.assetPath + "fontawesome/regular/hourglass.svg") - height: 10 * gcd.themeScale - sourceSize.height: 10 * gcd.themeScale - visible: fromMe - ToolTip.visible: ma.containsMouse - ToolTip.delay: 200 - //: Could not send this message - ToolTip.text: root.error != "" ? qsTr("could-not-send-msg-error") + ":" + root.error : (root.ackd ? qsTr("acknowledged-label") : qsTr("pending-label")) + Image { // ACKNOWLEDGEMENT ICON + id: ack + anchors.right: parent.right + source: root.error != "" ? gcd.assetPath + "fontawesome/regular/window-close.svg" : (root.ackd ? gcd.assetPath + "fontawesome/regular/check-circle.svg" : gcd.assetPath + "fontawesome/regular/hourglass.svg") + height: 10 * gcd.themeScale + sourceSize.height: 10 * gcd.themeScale + visible: fromMe + ToolTip.visible: ma.containsMouse + ToolTip.delay: 200 + //: Could not send this message + ToolTip.text: root.error != "" ? qsTr("could-not-send-msg-error") + ":" + root.error : (root.ackd ? qsTr("acknowledged-label") : qsTr("pending-label")) - MouseArea { - id: ma - anchors.fill: parent - hoverEnabled: true - } - } - } - } + MouseArea { + id: ma + anchors.fill: parent + hoverEnabled: true + } + } + } + } TextEdit { id: copyhelper @@ -188,5 +188,5 @@ Item { gcd.popup("message copied") } } - } -} \ No newline at end of file + } +} diff --git a/qml/widgets/MyProfile.qml b/qml/widgets/MyProfile.qml index bbfb44fc..364455e3 100644 --- a/qml/widgets/MyProfile.qml +++ b/qml/widgets/MyProfile.qml @@ -12,22 +12,22 @@ import "../styles" import "../theme" Item { - id: root - anchors.fill: parent - width: parent.width + id: root + anchors.fill: parent + width: parent.width - height: profile.height + searchAddText.height + 10 + height: profile.height + searchAddText.height + 10 implicitHeight: profile.height + searchAddText.height + 10 - property string image - property string nick - property string onion - property string tag - property bool dualPane: false + property string image + property string nick + property string onion + property string tag + property bool dualPane: false property real logscale: 4 * Math.log10(gcd.themeScale + 1) - onDualPaneChanged: { realignProfile() } +onDualPaneChanged: { realignProfile() } function realignProfile() { if (dualPane) { @@ -63,7 +63,7 @@ Item { } } - Component.onCompleted: { realignProfile() } +Component.onCompleted: { realignProfile() } @@ -85,10 +85,10 @@ Item { portraitColor: Theme.portraitOnlineBackgroundColor badgeContent: Image {// Profle Type - id: profiletype - source: tag == "v1-userPassword" ? gcd.assetPath + "/fontawesome/solid/lock.svg" : gcd.assetPath + "/fontawesome/solid/lock-open.svg" - height: Theme.badgeTextSize * gcd.themeScale - width: height + id: profiletype + source: tag == "v1-userPassword" ? gcd.assetPath + "/fontawesome/solid/lock.svg" : gcd.assetPath + "/fontawesome/solid/lock-open.svg" + height: Theme.badgeTextSize * gcd.themeScale + width: height } } @@ -124,34 +124,34 @@ Item { onClicked: { } - } + } } } - // TODO Remove for new global topbar - Widgets.Button {// BACK BUTTON - id: btnBack - icon: "solid/arrow-circle-left" - anchors.left: parent.left - anchors.leftMargin: 2 - anchors.top: parent.top - anchors.topMargin: 2 - onClicked: function() { - gcd.selectedProfile = "none" - gcd.reloadProfileList() - parentStack.pane = parentStack.managementPane - theStack.pane = theStack.emptyPane - } - } + // TODO Remove for new global topbar + Widgets.Button {// BACK BUTTON + id: btnBack + icon: "solid/arrow-circle-left" + anchors.left: parent.left + anchors.leftMargin: 2 + anchors.top: parent.top + anchors.topMargin: 2 + onClicked: function() { + gcd.selectedProfile = "none" + gcd.reloadProfileList() + parentStack.pane = parentStack.managementPane + theStack.pane = theStack.emptyPane + } + } - TextField { + TextField { id: searchAddText anchors.top: profile.bottom anchors.horizontalCenter: parent.horizontalCenter - style: CwtchTextFieldStyle{ } + style: CwtchTextFieldStyle{ } width: parent.width - 30 //: ex: "... paste an address here to add a contact ..." placeholderText: qsTr("paste-address-to-add-contact") @@ -165,19 +165,19 @@ Item { } } - Connections { - target: gcd + Connections { + target: gcd - onUpdateMyProfile: function(_nick, _onion, _image, _tag) { - nick = _nick - onion = _onion - image = _image - tag = _tag - } + onUpdateMyProfile: function(_nick, _onion, _image, _tag) { + nick = _nick + onion = _onion + image = _image + tag = _tag + } - /*onTorStatus: function(code, str) { - rectTorStatus.code = code - rectTorStatus.message = str - }*/ - } + /*onTorStatus: function(code, str) { + rectTorStatus.code = code + rectTorStatus.message = str + }*/ + } } diff --git a/qml/widgets/Portrait.qml b/qml/widgets/Portrait.qml index ce9526cb..41728cd8 100644 --- a/qml/widgets/Portrait.qml +++ b/qml/widgets/Portrait.qml @@ -7,16 +7,16 @@ import CustomQmlTypes 1.0 import "../theme" Item { - id: imgProfile - implicitWidth: baseWidth - implicitHeight: baseWidth + id: imgProfile + implicitWidth: baseWidth + implicitHeight: baseWidth - property string source - property alias badgeColor: badge.color + property string source + property alias badgeColor: badge.color - property real logscale: 4 * Math.log10(gcd.themeScale + 1) - property int baseWidth: 78 * logscale - height: 78 * logscale + property real logscale: 4 * Math.log10(gcd.themeScale + 1) + property int baseWidth: 78 * logscale + height: 78 * logscale property alias portraitBorderColor: mainImage.color property alias portraitColor: imageInner.color @@ -24,48 +24,48 @@ Item { property alias badgeContent: badge.content - Rectangle { - id: mainImage - //anchors.leftMargin: baseWidth * 0.1 - anchors.horizontalCenter: parent.horizontalCenter - width: baseWidth * 0.8 - height: width + Rectangle { + id: mainImage + //anchors.leftMargin: baseWidth * 0.1 + anchors.horizontalCenter: parent.horizontalCenter + width: baseWidth * 0.8 + height: width anchors.verticalCenter: parent.verticalCenter - color: Theme.portraitOfflineBorderColor - radius: width / 2 + color: Theme.portraitOfflineBorderColor + radius: width / 2 - Rectangle { - id: imageInner - width: parent.width - 4 - height: width - color: Theme.portraitOfflineBorderColor - radius: width / 2 - anchors.centerIn:parent + Rectangle { + id: imageInner + width: parent.width - 4 + height: width + color: Theme.portraitOfflineBorderColor + radius: width / 2 + anchors.centerIn:parent - Image { // PROFILE IMAGE - id: img - source: gcd.assetPath + imgProfile.source - anchors.fill: parent - fillMode: Image.PreserveAspectFit - visible: false - } + Image { // PROFILE IMAGE + id: img + source: gcd.assetPath + imgProfile.source + anchors.fill: parent + fillMode: Image.PreserveAspectFit + visible: false + } - Image { // CIRCLE MASK - id: mask - fillMode: Image.PreserveAspectFit - visible: false - source: "qrc:/qml/images/extra/clipcircle.png" - } + Image { // CIRCLE MASK + id: mask + fillMode: Image.PreserveAspectFit + visible: false + source: "qrc:/qml/images/extra/clipcircle.png" + } - OpacityMask { - anchors.fill: img - source: img - maskSource: mask - } - } - } + OpacityMask { + anchors.fill: img + source: img + maskSource: mask + } + } + } - Badge { + Badge { id: badge } -} \ No newline at end of file +} diff --git a/qml/widgets/PortraitRow.qml b/qml/widgets/PortraitRow.qml index 953edfc8..2895a8ef 100644 --- a/qml/widgets/PortraitRow.qml +++ b/qml/widgets/PortraitRow.qml @@ -12,21 +12,21 @@ import QtQuick.Controls.Styles 1.4 Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY id: crItem - anchors.left: parent.left - anchors.right: parent.right - height: 78 * logscale + 3 - implicitHeight: 78 * logscale + 3 //height + anchors.left: parent.left + anchors.right: parent.right + height: 78 * logscale + 3 + implicitHeight: 78 * logscale + 3 //height - property real logscale: 4 * Math.log10(gcd.themeScale + 1) - property string displayName - property alias image: portrait.source - property string handle - property bool isActive - property bool isHover - property string tag // profile version/type + property real logscale: 4 * Math.log10(gcd.themeScale + 1) + property string displayName + property alias image: portrait.source + property string handle + property bool isActive + property bool isHover + property string tag // profile version/type - property alias badgeColor: portrait.badgeColor - property alias portraitBorderColor: portrait.portraitBorderColor + property alias badgeColor: portrait.badgeColor + property alias portraitBorderColor: portrait.portraitBorderColor property alias portraitColor: portrait.portraitColor property alias nameColor: cn.color property alias onionColor: onion.color @@ -38,22 +38,22 @@ Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY property alias content: extraMeta.children // TODO: should be in ContactRow - property bool blocked + property bool blocked signal clicked(string handle) - Rectangle { // CONTACT ENTRY BACKGROUND COLOR - id: crRect - anchors.left: parent.left - anchors.right: parent.right - height: crItem.height - width: parent.width - color: isHover ? Theme.backgroundPaneColor : (isActive ? Theme.backgroundPaneColor : Theme.backgroundMainColor) + Rectangle { // CONTACT ENTRY BACKGROUND COLOR + id: crRect + anchors.left: parent.left + anchors.right: parent.right + height: crItem.height + width: parent.width + color: isHover ? Theme.backgroundPaneColor : (isActive ? Theme.backgroundPaneColor : Theme.backgroundMainColor) Portrait { id: portrait anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left + anchors.left: parent.left anchors.leftMargin: 25 * logscale } @@ -83,10 +83,10 @@ Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY strikeout: blocked } - onWidthChanged: { - cn.setTextResize() - onion.setTextResize() - } + onWidthChanged: { + cn.setTextResize() + onion.setTextResize() + } } @@ -95,40 +95,40 @@ Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY anchors.left: portraitMeta.right anchors.verticalCenter: parent.verticalCenter } - } + } - MouseArea { // Full row mouse area triggering onClick - id: buttonMA - anchors.fill: parent - hoverEnabled: true + MouseArea { // Full row mouse area triggering onClick + id: buttonMA + anchors.fill: parent + hoverEnabled: true - onClicked: { crItem.clicked(crItem.handle) } + onClicked: { crItem.clicked(crItem.handle) } - onEntered: { - isHover = true - } + onEntered: { + isHover = true + } - onExited: { - isHover = false - } - } + onExited: { + isHover = false + } + } - Connections { // UPDATE UNREAD MESSAGES COUNTER - target: gcd + Connections { // UPDATE UNREAD MESSAGES COUNTER + target: gcd - onResetMessagePane: function() { - isActive = false - } + onResetMessagePane: function() { + isActive = false + } onUpdateContactBlocked: function(_handle, _blocked) { if (handle == _handle) { - blocked = _blocked + blocked = _blocked } } onUpdateContactDisplayName: function(_handle, _displayName) { if (handle == _handle) { - displayName = _displayName + (blocked == true ? " (blocked)" : "") + displayName = _displayName + (blocked == true ? " (blocked)" : "") } } @@ -137,5 +137,5 @@ Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY image = _image } } - } + } } diff --git a/qml/widgets/ProfileList.qml b/qml/widgets/ProfileList.qml index 512ab35f..5de3472d 100644 --- a/qml/widgets/ProfileList.qml +++ b/qml/widgets/ProfileList.qml @@ -6,7 +6,7 @@ import QtQuick.Layouts 1.3 import "../theme" ColumnLayout { - id: root + id: root MouseArea { anchors.fill: parent @@ -16,30 +16,30 @@ ColumnLayout { } } - Flickable { // Profile List - id: sv - clip: true - Layout.minimumHeight: 100 - Layout.fillHeight: true - Layout.minimumWidth: parent.width - Layout.maximumWidth: parent.width - contentWidth: colContacts.width - contentHeight: colContacts.height - boundsBehavior: Flickable.StopAtBounds - maximumFlickVelocity: 400 + Flickable { // Profile List + id: sv + clip: true + Layout.minimumHeight: 100 + Layout.fillHeight: true + Layout.minimumWidth: parent.width + Layout.maximumWidth: parent.width + contentWidth: colContacts.width + contentHeight: colContacts.height + boundsBehavior: Flickable.StopAtBounds + maximumFlickVelocity: 400 - ScrollBar.vertical: ScrollBar { - policy: ScrollBar.AlwaysOn - } + ScrollBar.vertical: ScrollBar { + policy: ScrollBar.AlwaysOn + } ColumnLayout { - id: colContacts - width: root.width - spacing: 0 + id: colContacts + width: root.width + spacing: 0 - Connections { // ADD/REMOVE CONTACT ENTRIES - target: gcd + Connections { // ADD/REMOVE CONTACT ENTRIES + target: gcd onAddProfile: function(handle, displayName, image, tag) { @@ -59,50 +59,50 @@ ColumnLayout { } } - profilesModel.insert(index, - { - _handle: handle, - _displayName: displayName, - _image: image, - _tag: tag, - _status: 4, - }) - } + profilesModel.insert(index, + { + _handle: handle, + _displayName: displayName, + _image: image, + _tag: tag, + _status: 4, + }) + } /* - onRemoveProfile: function(handle) { - for(var i = 0; i < profilesModel.count; i++){ - if(profilesModel.get(i)["_handle"] == handle) { - console.log("deleting contact " + profilesModel.get(i)["_handle"]) - profilesModel.remove(i) - return - } - } - }*/ + onRemoveProfile: function(handle) { + for(var i = 0; i < profilesModel.count; i++){ + if(profilesModel.get(i)["_handle"] == handle) { + console.log("deleting contact " + profilesModel.get(i)["_handle"]) + profilesModel.remove(i) + return + } + } + }*/ - onResetProfileList: function() { - profilesModel.clear() - } - } + onResetProfileList: function() { + profilesModel.clear() + } + } - ListModel { // Profile OBJECTS ARE STORED HERE ... - id: profilesModel - } + ListModel { // Profile OBJECTS ARE STORED HERE ... + id: profilesModel + } - Repeater { - id: profileList - model: profilesModel // ... AND DISPLAYED HERE - delegate: ProfileRow { - handle: _handle - displayName: _displayName - image: _image - blocked: false + Repeater { + id: profileList + model: profilesModel // ... AND DISPLAYED HERE + delegate: ProfileRow { + handle: _handle + displayName: _displayName + image: _image + blocked: false tag: _tag - } - } + } + } - PortraitRow { - handle: "" + PortraitRow { + handle: "" displayName: qsTr("add-new-profile-btn") image: "/fontawesome/regular/user.svg" tag: "" @@ -110,13 +110,13 @@ ColumnLayout { portraitColor: Theme.defaultButtonColor badgeVisible: true badgeContent: Image { - source: gcd.assetPath + "/fontawesome/solid/plus.svg" - height: Theme.badgeTextSize * gcd.themeScale - width: height + source: gcd.assetPath + "/fontawesome/solid/plus.svg" + height: Theme.badgeTextSize * gcd.themeScale + width: height } badgeColor: Theme.portraitOnlineBorderColor - onClicked: function(handle) { profileAddEditPane.reset(); parentStack.pane = parentStack.addEditProfilePane } - } + onClicked: function(handle) { profileAddEditPane.reset(); parentStack.pane = parentStack.addEditProfilePane } + } } - } + } } diff --git a/qml/widgets/ProfileRow.qml b/qml/widgets/ProfileRow.qml index 6a48be9b..c70ee2d5 100644 --- a/qml/widgets/ProfileRow.qml +++ b/qml/widgets/ProfileRow.qml @@ -20,31 +20,31 @@ PortraitRow { onionColor: Theme.portraitOnlineTextColor badgeContent: Image {// Profle Type - id: profiletype - source: tag == "v1-userPassword" ? gcd.assetPath + "/fontawesome/solid/lock.svg" : gcd.assetPath + "/fontawesome/solid/lock-open.svg" - height: Theme.badgeTextSize * gcd.themeScale - width: height + id: profiletype + source: tag == "v1-userPassword" ? gcd.assetPath + "/fontawesome/solid/lock.svg" : gcd.assetPath + "/fontawesome/solid/lock-open.svg" + height: Theme.badgeTextSize * gcd.themeScale + width: height } Widgets.Button {// Edit BUTTON - id: btnEdit - icon: "solid/user-edit" + id: btnEdit + icon: "solid/user-edit" - anchors.right: parent.right + anchors.right: parent.right - //rectUnread.left - anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: 1 * gcd.themeScale - anchors.rightMargin: 20 * gcd.themeScale - height: parent.height * 0.75 + //rectUnread.left + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: 1 * gcd.themeScale + anchors.rightMargin: 20 * gcd.themeScale + height: parent.height * 0.75 - onClicked: { - profileAddEditPane.load(handle, displayName, tag) - parentStack.pane = parentStack.addEditProfilePane - } + onClicked: { + profileAddEditPane.load(handle, displayName, tag) + parentStack.pane = parentStack.addEditProfilePane } + } onClicked: function openClick(handle) { gcd.broadcast("ResetMessagePane"); @@ -53,4 +53,4 @@ PortraitRow { gcd.loadProfile(handle) parentStack.pane = parentStack.profilePane } -} \ No newline at end of file +} diff --git a/qml/widgets/RadioButton.qml b/qml/widgets/RadioButton.qml index 187822e6..5ce7b21a 100644 --- a/qml/widgets/RadioButton.qml +++ b/qml/widgets/RadioButton.qml @@ -6,22 +6,22 @@ import QtQuick.Controls 2.13 RadioButton { id: control - property real size: 12 - spacing: 0 + property real size: 12 + spacing: 0 - indicator: Rectangle { - width: 16 * gcd.themeScale - height: 16 * gcd.themeScale - anchors.verticalCenter: parent.verticalCenter - radius: 9 - border.width: 1 + indicator: Rectangle { + width: 16 * gcd.themeScale + height: 16 * gcd.themeScale + anchors.verticalCenter: parent.verticalCenter + radius: 9 + border.width: 1 - Rectangle { - anchors.fill: parent - visible: control.checked - color: "black" - radius: 9 - anchors.margins: 4 - } - } -} \ No newline at end of file + Rectangle { + anchors.fill: parent + visible: control.checked + color: "black" + radius: 9 + anchors.margins: 4 + } + } +} diff --git a/qml/widgets/ScalingLabel.qml b/qml/widgets/ScalingLabel.qml index cfa6ff20..e0471fd0 100644 --- a/qml/widgets/ScalingLabel.qml +++ b/qml/widgets/ScalingLabel.qml @@ -7,9 +7,9 @@ import QtQuick.Window 2.11 Label { - font.pixelSize: gcd.themeScale * size - wrapMode: Text.WordWrap - color: "#000000" - textFormat: Text.PlainText - property real size: 12 -} \ No newline at end of file + font.pixelSize: gcd.themeScale * size + wrapMode: Text.WordWrap + color: "#000000" + textFormat: Text.PlainText + property real size: 12 +} diff --git a/qml/widgets/StackToolbar.qml b/qml/widgets/StackToolbar.qml index 82d063c8..fb2cd8ba 100644 --- a/qml/widgets/StackToolbar.qml +++ b/qml/widgets/StackToolbar.qml @@ -8,62 +8,62 @@ import "../fonts/Twemoji.js" as T import "." as Widgets Rectangle { // OVERHEAD BAR ON STACK PANE - id: toolbar - anchors.left: parent.left - anchors.right: parent.right - anchors.top: parent.top - height: 20 * gcd.themeScale + 4 - Layout.minimumHeight: height - Layout.maximumHeight: height - color: "#EDEDED" + id: toolbar + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + height: 20 * gcd.themeScale + 4 + Layout.minimumHeight: height + Layout.maximumHeight: height + color: "#EDEDED" - property alias text: lbl.text - property alias aux: btnAux - property alias back: btnBack - property alias membership: btnMembership - property string stack: "profile" // profile(theStack) or management(parentStack) + property alias text: lbl.text + property alias aux: btnAux + property alias back: btnBack + property alias membership: btnMembership + property string stack: "profile" // profile(theStack) or management(parentStack) - Widgets.Button {// BACK BUTTON - id: btnBack - icon: "solid/arrow-circle-left" - anchors.left: parent.left - anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: 6 - onClicked: { - if (stack == "profile") { - theStack.pane = theStack.emptyPane - } else { - parentStack.pane = parentStack.managementPane - } - } - } + Widgets.Button {// BACK BUTTON + id: btnBack + icon: "solid/arrow-circle-left" + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: 6 + onClicked: { + if (stack == "profile") { + theStack.pane = theStack.emptyPane + } else { + parentStack.pane = parentStack.managementPane + } + } + } - ScalingLabel { // TEXT - id: lbl - text: "open privacy exec" + ScalingLabel { // TEXT + id: lbl + text: "open privacy exec" font.family: Fonts.applicationFontRegular.name font.styleName: "ExtraBold" - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - } + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + } - RowLayout { + RowLayout { - anchors.right: parent.right - anchors.rightMargin: 6 - anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: 6 + anchors.verticalCenter: parent.verticalCenter - Widgets.Button { // Membership Button - id: btnMembership - icon: "solid/users" + Widgets.Button { // Membership Button + id: btnMembership + icon: "solid/users" //: View Group Membership tooltip: qsTr("view-group-membership-tooltip") - } + } - Widgets.Button { // COG BUTTON - id: btnAux - icon: "solid/cog" - } - } + Widgets.Button { // COG BUTTON + id: btnAux + icon: "solid/cog" + } + } } diff --git a/qml/widgets/TextField.qml b/qml/widgets/TextField.qml index 6486f9d0..333f3bb3 100644 --- a/qml/widgets/TextField.qml +++ b/qml/widgets/TextField.qml @@ -13,4 +13,4 @@ TextField { color: windowItem.cwtch_background_color border.color: windowItem.cwtch_color } -} \ No newline at end of file +} diff --git a/qml/widgets/controls/FlagButton.qml b/qml/widgets/controls/FlagButton.qml index 858c7c5a..760ed21c 100644 --- a/qml/widgets/controls/FlagButton.qml +++ b/qml/widgets/controls/FlagButton.qml @@ -33,11 +33,11 @@ Rectangle { } } - Connections { - target: gcd + Connections { + target: gcd - onSupplySettings: function(zoom, newLocale) { - selected = newLocale == locale - } - } -} \ No newline at end of file + onSupplySettings: function(zoom, newLocale) { + selected = newLocale == locale + } + } +} diff --git a/qml/widgets/controls/ImageButton.qml b/qml/widgets/controls/ImageButton.qml index a3928ae5..b7665c0a 100644 --- a/qml/widgets/controls/ImageButton.qml +++ b/qml/widgets/controls/ImageButton.qml @@ -3,31 +3,31 @@ import QtQuick.Controls 2.4 import QtQuick.Controls.Material 2.0 import QtQuick.Layouts 1.3 Item { - id: root - property alias source: img.source - property int size: 24 - property string tooltip: "" - width: size - height: size - signal clicked() + id: root + property alias source: img.source + property int size: 24 + property string tooltip: "" + width: size + height: size + signal clicked() - ToolTip.visible: tooltip != "" && ma.containsMouse - ToolTip.text: tooltip + ToolTip.visible: tooltip != "" && ma.containsMouse + ToolTip.text: tooltip - Image { - id: img - width: root.size * (ma.pressed ? 0.5 : 0.8) - height: root.size * (ma.pressed ? 0.5 : 0.8) - anchors.topMargin: ma.pressed ? 2 : 0 - anchors.leftMargin: anchors.topMargin - anchors.centerIn: parent - } + Image { + id: img + width: root.size * (ma.pressed ? 0.5 : 0.8) + height: root.size * (ma.pressed ? 0.5 : 0.8) + anchors.topMargin: ma.pressed ? 2 : 0 + anchors.leftMargin: anchors.topMargin + anchors.centerIn: parent + } - MouseArea { - id: ma - anchors.fill: root + MouseArea { + id: ma + anchors.fill: root - onClicked: root.clicked() - hoverEnabled: tooltip != "" - } -} \ No newline at end of file + onClicked: root.clicked() + hoverEnabled: tooltip != "" + } +} diff --git a/quality.sh b/quality.sh new file mode 100755 index 00000000..f6fad191 --- /dev/null +++ b/quality.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# go get cwtch.im/ui/cmd/qmlfmt + +cd qml +find -iname "*.qml" | xargs qmlfmt + +cd ..