Don't show the landing page when there is an active user
This commit is contained in:
parent
9772f52876
commit
0237fec90c
@ -60,6 +60,8 @@ private slots:
|
|||||||
void removeOverlayProgressBar();
|
void removeOverlayProgressBar();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool hasActiveUser();
|
||||||
|
|
||||||
// The initial welcome screen.
|
// The initial welcome screen.
|
||||||
WelcomePage *welcome_page_;
|
WelcomePage *welcome_page_;
|
||||||
|
|
||||||
|
@ -81,6 +81,16 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
SIGNAL(loginSuccess(QString, QString, QString)),
|
SIGNAL(loginSuccess(QString, QString, QString)),
|
||||||
this,
|
this,
|
||||||
SLOT(showChatPage(QString, QString, QString)));
|
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()
|
void MainWindow::removeOverlayProgressBar()
|
||||||
@ -114,7 +124,15 @@ void MainWindow::showChatPage(QString userid, QString homeserver, QString token)
|
|||||||
settings.setValue("auth/user_id", userid);
|
settings.setValue("auth/user_id", userid);
|
||||||
|
|
||||||
int index = sliding_stack_->getWidgetIndex(chat_page_);
|
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) {
|
if (spinner_ == nullptr) {
|
||||||
spinner_ = new CircularProgress(this);
|
spinner_ = new CircularProgress(this);
|
||||||
@ -125,7 +143,7 @@ void MainWindow::showChatPage(QString userid, QString homeserver, QString token)
|
|||||||
if (progress_modal_ == nullptr) {
|
if (progress_modal_ == nullptr) {
|
||||||
progress_modal_ = new OverlayModal(this, spinner_);
|
progress_modal_ = new OverlayModal(this, spinner_);
|
||||||
progress_modal_->fadeIn();
|
progress_modal_->fadeIn();
|
||||||
progress_modal_->setDuration(300);
|
progress_modal_->setDuration(modalOpacityDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
login_page_->reset();
|
login_page_->reset();
|
||||||
@ -144,20 +162,6 @@ void MainWindow::showWelcomePage()
|
|||||||
|
|
||||||
void MainWindow::showLoginPage()
|
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_);
|
int index = sliding_stack_->getWidgetIndex(login_page_);
|
||||||
sliding_stack_->slideInIndex(index, SlidingStackWidget::AnimationDirection::LEFT_TO_RIGHT);
|
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()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user