diff --git a/include/ChatPage.h b/include/ChatPage.h
index 3a11f091..5d7d2806 100644
--- a/include/ChatPage.h
+++ b/include/ChatPage.h
@@ -77,6 +77,7 @@ signals:
void showNotification(const QString &msg);
void showLoginPage(const QString &msg);
void showUserSettingsPage();
+ void showOverlayProgressBar();
private slots:
void showUnreadMessageNotification(int count);
diff --git a/include/LoginPage.h b/include/LoginPage.h
index f3ea16a1..003f0ee2 100644
--- a/include/LoginPage.h
+++ b/include/LoginPage.h
@@ -40,6 +40,8 @@ public:
signals:
void backButtonClicked();
+ void loggingIn();
+ void errorOccured();
protected:
void paintEvent(QPaintEvent *event) override;
diff --git a/include/MainWindow.h b/include/MainWindow.h
index e4ffe2f4..54a4766d 100644
--- a/include/MainWindow.h
+++ b/include/MainWindow.h
@@ -59,7 +59,11 @@ private slots:
void iconActivated(QSystemTrayIcon::ActivationReason reason);
//! Show the welcome page in the main window.
- void showWelcomePage() { pageStack_->setCurrentWidget(welcome_page_); }
+ void showWelcomePage()
+ {
+ removeOverlayProgressBar();
+ pageStack_->setCurrentWidget(welcome_page_);
+ }
//! Show the login page in the main window.
void showLoginPage() { pageStack_->setCurrentWidget(login_page_); }
@@ -73,6 +77,7 @@ private slots:
//! Show the chat page and start communicating with the given access token.
void showChatPage(QString user_id, QString home_server, QString token);
+ void showOverlayProgressBar();
void removeOverlayProgressBar();
private:
diff --git a/src/ChatPage.cc b/src/ChatPage.cc
index a5e3a6f8..ace201eb 100644
--- a/src/ChatPage.cc
+++ b/src/ChatPage.cc
@@ -141,8 +141,11 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client,
typingRefresher_ = new QTimer(this);
typingRefresher_->setInterval(TYPING_REFRESH_TIMEOUT);
- connect(user_info_widget_, SIGNAL(logout()), client_.data(), SLOT(logout()));
- connect(client_.data(), SIGNAL(loggedOut()), this, SLOT(logout()));
+ connect(user_info_widget_, &UserInfoWidget::logout, this, [=]() {
+ client_->logout();
+ emit showOverlayProgressBar();
+ });
+ connect(client_.data(), &MatrixClient::loggedOut, this, &ChatPage::logout);
connect(top_bar_, &TopRoomBar::inviteUsers, this, [=](QStringList users) {
for (int ii = 0; ii < users.size(); ++ii) {
diff --git a/src/LoginPage.cc b/src/LoginPage.cc
index fca1ec68..a6cdb13c 100644
--- a/src/LoginPage.cc
+++ b/src/LoginPage.cc
@@ -141,6 +141,7 @@ LoginPage::LoginPage(QSharedPointer<MatrixClient> client, QWidget *parent)
connect(password_input_, SIGNAL(returnPressed()), login_button_, SLOT(click()));
connect(serverInput_, SIGNAL(returnPressed()), login_button_, SLOT(click()));
connect(client_.data(), SIGNAL(loginError(QString)), this, SLOT(loginError(QString)));
+ connect(client_.data(), SIGNAL(loginError(QString)), this, SIGNAL(errorOccured()));
connect(matrixid_input_, SIGNAL(editingFinished()), this, SLOT(onMatrixIdEntered()));
connect(client_.data(), SIGNAL(versionError(QString)), this, SLOT(versionError(QString)));
connect(client_.data(), SIGNAL(versionSuccess()), this, SLOT(versionSuccess()));
@@ -262,6 +263,7 @@ LoginPage::onLoginButtonClicked()
QString password = password_input_->text();
client_->setServer(serverInput_->text());
client_->login(user, password);
+ emit loggingIn();
}
}
diff --git a/src/MainWindow.cc b/src/MainWindow.cc
index 11df796c..98d758b2 100644
--- a/src/MainWindow.cc
+++ b/src/MainWindow.cc
@@ -76,10 +76,14 @@ MainWindow::MainWindow(QWidget *parent)
connect(welcome_page_, SIGNAL(userRegister()), this, SLOT(showRegisterPage()));
connect(login_page_, SIGNAL(backButtonClicked()), this, SLOT(showWelcomePage()));
+ connect(login_page_, &LoginPage::loggingIn, this, &MainWindow::showOverlayProgressBar);
+ connect(login_page_, &LoginPage::errorOccured, this, [=]() { removeOverlayProgressBar(); });
connect(register_page_, SIGNAL(backButtonClicked()), this, SLOT(showWelcomePage()));
connect(chat_page_, SIGNAL(close()), this, SLOT(showWelcomePage()));
connect(
+ chat_page_, &ChatPage::showOverlayProgressBar, this, &MainWindow::showOverlayProgressBar);
+ connect(
chat_page_, SIGNAL(changeWindowTitle(QString)), this, SLOT(setWindowTitle(QString)));
connect(chat_page_, SIGNAL(unreadMessages(int)), trayIcon_, SLOT(setUnreadCount(int)));
connect(chat_page_, &ChatPage::showLoginPage, this, [=](const QString &msg) {
@@ -191,32 +195,9 @@ MainWindow::showChatPage(QString userid, QString homeserver, QString token)
settings.setValue("auth/home_server", homeserver);
settings.setValue("auth/user_id", userid);
- int modalOpacityDuration = 300;
-
- // If we go directly from the welcome page don't show an animation.
- if (pageStack_->currentIndex() == 0)
- modalOpacityDuration = 0;
+ showOverlayProgressBar();
- QTimer::singleShot(
- modalOpacityDuration + 100, this, [=]() { pageStack_->setCurrentWidget(chat_page_); });
-
- if (spinner_.isNull()) {
- spinner_ = QSharedPointer<LoadingIndicator>(
- new LoadingIndicator(this),
- [=](LoadingIndicator *indicator) { indicator->deleteLater(); });
- spinner_->setFixedHeight(100);
- spinner_->setFixedWidth(100);
- spinner_->setObjectName("ChatPageLoadSpinner");
- spinner_->start();
- }
-
- if (progressModal_.isNull()) {
- progressModal_ =
- QSharedPointer<OverlayModal>(new OverlayModal(this, spinner_.data()),
- [=](OverlayModal *modal) { modal->deleteLater(); });
- progressModal_->setDismissible(false);
- progressModal_->show();
- }
+ QTimer::singleShot(100, this, [=]() { pageStack_->setCurrentWidget(chat_page_); });
login_page_->reset();
chat_page_->bootstrap(userid, homeserver, token);
@@ -282,3 +263,25 @@ MainWindow::openLeaveRoomDialog(const QString &room_id)
leaveRoomModal_->show();
}
+
+void
+MainWindow::showOverlayProgressBar()
+{
+ if (spinner_.isNull()) {
+ spinner_ = QSharedPointer<LoadingIndicator>(
+ new LoadingIndicator(this),
+ [=](LoadingIndicator *indicator) { indicator->deleteLater(); });
+ spinner_->setFixedHeight(100);
+ spinner_->setFixedWidth(100);
+ spinner_->setObjectName("ChatPageLoadSpinner");
+ spinner_->start();
+ }
+
+ if (progressModal_.isNull()) {
+ progressModal_ =
+ QSharedPointer<OverlayModal>(new OverlayModal(this, spinner_.data()),
+ [=](OverlayModal *modal) { modal->deleteLater(); });
+ progressModal_->setDismissible(false);
+ progressModal_->show();
+ }
+}
|