Commit 3ad36ed9 authored by Elvis Angelaccio's avatar Elvis Angelaccio

Disable create form while creating new accounts

When adding a new account in the KCM, it can take a while from the click
on the provider's button to the moment the window is presented to the user.
For example this happens with Google accounts, since we need to wait for
webkit plus the authentication page from Google.

To be sure that the users don't click twice the buttons while they are
waiting, disable the whole form and re-enable it later when the
authentication is done.

Reviewers: mck182

Differential Revision: https://phabricator.kde.org/D5727
parent 3b3842d1
......@@ -53,6 +53,7 @@ QWidget* Create::widget()
QWidget *widget = new QWidget(m_parent);
m_form->setupUi(widget);
m_form->progressBar->hide();
QMetaObject::invokeMethod(this, "fillInterface", Qt::QueuedConnection);
......@@ -108,11 +109,15 @@ void Create::fillInterface()
void Create::createAccount()
{
m_form->progressBar->show();
m_form->scrollAreaWidgetContents->setEnabled(false);
QString providerName = sender()->property("providerName").toString();
qDebug() << "Starting new account dialog for" << providerName;
CreateAccount *acc = new CreateAccount(providerName, this);
connect(acc, &CreateAccount::finished, [=](KJob *job) {
connect(acc, &CreateAccount::finished, this, [=](KJob *job) {
m_form->progressBar->hide();
m_form->scrollAreaWidgetContents->setEnabled(true);
if (job->error() == KJob::UserDefinedError) {
QMessageBox::critical(m_parent, i18nc("Messagebox title; meaning 'Unable to finish the action you started'", "Unable to finish"), job->errorText());
}
......
......@@ -2,7 +2,15 @@
<ui version="4.0">
<class>createForm</class>
<widget class="QWidget" name="createForm">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>354</width>
<height>92</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="frameShape">
......@@ -18,6 +26,14 @@
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>342</width>
<height>48</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
......@@ -66,6 +82,16 @@
</widget>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="maximum">
<number>0</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment