morpheus

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

commit 8d1b516a4c643c72cb71ec324d1a041fa45e00b6
parent 6eef581f6e72a7188714fef0a037ae1f30b1aa46
Author: MTRNord <mtrnord1@gmail.com>
Date:   Mon, 21 Aug 2017 19:21:25 +0200

Add Basic Login Page

Diffstat:
M.gitignore | 2++
Mmain.go | 104+++++++++++++++++++++++++++++++++++++++----------------------------------------
Amatrix/login.go | 5+++++
Aqml/login.ui | 115+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 173 insertions(+), 53 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -14,3 +14,5 @@ .glide/ deploy/ windows/ +rcc* +debug* diff --git a/main.go b/main.go @@ -3,70 +3,68 @@ package main import ( "os" + "github.com/therecipe/qt/core" + "github.com/therecipe/qt/uitools" "github.com/therecipe/qt/widgets" ) -//go:generate qtmoc -// type MocLabel struct { -// widgets.QLabel -// -// _ func(int) `signal:"updateLabel"` -// } - func main() { widgets.NewQApplication(len(os.Args), os.Args) - //create a window - window := widgets.NewQMainWindow(nil, 0) - window.SetWindowTitle("Neo") - window.SetMinimumSize2(200, 200) + desktopApp := widgets.QApplication_Desktop() + primaryScreen := desktopApp.PrimaryScreen() + screen := desktopApp.Screen(primaryScreen) + windowWidth := (screen.Width() / 2) + windowHeight := (screen.Height() / 2) - //create a layout - layout := widgets.NewQVBoxLayout() + loginUI := NewLoginUI(windowWidth, windowHeight) + loginUI.SetMinimumSize2(windowWidth, windowHeight) + + //Show loginUI + loginUI.Show() - //create a widget and set the layout + //enter the main event loop + widgets.QApplication_Exec() +} + +func NewLoginUI(windowWidth, windowHeight int) *widgets.QWidget { + var username string + var password string widget := widgets.NewQWidget(nil, 0) + + loader := uitools.NewQUiLoader(nil) + file := core.NewQFile2(":/qml/login.ui") + + file.Open(core.QIODevice__ReadOnly) + loginWidget := loader.Load(file, widget) + file.Close() + + var ( + ui_inputUsername = widgets.NewQLineEditFromPointer(widget.FindChild("UsernameInput", core.Qt__FindChildrenRecursively).Pointer()) + ui_inputPassword = widgets.NewQLineEditFromPointer(widget.FindChild("PasswordInput", core.Qt__FindChildrenRecursively).Pointer()) + ui_SubmitButton = widgets.NewQPushButtonFromPointer(widget.FindChild("loginButton", core.Qt__FindChildrenRecursively).Pointer()) + ) + + ui_inputUsername.ConnectTextChanged(func(value string) { + username = value + }) + + ui_inputPassword.ConnectTextChanged(func(value string) { + password = value + }) + + ui_SubmitButton.ConnectClicked(func(checked bool) { + println(username + " - " + password) + }) + + loginWidget.SetMinimumSize2(windowWidth, windowHeight) + + layout := widgets.NewQVBoxLayout() + layout.AddWidget(loginWidget, 0, 0) widget.SetLayout(layout) - //create a moc label - // label := NewMocLabel(nil, 0) - // label.SetAlignment(core.Qt__AlignCenter) - - //wrap the setText function with a custom signal - // label.ConnectUpdateLabel(func(s int) { - // - // //we are back in the main thread - // //so it's safe to update the label now - // label.SetText(fmt.Sprintf("%v second(s)", s)) - // }) - // - // //setup a ticker to update the label in the background - // t := time.Now() - // ticker := time.NewTicker(1 * time.Second) - // go func() { - // for _ = range ticker.C { - // label.UpdateLabel(int(time.Since(t).Seconds())) - // } - // }() - - //add the label to the layout - // layout.AddWidget(label, 0, 0) - - //create a button and add it to the layout - // button := widgets.NewQPushButton2("reset ticker", nil) - // button.ConnectClicked(func(checked bool) { - // label.UpdateLabel(0) - // t = time.Now() - // }) - // layout.AddWidget(button, 0, 0) - - //add the widget as the central widget to the window - window.SetCentralWidget(widget) - - //show the window - window.Show() + widget.SetWindowTitle("Neo - Login") - //enter the main event loop - widgets.QApplication_Exec() + return widget } diff --git a/matrix/login.go b/matrix/login.go @@ -0,0 +1,5 @@ +package matrix + +import ( + "github.com/matrix-org/gomatrix" +) diff --git a/qml/login.ui b/qml/login.ui @@ -0,0 +1,115 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>LoginForm</class> + <widget class="QWidget" name="LoginForm"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>813</width> + <height>356</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="windowTitle"> + <string>Neo - Login</string> + </property> + <widget class="QWidget" name="layoutWidget"> + <property name="geometry"> + <rect> + <x>330</x> + <y>80</y> + <width>258</width> + <height>147</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="LoginHeader"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="font"> + <font> + <family>Arial</family> + <pointsize>29</pointsize> + <underline>true</underline> + </font> + </property> + <property name="text"> + <string>Login</string> + </property> + </widget> + </item> + <item> + <layout class="QFormLayout" name="LoginFormLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="UsernameLabel"> + <property name="font"> + <font> + <family>Arial</family> + <pointsize>12</pointsize> + </font> + </property> + <property name="text"> + <string>Username:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="UsernameInput"> + <property name="inputMethodHints"> + <set>Qt::ImhNoAutoUppercase</set> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="PasswordLabel"> + <property name="font"> + <font> + <family>Arial</family> + <pointsize>12</pointsize> + </font> + </property> + <property name="inputMethodHints"> + <set>Qt::ImhNone</set> + </property> + <property name="text"> + <string>Password:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="PasswordInput"> + <property name="inputMethodHints"> + <set>Qt::ImhNoAutoUppercase|Qt::ImhSensitiveData</set> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QPushButton" name="loginButton"> + <property name="font"> + <font> + <family>Segoe UI</family> + <pointsize>12</pointsize> + </font> + </property> + <property name="text"> + <string>Login</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources/> + <connections/> +</ui>