Skip to content

Commit

Permalink
Use Kirigami.OverlaySheet instead of new Page
Browse files Browse the repository at this point in the history
  • Loading branch information
LNJ committed Mar 11, 2017
1 parent e4d8611 commit b91e7f9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 37 deletions.
8 changes: 8 additions & 0 deletions src/qml/GlobalDrawer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ Kirigami.GlobalDrawer {
handleVisible: true

actions: [
Kirigami.Action {
text: qsTr("Add Contact")
iconName: "contact-new"
onTriggered: {
console.log("Hello opening contact sheet 1");
applicationWindow().addContactDialogRequested();
}
},
Kirigami.Action {
text: qsTr("Logout")
iconName: "system-shutdown"
Expand Down
24 changes: 9 additions & 15 deletions src/qml/AddContactPage.qml → src/qml/RosterAddContactSheet.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Kaidan - Cross platform XMPP client
*
* Copyright (C) 2017 JBB <jbb.mail@gmx.de>
* 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
Expand All @@ -22,50 +23,43 @@ import QtQuick.Controls 2.0 as Controls
import QtQuick.Layouts 1.2
import org.kde.kirigami 1.0 as Kirigami

Kirigami.Page {
title: "Add Contact"

Kirigami.OverlaySheet {
Column {
width: parent.width

Kirigami.Heading {
text: qsTr("Add Contact")
}

Kirigami.Label {
text: qsTr("Name")
text: qsTr("Nickname:")
}

Controls.TextField {
id: nameField
id: nickField
selectByMouse: true
}

Kirigami.Label {
text: qsTr("Jabber ID")
text: qsTr("Jabber ID:")
}

Controls.TextField {
id: contactJidField
id: jidField
placeholderText: qsTr("user@example.org")
selectByMouse: true
}

Row {
Controls.Button {
text: qsTr("Cancel")
onClicked: pageStack.pop()
onClicked: close()
}

Controls.Button {
text: qsTr("Add")
enabled: contactJidField.length > 0
onClicked: {
kaidan.rosterController.addContact(contactJidField.text, nameField.text);
pageStack.pop();
kaidan.rosterController.addContact(jidField.text, nickField.text);
close();
}
}
}
}
}

18 changes: 16 additions & 2 deletions src/qml/RosterPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ import org.kde.kirigami 2.0 as Kirigami
import io.github.kaidanim 1.0

Kirigami.ScrollablePage {
id: rosterPage
title: qsTr("Contacts")

RosterAddContactSheet {
id: addContactSheet
}

ListView {
model: kaidan.rosterController.rosterModel

Expand All @@ -50,10 +53,21 @@ Kirigami.ScrollablePage {
Kirigami.Action {
iconName: "bookmark-remove"
onTriggered: {
kaidan.rosterController.removeContact(model.jid)
kaidan.rosterController.removeContact(model.jid);
}
}
]
}
}

Component.onCompleted: {
function openAddContactSheet() { addContactSheet.open(); }
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
connectionStateDisconnected.connect(disconnectOpenAddContactSheet);
}
}
23 changes: 3 additions & 20 deletions src/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,14 @@ Kirigami.ApplicationWindow {
width: 960
height: 540

// signals
signal addContactDialogRequested()

header: Kirigami.ToolBarApplicationHeader {
preferredHeight: Kirigami.Units.gridUnit * 2.25
}

<<<<<<< HEAD
globalDrawer: GlobalDrawer {}
=======
actions: [
Kirigami.Action {
text: qsTr("Add Contact")
iconName: "contact-new"
onTriggered: {
// prevent opening the page multiple times
pageStack.pop(rosterPage);
// open page
pageStack.push(addContactPage);
}
},
Kirigami.Action {
text: qsTr("Logout")
iconName: "system-shutdown"
onTriggered: {
kaidan.mainDisconnect();
>>>>>>> Add support for adding new contacts from the gui

// when the window was closed, disconnect from jabber server
onClosing: {
Expand All @@ -64,7 +48,6 @@ Kirigami.ApplicationWindow {
Component {id: loginPage; LoginPage {}}
Component {id: rosterPage; RosterPage {}}
Component {id: aboutPage; AboutPage {}}
Component {id: addContactPage; AddContactPage {}}

Component.onCompleted: {
function openLoginPage() {
Expand Down

0 comments on commit b91e7f9

Please sign in to comment.