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
|
2020-01-10 21:02:33 +00:00
|
|
|
import "fonts/MutantStandard.js" as Mutant
|
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"
|
2020-03-31 21:09:58 +00:00
|
|
|
import "theme"
|
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"
|
|
|
|
}
|
|
|
|
|
2020-01-10 21:02:33 +00:00
|
|
|
FontLoader {
|
|
|
|
source: "qrc:/qml/fonts/AdobeBlank.ttf"
|
|
|
|
}
|
|
|
|
|
|
|
|
function parse(text, size, isntEditable) { // REPLACE EMOJI WITH <IMG> TAGS
|
|
|
|
T.twemoji.base = gcd.assetPath + "twemoji/"
|
2018-10-28 02:49:14 +00:00
|
|
|
T.twemoji.ext = ".png"
|
|
|
|
T.twemoji.size = "72x72"
|
|
|
|
T.twemoji.className = "\" height=\""+size+"\" width=\""+size
|
2019-08-09 17:39:05 +00:00
|
|
|
var retText = T.twemoji.parse(Utils.htmlEscaped(text))
|
2020-01-10 21:02:33 +00:00
|
|
|
retText = retText.replace(/\n/g,"<br/>")
|
|
|
|
|
|
|
|
// mutant standard stickers
|
|
|
|
if (isntEditable) retText = Mutant.standard.parse(retText)
|
|
|
|
|
|
|
|
return retText
|
2018-10-28 02:49:14 +00:00
|
|
|
}
|
|
|
|
|
2018-10-29 18:00:21 +00:00
|
|
|
function restoreEmoji(text) { // REPLACE <IMG> TAGS WITH EMOJI
|
2020-01-10 21:02:33 +00:00
|
|
|
var re = RegExp('<img src="' + gcd.assetPath + 'twemoji/72x72/([^"]*?)\.png" width="10" height="10" \/>', 'g')
|
2018-10-28 02:49:14 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-04-16 19:40:19 +00:00
|
|
|
function ptToPx(pt) {
|
|
|
|
return Screen.pixelDensity * 25.4 * pt / 72
|
|
|
|
}
|
|
|
|
|
|
|
|
function pxToPt(px) {
|
|
|
|
return px * 72 / (Screen.pixelDensity * 25.4)
|
|
|
|
}
|
2018-10-30 19:48:37 +00:00
|
|
|
|
2019-03-19 20:35:31 +00:00
|
|
|
StackLayout {
|
|
|
|
id: parentStack
|
2020-01-10 21:02:33 +00:00
|
|
|
currentIndex: 1
|
2019-03-19 20:35:31 +00:00
|
|
|
anchors.fill: parent
|
2018-10-23 18:52:13 +00:00
|
|
|
|
2019-10-22 18:55:16 +00:00
|
|
|
readonly property int splashPane: 0
|
|
|
|
readonly property int managementPane: 1
|
2019-11-30 01:35:57 +00:00
|
|
|
readonly property int addEditProfilePane: 2
|
|
|
|
readonly property int profilePane: 3
|
2019-10-22 18:55:16 +00:00
|
|
|
property alias pane: parentStack.currentIndex
|
|
|
|
|
2019-03-19 20:35:31 +00:00
|
|
|
Rectangle { // Splash pane
|
|
|
|
color: "#FFFFFF"
|
|
|
|
//Layout.fillHeight: true
|
|
|
|
//Layout.minimumWidth: Layout.maximumWidth
|
|
|
|
//Layout.minimumHeight: parent.height
|
|
|
|
anchors.fill: parent
|
2018-10-23 18:52:13 +00:00
|
|
|
|
2019-03-19 20:35:31 +00:00
|
|
|
visible: true
|
2018-10-23 18:52:13 +00:00
|
|
|
|
2019-03-19 20:35:31 +00:00
|
|
|
SplashPane {
|
2019-04-24 20:32:20 +00:00
|
|
|
id: splashPane
|
2019-03-19 20:35:31 +00:00
|
|
|
anchors.fill: parent
|
2019-04-24 20:32:20 +00:00
|
|
|
running: true
|
2019-03-19 20:35:31 +00:00
|
|
|
}
|
|
|
|
}
|
2019-10-22 18:55:16 +00:00
|
|
|
|
|
|
|
Rectangle { // Profile login/management pane
|
|
|
|
anchors.fill: parent
|
|
|
|
visible: false
|
2020-03-31 21:09:58 +00:00
|
|
|
color: Theme.backgroundMainColor
|
2019-10-22 18:55:16 +00:00
|
|
|
|
|
|
|
ProfileManagerPane {
|
|
|
|
id: profilesPane
|
|
|
|
anchors.fill: parent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-30 01:35:57 +00:00
|
|
|
Rectangle { // Profile login/management pane
|
|
|
|
anchors.fill: parent
|
|
|
|
color: "#EEEEFF"
|
|
|
|
|
|
|
|
|
|
|
|
ProfileAddEditPane{
|
|
|
|
id: profileAddEditPane
|
|
|
|
anchors.fill: parent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-19 20:35:31 +00:00
|
|
|
RowLayout { // CONTAINS EVERYTHING EXCEPT THE TOOLBAR
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 0
|
2018-10-23 18:52:13 +00:00
|
|
|
|
2019-03-19 20:35:31 +00:00
|
|
|
Rectangle { // THE LEFT PANE WITH TOOLS AND CONTACTS
|
|
|
|
color: "#D2C0DD"
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.minimumWidth: Layout.maximumWidth
|
2020-04-16 22:24:20 +00:00
|
|
|
Layout.maximumWidth: theStack.pane == theStack.emptyPane ? parent.width : Theme.sidePaneMinSize
|
|
|
|
visible: (windowItem.width >= Theme.doublePaneMinSize && !Qt.inputMethod.visible) || theStack.pane == theStack.emptyPane
|
2018-10-29 18:00:21 +00:00
|
|
|
|
2019-02-02 00:12:44 +00:00
|
|
|
|
2019-03-19 20:35:31 +00:00
|
|
|
ContactList{
|
|
|
|
anchors.fill: parent
|
|
|
|
}
|
|
|
|
}
|
2018-10-29 18:00:21 +00:00
|
|
|
|
2019-03-19 20:35:31 +00:00
|
|
|
Rectangle { // THE RIGHT PANE WHERE THE MESSAGES AND STUFF GO
|
|
|
|
color: "#EEEEFF"
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2018-10-29 18:00:21 +00:00
|
|
|
|
|
|
|
|
2019-03-19 20:35:31 +00:00
|
|
|
StackLayout {
|
|
|
|
id: theStack
|
|
|
|
anchors.fill: parent
|
|
|
|
currentIndex: 0
|
2018-10-29 18:00:21 +00:00
|
|
|
|
2019-03-19 20:35:31 +00:00
|
|
|
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
|
|
|
|
readonly property int addGroupPane: 5
|
2018-10-29 18:00:21 +00:00
|
|
|
|
2019-03-19 20:35:31 +00:00
|
|
|
property string title
|
2018-10-29 18:00:21 +00:00
|
|
|
|
2019-03-19 20:35:31 +00:00
|
|
|
|
|
|
|
Item { anchors.fill: parent } // empty
|
|
|
|
|
|
|
|
OverlayPane { // messagePane
|
|
|
|
title: theStack.title
|
|
|
|
anchors.fill: parent
|
|
|
|
}
|
|
|
|
|
|
|
|
SettingsPane{ anchors.fill: parent }
|
|
|
|
|
|
|
|
PeerSettingsPane { anchors.fill: parent }
|
|
|
|
|
|
|
|
GroupSettingsPane{ anchors.fill: parent }
|
|
|
|
|
|
|
|
AddGroupPane { anchors.fill: parent }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-13 23:24:58 +00:00
|
|
|
|
|
|
|
focus: true
|
|
|
|
Keys.onPressed: {
|
|
|
|
if (event.key == Qt.Key_Back) {
|
|
|
|
event.accepted = true
|
|
|
|
if (theStack.currentIndex == theStack.emptyPane) {
|
|
|
|
androidCwtchActivity.rootHomeButtonHandle()
|
|
|
|
} else if (theStack.currentIndex == theStack.userProfilePane || theStack.currentIndex == theStack.groupProfilePane) {
|
|
|
|
theStack.currentIndex = theStack.messagePane
|
|
|
|
} else {
|
|
|
|
theStack.currentIndex = theStack.emptyPane
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
|
2019-04-17 21:03:50 +00:00
|
|
|
height: lblPopup.height + 8 * gcd.themeScale
|
2018-10-23 18:52:13 +00:00
|
|
|
color: "#000000"
|
|
|
|
opacity: 0.5
|
|
|
|
radius: 15
|
|
|
|
visible: false
|
|
|
|
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: lblPopup
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2019-04-17 21:03:50 +00:00
|
|
|
font.pixelSize: 18 * gcd.themeScale
|
2018-10-23 18:52:13 +00:00
|
|
|
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
|
|
|
|
}
|
2019-10-22 18:55:16 +00:00
|
|
|
|
|
|
|
onLoaded: function() {
|
|
|
|
parentStack.pane = parentStack.managementPane
|
|
|
|
splashPane.running = false
|
|
|
|
}
|
2018-10-23 18:52:13 +00:00
|
|
|
}
|
2019-09-26 23:36:35 +00:00
|
|
|
|
2020-01-10 21:02:33 +00:00
|
|
|
Component.onCompleted: Mutant.standard.imagePath = gcd.assetPath;
|
|
|
|
|
2019-09-26 23:36:35 +00:00
|
|
|
Connections {
|
|
|
|
target: Qt.application
|
|
|
|
onStateChanged: function() {
|
|
|
|
// https://doc.qt.io/qt-5/qt.html#ApplicationState-enum
|
|
|
|
if (Qt.application.state == 4) {
|
|
|
|
// Active
|
|
|
|
gcd.onActivate()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-19 20:35:31 +00:00
|
|
|
}
|