Commit 405b5a3c authored by JBBgameich's avatar JBBgameich Committed by Linus Jahn

Add global Kirigami drawer with banner

Currently you can only logout with this banner, but other actions
can be added later.

kaidan.getResourcePath() now returns a "file://"-path.

Closes #25.
parent 09a91e9c
......@@ -143,9 +143,9 @@ if(UNIX AND NOT APPLE)
)
# install kaidan media
# install(DIRECTORY "data/images"
# DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}"
# )
install(DIRECTORY "data/images"
DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}"
)
# install icon (scalable + 128x)
install(FILES "misc/kaidan.svg"
......
......@@ -208,7 +208,7 @@ QString Kaidan::getResourcePath(QString name_)
if (directory.exists(name_))
{
// found the file, return the path
return directory.absoluteFilePath(name_);
return QString("file://") + directory.absoluteFilePath(name_);
}
}
......
......@@ -65,9 +65,10 @@ Kirigami.ScrollablePage {
onClicked: {
// disable the button
connectButton.enabled = false;
// connect to given account data
// indicate that we're connecting now
connectButton.text = "<i>" + qsTr("Connecting...") + "</i>";
// connect to given account data
kaidan.jid = jidField.text;
kaidan.password = passField.text;
kaidan.mainConnect();
......@@ -76,9 +77,12 @@ Kirigami.ScrollablePage {
}
Component.onCompleted: {
function goToRoster() {
function openRosterPage() {
// we need to disconnect enableConnectButton to prevent calling it on normal disconnection
kaidan.connectionStateDisconnected.disconnect(enableConnectButton);
// reenable the controls
controlsVisible = true;
// open the roster page
pageStack.replace(rosterPage);
}
......@@ -90,7 +94,10 @@ Kirigami.ScrollablePage {
}
// connect functions to back-end events
kaidan.connectionStateConnected.connect(goToRoster);
kaidan.connectionStateConnected.connect(openRosterPage);
kaidan.connectionStateDisconnected.connect(enableConnectButton);
// disable the controls (this also makes the drawer invisible)
controlsVisible = false;
}
}
......@@ -26,6 +26,32 @@ Kirigami.ApplicationWindow {
width: 960
height: 540
globalDrawer: Kirigami.GlobalDrawer {
id: globalDrawer
title: "Kaidan"
titleIcon: "kaidan"
bannerImageSource: kaidan.getResourcePath("images/banner.png");
// make drawer floating (overlay)
modal: true
opened: false //drawerOpen: false // Kirigami2
actions: [
Kirigami.Action {
text: "Logout"
iconName: "system-shutdown"
onTriggered: {
kaidan.mainDisconnect();
// close all pages
pageStack.pop(undefined);
// open login page
pageStack.push(loginPage);
}
}
]
}
// load all pages
Component {id: chatPage; ChatPage {}}
Component {id: loginPage; LoginPage {}}
......@@ -38,14 +64,16 @@ Kirigami.ApplicationWindow {
Component.onCompleted: {
function openLoginPage() {
// disconnect this func; the login page will do that
// disconnect this func; the login page will do that now
kaidan.connectionStateDisconnected.disconnect(openLoginPage);
// close all pages
pageStack.pop(undefined);
// open login page
pageStack.pop(); // pop all pages
pageStack.push(loginPage, {"isRetry": true});
}
if (kaidan.newLoginNeeded()) {
// open login page and get new data from user
pageStack.push(loginPage);
......
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