diff --git a/gcd.go b/gcd.go index f61dfe6..d17b8a3 100644 --- a/gcd.go +++ b/gcd.go @@ -15,7 +15,8 @@ var TIME_FORMAT = "Mon 3:04pm" type GrandCentralDispatcher struct { core.QObject - currentOpenConversation string + currentOpenConversation string `property:"currentOpenConversation"` + themeScale float32 `property:"themeScale"` // messages pane stuff _ func(from, message, displayname string, mID uint, ts, source string) `signal:"AppendMessage"` @@ -133,6 +134,11 @@ func (this *GrandCentralDispatcher) broadcast(signal string) { } func (this *GrandCentralDispatcher) importString(str string) { + if len(str) < 5 { + log.Printf("ignoring short string") + return + } + log.Printf("importing: %s\n", str) onion := str name := onion diff --git a/main.go b/main.go index aaa27ba..3317cf2 100644 --- a/main.go +++ b/main.go @@ -22,7 +22,7 @@ import ( "log" "cwtch.im/cwtch/model" "encoding/hex" -) + ) var gcd *GrandCentralDispatcher @@ -242,7 +242,7 @@ func andHisBlackAndWhiteCat(incomingMessages chan Message) { } func initialize(view *quick.QQuickView) { - log.Printf(os.Args[0]) + var err error //TODO: this section is ported over and has a lot of printf errors, need to show them in the ui var dirname, filename string if os.Getenv("CWTCH_FOLDER") != "" { @@ -258,8 +258,13 @@ func initialize(view *quick.QQuickView) { filename = path.Join(dirname, "keep-this-file-private") } + /*_, err := app2.NewApp(dirname, "/data/data/org.qtproject.example.go/lib/libtor.so") + if err != nil { + log.Printf("ERROR CREATING CWTCH APP: %v", err) + } + time.Sleep(time.Second * 10) + */ os.MkdirAll(dirname, 0700) - var err error peer, err = libpeer.LoadCwtchPeer(filename, "be gay do crime") if err != nil { fmt.Println("couldn't load your config file, attempting to create a new one now") diff --git a/qml/main.qml b/qml/main.qml index 3925599..fe78b5b 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -3,6 +3,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.4 import QtQuick.Controls.Material 2.0 import QtQuick.Layouts 1.3 +import QtQuick.Window 2.11 import "fonts/Twemoji.js" as T import "widgets" @@ -42,6 +43,10 @@ Item { return newtext } + function scale() { + return 0.1 + 2 * zoomSlider.value + } + /* Rectangle { // THE TOOLBAR id: toolbar @@ -145,7 +150,37 @@ Item { aux.visible: false } - Label { text: "welcome to the global app settings page!" } + ScalingLabel { + Layout.maximumWidth: parent.width + text: "welcome to the global app settings page!" + } + + Slider { + id: zoomSlider + from: 0.5 + to: 1.6 + } + + ScalingLabel { + text: "Large text" + size: 20 + } + + ScalingLabel{ + text: "Default size text, scale factor: " + zoomSlider.value + } + + ScalingLabel { + text: "Small text" + size: 8 + } + + + Component.onCompleted: { + zoomSlider.value = Screen.pixelDensity / 3.2 // artistic license. set by erinn. fight me before changing + if (zoomSlider.value < zoomSlider.from) zoomSlider.value = zoomSlider.from + if (zoomSlider.value > zoomSlider.to) zoomSlider.value = zoomSlider.to + } } ColumnLayout { // userProfilePane diff --git a/qml/widgets/IconButton.qml b/qml/widgets/IconButton.qml deleted file mode 100644 index 1f9cd38..0000000 --- a/qml/widgets/IconButton.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtGraphicalEffects 1.0 -import QtQuick 2.7 -import QtQuick.Controls 2.4 -import QtQuick.Controls.Material 2.0 -import QtQuick.Layouts 1.3 - -SimpleButton { - id: root - font: "FontAwesome" - text: icon + (label == "" ? "" : " " + label) - - property string icon - property string label -} \ No newline at end of file diff --git a/qml/widgets/Message.qml b/qml/widgets/Message.qml index d954c18..d7f8de2 100644 --- a/qml/widgets/Message.qml +++ b/qml/widgets/Message.qml @@ -41,8 +41,12 @@ RowLayout { Rectangle { // THIS IS JUST A PRETTY MESSAGE-HOLDING RECTANGLE id: rectMessageBubble - height: lbl.height + ts.height + 4 + height: lbl.height + ts.height + 8 + Layout.minimumHeight: height + Layout.maximumHeight: height width: colMessageBubble.width + 6 + Layout.minimumWidth: width + Layout.maximumWidth: width color: from == "me" ? "#B09CBC" : "#4B3557" radius: 5 @@ -99,15 +103,13 @@ RowLayout { leftPadding: 10 } - Label { text: dummy.width+", "+root.width } - Label { // MESSAGE ACKNOWLEDGMENT id: ack color: "#FFFFFF" font.pixelSize: 10 anchors.right: parent.right font.family: "FontAwesome" - text: from == "me" ? awesome.icons.fa_ellipsis_h : displayname + text: from == "me" ? (awesome.loaded ? awesome.icons.fa_ellipsis_h : "") : displayname } } } diff --git a/qml/widgets/MessageList.qml b/qml/widgets/MessageList.qml index 0925827..779435b 100644 --- a/qml/widgets/MessageList.qml +++ b/qml/widgets/MessageList.qml @@ -87,8 +87,9 @@ ColumnLayout { RowLayout { // THE BOTTOM DRAWER Rectangle { // MESSAGE ENTRY TEXTFIELD id: rectMessage - Layout.fillWidth: true - height: 40 + Layout.fillWidth: 40 * zoomSlider.value + Layout.minimumHeight: 40 * zoomSlider.value + //height: 40 * zoomSlider.value color: "#EDEDED" border.color: "#AAAAAA" radius: 10 @@ -194,14 +195,17 @@ ColumnLayout { } ColumnLayout { + id: colRight spacing: 1 - IconButton { // SEND MESSAGE BUTTON + SimpleButton { // SEND MESSAGE BUTTON id: btnSend - icon: awesome.icons.fa_paper_plane - label: "send" - width: btnEmoji.width + btnAttach.width + 1 + icon: "regular/paper-plane" + text: "send" + Layout.minimumWidth: btnEmoji.width + btnAttach.width + 1 + Layout.maximumWidth: btnEmoji.width + btnAttach.width + 1 + property int nextMessageID: 1 TextEdit { @@ -225,17 +229,18 @@ ColumnLayout { SimpleButton { // EMOJI DRAWER BUTTON id: btnEmoji - text: awesome.icons.fa_smile_o - font: "FontAwesome" + icon: "regular/smile" onClicked: gcd.popup("emoji not yet implemented, sorry") } - IconButton { + SimpleButton { id: btnAttach - icon: awesome.icons.fa_paperclip + icon: "solid/paperclip" - onClicked: gcd.popup("attachments not yet implemented, sorry") + onClicked: { + gcd.popup("attachments not yet implemented, sorry") + } } } } diff --git a/qml/widgets/MyProfile.qml b/qml/widgets/MyProfile.qml index 2e74c04..3481110 100644 --- a/qml/widgets/MyProfile.qml +++ b/qml/widgets/MyProfile.qml @@ -4,6 +4,7 @@ import QtQuick.Controls 2.4 import QtQuick.Controls.Material 2.0 import QtQuick.Controls.Styles 1.4 import QtQuick.Layouts 1.3 +import QtQuick.Window 2.11 ColumnLayout { id: root @@ -146,8 +147,9 @@ ColumnLayout { text: "This is your address. You can give it out to people!\n" + onion } - RowLayout { // TOOLS FOR EDITING PROFILE + Row { // TOOLS FOR EDITING PROFILE anchors.horizontalCenter: parent.horizontalCenter + spacing: zoomSlider.value * 2 TextEdit { // USED TO POWER THE COPY/PASTE BUTTON @@ -155,9 +157,9 @@ ColumnLayout { visible: false } - IconButton { // COPY ONION ADDRESS BUTTON - icon: awesome.icons.fa_clipboard - label: "copy" + SimpleButton { // COPY ONION ADDRESS BUTTON + icon: "regular/clipboard" + text: "copy" onClicked: { gcd.popup("copied to clipboard!") @@ -167,16 +169,14 @@ ColumnLayout { } } - IconButton { // SETTINGS BUTTON - icon: awesome.icons.fa_cog - //label: "settings" + SimpleButton { // SETTINGS BUTTON + icon: "solid/cog" onClicked: theStack.pane = theStack.settingsPane } - IconButton { // SIGN OUT BUTTON - icon: awesome.icons.fa_sign_out - //label: "sign out" + SimpleButton { // SIGN OUT BUTTON + icon: "solid/sign-out-alt" onClicked: { gcd.popup("not yet implemented, sorry :(") @@ -207,6 +207,7 @@ ColumnLayout { color: "#888888" padding: 2 text: hint + selectByMouse: true onTextChanged: { if (text != hint && text != "") { diff --git a/qml/widgets/MyProfile.qmlc b/qml/widgets/MyProfile.qmlc index da21d08..4bb0b48 100644 Binary files a/qml/widgets/MyProfile.qmlc and b/qml/widgets/MyProfile.qmlc differ diff --git a/qml/widgets/SimpleButton.qml b/qml/widgets/SimpleButton.qml index aea7892..bb43ae2 100644 --- a/qml/widgets/SimpleButton.qml +++ b/qml/widgets/SimpleButton.qml @@ -1,36 +1,68 @@ -import QtQuick 2.0 +import QtGraphicalEffects 1.0 +import QtQuick 2.7 +import QtQuick.Controls 2.4 +import QtQuick.Controls.Material 2.0 +import QtQuick.Layouts 1.3 + +import "controls" as Awesome +import "../fonts/Twemoji.js" as T Rectangle { id: button - width: buttonText.width + 20 - height: 20 - color: "#4B3557" - //border.color: focus ? "#BBBBBB" : "#AAAAAA" - //border.width: 1 + width: (text == undefined || text == "" ? 0 : buttonText.width) + (icon == undefined || icon == "" ? 0 : ico.width) + 24 * zoomSlider.value + Layout.minimumWidth: width + Layout.maximumWidth: width + height: 20 * zoomSlider.value + Layout.minimumHeight: height + Layout.maximumHeight: height + color: mousedown ? "#B09CBC" : "#4B3557" + border.color: "#4B3557" + border.width: 1 radius: 2 antialiasing: true property bool checked: false property alias text: buttonText.text property alias font: buttonText.font.family + property string icon + property bool mousedown signal clicked - Text { - id: buttonText - anchors.centerIn: parent - font.pixelSize: parent.height * .5 - color: "#FFFFFF" - } + RowLayout { + anchors.centerIn: parent + + Image { + anchors.left: parent.left + id: ico + source: "qrc:/qml/images/fontawesome/"+icon+".svg" + height: button.height / 2 + sourceSize.height: button.height / 2 + } + + Label { + id: buttonText + font.pixelSize: button.height / 2 + color: "#FFFFFF" + anchors.left: ico.right + anchors.leftMargin: 6 + visible: button.text != "" && button.text != undefined + } + } MouseArea { id: mouseArea anchors.fill: parent + onClicked: { parent.focus = true parent.clicked() } + + onPressed: mousedown = true + + onReleased: mousedown = false } Keys.onSpacePressed: clicked() diff --git a/qml/widgets/SimpleButton.qmlc b/qml/widgets/SimpleButton.qmlc index ed4bb67..cf2ed5d 100644 Binary files a/qml/widgets/SimpleButton.qmlc and b/qml/widgets/SimpleButton.qmlc differ diff --git a/qml/widgets/StackToolbar.qml b/qml/widgets/StackToolbar.qml index 4ae957d..42aaca8 100644 --- a/qml/widgets/StackToolbar.qml +++ b/qml/widgets/StackToolbar.qml @@ -12,7 +12,9 @@ Rectangle { // OVERHEAD BAR ON STACK PANE anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top - height: 28 + height: 20 * zoomSlider.value//btnAux.height + 4 + Layout.minimumHeight: height + Layout.maximumHeight: height color: "#EDEDED" property alias text: lbl.text @@ -20,9 +22,9 @@ Rectangle { // OVERHEAD BAR ON STACK PANE property alias back: btnBack - IconButton {// BACK BUTTON + SimpleButton {// BACK BUTTON id: btnBack - icon: awesome.icons.fa_arrow_circle_o_left + icon: "solid/arrow-circle-left" anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter anchors.leftMargin: 6 @@ -31,19 +33,18 @@ Rectangle { // OVERHEAD BAR ON STACK PANE onClicked: theStack.pane = theStack.emptyPane } - Label { // TEXT + ScalingLabel { // TEXT id: lbl - font.pixelSize: 16 text: "Sarah Jamie Lewis" anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter } - IconButton { // COG BUTTON + SimpleButton { // COG BUTTON id: btnAux anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right anchors.rightMargin: 6 - icon: awesome.icons.fa_cog + icon: "solid/cog" } } \ No newline at end of file