Commit 1a951c1b authored by Linus Jahn's avatar Linus Jahn Committed by Jonah Brüchert
Browse files

RosterPage: New design, Add fallback avatar (#118)

The new roster page displays the last message with the contact.
parent b31e70f5
......@@ -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
......
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<defs>
<clipPath id="a">
<path fill="#338000" d="M0 0h256v256H0z"/>
</clipPath>
</defs>
<path fill="#338000" d="M0 0h256v256H0z"/>
<path d="M99.3 130.8l57-84.8 113.5 113.5-9.2 132.6z" clip-path="url(#a)" fill="#000007" opacity=".3"/>
<path d="M173 88.4a45 54.4 0 0 1-45 54.5 45 54.4 0 0 1-45-55 45 54.4 0 0 1 45-54 45 54.4 0 0 1 45 54.3zm61 107.2a106 45 0 0 1-106 45 106 45 0 0 1-106-45 106 45 0 0 1 106-45 106 45 0 0 1 106 45z" fill="#55d400"/>
<path d="M22 195.3h212V256H22z" fill="#55d400"/>
</svg>
......@@ -8,6 +8,8 @@
<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="qml/elements/MessageCounter.qml">src/qml/elements/MessageCounter.qml</file>
<file alias="qtquickcontrols2.conf">misc/qtquickcontrols2.conf</file>
</qresource>
......
......@@ -310,3 +310,8 @@ QString Kaidan::getVersionString()
{
return QString(VERSION_STRING);
}
QString Kaidan::removeNewLinesFromString(QString input)
{
return input.simplified();
}
......@@ -62,6 +62,7 @@ public:
Q_INVOKABLE void removeContact(QString jid);
Q_INVOKABLE QString getResourcePath(QString);
Q_INVOKABLE QString getVersionString();
Q_INVOKABLE QString removeNewLinesFromString(QString input);
bool getConnectionState() const;
QString getJid();
......
......@@ -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")
......@@ -35,41 +37,11 @@ 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
}
}
delegate: RosterListItem {
name: model.name ? model.name : model.jid
lastMessage: model.lastMessage
unreadMessages: model.unreadMessages
onClicked: {
// first push the chat page
......@@ -104,6 +76,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
......
/*
* 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 QtQuick 2.0
Rectangle {
property int counter: 0
id: counterCircle
radius: counterCircle.height * 0.5
color: "#4CAF50"
Text {
id: msgCounter
text: counter
color: "white"
anchors.centerIn: parent
}
}
/*
* 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 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 {
property string name;
property string lastMessage;
property int unreadMessages;
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 {
text: name
level: 3
Layout.fillWidth: true
}
}
// bottom
Kirigami.Label {
Layout.fillWidth: true
text: kaidan.removeNewLinesFromString(lastMessage);
}
}
// unread message counter
MessageCounter {
visible: unreadMessages > 0
counter: unreadMessages
Layout.preferredHeight: Kirigami.Units.gridUnit * 1.25
Layout.preferredWidth: Kirigami.Units.gridUnit * 1.25
}
// placeholder
Item {
width: Kirigami.Units.gridUnit * 2.5
}
}
}
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