summary refs log tree commit diff
path: root/src/MainWindow.cc
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-05-22 18:03:37 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-05-22 18:03:37 +0300
commit0237fec90c143df58becf3d411d29c5ee6878dd8 (patch)
treeb0b1030612f48a3dd0cb1415d25859cc3571e004 /src/MainWindow.cc
parentIncrease tray icon's bubble size (diff)
downloadnheko-0237fec90c143df58becf3d411d29c5ee6878dd8.tar.xz
Don't show the landing page when there is an active user
Diffstat (limited to 'src/MainWindow.cc')
-rw-r--r--src/MainWindow.cc45
1 files changed, 29 insertions, 16 deletions
diff --git a/src/MainWindow.cc b/src/MainWindow.cc
index 4f813c07..ce7ca206 100644
--- a/src/MainWindow.cc
+++ b/src/MainWindow.cc
@@ -81,6 +81,16 @@ MainWindow::MainWindow(QWidget *parent)
 		SIGNAL(loginSuccess(QString, QString, QString)),
 		this,
 		SLOT(showChatPage(QString, QString, QString)));
+
+	QSettings settings;
+
+	if (hasActiveUser()) {
+		QString token = settings.value("auth/access_token").toString();
+		QString home_server = settings.value("auth/home_server").toString();
+		QString user_id = settings.value("auth/user_id").toString();
+
+		showChatPage(user_id, home_server, token);
+	}
 }
 
 void MainWindow::removeOverlayProgressBar()
@@ -114,7 +124,15 @@ void MainWindow::showChatPage(QString userid, QString homeserver, QString token)
 	settings.setValue("auth/user_id", userid);
 
 	int index = sliding_stack_->getWidgetIndex(chat_page_);
-	sliding_stack_->slideInIndex(index, SlidingStackWidget::AnimationDirection::LEFT_TO_RIGHT);
+	int modalOpacityDuration = 300;
+
+	// If we go directly from the welcome page don't show an animation.
+	if (sliding_stack_->currentIndex() == 0) {
+		sliding_stack_->setCurrentIndex(index);
+		modalOpacityDuration = 0;
+	} else {
+		sliding_stack_->slideInIndex(index, SlidingStackWidget::AnimationDirection::LEFT_TO_RIGHT);
+	}
 
 	if (spinner_ == nullptr) {
 		spinner_ = new CircularProgress(this);
@@ -125,7 +143,7 @@ void MainWindow::showChatPage(QString userid, QString homeserver, QString token)
 	if (progress_modal_ == nullptr) {
 		progress_modal_ = new OverlayModal(this, spinner_);
 		progress_modal_->fadeIn();
-		progress_modal_->setDuration(300);
+		progress_modal_->setDuration(modalOpacityDuration);
 	}
 
 	login_page_->reset();
@@ -144,20 +162,6 @@ void MainWindow::showWelcomePage()
 
 void MainWindow::showLoginPage()
 {
-	QSettings settings;
-
-	if (settings.contains("auth/access_token") &&
-	    settings.contains("auth/home_server") &&
-	    settings.contains("auth/user_id")) {
-		QString token = settings.value("auth/access_token").toString();
-		QString home_server = settings.value("auth/home_server").toString();
-		QString user_id = settings.value("auth/user_id").toString();
-
-		showChatPage(user_id, home_server, token);
-
-		return;
-	}
-
 	int index = sliding_stack_->getWidgetIndex(login_page_);
 	sliding_stack_->slideInIndex(index, SlidingStackWidget::AnimationDirection::LEFT_TO_RIGHT);
 }
@@ -191,6 +195,15 @@ void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason)
 	}
 }
 
+bool MainWindow::hasActiveUser()
+{
+	QSettings settings;
+
+	return settings.contains("auth/access_token") &&
+	       settings.contains("auth/home_server") &&
+	       settings.contains("auth/user_id");
+}
+
 MainWindow::~MainWindow()
 {
 }