diff --git a/collapsiblepasswordwidget.cpp b/collapsiblepasswordwidget.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7486458827af883d4ffeb846d203615073743045 --- /dev/null +++ b/collapsiblepasswordwidget.cpp @@ -0,0 +1,50 @@ +/************************************************************************** +* 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; +} diff --git a/collapsiblepasswordwidget.h b/collapsiblepasswordwidget.h new file mode 100644 index 0000000000000000000000000000000000000000..6320775033e0028b3a99f0740090f00648809d56 --- /dev/null +++ b/collapsiblepasswordwidget.h @@ -0,0 +1,45 @@ +/************************************************************************** +* 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; +}; diff --git a/collapsiblepasswordwidget.ui b/collapsiblepasswordwidget.ui new file mode 100644 index 0000000000000000000000000000000000000000..4432952a55ab09559f4ae4879b289cb024746787 --- /dev/null +++ b/collapsiblepasswordwidget.ui @@ -0,0 +1,160 @@ +<?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> diff --git a/jami-qt.pro b/jami-qt.pro index d9e111a1a8109802b307892e28ef522fe1f90b82..abd11f049ceb84933e113bcd1dba61b4189cdb0a 100644 --- a/jami-qt.pro +++ b/jami-qt.pro @@ -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 diff --git a/newwizardwidget.cpp b/newwizardwidget.cpp index d9b76465b8507c5d2a89fe11772fb92342875189..e04f7b6636404e74ea4d5d745ec2cc9960d71646 100644 --- a/newwizardwidget.cpp +++ b/newwizardwidget.cpp @@ -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...")); diff --git a/newwizardwidget.h b/newwizardwidget.h index 8a83fc2519e272b8021bc1306ff3cb04236ba6b9..fa90ea685c1977a410248e30a8072b5fde997dc1 100644 --- a/newwizardwidget.h +++ b/newwizardwidget.h @@ -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); diff --git a/newwizardwidget.ui b/newwizardwidget.ui index d837a3619af9800cb2fd26872345b8da04c17fa0..5c03589b871dd3891923dec7efa6ea4d64d19f3f 100644 --- a/newwizardwidget.ui +++ b/newwizardwidget.ui @@ -611,6 +611,12 @@ <height>261</height> </size> </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>16777215</height> + </size> + </property> <property name="styleSheet"> <string notr="true"/> </property> @@ -624,12 +630,12 @@ <enum>Qt::Vertical</enum> </property> <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> + <enum>QSizePolicy::Minimum</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> - <height>6</height> + <height>3</height> </size> </property> </spacer> @@ -753,34 +759,16 @@ <enum>Qt::Vertical</enum> </property> <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> + <enum>QSizePolicy::Minimum</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> - <height>20</height> + <height>12</height> </size> </property> </spacer> </item> - <item> - <widget class="QLabel" name="accountSectionLabel"> - <property name="font"> - <font> - <pointsize>13</pointsize> - </font> - </property> - <property name="styleSheet"> - <string notr="true">color: rgb(63, 63, 63)</string> - </property> - <property name="text"> - <string>Account</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> <item> <widget class="QWidget" name="accountSectionInnerWidget" native="true"> <property name="styleSheet"> @@ -790,11 +778,17 @@ <property name="topMargin"> <number>0</number> </property> + <property name="bottomMargin"> + <number>0</number> + </property> <item> <layout class="QGridLayout" name="gridLayout_6"> <property name="topMargin"> <number>0</number> </property> + <property name="verticalSpacing"> + <number>3</number> + </property> <item row="1" column="0"> <widget class="QWidget" name="verticalWidget1" native="true"> <property name="sizePolicy"> @@ -822,7 +816,7 @@ <item> <layout class="QGridLayout" name="gridLayout_9"> <property name="topMargin"> - <number>10</number> + <number>0</number> </property> <property name="rightMargin"> <number>0</number> @@ -830,33 +824,89 @@ <property name="horizontalSpacing"> <number>0</number> </property> - <item row="1" column="0"> - <spacer name="horizontalSpacer_6"> + <property name="verticalSpacing"> + <number>5</number> + </property> + <item row="3" column="2"> + <layout class="QHBoxLayout" name="horizontalLayout_8"> + <item> + <spacer name="horizontalSpacer_2"> + <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="lookupStatusLabel"> + <property name="minimumSize"> + <size> + <width>30</width> + <height>30</height> + </size> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + <item row="2" column="2"> + <spacer name="horizontalSpacer_9"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> <property name="sizeHint" stdset="0"> <size> - <width>40</width> - <height>20</height> + <width>37</width> + <height>0</height> </size> </property> </spacer> </item> - <item row="3" column="0"> - <spacer name="horizontalSpacer_8"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> + <item row="0" column="1"> + <widget class="QLabel" name="accountSectionLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - <property name="sizeHint" stdset="0"> + <property name="maximumSize"> <size> - <width>40</width> - <height>20</height> + <width>16777215</width> + <height>30</height> </size> </property> - </spacer> + <property name="font"> + <font> + <pointsize>13</pointsize> + </font> + </property> + <property name="styleSheet"> + <string notr="true">color: rgb(63, 63, 63)</string> + </property> + <property name="text"> + <string>Account</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> </item> - <item row="2" column="0"> + <item row="4" column="0"> <spacer name="horizontalSpacer_7"> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -869,12 +919,18 @@ </property> </spacer> </item> - <item row="0" column="1"> + <item row="2" column="1"> <widget class="QCheckBox" name="signUpCheckbox"> <property name="minimumSize"> <size> <width>0</width> - <height>30</height> + <height>25</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>25</height> </size> </property> <property name="font"> @@ -903,7 +959,7 @@ instead of using your ID.</string> </widget> </item> <item row="3" column="1"> - <widget class="QWidget" name="confPassWidget" native="true"> + <widget class="QWidget" name="usernameWidget" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> <horstretch>0</horstretch> @@ -919,10 +975,10 @@ instead of using your ID.</string> <property name="maximumSize"> <size> <width>16777215</width> - <height>16777215</height> + <height>30</height> </size> </property> - <layout class="QHBoxLayout" name="confirmPassLabel"> + <layout class="QHBoxLayout" name="usernameLayout"> <property name="spacing"> <number>0</number> </property> @@ -939,7 +995,7 @@ instead of using your ID.</string> <number>0</number> </property> <item> - <widget class="QLineEdit" name="confirmPasswordEdit"> + <widget class="QLineEdit" name="usernameEdit"> <property name="minimumSize"> <size> <width>261</width> @@ -958,256 +1014,69 @@ instead of using your ID.</string> </font> </property> <property name="toolTip"> - <string>Password confirmation text input</string> + <string>Public username edit</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> + <string>Choose your username</string> </property> <property name="clearButtonEnabled"> - <bool>false</bool> + <bool>true</bool> </property> </widget> </item> </layout> </widget> </item> - <item row="2" column="1"> - <widget class="QWidget" name="passWidget" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>30</height> - </size> + <item row="3" column="0"> + <spacer name="horizontalSpacer_6"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> </property> - <property name="maximumSize"> + <property name="sizeHint" stdset="0"> <size> - <width>16777215</width> - <height>16777215</height> + <width>40</width> + <height>20</height> </size> </property> - <layout class="QHBoxLayout" name="passLayout"> - <property name="spacing"> - <number>0</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="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> - </layout> - </widget> + </spacer> </item> - <item row="1" column="1"> - <widget class="QWidget" name="usernameWidget" native="true"> + <item row="4" column="1"> + <widget class="SectionWidget" name="expandablePasswordWidget" native="true"> <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="minimumSize"> <size> - <width>0</width> + <width>261</width> <height>30</height> </size> </property> <property name="maximumSize"> <size> - <width>16777215</width> - <height>16777215</height> + <width>261</width> + <height>30</height> </size> </property> - <layout class="QHBoxLayout" name="usernameLayout"> - <property name="spacing"> - <number>0</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="QLineEdit" name="usernameEdit"> - <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>Public username edit</string> - </property> - <property name="accessibleName"> - <string/> - </property> - <property name="placeholderText"> - <string>Choose your username</string> - </property> - <property name="clearButtonEnabled"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> </widget> </item> - <item row="1" column="2"> - <layout class="QHBoxLayout" name="horizontalLayout_8"> - <item> - <spacer name="horizontalSpacer_2"> - <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="lookupStatusLabel"> - <property name="minimumSize"> - <size> - <width>30</width> - <height>30</height> - </size> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item row="3" column="2"> - <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> - <item row="0" column="2"> - <spacer name="horizontalSpacer_9"> + <item row="1" column="1"> + <spacer name="verticalSpacer"> <property name="orientation"> - <enum>Qt::Horizontal</enum> + <enum>Qt::Vertical</enum> </property> <property name="sizeType"> <enum>QSizePolicy::Fixed</enum> </property> <property name="sizeHint" stdset="0"> <size> - <width>37</width> - <height>0</height> + <width>20</width> + <height>3</height> </size> </property> </spacer> @@ -1217,42 +1086,6 @@ instead of using your ID.</string> </layout> </widget> </item> - <item row="0" column="0"> - <widget class="QWidget" name="infoWidget" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_17"> - <property name="topMargin"> - <number>1</number> - </property> - <item> - <widget class="QLabel" name="infoLabel"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>30</height> - </size> - </property> - <property name="baseSize"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="font"> - <font> - <pointsize>10</pointsize> - </font> - </property> - <property name="text"> - <string/> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - </layout> - </widget> - </item> </layout> </item> </layout> @@ -3067,6 +2900,12 @@ instead of using your ID.</string> <header>photoboothwidget.h</header> <container>1</container> </customwidget> + <customwidget> + <class>SectionWidget</class> + <extends>QWidget</extends> + <header>section.h</header> + <container>1</container> + </customwidget> </customwidgets> <tabstops> <tabstop>newAccountButton</tabstop> @@ -3074,8 +2913,6 @@ instead of using your ID.</string> <tabstop>fullNameEdit</tabstop> <tabstop>signUpCheckbox</tabstop> <tabstop>usernameEdit</tabstop> - <tabstop>passwordEdit</tabstop> - <tabstop>confirmPasswordEdit</tabstop> <tabstop>previousButton</tabstop> <tabstop>backButton</tabstop> <tabstop>nextButton</tabstop> diff --git a/ring-client-windows.vcxproj b/ring-client-windows.vcxproj index df350a26bf2a1a3ebcccf3cf460480e36b80ece5..7c7c88dbcbc2cd01fa41af9959e3a33484932374 100644 --- a/ring-client-windows.vcxproj +++ b/ring-client-windows.vcxproj @@ -344,6 +344,7 @@ del /s /q $(OutDir)\Jami.exp</Command> <ClCompile Include="bannedlistmodel.cpp" /> <ClCompile Include="animationhelpers.cpp" /> <ClCompile Include="callaudioonlyavataroverlay.cpp" /> + <ClCompile Include="collapsiblepasswordwidget.cpp" /> <ClCompile Include="connectivitymonitor.cpp" /> <ClCompile Include="contactpicker.cpp" /> <ClCompile Include="contactpickeritemdelegate.cpp" /> @@ -355,6 +356,7 @@ del /s /q $(OutDir)\Jami.exp</Command> <ClCompile Include="overlaybutton.cpp" /> <ClCompile Include="previewwidget.cpp" /> <ClCompile Include="rendermanager.cpp" /> + <ClCompile Include="section.cpp" /> <ClCompile Include="sipinputpanel.cpp" /> <ClCompile Include="splashscreen.cpp" /> <ClCompile Include="updatedownloaddialog.cpp" /> @@ -645,6 +647,11 @@ del /s /q $(OutDir)\Jami.exp</Command> <IncludePath Condition="'$(Configuration)|$(Platform)'=='ReleaseCompile|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)winsparkle\include;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> <IncludePath Condition="'$(Configuration)|$(Platform)'=='Beta|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> </QtMoc> + <QtMoc Include="collapsiblepasswordwidget.h"> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='ReleaseCompile|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)winsparkle\include;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='Beta|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> + </QtMoc> <QtMoc Include="notifypushbutton.h"> <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> <IncludePath Condition="'$(Configuration)|$(Platform)'=='ReleaseCompile|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)winsparkle\include;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> @@ -677,6 +684,11 @@ del /s /q $(OutDir)\Jami.exp</Command> <IncludePath Condition="'$(Configuration)|$(Platform)'=='Beta|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> <IncludePath Condition="'$(Configuration)|$(Platform)'=='ReleaseCompile|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)winsparkle\include;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> </QtMoc> + <QtMoc Include="section.h"> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='ReleaseCompile|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)winsparkle\include;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='Beta|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> + </QtMoc> <ClInclude Include="settingskey.h" /> <QtMoc Include="smartlistview.h"> <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName)\.;.\GeneratedFiles;.;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\lrc\src;$(ProjectDir)..\client-windows\winsparkle\include;$(ProjectDir)..\client-windows\qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> @@ -870,6 +882,8 @@ del /s /q $(OutDir)\Jami.exp</Command> <QtUic Include="callwidget.ui"> <SubType>Designer</SubType> </QtUic> + <QtUic Include="collapsiblepasswordwidget.ui" /> + <QtUic Include="section.ui" /> <QtUic Include="sipkeypad.ui" /> <QtUic Include="updatedownloaddialog.ui" /> <QtUic Include="contactpicker.ui" /> @@ -967,4 +981,4 @@ del /s /q $(OutDir)\Jami.exp</Command> <UserProperties UicDir=".\GeneratedFiles" RccDir=".\GeneratedFiles" Qt5Version_x0020_x64="$(DefaultQtVersion)" /> </VisualStudio> </ProjectExtensions> -</Project> \ No newline at end of file +</Project> diff --git a/ring-client-windows.vcxproj.filters b/ring-client-windows.vcxproj.filters index 6f5c52dc53106952ad715fc48e5de3c244f5d48a..7cd6244fed52f77f39a913e78f85bfcddd6cc392 100644 --- a/ring-client-windows.vcxproj.filters +++ b/ring-client-windows.vcxproj.filters @@ -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"> diff --git a/section.cpp b/section.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f505dce571ddb2cd030671c6a49061403488ea9b --- /dev/null +++ b/section.cpp @@ -0,0 +1,85 @@ +/************************************************************************** +* 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(); +} diff --git a/section.h b/section.h new file mode 100644 index 0000000000000000000000000000000000000000..8a793bb3904208d23b6f6f36559712c1781d3caf --- /dev/null +++ b/section.h @@ -0,0 +1,52 @@ +/************************************************************************** +* 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); +}; diff --git a/section.ui b/section.ui new file mode 100644 index 0000000000000000000000000000000000000000..8e82770c12cc2849b224822da58fde8256753808 --- /dev/null +++ b/section.ui @@ -0,0 +1,93 @@ +<?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>