Commit 654477b3 authored by Linus Jahn's avatar Linus Jahn Committed by GitHub

Add simple, non-functional, QQC2 chat (#49)

Enable High DPI Scaling
parent 71f38813
......@@ -3,5 +3,6 @@
<file alias="qml/main.qml">src/qml/main.qml</file>
<file alias="qml/RosterPage.qml">src/qml/RosterPage.qml</file>
<file alias="qml/LoginPage.qml">src/qml/LoginPage.qml</file>
<file alias="qml/ChatPage.qml">src/qml/ChatPage.qml</file>
</qresource>
</RCC>
/*
* Kaidan - Cross platform XMPP client
*
* Copyright (C) 2016 LNJ <git@lnj.li>
* Copyright (C) 2016-2017 LNJ <git@lnj.li>
* Copyright (C) 2016 Marzanna
* Copyright (C) 2016 geobra <s.g.b@gmx.de>
*
......@@ -74,10 +74,15 @@ int main(int argc, char *argv[])
// create a qt app
QGuiApplication app(argc, argv);
// name, display name, description
QGuiApplication::setApplicationName(APPLICATION_NAME);
QGuiApplication::setApplicationDisplayName(APPLICATION_DISPLAY_NAME);
QGuiApplication::setApplicationVersion(VERSION_STRING);
// attributes
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
// create parser and add a description
QCommandLineParser parser;
parser.setApplicationDescription(QString(APPLICATION_DISPLAY_NAME) +
......
/*
* Kaidan - Cross platform XMPP client
*
* Copyright (C) 2016-2017 LNJ <git@lnj.li>
*
* Kaidan is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Kaidan is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Kaidan. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.6
import QtQuick.Controls 2.0 as Controls
import QtQuick.Layouts 1.3
import org.kde.kirigami 1.0 as Kirigami
import harbour.kaidan 1.0
Kirigami.Page {
property string chatName
property string toJid
title: chatName
ColumnLayout {
anchors.fill: parent
//
// Chat
//
ListView {
Layout.fillWidth: true
Layout.fillHeight: true
Layout.margins: pane.leftPadding + messageField.leftPadding
displayMarginBeginning: 40
displayMarginEnd: 40
verticalLayoutDirection: ListView.BottomToTop
spacing: 12
model: 10
delegate: Row {
readonly property bool sentByMe: index % 2 == 0
anchors.right: sentByMe ? parent.right : undefined
spacing: 6
Rectangle {
id: avatar
width: height
height: parent.height
color: "grey"
visible: !sentByMe
}
Rectangle {
width: 80
height: 40
color: sentByMe ? "lightgrey" : "steelblue"
Kirigami.Label {
anchors.centerIn: parent
text: index
color: sentByMe ? "black" : "white"
}
}
}
//Controls.ScrollBar.vertical: Controls.ScrollBar {}
}
//
// Message Writing
//
Controls.Pane {
id: pane
Layout.fillWidth: true
RowLayout {
width: parent.width
Controls.TextArea {
id: messageField
Layout.fillWidth: true
placeholderText: qsTr("Compose message")
wrapMode: TextArea.Wrap
}
Controls.Button {
id: sendButton
text: qsTr("Send")
enabled: messageField.length > 0
}
}
}
}
}
......@@ -25,17 +25,15 @@ import org.kde.kirigami 1.0 as Kirigami
import harbour.kaidan 1.0
Kirigami.ScrollablePage {
id: page
title: "Login"
Layout.fillWidth: true
implicitWidth: applicationWindow().width
GridLayout {
columns: 2
anchors.fill: parent
Layout.fillWidth: true
Controls.Label {
// JID field
Kirigami.Label {
text: "Your Jabber-ID:"
}
Controls.TextField {
......@@ -44,7 +42,8 @@ Kirigami.ScrollablePage {
Layout.fillWidth: true
}
Controls.Label {
// Password field
Kirigami.Label {
text: "Your Password:"
}
Controls.TextField {
......@@ -54,14 +53,18 @@ Kirigami.ScrollablePage {
Layout.fillWidth: true
}
// Connect button
Controls.Button {
id: connectButton
text: "Connect"
Layout.columnSpan: 2
Layout.alignment: Qt.AlignRight
onClicked: {
// disable the button
connectButton.enabled = false;
connectButton.text = "<i>Connecting...</i>"
// connect to given account data
kaidan.mainConnect(jidField.text, passField.text);
}
}
......@@ -69,10 +72,10 @@ Kirigami.ScrollablePage {
Component.onCompleted: {
function goToRoster() {
//we need to disconnect enableConnectButton to prevent calling it on normal disconnection
// we need to disconnect enableConnectButton to prevent calling it on normal disconnection
kaidan.connectionStateDisconnected.disconnect(enableConnectButton)
//open the roster page, loaded in main.qml
applicationWindow().pageStack.replace(rosterPageComponent)
// open the roster page
pageStack.replace(rosterPage)
}
function enableConnectButton() {
......@@ -80,6 +83,7 @@ Kirigami.ScrollablePage {
connectButton.enabled = true
}
// connect functions to back-end events
kaidan.connectionStateConnected.connect(goToRoster)
kaidan.connectionStateDisconnected.connect(enableConnectButton)
}
......
/*
* Kaidan - Cross platform XMPP client
*
* Copyright (C) 2016 LNJ <git@lnj.li>
* Copyright (C) 2016-2017 LNJ <git@lnj.li>
* Copyright (C) 2016 Marzanna
*
* Kaidan is free software: you can redistribute it and/or modify
......@@ -23,15 +23,34 @@ import org.kde.kirigami 1.0 as Kirigami
import harbour.kaidan 1.0
Kirigami.ScrollablePage {
id: rosterPage
title: "Contacts"
ListView {
id: rosterView
model: kaidan.rosterController.rosterList
delegate: Kirigami.BasicListItem {
label: model.modelData.jid
delegate: Kirigami.SwipeListItem {
Kirigami.Label {
// use the Name or JID
text: name ? name : jid
}
onClicked: {
//kaidan.setCurrentChatPartner(jid)
pageStack.push(chatPage, {
"chatName": (name ? name : jid),
"toJid": jid
})
}
actions: [
Kirigami.Action {
iconName: "bookmark-remove"
onTriggered: {
print("deleting contact from roster: " + jid)
//kaidan.removeContactFromRoster()
}
}
]
}
}
}
......@@ -26,16 +26,14 @@ Kirigami.ApplicationWindow {
id: root
visible: true
pageStack.initialPage: loginPageComponent
// first page: login, the roster page will be opened after it
pageStack.initialPage: loginPage
Component {
id: rosterPageComponent
RosterPage {}
}
Component {
id: loginPageComponent
LoginPage {}
}
// load all pages
Component {id: chatPage; ChatPage {}}
Component {id: loginPage; LoginPage {}}
Component {id: rosterPage; RosterPage {}}
// diconnect from jabber server
onClosing: kaidan.mainDisconnect()
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment