Commit 672b11fb authored by Linus Jahn's avatar Linus Jahn Committed by Jonah Brüchert

Use passive notifications when online actions fail

This will throw a Kirigami passive notification, whenever you try to add or
remove a contact or send a message when being offline. It uses the "long" preset
for the timeout.
parent 855bc84f
......@@ -190,29 +190,32 @@ quint8 Kaidan::getDisconnReason() const
void Kaidan::sendMessage(QString jid, QString message)
{
// TODO: Add offline message cache
if (client->isConnected())
if (client->isConnected()) {
emit client->sendMessageRequested(jid, message);
else
qWarning() << "[main] Couldn't send message, because not being connected.";
} else {
emit passiveNotificationRequested(tr("Could not send message, because not being connected."));
qWarning() << "[main] Could not send message, because not being connected.";
}
}
void Kaidan::addContact(QString jid, QString nick)
{
// TODO: Add an error notification/message if not connected
if (client->isConnected())
if (client->isConnected()) {
emit client->addContactRequested(jid, nick);
else
qWarning() << "[main] Couldn't add contact, because not being connected.";
} else {
emit passiveNotificationRequested(tr("Could not add contact, because not being connected."));
qWarning() << "[main] Could not add contact, because not being connected.";
}
}
void Kaidan::removeContact(QString jid)
{
// TODO: Add an error notification/message if not connected
if (client->isConnected())
if (client->isConnected()) {
emit client->removeContactRequested(jid);
else
qWarning() << "[main] Couldn't remove contact, because not being connected.";
} else {
emit passiveNotificationRequested(tr("Could not remove contact, because not being connected."));
qWarning() << "[main] Could not remove contact, because not being connected.";
}
}
QString Kaidan::getResourcePath(QString name) const
......
......@@ -303,6 +303,11 @@ signals:
*/
void logInWorked();
/**
* Show passive notification
*/
void passiveNotificationRequested(QString text);
private:
void connectDatabases();
......
......@@ -71,6 +71,10 @@ Kirigami.ApplicationWindow {
Component {id: loginPage; LoginPage {}}
Component {id: rosterPage; RosterPage {}}
function passiveNotification(text) {
showPassiveNotification(text, "long")
}
function openLogInPage() {
// close all pages (we don't know on which page we're on,
// thus we don't use replace)
......@@ -93,8 +97,9 @@ Kirigami.ApplicationWindow {
}
Component.onCompleted: {
kaidan.newCredentialsNeeded.connect(openLogInPage);
kaidan.logInWorked.connect(closeLogInPage);
kaidan.passiveNotificationRequested.connect(passiveNotification)
kaidan.newCredentialsNeeded.connect(openLogInPage)
kaidan.logInWorked.connect(closeLogInPage)
// push roster page (trying normal start up)
pageStack.push(rosterPage)
......
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