Commit 6ace34fc authored by Andreas Traczyk's avatar Andreas Traczyk

add new wizard

Change-Id: I138136ff268d717967d62e2e612798c39f3e098d
parent 5bafcb9d
......@@ -25,6 +25,7 @@
#include "utils.h"
#include "accountlistmodel.h"
#include "ringthemeutils.h"
#include "lrcinstance.h"
#undef REGISTERED
......@@ -62,6 +63,20 @@ AccountItemDelegate::paint(QPainter* painter,
QRect &rect = opt.rect;
QFont font(painter->font());
font.setPointSize(fontSize_);
QPen pen(painter->pen());
// is it the add account row?
if (index.row() == LRCInstance::accountModel().getAccountList().size()) {
pen.setColor(RingTheme::lightBlack_);
painter->setPen(pen);
painter->setFont(font);
QFontMetrics fontMetrics(font);
painter->drawText(rect, Qt::AlignVCenter | Qt::AlignHCenter, tr("Add Account") + "+");
return;
}
// Avatar drawing
opt.decorationSize = QSize(avatarSize_, avatarSize_);
opt.decorationPosition = QStyleOptionViewItem::Left;
......@@ -72,8 +87,6 @@ AccountItemDelegate::paint(QPainter* painter,
QPixmap::fromImage(index.data(AccountListModel::Role::Picture).value<QImage>())
.scaled(avatarSize_, avatarSize_, Qt::KeepAspectRatio, Qt::SmoothTransformation));
QFont font(painter->font());
// Presence indicator
QPainterPath outerCircle, innerCircle;
QPointF center(rectAvatar.right() - avatarSize_ / 6, (rectAvatar.bottom() - avatarSize_ / 6) + 1);
......@@ -87,9 +100,6 @@ AccountItemDelegate::paint(QPainter* painter,
painter->fillPath(innerCircle, RingTheme::presenceGreen_);
}
font.setPointSize(fontSize_);
QPen pen(painter->pen());
painter->setPen(pen);
QRect rectTexts(dx_ + rect.left() + dx_ + avatarSize_,
......
......@@ -37,7 +37,7 @@ AccountListModel::AccountListModel(QObject *parent)
int AccountListModel::rowCount(const QModelIndex &parent) const
{
if (!parent.isValid()) {
return LRCInstance::accountModel().getAccountList().size(); // count
return LRCInstance::accountModel().getAccountList().size() + 1; // count
}
return 0; // A valid QModelIndex returns 0 as no entry has sub-elements
}
......
......@@ -128,6 +128,11 @@ CallWidget::CallWidget(QWidget* parent) :
connect(ui->currentAccountComboBox, &CurrentAccountComboBox::settingsButtonClicked,
this, &CallWidget::settingsButtonClicked);
connect(ui->currentAccountComboBox, &CurrentAccountComboBox::newAccountClicked,
[this]() {
emit NavigationRequested(ScreenEnum::WizardScreen);
});
connect(ui->videoWidget, &VideoView::setChatVisibility,
[this](bool visible) {
if (visible) {
......@@ -223,12 +228,17 @@ CallWidget::navigated(bool to)
if (to) {
updateSmartList();
connectConversationModel();
ui->currentAccountComboBox->accountListUpdate();
} else {
QObject::disconnect(smartlistSelectionConnection_);
smartListModel_.reset(nullptr);
}
}
void CallWidget::updateCustomUI()
{
}
int
CallWidget::getLeftPanelWidth()
{
......@@ -592,8 +602,12 @@ void CallWidget::slotCustomContextMenuRequested(const QPoint& pos)
void CallWidget::slotAccountChanged(int index)
{
auto accountList = LRCInstance::accountModel().getAccountList();
setSelectedAccount(accountList.at(index));
try {
auto accountList = LRCInstance::accountModel().getAccountList();
setSelectedAccount(accountList.at(index));
} catch (...) {
qWarning() << "exception changing account";
}
}
void CallWidget::slotShowCallView(const std::string& accountId,
......@@ -914,12 +928,6 @@ CallWidget::on_sendContactRequestButton_clicked()
LRCInstance::getCurrentConversationModel()->makePermanent(selectedConvUid());
}
void
CallWidget::on_pendingCRBackButton_clicked()
{
ui->stackedWidget->setCurrentWidget(ui->welcomePage);
}
void
CallWidget::on_btnAudioCall_clicked()
{
......
......@@ -68,6 +68,7 @@ public:
// NavWidget
virtual void navigated(bool to);
virtual void updateCustomUI();
public slots:
void on_ringContactLineEdit_returnPressed();
......@@ -98,7 +99,6 @@ private slots:
void on_smartList_clicked(const QModelIndex &index);
void on_qrButton_toggled(bool checked);
void on_shareButton_clicked();
void on_pendingCRBackButton_clicked();
void on_btnAudioCall_clicked();
void on_btnVideoCall_clicked();
......
......@@ -39,7 +39,7 @@ CurrentAccountComboBox::CurrentAccountComboBox(QWidget* parent)
gearLabel_.setMouseTracking(true);
accountListUpdate();
accountItemDelegate_ = new AccountItemDelegate();
accountItemDelegate_ = new AccountItemDelegate(this);
this->setItemDelegate(accountItemDelegate_);
// combobox index changed and so must the avatar
......@@ -131,6 +131,10 @@ CurrentAccountComboBox::paintEvent(QPaintEvent* e)
painter.setPen(Qt::lightGray);
painter.drawText(comboBoxRect, (Qt::AlignBottom | Qt::AlignLeft), secondaryAccountID);
}
if (QWidget* popupWidget = this->findChild<QFrame*>()) {
popupWidget->setStyleSheet("QFrame{border: 0px;border-bottom: 1px solid #f0f0f0;}");
}
}
void CurrentAccountComboBox::resizeEvent(QResizeEvent* event)
......@@ -160,8 +164,13 @@ CurrentAccountComboBox::importLabelPhoto(int index)
void
CurrentAccountComboBox::setCurrentIndex(int index)
{
importLabelPhoto(index);
QComboBox::setCurrentIndex(index);
auto accountListSize = LRCInstance::accountModel().getAccountList().size();
if (index == accountListSize) {
emit newAccountClicked();
} else if (index < accountListSize) {
importLabelPhoto(index);
QComboBox::setCurrentIndex(index);
}
}
void
......@@ -176,9 +185,7 @@ void
CurrentAccountComboBox::mousePressEvent(QMouseEvent* mouseEvent)
{
if (!gearLabel_.frameGeometry().contains(mouseEvent->localPos().toPoint())) {
if (count() > 1) {
QComboBox::mousePressEvent(mouseEvent);
}
QComboBox::mousePressEvent(mouseEvent);
} else {
emit settingsButtonClicked();
}
......
......@@ -40,6 +40,7 @@ public:
signals:
void settingsButtonClicked();
void newAccountClicked();
protected:
void paintEvent(QPaintEvent* e);
......@@ -47,12 +48,12 @@ protected:
void mousePressEvent(QMouseEvent* mouseEvent);
void mouseMoveEvent(QMouseEvent* event);
void leaveEvent(QEvent * event);
void showPopup();
void hidePopup();
private:
void importLabelPhoto(int index);
void setupSettingsButton();
void showPopup();
void hidePopup();
AccountItemDelegate* accountItemDelegate_;
std::unique_ptr<AccountListModel> accountListModel_;
......
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><circle cx="12" cy="12" r="3.2"/><path d="M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/><path d="M0 0h24v24H0z" fill="none"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/><path d="M0 0h24v24H0z" fill="none"/></svg>
\ No newline at end of file
......@@ -104,6 +104,7 @@ int
main(int argc, char *argv[])
{
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QApplication a(argc, argv);
......
......@@ -65,6 +65,7 @@ MainWindow::MainWindow(QWidget* parent) :
QIcon icon(":images/jami.png");
this->setWindowIcon(icon);
setWindowTitle(" ");
GlobalSystemTray& sysIcon = GlobalSystemTray::instance();
sysIcon.setIcon(icon);
......@@ -147,6 +148,15 @@ MainWindow::MainWindow(QWidget* parent) :
}
lastScr_ = startScreen;
connect(windowHandle(), &QWindow::activeChanged,
[this]() {
auto screenNumber = qApp->desktop()->screenNumber();
QScreen* screen = qApp->screens().at(screenNumber);
windowHandle()->setScreen(nullptr);
windowHandle()->setScreen(screen);
});
}
MainWindow::~MainWindow()
......@@ -297,7 +307,6 @@ void
MainWindow::setWindowSize(ScreenEnum scr, bool firstUse)
{
auto screenNumber = qApp->desktop()->screenNumber();
QScreen* screen = qApp->screens().at(screenNumber);
auto accountList = LRCInstance::accountModel().getAccountList();
if (scr == ScreenEnum::WizardScreen && !accountList.size()) {
hide();
......@@ -315,7 +324,6 @@ MainWindow::setWindowSize(ScreenEnum scr, bool firstUse)
qApp->desktop()->screenGeometry(screenNumber)
)
);
windowHandle()->setScreen(screen);
if (scr == ScreenEnum::WizardScreen) {
setWindowFlags(Qt::Dialog);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
......@@ -336,8 +344,21 @@ MainWindow::show()
disconnect(screenChangedConnection_);
screenChangedConnection_ = connect(windowHandle(), &QWindow::screenChanged,
[this](QScreen* screen) {
Q_UNUSED(screen);
adjustSize();
updateGeometry();
update();
// a little delay won't hurt ;)
QTimer::singleShot(100, this,
[this] {
qobject_cast<NavWidget*>(ui->navStack->currentWidget())->updateCustomUI();
});
});
}
void
MainWindow::resizeEvent(QResizeEvent* event)
{
Q_UNUSED(event);
qobject_cast<NavWidget*>(ui->navStack->currentWidget())->updateCustomUI();
}
......@@ -59,6 +59,7 @@ public:
protected:
bool nativeEvent(const QByteArray& eventType, void* message, long* result);
void closeEvent(QCloseEvent* event);
void resizeEvent(QResizeEvent *event);
public slots:
void onRingEvent(const QString& uri);
......
......@@ -463,7 +463,7 @@
</property>
<item>
<widget class="QStackedWidget" name="navStack">
<widget class="WizardWidget" name="wizardwidget"/>
<widget class="NewWizardWidget" name="wizardwidget"/>
<widget class="CallWidget" name="callwidget"/>
<widget class="SettingsWidget" name="settingswidget">
<property name="sizePolicy">
......@@ -487,15 +487,15 @@
<container>1</container>
</customwidget>
<customwidget>
<class>WizardWidget</class>
<class>SettingsWidget</class>
<extends>QWidget</extends>
<header>wizardwidget.h</header>
<container>1</container>
<header>settingswidget.h</header>
</customwidget>
<customwidget>
<class>SettingsWidget</class>
<class>NewWizardWidget</class>
<extends>QWidget</extends>
<header>settingswidget.h</header>
<header>newwizardwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
......
......@@ -37,6 +37,7 @@ public:
~NavWidget();
virtual void navigated(bool to) = 0;
virtual void updateCustomUI() = 0;
signals:
void NavigationRequested(ScreenEnum screen);
......
This diff is collapsed.
/**************************************************************************
* Copyright (C) 2018 by Savoir-faire Linux *
* 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 <QLabel>
#include <QtConcurrent/QtConcurrent>
#include "account.h"
#include "person.h"
#include "lrcinstance.h"
#include "navwidget.h"
namespace Ui {
class NewWizardWidget;
}
using namespace lrc::api::account;
class NewWizardWidget : public NavWidget
{
Q_OBJECT
public:
using AccountInfo = Info;
enum WizardMode { WIZARD, NEW_ACCOUNT, IMPORT, MIGRATION };
private:
enum NameRegistrationUIState { BLANK, INVALID, TAKEN, FREE, SEARCHING };
public:
explicit NewWizardWidget(WizardMode wizardMode = WIZARD,
AccountInfo* toBeMigrated = nullptr,
QWidget* parent = 0);
~NewWizardWidget();
// NavWidget
virtual void navigated(bool to);
virtual void updateCustomUI();
//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 slotRegisteredNameFound(const std::string& accountId,
LookupStatus status,
const std::string& address,
const std::string& name);
void handle_nameRegistrationEnded(NameDirectory::RegisterNameStatus status, const QString& name);
void timeoutNameLookupTimer();
void on_photoTaken(QString fileName);
void on_signUpCheckbox_toggled(bool checked);
private:
Ui::NewWizardWidget* ui;
WizardMode wizardMode_;
QPixmap statusSuccessPixmap_;
QPixmap statusInvalidPixmap_;
QPixmap statusErrorPixmap_;
AccountInfo* account_;
QMovie* creationSpinnerMovie_;
QMovie* lookupSpinnerMovie_;
QTimer lookupTimer_;
QLabel* lookupStatusLabel_;
QString registeredName_;
bool registrationStateOk_;
QMetaObject::Connection registeredNameFoundConnection_;
QLabel* passwordStatusLabel_;
void updateNameRegistrationUi(NameRegistrationUIState state);
void changePage(QWidget* toPage);
void setNavBarVisibility(bool visible, bool back=false);
void validateFileImport();
void validateWizardProgression();
void createRingAccount(const QString &displayName = QString(),
const QString &password = QString(),
const QString &pin = QString(),
const QString &archivePath = QString());
void processWizardInformations();
};
This diff is collapsed.
......@@ -23,6 +23,13 @@
#include <QStandardPaths>
#include "video/previewmanager.h"
#include "profilemodel.h"
#include "profile.h"
#include "account.h"
#include "person.h"
#include "utils.h"
PhotoboothWidget::PhotoboothWidget(QWidget *parent) :
QWidget(parent),
......@@ -46,12 +53,16 @@ void PhotoboothWidget::startBooth()
Video::PreviewManager::instance().stopPreview();
Video::PreviewManager::instance().startPreview();
ui->videoFeed->show();
ui->avatarLabel->hide();
takePhotoState_ = true;
}
void PhotoboothWidget::stopBooth()
{
Video::PreviewManager::instance().stopPreview();
hide();
ui->videoFeed->hide();
ui->avatarLabel->show();
takePhotoState_ = false;
}
void
......@@ -60,21 +71,35 @@ PhotoboothWidget::on_importButton_clicked()
fileName_ = QFileDialog::getOpenFileName(this, tr("Choose File"),
"",
tr("Files (*)"));
if (fileName_.isEmpty())
if (fileName_.isEmpty()) {
fileName_ = QStandardPaths::standardLocations(
QStandardPaths::TempLocation).first()
+ QStringLiteral("profile.png");
else {
QStandardPaths::TempLocation).first()
+ QStringLiteral("profile.png");
} else {
Video::PreviewManager::instance().stopPreview();
}
auto image = QImage(fileName_);
auto avatar = image.scaled(100, 100, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
ProfileModel::instance().selectedProfile()->person()->setPhoto(avatar);
ui->avatarLabel->setPixmap(QPixmap::fromImage(Utils::getCirclePhoto(avatar, ui->avatarLabel->width())));
emit photoTaken(fileName_);
}
void
PhotoboothWidget::on_takePhotoButton_clicked()
{
auto photo = ui->videoFeed->takePhoto();
Video::PreviewManager::instance().stopPreview();
photo.save(fileName_);
emit photoTaken(fileName_);
if (!takePhotoState_) {
takePhotoState_ = true;
ui->takePhotoButton->setIcon(QPixmap(":/images/icons/baseline-camera_alt-24px.svg"));
emit photoReady();
} else {
auto photo = ui->videoFeed->takePhoto();
Video::PreviewManager::instance().stopPreview();
photo.save(fileName_);
auto avatar = photo.scaled(100, 100, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
ProfileModel::instance().selectedProfile()->person()->setPhoto(avatar);
ui->avatarLabel->setPixmap(QPixmap::fromImage(Utils::getCirclePhoto(avatar, ui->avatarLabel->width())));
ui->takePhotoButton->setIcon(QPixmap(":/images/icons/baseline-refresh-24px.svg"));
emit photoTaken(fileName_);
}
}
......@@ -43,8 +43,11 @@ private:
QString fileName_;
Ui::PhotoboothWidget *ui;
bool takePhotoState_;
signals:
void photoTaken(QString fileName);
void photoReady();
};
#endif // PHOTOBOOTHWIDGET_H
......@@ -6,28 +6,143 @@
<rect>
<x>0</x>
<y>0</y>
<width>558</width>
<height>458</height>
<width>392</width>
<height>160</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="9,0">
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
<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="VideoWidget" name="videoFeed" native="true">
<property name="toolTip">
<string>Photobooth display</string>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<widget class="QWidget" name="horizontalWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<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>3</number>
</property>
<item>
<widget class="QWidget" name="verticalWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>120</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>120</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</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="QLabel" name="avatarLabel">
<property name="minimumSize">
<size>
<width>120</width>
<height>120</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>120</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="VideoWidget" name="videoFeed" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>120</height>
</size>
</property>
<property name="toolTip">
<string>Photobooth display</string>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="topMargin">
<number>10</number>
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_3">
......@@ -44,54 +159,64 @@
</item>
<item>
<widget class="QPushButton" name="takePhotoButton">
<property name="enabled">
<bool>true</bool>
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>Take photo</string>
<property name="maximumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="ressources.qrc">
<normaloff>:/images/icons/ic_photo_camera_white_24dp_2x.png</normaloff>:/images/icons/ic_photo_camera_white_24dp_2x.png</iconset>
</property>
<property name="iconSize">
<size>
<width>36</width>
<height>36</height>
</size>
<normaloff>:/images/icons/baseline-camera_alt-24px.svg</normaloff>:/images/icons/baseline-camera_alt-24px.svg</iconset>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label">
<property name="text">
<string>or</string>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>