Immediately display connect errors in the login page
This is using a Kirigami.InlineMessage component.
This commit is contained in:
@@ -19,6 +19,16 @@ Kirigami.ScrollablePage {
|
||||
|
||||
title: i18n("Login")
|
||||
|
||||
header: QQC2.Control {
|
||||
padding: Kirigami.Units.smallSpacing
|
||||
contentItem: Kirigami.InlineMessage {
|
||||
id: inlineMessage
|
||||
type: Kirigami.MessageType.Error
|
||||
visible: false
|
||||
showCloseButton: true
|
||||
}
|
||||
}
|
||||
|
||||
Kirigami.FormLayout {
|
||||
id: formLayout
|
||||
QQC2.TextField {
|
||||
@@ -51,6 +61,18 @@ Kirigami.ScrollablePage {
|
||||
text: i18n("Login")
|
||||
onClicked: doLogin()
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: Controller
|
||||
onErrorOccured: {
|
||||
if (detail.length !== 0) {
|
||||
inlineMessage.text = i18n("%1: %2", error, detail);
|
||||
} else {
|
||||
inlineMessage.text = error;
|
||||
}
|
||||
inlineMessage.visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function doLogin() {
|
||||
|
||||
@@ -151,7 +151,7 @@ Kirigami.ApplicationWindow {
|
||||
pageStack.replace("qrc:/imports/NeoChat/Page/LoginPage.qml")
|
||||
}
|
||||
|
||||
onErrorOccured: showPassiveNotification(error + ": " + detail)
|
||||
onGlobalErrorOccured: showPassiveNotification(error + ": " + detail)
|
||||
}
|
||||
|
||||
RoomListModel {
|
||||
|
||||
@@ -117,17 +117,16 @@ void Controller::loginWithCredentials(QString serverAddr, QString user, QString
|
||||
setActiveConnection(finalConn);
|
||||
});
|
||||
connect(finalConn, &Connection::networkError, [=](QString error, QString, int, int) {
|
||||
Q_EMIT errorOccured(i18n("Network Error"), error);
|
||||
Q_EMIT globalErrorOccured(i18n("Network Error"), error);
|
||||
});
|
||||
connect(finalConn, &Connection::loginError, [=](QString error, QString) {
|
||||
Q_EMIT errorOccured(i18n("Login Failed"), error);
|
||||
});
|
||||
} else {
|
||||
Q_EMIT errorOccured(i18n("Error connecting to server"), "");
|
||||
}
|
||||
});
|
||||
connect(conn, &Connection::networkError, this, [=](QString error, QString, int, int) {
|
||||
Q_EMIT errorOccured(i18n("Network Error"), error);
|
||||
connect(job, &BaseJob::retryScheduled, this, [=](int, Quotient::BaseJob::duration_ms_t) {
|
||||
Q_EMIT errorOccured(i18n("%1 is not a matrix server or is unreachable", serverUrl.toString()), QString());
|
||||
job->abandon();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,11 @@ private Q_SLOTS:
|
||||
|
||||
Q_SIGNALS:
|
||||
void busyChanged();
|
||||
/// Error occured because of user inputs
|
||||
void errorOccured(QString error, QString detail);
|
||||
|
||||
/// Error occured because of server or bug in NeoChat
|
||||
void globalErrorOccured(QString error, QString detail);
|
||||
void syncDone();
|
||||
void connectionAdded(Quotient::Connection *conn);
|
||||
void connectionDropped(Quotient::Connection *conn);
|
||||
|
||||
Reference in New Issue
Block a user