morpheus

A Matrix client written in Go-QT
git clone git://archive.git.mtrnord.blog/Nordgedanken/morpheus.git
Log | Files | Refs | README | LICENSE

commit f26d02df8f23a9a010ab7e4ae35ee5f0b56a386d
parent a13a5e23fa9a9c09f022f134c4fece00c6d2adf1
Author: MTRNord <mtrnord1@gmail.com>
Date:   Mon, 21 Aug 2017 23:27:58 +0200

Add Mokup Main Page and Remove Log

Diffstat:
M.gitignore | 1+
Dlog/Main.log | 4----
Amatrix/ownUser.go | 15+++++++++++++++
Aqml/Main.ui | 156+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Muis.go | 67+++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
5 files changed, 229 insertions(+), 14 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -16,3 +16,4 @@ deploy/ windows/ rcc* debug* +log/ diff --git a/log/Main.log b/log/Main.log @@ -1,4 +0,0 @@ -2017-08-21 21:43:23 - Starting Neo -2017-08-21 21:43:23 - Starting Login Sequenze -2017-08-21 21:43:23 - Avatar: -2017-08-21 21:43:23 - Finished Startup Neo diff --git a/matrix/ownUser.go b/matrix/ownUser.go @@ -0,0 +1,15 @@ +package matrix + +import ( + "github.com/matrix-org/gomatrix" +) + +type RespUserDisplayName struct { + DisplayName string `json:"displayname"` +} + +func GetUserDisplayName(mxid string, cli *gomatrix.Client) (resp *RespUserDisplayName, err error) { + urlPath := cli.BuildURL("profile", mxid, "displayname") + _, err = cli.MakeRequest("GET", urlPath, nil, &resp) + return +} diff --git a/qml/Main.ui b/qml/Main.ui @@ -0,0 +1,156 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainForm</class> + <widget class="QWidget" name="MainForm"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>1007</width> + <height>652</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="font"> + <font> + <underline>true</underline> + </font> + </property> + <property name="windowTitle"> + <string>Neo</string> + </property> + <widget class="QColumnView" name="columnView"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>1001</width> + <height>651</height> + </rect> + </property> + </widget> + <widget class="QScrollArea" name="scrollArea"> + <property name="geometry"> + <rect> + <x>220</x> + <y>60</y> + <width>781</width> + <height>591</height> + </rect> + </property> + <property name="widgetResizable"> + <bool>true</bool> + </property> + <widget class="QWidget" name="scrollAreaWidgetContents"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>779</width> + <height>589</height> + </rect> + </property> + </widget> + </widget> + <widget class="QScrollArea" name="scrollArea_2"> + <property name="geometry"> + <rect> + <x>0</x> + <y>60</y> + <width>211</width> + <height>591</height> + </rect> + </property> + <property name="widgetResizable"> + <bool>true</bool> + </property> + <widget class="QWidget" name="scrollAreaWidgetContents_2"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>209</width> + <height>589</height> + </rect> + </property> + </widget> + </widget> + <widget class="QLabel" name="RoomNameLabel"> + <property name="geometry"> + <rect> + <x>230</x> + <y>10</y> + <width>741</width> + <height>41</height> + </rect> + </property> + <property name="font"> + <font> + <family>Arial</family> + <pointsize>31</pointsize> + <underline>false</underline> + </font> + </property> + <property name="text"> + <string>Titel</string> + </property> + </widget> + <widget class="QGraphicsView" name="AvatarImage"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>71</width> + <height>61</height> + </rect> + </property> + </widget> + <widget class="QLabel" name="UsernameLabel"> + <property name="geometry"> + <rect> + <x>80</x> + <y>10</y> + <width>121</width> + <height>21</height> + </rect> + </property> + <property name="font"> + <font> + <family>Arial</family> + <pointsize>16</pointsize> + </font> + </property> + <property name="text"> + <string>Username</string> + </property> + </widget> + <widget class="QLabel" name="MXIDLabel"> + <property name="geometry"> + <rect> + <x>80</x> + <y>35</y> + <width>121</width> + <height>21</height> + </rect> + </property> + <property name="font"> + <font> + <family>Arial</family> + <pointsize>10</pointsize> + <underline>false</underline> + </font> + </property> + <property name="text"> + <string>@User:matrix.org</string> + </property> + </widget> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources/> + <connections/> +</ui> diff --git a/uis.go b/uis.go @@ -1,17 +1,20 @@ package main import ( + "fmt" + "github.com/Nordgedanken/Neo/matrix" + "github.com/matrix-org/gomatrix" "github.com/therecipe/qt/core" "github.com/therecipe/qt/uitools" "github.com/therecipe/qt/widgets" ) +var username string +var password string + //NewLoginUI initializes the login Screen func NewLoginUI(windowWidth, windowHeight int) *widgets.QWidget { - var username string - var password string - widget := widgets.NewQWidget(nil, 0) loader := uitools.NewQUiLoader(nil) @@ -39,15 +42,14 @@ func NewLoginUI(windowWidth, windowHeight int) *widgets.QWidget { localLog.Println("Starting Login Sequenze") cli, err := matrix.LoginUser(username, password) if err != nil { - localLog.Panicln(err) + localLog.Fatalln(err) } + MainUI := NewMainUI(windowWidth, windowHeight, cli) + MainUI.SetMinimumSize2(windowWidth, windowHeight) - //TODO remove after testing - avatarURL, avatarErr := cli.GetAvatarURL() - if avatarErr != nil { - localLog.Panicln(avatarErr) - } - localLog.Println("Avatar: " + avatarURL) + //Show MainUI + widget.Close() + MainUI.Show() }) loginWidget.SetMinimumSize2(windowWidth, windowHeight) @@ -60,3 +62,48 @@ func NewLoginUI(windowWidth, windowHeight int) *widgets.QWidget { return widget } + +//NewMainUI initializes the login Screen +func NewMainUI(windowWidth, windowHeight int, cli *gomatrix.Client) *widgets.QWidget { + widget := widgets.NewQWidget(nil, 0) + + loader := uitools.NewQUiLoader(nil) + file := core.NewQFile2(":/qml/Main.ui") + + file.Open(core.QIODevice__ReadOnly) + loginWidget := loader.Load(file, widget) + file.Close() + + var ( + usernameLabel = widgets.NewQLabelFromPointer(widget.FindChild("UsernameLabel", core.Qt__FindChildrenRecursively).Pointer()) + mxidLabel = widgets.NewQLabelFromPointer(widget.FindChild("MXIDLabel", core.Qt__FindChildrenRecursively).Pointer()) + //avatarLogo = widgets.NewQGraphicsViewFromPointer(widget.FindChild("loginButton", core.Qt__FindChildrenRecursively).Pointer()) + ) + + // Set MXID Label + mxidLabel.SetText(fmt.Sprint(username)) + + // Set Dispalyname Label + DisplayNameResp, DisplayNameErr := matrix.GetUserDisplayName(username, cli) + if DisplayNameErr != nil { + localLog.Println(DisplayNameErr) + } + usernameLabel.SetText(fmt.Sprint(DisplayNameResp.DisplayName)) + + //TODO remove after testing + avatarURL, avatarErr := cli.GetAvatarURL() + if avatarErr != nil { + localLog.Println(avatarErr) + } + localLog.Println("Avatar: " + avatarURL) + + loginWidget.SetMinimumSize2(windowWidth, windowHeight) + + layout := widgets.NewQVBoxLayout() + layout.AddWidget(loginWidget, 0, 0) + widget.SetLayout(layout) + + widget.SetWindowTitle("Neo - Login") + + return widget +}