Commit b8b13ba8 authored by Andreas Traczyk's avatar Andreas Traczyk

refactor: implement new lrc api

- use new lrc models for
 - smartlist
 - conversation view
 - account selector

Change-Id: I0a009d4e9be6f84100f49ba176d853e05364c351
parent ce4309cd
......@@ -41,7 +41,7 @@ isEmpty(QMAKE_LRELEASE) {
}
SOURCES += main.cpp\
mainwindow.cpp \
mainwindow.cpp \
callwidget.cpp \
configurationwidget.cpp \
navwidget.cpp \
......@@ -59,13 +59,11 @@ SOURCES += main.cpp\
videooverlay.cpp \
imdelegate.cpp \
contactpicker.cpp \
contactmethodpicker.cpp \
globalsystemtray.cpp \
smartlistdelegate.cpp \
conversationitemdelegate.cpp \
conversationsfilterwidget.cpp \
callutilsdialog.cpp \
combar.cpp \
idlabel.cpp \
smartlist.cpp \
ringcontactlineedit.cpp \
pixbufmanipulator.cpp \
qualitydialog.cpp \
......@@ -74,13 +72,16 @@ SOURCES += main.cpp\
sendcontactrequestwidget.cpp \
currentaccountwidget.cpp \
contactrequestwidget.cpp \
contactrequestitemdelegate.cpp \
quickactcontactrequestwidget.cpp \
contactrequestlistwidget.cpp \
smartlistselectorbuttonnotifier.cpp \
deleteaccountdialog.cpp \
bannedcontactswidget.cpp \
photoboothwidget.cpp \
deletecontactdialog.cpp
smartlistmodel.cpp \
smartlistview.cpp \
accountitemdelegate.cpp \
accountlistmodel.cpp \
messagemodel.cpp \
invitebuttonswidget.cpp
HEADERS += mainwindow.h \
callwidget.h \
......@@ -100,14 +101,12 @@ HEADERS += mainwindow.h \
videooverlay.h \
imdelegate.h \
contactpicker.h \
contactmethodpicker.h \
settingskey.h \
globalsystemtray.h \
smartlistdelegate.h \
conversationitemdelegate.h \
conversationsfilterwidget.h \
callutilsdialog.h \
combar.h \
idlabel.h \
smartlist.h \
ringcontactlineedit.h \
pixbufmanipulator.h \
qualitydialog.h \
......@@ -117,14 +116,17 @@ HEADERS += mainwindow.h \
sendcontactrequestwidget.h \
currentaccountwidget.h \
contactrequestwidget.h \
contactrequestitemdelegate.h \
quickactcontactrequestwidget.h \
contactrequestlistwidget.h \
smartlistselectorbuttonnotifier.h \
deleteaccountdialog.h \
bannedcontactswidget.h \
photoboothwidget.h \
deletecontactdialog.h \
lrcinstance.h
lrcinstance.h \
smartlistmodel.h \
smartlistview.h \
accountitemdelegate.h \
accountlistmodel.h \
messagemodel.h \
invitebuttonswidget.h
contains(DEFINES, URI_PROTOCOL) {
HEADERS += shmclient.h
......@@ -141,20 +143,17 @@ FORMS += mainwindow.ui \
videoview.ui \
videooverlay.ui \
contactpicker.ui \
contactmethodpicker.ui \
callutilsdialog.ui \
combar.ui \
qualitydialog.ui \
ringbutton.ui \
photoboothdialog.ui \
sendcontactrequestwidget.ui \
currentaccountwidget.ui \
contactrequestwidget.ui \
quickactcontactrequestwidget.ui \
deleteaccountdialog.ui \
bannedcontactswidget.ui \
photoboothwidget.ui \
deletecontactdialog.ui
invitebuttonswidget.ui
win32: LIBS += -lole32 -luuid -lshlwapi -lgdi32
LIBS += -lqrencode
......
/***************************************************************************
* Copyright (C) 2015-2017 by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* 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 *
......@@ -15,29 +15,26 @@
* 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 <QObject>
#include <QPainter>
#include <QItemDelegate>
class QPainter;
class SmartListDelegate : public QItemDelegate
class AccountItemDelegate : public QItemDelegate
{
Q_OBJECT
public:
explicit SmartListDelegate(QObject* parent = 0);
explicit AccountItemDelegate(QObject *parent = nullptr);
protected:
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
private:
constexpr static int sizeImage_ = 48;
constexpr static int cellHeight_ = 60;
constexpr static int fontSize_ = 10;
const QFont font_ = QFont("Arial", fontSize_);
constexpr static int dy_ = 6;
constexpr static int dx_ = 12;
constexpr static int fontSize_ = 10;
constexpr static int effectiveComBarSize_ = 48;
constexpr static int avatarSize_ = 36;
constexpr static int cellHeight_ = 48;
};
/***************************************************************************
* 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/>. *
***************************************************************************/
#include "accountlistmodel.h"
// Qt
#include <QDateTime>
// LRC
#include "globalinstances.h"
// Client
#include "pixbufmanipulator.h"
#include "lrcinstance.h"
#include "utils.h"
AccountListModel::AccountListModel(QObject *parent)
: QAbstractItemModel(parent)
{
}
int AccountListModel::rowCount(const QModelIndex &parent) const
{
if (!parent.isValid()) {
return LRCInstance::accountModel().getAccountList().size(); // count
}
return 0; // A valid QModelIndex returns 0 as no entry has sub-elements
}
int AccountListModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return 1;
}
QVariant AccountListModel::data(const QModelIndex &index, int role) const
{
auto accountList = LRCInstance::accountModel().getAccountList();
if (!index.isValid() || accountList.size() == 0) {
return QVariant();
}
auto& accountInfo = LRCInstance::accountModel().getAccountInfo(accountList.at(index.row()));
switch (role) {
case Role::Alias:
case Qt::DisplayRole:
return QVariant(QString::fromStdString(accountInfo.profileInfo.alias));
case Role::Username:
return QVariant(QString::fromStdString(accountInfo.profileInfo.uri));
case Role::Type:
return QVariant(Utils::toUnderlyingValue<lrc::api::profile::Type>(accountInfo.profileInfo.type));
case Role::Status:
return QVariant(Utils::toUnderlyingValue<lrc::api::account::Status>(accountInfo.status));
case Role::Picture:
case Qt::DecorationRole:
return PixbufManipulator::accountPhoto(accountInfo);
case Role::ID:
return QVariant(QString::fromStdString(accountInfo.id));
}
return QVariant();
}
QModelIndex AccountListModel::index(int row, int column, const QModelIndex &parent) const
{
Q_UNUSED(parent);
if (column != 0) {
return QModelIndex();
}
if (row >= 0 && row < rowCount()) {
return createIndex(row, column);
}
return QModelIndex();
}
QModelIndex AccountListModel::parent(const QModelIndex &child) const
{
Q_UNUSED(child);
return QModelIndex();
}
Qt::ItemFlags AccountListModel::flags(const QModelIndex &index) const
{
auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable;
if (!index.isValid()) {
return QAbstractItemModel::flags(index);
}
return flags;
}
/**************************************************************************
* Copyright (C) 2015-2017 by Savoir-faire Linux *
* Author: Anthony Léonard <anthony.leonard@savoirfairelinux.com> *
* Author: Olivier Soldano <olivier.soldano@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/>. *
**************************************************************************/
/***************************************************************************
* 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
#ifndef CONTACTREQUESTLISTWIDGET_H
#define CONTACTREQUESTLISTWIDGET_H
// Qt include
#include <QAbstractItemModel>
#include <QTreeView>
// LRC
#include "api/account.h"
#include "api/conversation.h"
#include "api/contact.h"
class ContactRequestListWidget : public QTreeView
class AccountListModel : public QAbstractItemModel
{
Q_OBJECT
public:
explicit ContactRequestListWidget(QWidget *parent = 0);
~ContactRequestListWidget();
void setItemModel(QAbstractItemModel *model);
enum Role {
Alias = Qt::UserRole + 1,
Username,
Picture,
Type,
Status,
ID
};
private:
QModelIndex hoveredCRIndex_;
explicit AccountListModel(QObject *parent = 0);
protected:
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);
bool eventFilter(QObject *watched, QEvent *event);
void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
// QAbstractItemModel
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &child) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
};
#endif // CONTACTREQUESTLISTWIDGET_H
......@@ -34,7 +34,7 @@ CallUtilsDialog::CallUtilsDialog(QWidget* parent) :
QDialog(parent),
ui(new Ui::CallUtilsDialog),
confMode_(false),
smartListDelegate_(nullptr),
conversationItemDelegate_(nullptr),
notCurrentProxyModel_(nullptr),
spikeMask_(new QPixmap(":/images/spikeMask.png"))
{
......@@ -62,7 +62,7 @@ CallUtilsDialog::~CallUtilsDialog()
delete effect_;
delete spikeMask_;
delete fadeAnim_;
delete smartListDelegate_;
delete conversationItemDelegate_;
delete notCurrentProxyModel_;
delete ui;
}
......@@ -77,10 +77,10 @@ CallUtilsDialog::showEvent(QShowEvent* event)
notCurrentProxyModel_ = new NotCurrentProxyModel(&RecentModel::instance());
}
ui->contactView->setModel(notCurrentProxyModel_);
if (not smartListDelegate_) {
smartListDelegate_ = new SmartListDelegate();
if (not conversationItemDelegate_) {
conversationItemDelegate_ = new ConversationItemDelegate();
}
ui->contactView->setItemDelegate(smartListDelegate_);
ui->contactView->setItemDelegate(conversationItemDelegate_);
emit(isVisible(true));
......
......@@ -24,7 +24,7 @@
#include "callmodel.h"
#include "recentmodel.h"
#include "smartlistdelegate.h"
#include "conversationitemdelegate.h"
#include <ciso646>
......@@ -79,7 +79,7 @@ private slots:
private:
Ui::CallUtilsDialog* ui;
bool confMode_;
SmartListDelegate* smartListDelegate_;
ConversationItemDelegate* conversationItemDelegate_;
NotCurrentProxyModel* notCurrentProxyModel_;
QPixmap* spikeMask_;
QPropertyAnimation* fadeAnim_;
......
This diff is collapsed.
/**************************************************************************
* Copyright (C) 2015-2017 by Savoir-faire Linux *
* 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 *
......@@ -29,7 +30,9 @@
#include "navwidget.h"
#include "instantmessagingwidget.h"
#include "smartlistmodel.h"
// old LRC
#include "callmodel.h"
#include "video/renderer.h"
#include "video/previewmanager.h"
......@@ -37,7 +40,16 @@
#include "categorizedhistorymodel.h"
#include "media/textrecording.h"
class SmartListDelegate;
// new LRC
#include "globalinstances.h"
#include "api/newaccountmodel.h"
#include "api/conversationmodel.h"
#include "api/account.h"
#include "api/contact.h"
#include "api/contactmodel.h"
#include "api/newcallmodel.h"
class ConversationItemDelegate;
class ImDelegate;
class QPropertyAnimation;
......@@ -52,18 +64,22 @@ class CallWidget : public NavWidget
public:
explicit CallWidget(QWidget* parent = 0);
~CallWidget();
void atExit();
bool findRingAccount();
public slots:
void settingsButtonClicked();
void showIMOutOfCall(const QModelIndex& nodeIdx);
void btnComBarVideoClicked();
void on_ringContactLineEdit_returnPressed();
//UI SLOTS
public slots:
void on_ringContactLineEdit_returnPressed();
inline void on_entered(const QModelIndex& i){if (i.isValid()) highLightedIndex_ = i;}
void settingsButtonClicked();
void showIMOutOfCall(const QModelIndex& nodeIdx);
void slotAcceptInviteClicked(const QModelIndex& index);
void slotBlockInviteClicked(const QModelIndex& index);
void slotIgnoreInviteClicked(const QModelIndex& index);
void slotCustomContextMenuRequested(const QPoint & pos);
void slotShowCallView(const std::string & accountId, const lrc::api::conversation::Info & convInfo);
void slotShowIncomingCallView(const std::string & accountId, const lrc::api::conversation::Info & convInfo);
void slotShowChatView(const std::string & accountId, const lrc::api::conversation::Info & convInfo);
void update();
private slots:
void on_acceptButton_clicked();
......@@ -82,55 +98,75 @@ private slots:
void on_pendingCRBackButton_clicked();
private slots:
void callIncoming(Call* call);
void callStateChanged(Call* call, Call::State previousState);
void smartListCurrentChanged(const QModelIndex &currentIdx, const QModelIndex &previousIdx);
void smartListSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
void contactReqListCurrentChanged(const QModelIndex &currentIdx, const QModelIndex &previousIdx);
void slotAccountMessageReceived(const QMap<QString,QString> message,ContactMethod* cm, media::Media::Direction dir);
void onIncomingMessage(::media::TextRecording* t, ContactMethod* cm);
void callChangedSlot();
void contactLineEdit_registeredNameFound(Account *account, NameDirectory::LookupStatus status, const QString& address, const QString& name);
void searchBtnClicked();
void selectedAccountChanged(const QModelIndex &current, const QModelIndex &previous);
void on_contactMethodComboBox_currentIndexChanged(int index);
void on_contactRequestList_clicked(const QModelIndex &index);
void onIncomingMessage(const std::string & convUid, uint64_t interactionId, const lrc::api::interaction::Info & interaction);
void currentAccountChanged(const QModelIndex &current);
private:
Ui::CallWidget* ui;
Call* actualCall_;
Video::Renderer* videoRenderer_;
CallModel* callModel_;
int outputVolume_;
int inputVolume_;
void placeCall();
void conversationsButtonClicked();
void invitationsButtonClicked();
void setupOutOfCallIM();
void setupSmartListContextMenu(const QPoint &pos);
void setupQRCode(QString ringID);
void backToWelcomePage();
void triggerDeleteContactDialog(ContactMethod *cm, Account *ac);
// lrc
void selectConversation(const QModelIndex& index);
bool selectConversation(const lrc::api::conversation::Info& item,
lrc::api::ConversationModel& convModel);
void deselectConversation();
bool connectConversationModel();
void updateConversationView(const std::string& convUid);
void showConversationView();
void selectSmartlistItem(const std::string& convUid);
QImage imageForConv(const std::string & convUid);
void processContactLineEdit();
void hideMiniSpinner();
void updateConversationForNewContact(const std::string& convUid);
void updateSmartList();
void setSelectedAccount(const std::string & accountId);
void setConversationFilter(const QString& filter);
void setConversationFilter(lrc::api::profile::Type filter);
void updateConversationsFilterWidget();
const std::string& selectedAccountId();
const std::string& selectedConvUid();
QMenu* menu_;
SmartListDelegate* smartListDelegate_;
QPersistentModelIndex highLightedIndex_;
ConversationItemDelegate* conversationItemDelegate_;
ImDelegate* imDelegate_;
QMetaObject::Connection imConnection_;
QMetaObject::Connection imVisibleConnection_;
QMetaObject::Connection callChangedConnection_;
QMetaObject::Connection imClickedConnection_;
QMetaObject::Connection crListSelectionConnection_;
QPropertyAnimation* pageAnim_;
QMenu* shareMenu_;
Ui::CallWidget* ui;
QMovie* miniSpinner_;
constexpr static int qrSize_ = 200;
private:
void setActualCall(Call* value);
void placeCall();
void setupOutOfCallIM();
void setupSmartListMenu(const QPoint &pos);
void slidePage(QWidget* widget, bool toRight = false);
void callStateToView(Call* value);
void setupQRCode(QString ringID);
void searchContactLineEditEntry(const URI &uri);
bool uriNeedNameLookup(const URI uri_passed);
void processContactLineEdit();
static Account* getSelectedAccount();
static bool shouldDisplayInviteButton(ContactMethod& cm);
void backToWelcomePage();
void hideMiniSpinner();
void triggerDeleteContactDialog(ContactMethod *cm, Account *ac);
// lrc
Video::Renderer* videoRenderer_;
std::string lastConvUid_ {};
lrc::api::profile::Type currentTypeFilter_{};
std::unique_ptr<SmartListModel> smartListModel_;
std::unique_ptr<MessageModel> messageModel_;
QMetaObject::Connection modelSortedConnection_;
QMetaObject::Connection modelUpdatedConnection_;
QMetaObject::Connection filterChangedConnection_;
QMetaObject::Connection newConversationConnection_;
QMetaObject::Connection conversationRemovedConnection_;
QMetaObject::Connection newInteractionConnection_;
QMetaObject::Connection interactionStatusUpdatedConnection_;
QMetaObject::Connection conversationClearedConnection;
QMetaObject::Connection selectedCallChanged_;
QMetaObject::Connection smartlistSelectionConnection_;
};
This diff is collapsed.
......@@ -77,9 +77,6 @@ ConfigurationWidget::ConfigurationWidget(QWidget *parent) :
}
accountModel_->save();
accountDetails_->save();
});
connect(ui->exitSettingsButton, &QPushButton::clicked, this, [=]() {
emit NavigationRequested(ScreenEnum::CallScreen);
});
......
/***************************************************************************
* Copyright (C) 2015-2017 by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@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 "contactmethodpicker.h"
#include "ui_contactmethodpicker.h"
#include "contactmethod.h"
ContactMethodPicker::ContactMethodPicker(const Person::ContactMethods& cM, QWidget *parent) :
QDialog(parent),
ui(new Ui::ContactMethodPicker),
contactMethods_(cM)
{
ui->setupUi(this);
this->setWindowFlags(Qt::CustomizeWindowHint);
this->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);
for (auto contactMethod : cM) {
auto item = new QListWidgetItem();
item->setText(contactMethod->uri());
ui->contactMethodListWidget->addItem(item);
}
}
ContactMethodPicker::~ContactMethodPicker()
{
delete ui;
}
void
ContactMethodPicker::on_contactMethodListWidget_clicked(const QModelIndex &index)
{
index_ = index.row();
accept();
}
ContactMethod*
ContactMethodPicker::getSelected() const
{
return contactMethods_.at(index_);
}
/***************************************************************************
* Copyright (C) 2015-2017 by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@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 "person.h"
#include "personmodel.h"
namespace Ui {
class ContactMethodPicker;
}
class ContactMethodPicker final : public QDialog
{
Q_OBJECT
public:
explicit ContactMethodPicker(const Person::ContactMethods &cM, QWidget *parent = 0);
~ContactMethodPicker();
ContactMethod* getSelected() const;
//UI SLOTS
private slots:
void on_contactMethodListWidget_clicked(const QModelIndex &index);
private:
Ui::ContactMethodPicker *ui;
const Person::ContactMethods& contactMethods_;
int index_;
};
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ContactMethodPicker</class>
<widget class="QDialog" name="ContactMethodPicker">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>93</width>
<height>93</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>