Commit 55f92cb9 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Isa

ux: change application start

- make the wizard a widget in the mainwindow navstack
- remove findRingAccount, any account present should not invoke the
  wizard

Change-Id: I5341d9060e17b74ac253619d70aad6d2d9a93874
Reviewed-by: Isa's avatarIsa Nanic <isa.nanic@savoirfairelinux.com>
parent 0a4e7aa3
......@@ -81,7 +81,8 @@ SOURCES += main.cpp\
accountitemdelegate.cpp \
accountlistmodel.cpp \
messagemodel.cpp \
invitebuttonswidget.cpp
invitebuttonswidget.cpp \
wizardwidget.cpp
HEADERS += mainwindow.h \
callwidget.h \
......@@ -126,7 +127,8 @@ HEADERS += mainwindow.h \
accountitemdelegate.h \
accountlistmodel.h \
messagemodel.h \
invitebuttonswidget.h
invitebuttonswidget.h \
wizardwidget.h
contains(DEFINES, URI_PROTOCOL) {
HEADERS += shmclient.h
......@@ -153,7 +155,8 @@ FORMS += mainwindow.ui \
deleteaccountdialog.ui \
bannedcontactswidget.ui \
photoboothwidget.ui \
invitebuttonswidget.ui
invitebuttonswidget.ui \
wizardwidget.ui
win32: LIBS += -lole32 -luuid -lshlwapi -lgdi32
LIBS += -lqrencode
......
......@@ -51,7 +51,7 @@ int AccountListModel::columnCount(const QModelIndex &parent) const
QVariant AccountListModel::data(const QModelIndex &index, int role) const
{
auto accountList = LRCInstance::accountModel().getAccountList();
if (!index.isValid() || accountList.size() == 0) {
if (!index.isValid() || accountList.size() <= index.row()) {
return QVariant();
}
......
......@@ -108,8 +108,6 @@ CallWidget::CallWidget(QWidget* parent) :
ui->spinnerLabel->setMovie(miniSpinner_);
ui->spinnerLabel->hide();
// set to welcome view
ui->stackedWidget->setCurrentWidget(ui->welcomePage);
setupOutOfCallIM();
// connections
......@@ -155,6 +153,9 @@ CallWidget::CallWidget(QWidget* parent) :
connect(&LRCInstance::behaviorController(), &BehaviorController::showChatView,
this, &CallWidget::slotShowChatView);
// set first view to welcome view
ui->stackedWidget->setCurrentWidget(ui->welcomePage);
}
CallWidget::~CallWidget()
......@@ -320,36 +321,6 @@ CallWidget::setupQRCode(QString ringID)
Qt::KeepAspectRatio)));
}
bool
CallWidget::findRingAccount()
{
bool ringAccountFound = false;
auto accountList = LRCInstance::accountModel().getAccountList();
for (int i = 0; i < accountList.size(); ++i) {
auto accountId = accountList.at(i);
auto& accountInfo = LRCInstance::accountModel().getAccountInfo(accountId);
if (accountInfo.profileInfo.type == lrc::api::profile::Type::RING) {
ringAccountFound = true;
if (accountInfo.status == lrc::api::account::Status::ERROR_NEED_MIGRATION) {
WizardDialog dlg(WizardDialog::MIGRATION);
dlg.exec();
}
}
}
if (!ringAccountFound) {
WizardDialog wizardDialog;
wizardDialog.exec();
if (wizardDialog.result() != QDialog::Accepted) {
return false;
}
}
ui->currentAccountWidget->update();
return true;
}
void
CallWidget::on_smartList_clicked(const QModelIndex& index)
{
......
......@@ -64,7 +64,6 @@ class CallWidget : public NavWidget
public:
explicit CallWidget(QWidget* parent = 0);
~CallWidget();
bool findRingAccount();
public slots:
void on_ringContactLineEdit_returnPressed();
......
......@@ -89,6 +89,9 @@ ConfigurationWidget::ConfigurationWidget(QWidget *parent) :
auto idx = ui->accountView->currentIndex();
DeleteAccountDialog dialog(idx);
dialog.exec();
if (!LRCInstance::accountModel().getAccountList().size()) {
emit NavigationRequested(ScreenEnum::WizardScreen);
}
});
isLoading_ = true;
......
......@@ -180,10 +180,6 @@ main(int argc, char *argv[])
QFontDatabase::addApplicationFont(":/images/FontAwesome.otf");
if (not MainWindow::instance().init()) {
return 1;
}
MainWindow::instance().createThumbBar();
if (not uri.isEmpty()) {
......
......@@ -37,6 +37,7 @@
#include "callmodel.h"
#include "callwidget.h"
#include "utils.h"
#include "wizarddialog.h"
MainWindow::MainWindow(QWidget* parent) :
QMainWindow(parent),
......@@ -44,6 +45,11 @@ MainWindow::MainWindow(QWidget* parent) :
{
ui->setupUi(this);
connect(ui->wizardwidget, &WizardWidget::NavigationRequested,
[this](ScreenEnum scr) {
Utils::setStackWidget(ui->navStack, ui->navStack->widget(scr));
});
connect(ui->callwidget, &CallWidget::NavigationRequested,
[this](ScreenEnum scr) {
Utils::setStackWidget(ui->navStack, ui->navStack->widget(scr));
......@@ -117,6 +123,22 @@ MainWindow::MainWindow(QWidget* parent) :
Q_UNUSED(online)
AccountModel::instance().slotConnectivityChanged();
});
auto accountList = LRCInstance::accountModel().getAccountList();
if (accountList.size()) {
for (const auto& accountId : accountList) {
auto& accountInfo = LRCInstance::accountModel().getAccountInfo(accountId);
if (accountInfo.profileInfo.type == lrc::api::profile::Type::RING) {
if (accountInfo.status == lrc::api::account::Status::ERROR_NEED_MIGRATION) {
WizardDialog dlg(WizardDialog::MIGRATION);
dlg.exec();
}
}
}
Utils::setStackWidget(ui->navStack, ui->navStack->widget(ScreenEnum::CallScreen));
} else {
Utils::setStackWidget(ui->navStack, ui->navStack->widget(ScreenEnum::WizardScreen));
}
}
MainWindow::~MainWindow()
......@@ -124,12 +146,6 @@ MainWindow::~MainWindow()
delete ui;
}
bool
MainWindow::init()
{
return ui->callwidget->findRingAccount();
}
void
MainWindow::onRingEvent(const QString& uri)
{
......@@ -218,6 +234,7 @@ MainWindow::switchNormalMaximize()
void
MainWindow::closeEvent(QCloseEvent* event)
{
Video::PreviewManager::instance().stopPreview();
QSettings settings;
if (settings.value(SettingsKey::closeOrMinimized).toBool()) {
this->hide();
......
......@@ -463,6 +463,7 @@
</property>
<item>
<widget class="QStackedWidget" name="navStack">
<widget class="WizardWidget" name="wizardwidget"/>
<widget class="CallWidget" name="callwidget"/>
<widget class="ConfigurationWidget" name="configurationwidget"/>
</widget>
......@@ -484,6 +485,12 @@
<header>configurationwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>WizardWidget</class>
<extends>QWidget</extends>
<header>wizardwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="ressources.qrc"/>
......
......@@ -22,6 +22,7 @@
enum ScreenEnum {
//DO not add main widget screen before callScreen
WizardScreen,
CallScreen,
ConfScreen,
END
......
......@@ -169,8 +169,13 @@
<ClCompile Include="videowidget.cpp" />
<ClCompile Include="windowscontactbackend.cpp" />
<ClCompile Include="wizarddialog.cpp" />
<ClCompile Include="wizardwidget.cpp" />
</ItemGroup>
<ItemGroup>
<QtMoc Include="wizardwidget.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>
<Define Condition="'$(Configuration)|$(Platform)'=='Release|x64'">_WINDOWS;UNICODE;_UNICODE;WIN32;WIN64;NIGHTLY_VERSION=20180706;ENABLE_AUTOUPDATE;QT_NO_DEBUG;NDEBUG</Define>
</QtMoc>
<QtMoc Include="aboutdialog.h">
</QtMoc>
<QtMoc Include="accountdetails.h">
......@@ -386,6 +391,7 @@
</QtUic>
<QtUic Include="invitebuttonswidget.ui" />
<QtUic Include="mainwindow.ui">
<SubType>Designer</SubType>
</QtUic>
<QtUic Include="photoboothdialog.ui">
</QtUic>
......@@ -405,6 +411,9 @@
</QtUic>
<QtUic Include="wizarddialog.ui">
</QtUic>
<QtUic Include="wizardwidget.ui">
<SubType>Designer</SubType>
</QtUic>
</ItemGroup>
<ItemGroup>
<None Include="images\FontAwesome.otf" />
......
......@@ -183,6 +183,9 @@
<ClCompile Include="invitebuttonswidget.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="wizardwidget.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<QtMoc Include="aboutdialog.h">
......@@ -314,6 +317,9 @@
<QtMoc Include="invitebuttonswidget.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="wizardwidget.h">
<Filter>Header Files</Filter>
</QtMoc>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="debug\moc_predefs.h.cbt">
......@@ -611,6 +617,9 @@
<QtUic Include="invitebuttonswidget.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="wizardwidget.ui">
<Filter>Form Files</Filter>
</QtUic>
</ItemGroup>
<ItemGroup>
<None Include="images\FontAwesome.otf">
......
......@@ -41,7 +41,7 @@ private:
void hideButtonsWidgets();
QModelIndex hoveredRow_;
signals:
signals:
void btnAcceptInviteClicked(const QModelIndex& index) const;
void btnBlockInviteClicked(const QModelIndex& index) const;
void btnIgnoreInviteClicked(const QModelIndex& index) const;
......
......@@ -375,21 +375,23 @@ WizardDialog::createRingAccount(const QString &displayName,
);
});
connect(&LRCInstance::accountModel(),
&lrc::api::NewAccountModel::accountAdded,
[this](const std::string& accountId) {
//set default ringtone
auto confProps = LRCInstance::accountModel().getAccountConfig(accountId);
confProps.Ringtone.ringtonePath = Utils::GetRingtonePath().toStdString();
LRCInstance::accountModel().setAccountConfig(accountId, confProps);
accept();
});
connect(&LRCInstance::accountModel(), &lrc::api::NewAccountModel::accountAdded,
this, &WizardDialog::slotAccountAdded);
ui->navBarWidget->hide();
Utils::setStackWidget(ui->stackedWidget, ui->spinnerPage);
repaint();
}
void
WizardDialog::slotAccountAdded(const std::string& accountId)
{
auto confProps = LRCInstance::accountModel().getAccountConfig(accountId);
confProps.Ringtone.ringtonePath = Utils::GetRingtonePath().toStdString();
LRCInstance::accountModel().setAccountConfig(accountId, confProps);
accept();
}
void
WizardDialog::on_dhtImportBtn_clicked()
{
......
......@@ -26,7 +26,6 @@
#include "account.h"
#include "person.h"
// new lrc
#include "lrcinstance.h"
namespace Ui {
......@@ -70,6 +69,7 @@ private slots:
void on_archivePathSelector_clicked();
void on_dhtImportBtn_clicked();
void on_fileImportBtn_clicked();
void slotAccountAdded(const std::string & accountId);
private:
Ui::WizardDialog* ui;
......
This diff is collapsed.
/**************************************************************************
* Copyright (C) 2015-2018 by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* Author: Anthony Léonard <anthony.leonard@savoirfairelinux.com> *
* Author: Olivier Soldano <olivier.soldano@savoirfairelinux.com> *
* Author: Andreas Traczyk <andreas.traczyk@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
#include <QDialog>
#include <QtConcurrent/QtConcurrent>
#include "account.h"
#include "person.h"
#include "lrcinstance.h"
#include "navwidget.h"
namespace Ui {
class WizardWidget;
}
class WizardWidget : public NavWidget
{
Q_OBJECT
public:
using AccountInfo = lrc::api::account::Info;
enum WizardMode {
WIZARD,
NEW_ACCOUNT,
IMPORT,
MIGRATION
};
public:
explicit WizardWidget(WizardMode wizardMode = WIZARD, AccountInfo* toBeMigrated = nullptr, QWidget* parent = 0);
~WizardWidget();
//UI Slots
private slots:
void on_existingPushButton_clicked();
void on_newAccountButton_clicked();
void on_nextButton_clicked();
void on_previousButton_clicked();
void on_passwordEdit_textChanged(const QString& arg1);
private slots:
void on_usernameEdit_textChanged(const QString& arg1);
void handle_registeredNameFound(Account *account, NameDirectory::LookupStatus status, const QString& address, const QString& name);
void handle_nameRegistrationEnded(NameDirectory::RegisterNameStatus status, const QString& name);
void timeoutNameLookupTimer();
void on_photoTaken(QString fileName);
void on_signUpCheckbox_toggled(bool checked);
void on_archivePathSelector_clicked();
void on_dhtImportBtn_clicked();
void on_fileImportBtn_clicked();
private:
Ui::WizardWidget* ui;
AccountInfo* account_;
WizardMode wizardMode_;
QMovie* movie_;
QTimer nameLookupTimer_;
QMetaObject::Connection accountAddedConnection_;
void setup();
void changePage(bool existingAccount);
void validateFileImport();
void createRingAccount(const QString &displayName = QString(),
const QString &password = QString(),
const QString &pin = QString(),
const QString &archivePath = QString());
void processWizardInformations();
};
This diff is collapsed.
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