Commit 8e467bd4 authored by Ming Rui Zhang's avatar Ming Rui Zhang Committed by Andreas Traczyk

newwizardwidget: don't show password entry by default

- add a checkbox to control the collapsoble area, once the checkbox is selected,
  the password and confirm password dialog will be shown, to enable the user to
  select a password

Change-Id: I0f3a3ceacd848ce7d69df03647ee2308bc07160c
parent bceb3f15
/**************************************************************************
* Copyright (C) 2015-2019 by Savoir-faire Linux *
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#include "collapsiblepasswordwidget.h"
#include "ui_collapsiblepasswordwidget.h"
CollapsiblePasswordWidget::CollapsiblePasswordWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::CollapsiblePasswordWidget)
{
ui->setupUi(this);
}
CollapsiblePasswordWidget::~CollapsiblePasswordWidget()
{
delete ui;
}
QLineEdit*
CollapsiblePasswordWidget::getPasswordEdit()
{
return ui->passwordEdit;
}
QLineEdit*
CollapsiblePasswordWidget::getConfirmPasswordEdit()
{
return ui->confirmPasswordEdit;
}
QLabel*
CollapsiblePasswordWidget::getPasswordStatusLabel()
{
return ui->passwordStatusLabel;
}
/**************************************************************************
* Copyright (C) 2015-2019 by Savoir-faire Linux *
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#pragma once
// qt
#include <QWidget>
#include <QLineEdit>
#include <QLabel>
namespace Ui
{
class CollapsiblePasswordWidget;
}
class CollapsiblePasswordWidget : public QWidget
{
Q_OBJECT
public:
explicit CollapsiblePasswordWidget(QWidget *parent = nullptr);
~CollapsiblePasswordWidget();
QLineEdit* getPasswordEdit();
QLineEdit* getConfirmPasswordEdit();
QLabel* getPasswordStatusLabel();
private:
Ui::CollapsiblePasswordWidget *ui;
};
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CollapsiblePasswordWidget</class>
<widget class="QWidget" name="CollapsiblePasswordWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>316</width>
<height>71</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>316</width>
<height>71</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLineEdit" name="confirmPasswordEdit">
<property name="minimumSize">
<size>
<width>261</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="toolTip">
<string>Password confirmation text input</string>
</property>
<property name="accessibleName">
<string/>
</property>
<property name="accessibleDescription">
<string>Password confirmation text input</string>
</property>
<property name="echoMode">
<enum>QLineEdit::PasswordEchoOnEdit</enum>
</property>
<property name="placeholderText">
<string>Confirm password</string>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLineEdit" name="passwordEdit">
<property name="minimumSize">
<size>
<width>261</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="toolTip">
<string>Password text input</string>
</property>
<property name="accessibleName">
<string/>
</property>
<property name="accessibleDescription">
<string>Password text entry</string>
</property>
<property name="echoMode">
<enum>QLineEdit::PasswordEchoOnEdit</enum>
</property>
<property name="placeholderText">
<string>Password</string>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>7</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="passwordStatusLabel">
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -79,6 +79,8 @@ HEADERS += ./aboutdialog.h \
./rendermanager.h \
./distantwidget.h \
./videowidgetbase.h \
./section.h \
./collapsiblepasswordwidget.h \
./notifypushbutton.h
SOURCES += ./aboutdialog.cpp \
./banneditemwidget.cpp \
......@@ -140,6 +142,8 @@ SOURCES += ./aboutdialog.cpp \
./rendermanager.cpp \
./distantwidget.cpp \
./videowidgetbase.cpp \
./section.cpp \
./collapsiblepasswordwidget.cpp \
./notifypushbutton.cpp
FORMS += ./aboutdialog.ui \
./advancedsipsettingwidget.ui \
......@@ -165,5 +169,7 @@ FORMS += ./aboutdialog.ui \
./videoview.ui \
./sipkeypad.ui \
./callaudioonlyavataroverlay.ui \
./accountmigration.ui
./accountmigration.ui \
./section.ui \
./collapsiblepasswordwidget.ui
RESOURCES += ressources.qrc
......@@ -63,11 +63,15 @@ NewWizardWidget::NewWizardWidget(QWidget* parent) :
statusInvalidPixmap_ = Utils::generateTintedPixmap(":/images/icons/baseline-error_outline-24px.svg", RingTheme::urgentOrange_);
statusErrorPixmap_ = Utils::generateTintedPixmap(":/images/icons/baseline-close-24px.svg", RingTheme::red_);
ui->infoWidget->hide();
setNavBarVisibility(false, true);
lookupTimer_.setSingleShot(true);
collapsiblePasswordWidget_ = new CollapsiblePasswordWidget(this);
collapsiblePasswordWidget_->setParent(ui->expandablePasswordWidget);
ui->expandablePasswordWidget->setLabelText("Choose a password for enchanced security");
ui->expandablePasswordWidget->addExpandWidget(collapsiblePasswordWidget_);
connect(ui->fileImportBtn, &QPushButton::clicked,
[this] {
QString filePath;
......@@ -93,7 +97,7 @@ NewWizardWidget::NewWizardWidget(QWidget* parent) :
emit NavigationRequested(ScreenEnum::CallScreen);
});
connect(ui->confirmPasswordEdit, &QLineEdit::textChanged,
connect(collapsiblePasswordWidget_->getConfirmPasswordEdit(), &QLineEdit::textChanged,
[this] {
validateWizardProgression();
});
......@@ -126,18 +130,6 @@ NewWizardWidget::~NewWizardWidget()
delete ui;
}
void
NewWizardWidget::setToMigrate(AccountInfo* toBeMigrated)
{
wizardMode_ = WizardMode::MIGRATE;
changePage(ui->createAccountPage);
ui->usernameEdit->setEnabled(false);
ui->usernameEdit->setText(QString::fromStdString(toBeMigrated->profileInfo.alias));
ui->previousButton->hide();
ui->infoWidget->show();
ui->infoLabel->setText(tr("Your account needs to be migrated. Enter your password."));
}
void
NewWizardWidget::updateNameRegistrationUi(NameRegistrationUIState state)
{
......@@ -222,13 +214,13 @@ void NewWizardWidget::changePage(QWidget* toPage)
fileToImport_ = QString("");
setNavBarVisibility(false, true);
ui->lookupStatusLabel->hide();
ui->passwordStatusLabel->hide();
collapsiblePasswordWidget_->getPasswordStatusLabel()->hide();
ui->newSIPAccountButton->hide();
ui->connectAccountManagerButton->hide();
} else if (toPage == ui->createAccountPage) {
ui->usernameEdit->clear();
ui->passwordEdit->clear();
ui->confirmPasswordEdit->clear();
collapsiblePasswordWidget_->getPasswordEdit()->clear();
collapsiblePasswordWidget_->getConfirmPasswordEdit()->clear();
ui->signUpCheckbox->setChecked(true);
ui->usernameEdit->setEnabled(true);
ui->fullNameEdit->setText(QString());
......@@ -256,7 +248,7 @@ void NewWizardWidget::changePage(QWidget* toPage)
ui->pinInfoLabel->hide();
} else if (toPage == ui->spinnerPage) {
ui->lookupStatusLabel->hide();
ui->passwordStatusLabel->hide();
collapsiblePasswordWidget_->getPasswordStatusLabel()->hide();
} else if (toPage == ui->connectToAccountManagerPage) {
setNavBarVisibility(true);
ui->usernameManagerEdit->clear();
......@@ -321,7 +313,7 @@ NewWizardWidget::on_previousButton_clicked()
if (curWidget == ui->createSIPAccountPage) { ui->setSIPAvatarWidget->stopBooth(); }
disconnect(registeredNameFoundConnection_);
ui->lookupStatusLabel->hide();
ui->passwordStatusLabel->hide();
collapsiblePasswordWidget_->getPasswordStatusLabel()->hide();
if (curWidget == ui->createAccountPage ||
curWidget == ui->importFromDevicePage ||
curWidget == ui->createSIPAccountPage ||
......@@ -481,15 +473,16 @@ NewWizardWidget::validateWizardProgression()
!registeredName_.isEmpty() &&
(registeredName_ == ui->usernameEdit->text()) &&
registrationStateOk_ == true);
bool passwordOk = ui->passwordEdit->text() == ui->confirmPasswordEdit->text();
if (passwordOk && !ui->passwordEdit->text().isEmpty()) {
ui->passwordStatusLabel->show();
ui->passwordStatusLabel->setPixmap(statusSuccessPixmap_);
bool passwordOk = collapsiblePasswordWidget_->getPasswordEdit()->text()
== collapsiblePasswordWidget_->getConfirmPasswordEdit()->text();
if (passwordOk && !collapsiblePasswordWidget_->getPasswordEdit()->text().isEmpty()) {
collapsiblePasswordWidget_->getPasswordStatusLabel()->show();
collapsiblePasswordWidget_->getPasswordStatusLabel()->setPixmap(statusSuccessPixmap_);
} else if (!passwordOk) {
ui->passwordStatusLabel->show();
ui->passwordStatusLabel->setPixmap(statusErrorPixmap_);
collapsiblePasswordWidget_->getPasswordStatusLabel()->show();
collapsiblePasswordWidget_->getPasswordStatusLabel()->setPixmap(statusErrorPixmap_);
} else {
ui->passwordStatusLabel->hide();
collapsiblePasswordWidget_->getPasswordStatusLabel()->hide();
}
ui->nextButton->setEnabled(usernameOk && passwordOk);
}
......@@ -502,10 +495,10 @@ NewWizardWidget::processWizardInformations()
case WizardMode::CREATE:
ui->progressLabel->setText(tr("Generating your Jami account..."));
inputPara_["alias"] = ui->fullNameEdit->text();
inputPara_["password"] = ui->passwordEdit->text();
inputPara_["password"] = collapsiblePasswordWidget_->getPasswordEdit()->text();
ui->fullNameEdit->clear();
ui->passwordEdit->clear();
ui->confirmPasswordEdit->clear();
collapsiblePasswordWidget_->getPasswordEdit()->clear();
collapsiblePasswordWidget_->getConfirmPasswordEdit()->clear();
break;
case WizardMode::IMPORT:
ui->progressLabel->setText(tr("Importing account archive..."));
......
......@@ -22,6 +22,7 @@
#include <QTimer>
#include <map>
#include "collapsiblepasswordwidget.h"
#include "lrcinstance.h"
#include "navwidget.h"
......@@ -50,8 +51,6 @@ public:
explicit NewWizardWidget(QWidget* parent = 0);
~NewWizardWidget();
void setToMigrate(AccountInfo* toBeMigrated);
// NavWidget
virtual void navigated(bool to);
virtual void updateCustomUI();
......@@ -105,6 +104,8 @@ private:
QString fileToImport_;
std::map<std::string, QString> inputPara_;
CollapsiblePasswordWidget* collapsiblePasswordWidget_;
void updateNameRegistrationUi(NameRegistrationUIState state);
void changePage(QWidget* toPage);
void setNavBarVisibility(bool visible, bool back=false);
......
This diff is collapsed.
This diff is collapsed.
......@@ -243,6 +243,12 @@
<ClCompile Include="distantwidget.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="section.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="collapsiblepasswordwidget.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="notifypushbutton.cpp">
<Filter>Source Files</Filter>
</ClCompile>
......@@ -431,6 +437,12 @@
<QtMoc Include="distantwidget.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="section.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="collapsiblepasswordwidget.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="notifypushbutton.h">
<Filter>Header Files</Filter>
</QtMoc>
......@@ -725,6 +737,12 @@
<QtUic Include="accountmigration.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="section.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="collapsiblepasswordwidget.ui">
<Filter>Form Files</Filter>
</QtUic>
</ItemGroup>
<ItemGroup>
<None Include="images\FontAwesome.otf">
......
/**************************************************************************
* Copyright (C) 2015-2019 by Savoir-faire Linux *
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#include "section.h"
#include "ui_section.h"
SectionWidget::SectionWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::SectionWidget)
{
ui->setupUi(this);
// let the entire widget grow and shrink with its content
animationGroup_.addAnimation(new QPropertyAnimation(this, "maximumHeight"));
animationGroup_.addAnimation(new QPropertyAnimation(this, "minimumHeight"));
connect(ui->expandCollapseCheckBox, &QCheckBox::stateChanged, this, &SectionWidget::expandCollapseButtonToggled);
connect(&animationGroup_, &QParallelAnimationGroup::finished,
[this] {
if (animationGroup_.direction() == QAbstractAnimation::Backward) {
currentExpandwidget_->hide();
}
});
}
SectionWidget::~SectionWidget()
{
delete ui;
}
void
SectionWidget::setLabelText(const QString& label)
{
ui->expandCollapseCheckBox->setText(label);
}
void
SectionWidget::addExpandWidget(QWidget *widget)
{
currentExpandwidget_ = widget;
ui->verticalLayout->addWidget(widget);
// section itself min = max, minimum expanding size policy, or preferred
// added widget minimum height should be 0, minimum expanding size policy
const auto collapsedHeight = minimumHeight();
auto contentHeight = widget->maximumHeight();
for (int i = 0; i < animationGroup_.animationCount() - 1; ++i) {
QPropertyAnimation * spoilerAnimation = static_cast<QPropertyAnimation *>(animationGroup_.animationAt(i));
spoilerAnimation->setDuration(animationDuration_);
spoilerAnimation->setStartValue(collapsedHeight);
spoilerAnimation->setEndValue(collapsedHeight + contentHeight);
}
// make sure that currentExpandwidget does not lay on the expandCollapseButton
currentExpandwidget_->hide();
}
void
SectionWidget::expandCollapseButtonToggled(bool state)
{
//QAbstractAnimation::Backward
//The current time of the animation decreases with time (i.e., moves from the end / duration and towards 0).
if (state) {
currentExpandwidget_->show();
}
animationGroup_.setDirection(state ? QAbstractAnimation::Forward : QAbstractAnimation::Backward);
animationGroup_.start();
}
/**************************************************************************
* Copyright (C) 2015-2019 by Savoir-faire Linux *
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#pragma once
// qt
#include <QWidget>
#include <QLabel>
#include <QPropertyAnimation>
#include <QParallelAnimationGroup>
namespace Ui
{
class SectionWidget;
}
class SectionWidget : public QWidget
{
Q_OBJECT
public:
explicit SectionWidget(QWidget *parent = nullptr);
~SectionWidget();
void setLabelText(const QString& label);
void addExpandWidget(QWidget *widget);
private:
Ui::SectionWidget *ui;
const int animationDuration_ = 200;
QParallelAnimationGroup animationGroup_;
QWidget* currentExpandwidget_;
private slots:
void expandCollapseButtonToggled(bool state);
};
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SectionWidget</class>
<widget class="QWidget" name="SectionWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>261</width>
<height>30</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>261</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>261</width>
<height>30</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="expandCollapseCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>261</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>261</width>
<height>30</height>
</size>
</property>
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="contextMenuPolicy">
<enum>Qt::DefaultContextMenu</enum>
</property>
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Section</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
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