commit 20964d0787727e17ea952b30aeb70d9352866675
parent afc267af447a11f9da100f19b9525a08a133b8bf
Author: MTRNord <mtrnord1@gmail.com>
Date: Sun, 27 Aug 2017 14:10:30 +0200
Multiple UI Changes
Signed-off-by: MTRNord <mtrnord1@gmail.com>
Diffstat:
12 files changed, 189 insertions(+), 37 deletions(-)
diff --git a/main.go b/main.go
@@ -4,7 +4,6 @@ import (
"log"
"os"
- "fmt"
"github.com/Nordgedanken/Morpheus/matrix"
"github.com/Nordgedanken/Morpheus/util"
"github.com/matrix-org/gomatrix"
@@ -82,10 +81,8 @@ func main() {
//Show MainUI
for result := range results {
- fmt.Println(result)
//TODO Don't switch screen on wrong login data.
- //mainUI := NewMainUI(windowWidth, windowHeight, result)
- mainUI := NewMainUI(windowWidth, windowHeight)
+ mainUI := NewMainUI(windowWidth, windowHeight, result)
mainUI.SetMinimumSize2(windowWidth, windowHeight)
window.SetCentralWidget(mainUI)
}
diff --git a/matrix/ownUser.go b/matrix/ownUser.go
@@ -21,7 +21,7 @@ func init() {
}
// getOwnUserAvatar returns a *gui.QPixmap of an UserAvatar
-func getOwnUserAvatar(cli *gomatrix.Client) *gui.QPixmap {
+func GetOwnUserAvatar(cli *gomatrix.Client) *gui.QPixmap {
// Init local vars
var avatarData string
var IMGdata string
diff --git a/qml/icons/ic_add_white_48px.svg b/qml/icons/ic_add_white_48px.svg
@@ -1,4 +1,4 @@
-<svg fill="#FFFFFF" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
+<svg fill="#fafafa" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
<path d="M0 0h24v24H0z" fill="none"/>
</svg>
\ No newline at end of file
diff --git a/qml/icons/ic_menu_white_48px.svg b/qml/icons/ic_menu_white_48px.svg
@@ -1,4 +1,4 @@
-<svg fill="#FFFFFF" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
+<svg fill="#fafafa" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0h24v24H0z" fill="none"/>
<path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/>
</svg>
\ No newline at end of file
diff --git a/qml/icons/ic_person_white_48px.svg b/qml/icons/ic_person_white_48px.svg
@@ -1,4 +1,4 @@
-<svg fill="#FFFFFF" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
+<svg fill="#fafafa" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
<path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/>
<path d="M0 0h24v24H0z" fill="none"/>
</svg>
\ No newline at end of file
diff --git a/qml/icons/ic_phone_white_48px.svg b/qml/icons/ic_phone_white_48px.svg
@@ -1,4 +1,4 @@
-<svg fill="#FFFFFF" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
+<svg fill="#fafafa" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0h24v24H0z" fill="none"/>
<path d="M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z"/>
</svg>
\ No newline at end of file
diff --git a/qml/icons/ic_power_settings_new_black_48px.svg b/qml/icons/ic_power_settings_new_black_48px.svg
@@ -0,0 +1,4 @@
+<svg fill="#000000" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
+ <path d="M0 0h24v24H0z" fill="none"/>
+ <path d="M13 3h-2v10h2V3zm4.83 2.17l-1.42 1.42C17.99 7.86 19 9.81 19 12c0 3.87-3.13 7-7 7s-7-3.13-7-7c0-2.19 1.01-4.14 2.58-5.42L6.17 5.17C4.23 6.82 3 9.26 3 12c0 4.97 4.03 9 9 9s9-4.03 9-9c0-2.74-1.23-5.18-3.17-6.83z"/>
+</svg>
+\ No newline at end of file
diff --git a/qml/icons/ic_power_settings_new_white_48px.svg b/qml/icons/ic_power_settings_new_white_48px.svg
@@ -0,0 +1,4 @@
+<svg fill="#fafafa" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
+ <path d="M0 0h24v24H0z" fill="none"/>
+ <path d="M13 3h-2v10h2V3zm4.83 2.17l-1.42 1.42C17.99 7.86 19 9.81 19 12c0 3.87-3.13 7-7 7s-7-3.13-7-7c0-2.19 1.01-4.14 2.58-5.42L6.17 5.17C4.23 6.82 3 9.26 3 12c0 4.97 4.03 9 9 9s9-4.03 9-9c0-2.74-1.23-5.18-3.17-6.83z"/>
+</svg>
+\ No newline at end of file
diff --git a/qml/icons/ic_settings_white_48px.svg b/qml/icons/ic_settings_white_48px.svg
@@ -1,4 +1,4 @@
-<svg fill="#FFFFFF" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
+<svg fill="#fafafa" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0h24v24H0z" fill="none"/>
<path d="M19.43 12.98c.04-.32.07-.64.07-.98s-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.3-.61-.22l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.23-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98s.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.23.09.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.65zM12 15.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z"/>
</svg>
\ No newline at end of file
diff --git a/qml/icons/ic_video_call_white_48px.svg b/qml/icons/ic_video_call_white_48px.svg
@@ -1,4 +1,4 @@
-<svg fill="#FFFFFF" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
+<svg fill="#fafafa" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0h24v24H0V0z" fill="none"/>
<path d="M17 10.5V7c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-3.5l4 4v-11l-4 4zM14 13h-3v3H9v-3H6v-2h3V8h2v3h3v2z"/>
</svg>
\ No newline at end of file
diff --git a/qml/ui/chat.ui b/qml/ui/chat.ui
@@ -50,7 +50,8 @@
</sizepolicy>
</property>
<property name="styleSheet">
- <string notr="true">background-color: rgb(70, 79, 96);</string>
+ <string notr="true">background-color: rgb(91, 103, 125);
+/* rgb(70, 79, 96);*/</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<property name="leftMargin">
@@ -85,21 +86,18 @@
<height>61</height>
</rect>
</property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
+ <property name="mouseTracking">
+ <bool>true</bool>
</property>
<property name="text">
<string/>
</property>
- <property name="pixmap">
- <pixmap>../../../../../../../Downloads/avatar512.png</pixmap>
- </property>
<property name="scaledContents">
<bool>true</bool>
</property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
</widget>
</widget>
</item>
@@ -143,7 +141,7 @@
<number>7</number>
</property>
<property name="topMargin">
- <number>82</number>
+ <number>45</number>
</property>
<property name="rightMargin">
<number>9</number>
@@ -177,18 +175,21 @@
<height>41</height>
</size>
</property>
+ <property name="toolTip">
+ <string>New 1-1 Chat</string>
+ </property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="styleSheet">
- <string notr="true">border: 0;</string>
+ <string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
- <normaloff>:/qml/icons/ic_person_black_48px.svg</normaloff>:/qml/icons/ic_person_black_48px.svg</iconset>
+ <normaloff>:/qml/icons/ic_person_white_48px.svg</normaloff>:/qml/icons/ic_person_white_48px.svg</iconset>
</property>
<property name="iconSize">
<size>
@@ -196,6 +197,9 @@
<height>25</height>
</size>
</property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
</widget>
</item>
</layout>
@@ -233,18 +237,21 @@
<height>41</height>
</size>
</property>
+ <property name="toolTip">
+ <string>New Room</string>
+ </property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="styleSheet">
- <string notr="true">border: 0;</string>
+ <string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
- <normaloff>:/qml/icons/ic_add_black_48px.svg</normaloff>:/qml/icons/ic_add_black_48px.svg</iconset>
+ <normaloff>:/qml/icons/ic_add_white_48px.svg</normaloff>:/qml/icons/ic_add_white_48px.svg</iconset>
</property>
<property name="iconSize">
<size>
@@ -252,6 +259,9 @@
<height>30</height>
</size>
</property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
</widget>
</item>
</layout>
@@ -289,18 +299,21 @@
<height>41</height>
</size>
</property>
+ <property name="toolTip">
+ <string>Directory</string>
+ </property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="styleSheet">
- <string notr="true">border: 0;</string>
+ <string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
- <normaloff>:/qml/icons/ic_menu_black_48px.svg</normaloff>:/qml/icons/ic_menu_black_48px.svg</iconset>
+ <normaloff>:/qml/icons/ic_menu_white_48px.svg</normaloff>:/qml/icons/ic_menu_white_48px.svg</iconset>
</property>
<property name="iconSize">
<size>
@@ -308,6 +321,9 @@
<height>25</height>
</size>
</property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
</widget>
</item>
</layout>
@@ -345,18 +361,83 @@
<height>41</height>
</size>
</property>
+ <property name="mouseTracking">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>Settings</string>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normaloff>:/qml/icons/ic_settings_white_48px.svg</normaloff>:/qml/icons/ic_settings_white_48px.svg</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QWidget" name="LogoutButtonLayout" native="true">
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>9</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="LogoutButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>41</width>
+ <height>41</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Logout</string>
+ </property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="styleSheet">
- <string notr="true">border: 0;</string>
+ <string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
- <normaloff>:/qml/icons/ic_settings_black_48px.svg</normaloff>:/qml/icons/ic_settings_black_48px.svg</iconset>
+ <normaloff>:/qml/icons/ic_power_settings_new_white_48px.svg</normaloff>:/qml/icons/ic_power_settings_new_white_48px.svg</iconset>
</property>
<property name="iconSize">
<size>
@@ -364,6 +445,9 @@
<height>25</height>
</size>
</property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
</widget>
</item>
</layout>
@@ -374,6 +458,7 @@
<zorder>directoryButtonLayout</zorder>
<zorder>to1ChatButtonLayout</zorder>
<zorder>newRoomButtonLayout</zorder>
+ <zorder>LogoutButtonLayout</zorder>
</widget>
</item>
</layout>
@@ -644,11 +729,14 @@ border-radius: 5px;</string>
<height>41</height>
</size>
</property>
+ <property name="toolTip">
+ <string>Start Voice Chat</string>
+ </property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
- <string notr="true">border: 0;</string>
+ <string notr="true"/>
</property>
<property name="text">
<string/>
@@ -663,6 +751,9 @@ border-radius: 5px;</string>
<height>25</height>
</size>
</property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item row="0" column="3">
@@ -679,8 +770,11 @@ border-radius: 5px;</string>
<height>41</height>
</size>
</property>
+ <property name="toolTip">
+ <string>Start Video Chat</string>
+ </property>
<property name="styleSheet">
- <string notr="true">border: 0;</string>
+ <string notr="true">;</string>
</property>
<property name="text">
<string/>
@@ -695,6 +789,9 @@ border-radius: 5px;</string>
<height>25</height>
</size>
</property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
</widget>
</item>
</layout>
@@ -724,7 +821,7 @@ border-radius: 5px;</string>
<rect>
<x>0</x>
<y>0</y>
- <width>1217</width>
+ <width>1216</width>
<height>581</height>
</rect>
</property>
diff --git a/uis.go b/uis.go
@@ -1,13 +1,13 @@
package main
import (
- "fmt"
"github.com/Nordgedanken/Morpheus/matrix"
"github.com/matrix-org/gomatrix"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/uitools"
"github.com/therecipe/qt/widgets"
+ "github.com/tidwall/buntdb"
"log"
"strings"
"sync"
@@ -128,10 +128,9 @@ func NewLoginUI(windowWidth, windowHeight int) *widgets.QWidget {
//Show MainUI
for result := range results {
- fmt.Println(result)
//TODO Don't switch screen on wrong login data.
- //MainUI := NewMainUI(windowWidth, windowHeight, result)
- mainUI := NewMainUI(windowWidth, windowHeight)
+ mainUI := NewMainUI(windowWidth, windowHeight, result)
+ mainUI.SetMinimumSize2(windowWidth, windowHeight)
window.SetCentralWidget(mainUI)
}
} else {
@@ -146,7 +145,7 @@ func NewLoginUI(windowWidth, windowHeight int) *widgets.QWidget {
//NewMainUI initializes the login Screen
//func NewMainUI(windowWidth, windowHeight int, cli *gomatrix.Client) *widgets.QWidget {
-func NewMainUI(windowWidth, windowHeight int) *widgets.QWidget {
+func NewMainUI(windowWidth, windowHeight int, cli *gomatrix.Client) *widgets.QWidget {
var widget = widgets.NewQWidget(nil, 0)
var loader = uitools.NewQUiLoader(nil)
@@ -185,5 +184,54 @@ func NewMainUI(windowWidth, windowHeight int) *widgets.QWidget {
chatWidget.Resize(event.Size())
})
+ //Set Avatar
+ avatarLogo := widgets.NewQLabelFromPointer(widget.FindChild("UserAvatar", core.Qt__FindChildrenRecursively).Pointer())
+ avatarLogo.SetPixmap(matrix.GetOwnUserAvatar(cli))
+
+ //Handle LogoutButton
+ logoutButton := widgets.NewQPushButtonFromPointer(widget.FindChild("LogoutButton", core.Qt__FindChildrenRecursively).Pointer())
+ logoutButton.ConnectClicked(func(checked bool) {
+ //TODO register enter and show loader or so
+ localLog.Println("Starting Logout Sequenze in background")
+ var wg sync.WaitGroup
+ results := make(chan bool)
+
+ wg.Add(1)
+ go func(cli *gomatrix.Client, localLog *log.Logger, results chan<- bool) {
+ defer wg.Done()
+ _, err := cli.Logout()
+ if err != nil {
+ localLog.Println(err)
+ results <- false
+ } else {
+ cli.ClearCredentials()
+ //Flush complete DB
+ db.View(func(tx *buntdb.Tx) error {
+ var QueryErr error
+ QueryErr = tx.DeleteAll()
+ if QueryErr != nil {
+ return QueryErr
+ }
+ return nil
+ })
+ results <- true
+ }
+ }(cli, localLog, results)
+
+ go func() {
+ wg.Wait() // wait for each execTask to return
+ close(results) // then close the results channel
+ }()
+
+ //Show LoginUI
+ for result := range results {
+ if result {
+ loginUI := NewLoginUI(windowWidth, windowHeight)
+ loginUI.SetMinimumSize2(windowWidth, windowHeight)
+ window.SetCentralWidget(loginUI)
+ }
+ }
+ })
+
return widget
}