summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-02-18 22:22:26 +0200
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-02-18 22:22:26 +0200
commitc8bfb02211f93ec41f6d39edab5cf3298ed069ab (patch)
treede27aaec13be938be47ef272095ef222511f2cbf /src
parentProperly detect the start of the timeline (diff)
downloadnheko-c8bfb02211f93ec41f6d39edab5cf3298ed069ab.tar.xz
Show loading indicator while waiting for /login & /logout
fixes #208
Diffstat (limited to 'src')
-rw-r--r--src/ChatPage.cc7
-rw-r--r--src/LoginPage.cc2
-rw-r--r--src/MainWindow.cc53
3 files changed, 35 insertions, 27 deletions
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(); + } +}