diff --git a/TODO.md b/TODO.md index 3ebb939c..950838fc 100644 --- a/TODO.md +++ b/TODO.md @@ -14,8 +14,10 @@ - ![A picture](https://picsum.photos/256/256) not clickable? - Icons aren't reloaded - Bug when resizing window being tiled (i3), can't figure it out + - HStyle singleton isn't reloaded - UI + - Test HGlassRectangle elements when no effects are available - Leave room - Forget room warning popup - Use HRowLayout and its totalSpacing wherever possible diff --git a/harmonyqml/components/UI.qml b/harmonyqml/components/UI.qml index 99366b09..cff0cbaa 100644 --- a/harmonyqml/components/UI.qml +++ b/harmonyqml/components/UI.qml @@ -1,21 +1,23 @@ import QtQuick 2.7 -import QtQuick.Controls 1.4 as Controls1 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.4 import "base" as Base import "sidePane" as SidePane import "chat" as Chat -Base.HImage { +Item { id: mainUI - fillMode: Image.PreserveAspectCrop - source: "../images/login_background.jpg" - anchors.fill: parent + + Base.HImage { + id: mainUIBackground + fillMode: Image.PreserveAspectCrop + source: "../images/login_background.jpg" + anchors.fill: parent + } property bool accountsLoggedIn: Backend.clientManager.clientCount > 0 - //https://doc.qt.io/qt-5/qml-qtquick-controls-splitview.html - Controls1.SplitView { + Base.HSplitView { anchors.fill: parent SidePane.Root { @@ -25,6 +27,10 @@ Base.HImage { } StackView { + id: pageStack + + property bool initialPageSet: false + function showPage(name, properties) { pageStack.replace("pages/" + name + ".qml", properties || {}) } @@ -35,10 +41,11 @@ Base.HImage { ) } - id: pageStack - Component.onCompleted: showPage( - accountsLoggedIn ? "Default" : "SignIn" - ) + Component.onCompleted: { + if (initialPageSet) { return } + initialPageSet = true + showPage(accountsLoggedIn ? "Default" : "SignIn") + } onCurrentItemChanged: if (currentItem) { currentItem.forceActiveFocus() diff --git a/harmonyqml/components/Window.qml b/harmonyqml/components/Window.qml index f8f80c9b..21e759a5 100644 --- a/harmonyqml/components/Window.qml +++ b/harmonyqml/components/Window.qml @@ -3,6 +3,7 @@ import QtQuick.Controls 2.2 import QtQuick.Window 2.7 ApplicationWindow { + id: appWindow visible: true width: Math.min(Screen.width, 1152) height: Math.min(Screen.height, 768) diff --git a/harmonyqml/components/base/HGlassRectangle.qml b/harmonyqml/components/base/HGlassRectangle.qml new file mode 100644 index 00000000..c686e7a7 --- /dev/null +++ b/harmonyqml/components/base/HGlassRectangle.qml @@ -0,0 +1,34 @@ +import QtQuick 2.7 +import QtGraphicalEffects 1.0 + +Item { + default property alias children: rectangle.children + property alias color: rectangle.color + property alias gradient: rectangle.gradient + property alias blurRadius: fastBlur.radius + property alias border: rectangle.border + property alias radius: rectangle.radius + + ShaderEffectSource { + id: effectSource + sourceItem: mainUIBackground + anchors.fill: parent + sourceRect: Qt.rect( + pageStack.x + parent.x, pageStack.y + parent.y, width, height + ) + } + + FastBlur { + id: fastBlur + cached: true + anchors.fill: effectSource + source: effectSource + radius: 8 + } + + Rectangle { + id: rectangle + anchors.fill: parent + color: HStyle.sidePane.background + } +} diff --git a/harmonyqml/components/base/HScalingBox.qml b/harmonyqml/components/base/HScalingBox.qml index 1dc83b13..6248d8c0 100644 --- a/harmonyqml/components/base/HScalingBox.qml +++ b/harmonyqml/components/base/HScalingBox.qml @@ -1,6 +1,6 @@ import QtQuick 2.7 -Rectangle { +HGlassRectangle { property real widthForHeight: 0.75 property int baseHeight: 300 property int startScalingUpAboveHeight: 1080 @@ -8,7 +8,7 @@ Rectangle { readonly property int baseWidth: baseHeight * widthForHeight readonly property int margins: baseHeight * 0.03 - color: Qt.hsla(1, 1, 1, 0.3) + color: HStyle.boxes.background height: Math.min(parent.height, baseHeight) width: Math.min(parent.width, baseWidth) scale: Math.max(1, parent.height / startScalingUpAboveHeight) diff --git a/harmonyqml/components/base/HSplitView.qml b/harmonyqml/components/base/HSplitView.qml new file mode 100644 index 00000000..8ed5541d --- /dev/null +++ b/harmonyqml/components/base/HSplitView.qml @@ -0,0 +1,7 @@ +import QtQuick 2.7 +import QtQuick.Controls 1.4 as Controls1 + +//https://doc.qt.io/qt-5/qml-qtquick-controls-splitview.html +Controls1.SplitView { + handleDelegate: Item {} +} diff --git a/harmonyqml/components/base/HStyle.qml b/harmonyqml/components/base/HStyle.qml index b144622e..fabf91f4 100644 --- a/harmonyqml/components/base/HStyle.qml +++ b/harmonyqml/components/base/HStyle.qml @@ -2,21 +2,36 @@ pragma Singleton import QtQuick 2.7 QtObject { - readonly property int foo: 3 - readonly property QtObject fontSize: QtObject { - readonly property int smallest: 6 - readonly property int smaller: 8 - readonly property int small: 12 - readonly property int normal: 16 - readonly property int big: 24 - readonly property int bigger: 32 - readonly property int biggest: 48 + property int smallest: 6 + property int smaller: 8 + property int small: 12 + property int normal: 16 + property int big: 24 + property int bigger: 32 + property int biggest: 48 } readonly property QtObject fontFamily: QtObject { - readonly property string sans: "Roboto" - readonly property string serif: "Roboto Slab" - readonly property string mono: "Hack" + property string sans: "SFNS Display" + property string serif: "Roboto Slab" + property string mono: "Hack" + } + + readonly property QtObject colors: QtObject { + property color background0: Qt.hsla(1, 1, 1, 0.4) + } + + readonly property QtObject sidePane: QtObject { + property color background: colors.background0 + } + + readonly property QtObject boxes: QtObject { + property color background: colors.background0 + property int radius: 5 + } + + readonly property QtObject avatars: QtObject { + property int radius: 5 } } diff --git a/harmonyqml/components/pages/Default.qml b/harmonyqml/components/pages/Default.qml index 2a311546..f4aa9919 100644 --- a/harmonyqml/components/pages/Default.qml +++ b/harmonyqml/components/pages/Default.qml @@ -16,7 +16,8 @@ Base.HRowLayout { Layout.maximumWidth: parent.width - Layout.margins * 2 background: Rectangle { - color: Qt.hsla(1, 1, 1, 0.3) + color: Base.HStyle.boxes.background + radius: Base.HStyle.boxes.radius } } } diff --git a/harmonyqml/components/pages/SignIn.qml b/harmonyqml/components/pages/SignIn.qml index 4204c805..150cec5a 100644 --- a/harmonyqml/components/pages/SignIn.qml +++ b/harmonyqml/components/pages/SignIn.qml @@ -5,9 +5,11 @@ import "../base" as Base Item { property string loginWith: "username" - onFocusChanged: identifierField.forceActiveFocus() + property int wi: x + onWiChanged: console.log("loginI", wi) + Base.HInterfaceBox { id: signInBox title: "Sign in" diff --git a/harmonyqml/components/sidePane/Root.qml b/harmonyqml/components/sidePane/Root.qml index ead97adc..f8c5a935 100644 --- a/harmonyqml/components/sidePane/Root.qml +++ b/harmonyqml/components/sidePane/Root.qml @@ -1,11 +1,11 @@ import QtQuick 2.7 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.4 +import QtGraphicalEffects 1.0 import "../base" as Base -Rectangle { +Base.HGlassRectangle { id: sidePane - color: "gray" clip: true // Avoid artifacts when resizing pane width to minimum ColumnLayout { diff --git a/harmonyqml/engine.py b/harmonyqml/engine.py index b0392eca..31e77e37 100644 --- a/harmonyqml/engine.py +++ b/harmonyqml/engine.py @@ -62,9 +62,9 @@ class Engine(QQmlApplicationEngine): def reload_qml(self) -> None: - self.clearComponentCache() loader = self.rootObjects()[0].findChild(QObject, "UILoader") source = loader.property("source") loader.setProperty("source", None) + self.clearComponentCache() loader.setProperty("source", source) logging.info("Reloaded: %s", source) diff --git a/harmonyqml/images/.login_background.jpg-autosave.kra b/harmonyqml/images/.login_background.jpg-autosave.kra new file mode 100644 index 00000000..7275a9de Binary files /dev/null and b/harmonyqml/images/.login_background.jpg-autosave.kra differ diff --git a/harmonyqml/images/matrix_logo.svg b/harmonyqml/images/matrix_logo.svg deleted file mode 100644 index 743a1eed..00000000 --- a/harmonyqml/images/matrix_logo.svg +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - -