Skip to content

Commit

Permalink
xz
Browse files Browse the repository at this point in the history
  • Loading branch information
LNJ committed Aug 3, 2017
1 parent ff7ce45 commit f010784
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 59 deletions.
3 changes: 3 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ Copyright (C) 2016-2017 Ilya Bizyaev <bizyaev.game@yandex.ru> (CC BY-SA 4.0):
misc/kaidan.svg
misc/kaidan-128x128.png

Copyright (C) 2017 LNJ <git@lnj.li> (CC BY-SA 4.0):
data/images/fallback-avatar.svg

Copyright (C) 2016 MBB <mbb-mail@gmx.de> (CC BY-SA 4.0):
data/images/banner.png

Expand Down
1 change: 1 addition & 0 deletions kaidan_qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<file alias="qml/ChatPage.qml">src/qml/ChatPage.qml</file>
<file alias="qml/AboutPage.qml">src/qml/AboutPage.qml</file>
<file alias="qml/GlobalDrawer.qml">src/qml/GlobalDrawer.qml</file>
<file alias="qml/elements/RosterListItem.qml">src/qml/elements/RosterListItem.qml</file>

<file alias="qtquickcontrols2.conf">misc/qtquickcontrols2.conf</file>
</qresource>
Expand Down
63 changes: 4 additions & 59 deletions src/qml/RosterPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

import QtQuick 2.0
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.0 as Controls
import org.kde.kirigami 2.0 as Kirigami
import "elements"

Kirigami.ScrollablePage {
title: qsTr("Contacts")
Expand All @@ -35,66 +37,8 @@ Kirigami.ScrollablePage {

ListView {
verticalLayoutDirection: ListView.TopToBottom

model: kaidan.rosterModel

delegate: Kirigami.SwipeListItem {
id: listItem
height: Kirigami.Units.gridUnit * 2.5

RowLayout {
Kirigami.Label {
Layout.fillWidth: true
// use the Name or JID
text: model.name ? model.name : model.jid
}

Rectangle {
id: counterCircle
visible: model.unreadMessages > 0
Layout.preferredHeight: Kirigami.Units.gridUnit * 1.25
Layout.preferredWidth: Kirigami.Units.gridUnit * 1.25
radius: counterCircle.height * 0.5
color: "#4CAF50"

Text {
id: msgCounter
text: model.unreadMessages
color: "white"
anchors.centerIn: parent
}
}

// placeholder
Item {
width: Kirigami.Units.gridUnit * 2
}
}

onClicked: {
// first push the chat page
pageStack.push(chatPage, {
"chatName": (model.name ? model.name : model.jid),
"recipientJid": model.jid
});

// then set the message filter for this jid
// this will update the unread message count,
// which will update the roster and will reset the
// model variable
kaidan.chatPartner = model.jid;
}

actions: [
Kirigami.Action {
iconName: "bookmark-remove"
onTriggered: {
removeContactSheet.jid = model.jid;
removeContactSheet.open();
}
}
]
}
delegate: RosterListItem {}
}

Component.onCompleted: {
Expand All @@ -104,6 +48,7 @@ Kirigami.ScrollablePage {
function disconnectOpenAddContactSheet() {
addContactDialogRequested.disconnect(openAddContactSheet);
}

// open sheet when requested from drawer over signal
addContactDialogRequested.connect(openAddContactSheet);
// disconnect the open function, when the roster page is closed
Expand Down
105 changes: 105 additions & 0 deletions src/qml/elements/RosterListItem.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Kaidan - A user-friendly XMPP client for every device!
*
* Copyright (C) 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 QtQml 2.0
import QtQuick 2.0
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.0 as Controls
import org.kde.kirigami 2.0 as Kirigami

Kirigami.SwipeListItem {
id: listItem
topPadding: Kirigami.Units.smallSpacing * 1.5
height: Kirigami.Units.gridUnit * 3.5

RowLayout {
spacing: Kirigami.Units.gridUnit * 0.5

// left side: Avatar
Image {
source: kaidan.getResourcePath("images/fallback-avatar.svg")
fillMode: Image.PreserveAspectFit
Layout.preferredHeight: parent.height
Layout.preferredWidth: parent.height
}
// right side
ColumnLayout {
// top
RowLayout {
// contact name
Kirigami.Heading {
// use the Name or JID
text: model.name ? model.name : model.jid
level: 3
Layout.fillWidth: true
}
// unread message counter
Rectangle {
id: counterCircle
visible: model.unreadMessages > 0
Layout.preferredHeight: Kirigami.Units.gridUnit * 1.25
Layout.preferredWidth: Kirigami.Units.gridUnit * 1.25
radius: counterCircle.height * 0.5
color: "#4CAF50"

Text {
id: msgCounter
text: model.unreadMessages
color: "white"
anchors.centerIn: parent
}
}
}
// bottom
Kirigami.Label {
Layout.fillWidth: true
text: model.lastMessage
}
}

// placeholder
Item {
width: Kirigami.Units.gridUnit * 2.5
}
}

onClicked: {
// first push the chat page
pageStack.push(chatPage, {
"chatName": (model.name ? model.name : model.jid),
"recipientJid": model.jid
});

// then set the message filter for this jid
// this will update the unread message count,
// which will update the roster and will reset the
// model variable
kaidan.chatPartner = model.jid;
}

actions: [
Kirigami.Action {
iconName: "bookmark-remove"
onTriggered: {
removeContactSheet.jid = model.jid;
removeContactSheet.open();
}
}
]
}

0 comments on commit f010784

Please sign in to comment.