This repository has been archived on 2021-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
ui/qml/main.qml

210 lines
4.9 KiB
QML
Raw Permalink Normal View History

2018-10-23 18:52:13 +00:00
import QtGraphicalEffects 1.0
import QtQuick 2.7
import QtQuick.Controls 2.4
import QtQuick.Controls.Material 2.0
import QtQuick.Layouts 1.3
2018-10-30 19:48:37 +00:00
import QtQuick.Window 2.11
2018-10-23 18:52:13 +00:00
2018-10-28 02:49:14 +00:00
import "fonts/Twemoji.js" as T
2019-01-26 22:54:08 +00:00
import "overlays"
2018-11-22 00:01:17 +00:00
import "panes"
2018-10-23 18:52:13 +00:00
import "widgets"
2019-01-30 19:46:22 +00:00
import "utils.js" as Utils
2018-10-23 18:52:13 +00:00
2019-02-13 00:06:52 +00:00
ApplicationWindow {
2018-10-29 18:00:21 +00:00
id: windowItem
2019-01-30 19:58:23 +00:00
width: 1200
height: 800
2019-02-13 00:06:52 +00:00
visible: true
title: "cwtch" + ""
2018-10-23 18:52:13 +00:00
2018-10-29 18:00:21 +00:00
readonly property real ratio: height / width
2018-10-23 18:52:13 +00:00
2019-02-03 00:04:41 +00:00
readonly property string cwtch_background_color: '#EEEEFF'
readonly property string cwtch_color: '#B09CBC'
readonly property string cwtch_dark_color: '#4B3557'
2018-10-29 18:00:21 +00:00
FontAwesome { // PRETTY BUTTON ICONS
2018-10-28 02:49:14 +00:00
id: awesome
resource: "qrc:/qml/fonts/fontawesome.ttf"
}
2018-10-29 18:00:21 +00:00
function parse(text, size) { // REPLACE EMOJI WITH <IMG> TAGS
2018-10-28 02:49:14 +00:00
T.twemoji.base = "qrc:/qml/fonts/twemoji/"
T.twemoji.ext = ".png"
T.twemoji.size = "72x72"
T.twemoji.className = "\" height=\""+size+"\" width=\""+size
2019-01-30 19:46:22 +00:00
return T.twemoji.parse(Utils.htmlEscaped(text))
2018-10-28 02:49:14 +00:00
}
2018-10-29 18:00:21 +00:00
function restoreEmoji(text) { // REPLACE <IMG> TAGS WITH EMOJI
2018-10-28 02:49:14 +00:00
var re = /<img src="qrc:\/qml\/fonts\/twemoji\/72x72\/([^"]*?)\.png" width="10" height="10" \/>/g
var arr
var newtext = text
while (arr = re.exec(text)) {
var pieces = arr[1].split("-")
var replacement = ""
for (var i = 0; i < pieces.length; i++) {
replacement += T.twemoji.convert.fromCodePoint(pieces[i])
}
newtext = newtext.replace(arr[0], replacement)
}
return newtext
}
2018-10-30 19:48:37 +00:00
function scale() {
return 0.1 + 2 * zoomSlider.value
}
2018-10-28 02:49:14 +00:00
2018-10-29 18:00:21 +00:00
/* Rectangle { // THE TOOLBAR
id: toolbar
anchors.top: parent.top
anchors.left: parent.left
width: ratio >= 0.92 ? parent.width : 70
height: ratio >= 0.92 ? 70 : parent.height
color: "#4B3557"
GridLayout {
width: parent.width
height: parent.height
columns: ratio >= 0.92 ? children.length : 1
ContactPicture {
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
source: "qrc:/qml/images/profiles/001-centaur.png"
status: -2
}
ContactPicture {
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
source: "qrc:/qml/images/profiles/002-kraken.png"
status: -2
}
ContactPicture {
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
source: "qrc:/qml/images/profiles/003-dinosaur.png"
status: -2
}
ContactPicture {
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
source: "qrc:/qml/images/profiles/004-tree-1.png"
status: -2
}
ContactPicture {
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
source: "qrc:/qml/images/profiles/005-hand.png"
status: -2
}
}
}*/
RowLayout { // CONTAINS EVERYTHING EXCEPT THE TOOLBAR
/* anchors.left: ratio >= 0.92 ? parent.left : toolbar.right
anchors.top: ratio >= 0.92 ? toolbar.bottom : parent.top
anchors.right: parent.right
anchors.bottom: parent.bottom */
2018-10-23 18:52:13 +00:00
anchors.fill: parent
spacing: 0
Rectangle { // THE LEFT PANE WITH TOOLS AND CONTACTS
2018-10-25 00:13:03 +00:00
color: "#D2C0DD"
2018-10-23 18:52:13 +00:00
Layout.fillHeight: true
2018-10-29 18:00:21 +00:00
Layout.minimumWidth: Layout.maximumWidth
2019-02-12 21:22:14 +00:00
Layout.maximumWidth: theStack.pane == theStack.emptyPane ? parent.width : 450
2018-10-29 18:00:21 +00:00
visible: (ratio <= 1.08 && windowItem.width >= 500) || theStack.pane == theStack.emptyPane
2018-10-23 18:52:13 +00:00
ContactList{
anchors.fill: parent
}
}
2019-01-26 22:54:08 +00:00
Rectangle { // THE RIGHT PANE WHERE THE MESSAGES AND STUFF GO
2018-10-23 18:52:13 +00:00
color: "#EEEEFF"
Layout.fillWidth: true
Layout.fillHeight: true
2018-10-29 18:00:21 +00:00
StackLayout {
id: theStack
2018-10-23 18:52:13 +00:00
anchors.fill: parent
2018-10-29 18:00:21 +00:00
currentIndex: 0
property alias pane: theStack.currentIndex
readonly property int emptyPane: 0
readonly property int messagePane: 1
readonly property int settingsPane: 2
readonly property int userProfilePane: 3
readonly property int groupProfilePane: 4
2018-11-22 00:01:17 +00:00
readonly property int addGroupPane: 5
2018-10-29 18:00:21 +00:00
2019-02-02 00:12:44 +00:00
property string title
2018-10-29 18:00:21 +00:00
2019-02-04 23:00:12 +00:00
Item { anchors.fill: parent } // empty
2018-10-29 18:00:21 +00:00
2019-01-26 22:54:08 +00:00
OverlayPane { // messagePane
2019-02-02 00:12:44 +00:00
title: theStack.title
2018-10-29 18:00:21 +00:00
anchors.fill: parent
}
2019-02-04 23:00:12 +00:00
SettingsPane{ anchors.fill: parent }
2018-10-29 18:00:21 +00:00
PeerSettingsPane { anchors.fill: parent }
2018-10-29 18:00:21 +00:00
2019-02-04 23:00:12 +00:00
GroupSettingsPane{ anchors.fill: parent }
2018-10-29 18:00:21 +00:00
2018-11-22 00:01:17 +00:00
AddGroupPane { anchors.fill: parent }
2018-10-23 18:52:13 +00:00
}
}
}
PropertyAnimation { id: anmPopup; easing.type: Easing.InQuart; duration: 7000; target: popup; property: "opacity"; to: 0; }
2018-10-29 18:00:21 +00:00
Rectangle { // THE ERROR MESSAGE POPUP
2018-10-23 18:52:13 +00:00
id: popup
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 20
width: lblPopup.width + 30
height: lblPopup.height + 8
color: "#000000"
opacity: 0.5
radius: 15
visible: false
Label {
id: lblPopup
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 18
color: "#FFFFFF"
}
}
2018-10-29 18:00:21 +00:00
Connections { // POPUPS ARE INVOKED BY GO FUNCS
2018-10-23 18:52:13 +00:00
target: gcd
onInvokePopup: function(str) {
lblPopup.text = str
popup.opacity = 0.5
popup.visible = true
anmPopup.restart()
}
2019-02-02 00:27:17 +00:00
onSetToolbarTitle: function(str) {
theStack.title = str
}
2018-10-23 18:52:13 +00:00
}
}