blob: c4ae65dad3b8de881be790ed61ec98944e84c353 [file] [log] [blame]
Olivier SOLDANO47aa97f2017-04-04 10:40:00 -04001/**************************************************************************
Anthony Léonard2fde81d2017-04-17 10:06:55 -04002* Copyright (C) 2015-2017 by Savoir-faire Linux *
Olivier SOLDANO47aa97f2017-04-04 10:40:00 -04003* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
4* Author: Anthony Léonard <anthony.leonard@savoirfairelinux.com> *
5* Author: Olivier Soldano <olivier.soldano@savoirfairelinux.com> *
6* *
7* This program is free software; you can redistribute it and/or modify *
8* it under the terms of the GNU General Public License as published by *
9* the Free Software Foundation; either version 3 of the License, or *
10* (at your option) any later version. *
11* *
12* This program is distributed in the hope that it will be useful, *
13* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15* GNU General Public License for more details. *
16* *
17* You should have received a copy of the GNU General Public License *
18* along with this program. If not, see <http://www.gnu.org/licenses/>. *
19**************************************************************************/
Edric Milaret627500d2015-03-27 16:41:40 -040020
Edric Milaret5f316da2015-09-28 11:57:42 -040021#pragma once
Edric Milaret627500d2015-03-27 16:41:40 -040022
23#include <QWidget>
Edric Milaret67007d12015-05-07 09:40:09 -040024#include <QVector>
25#include <QString>
Edric Milaret7d40a4a2015-05-13 13:01:15 -040026#include <QMenu>
Edric Milaret029b95a2015-06-09 09:51:44 -040027#include <QItemSelection>
Edric Milaretc7ab5502015-06-15 11:18:02 -040028#include <QMovie>
Edric Milaret627500d2015-03-27 16:41:40 -040029
30#include "navwidget.h"
Edric Milaretcdc978b2015-06-04 11:25:12 -040031#include "instantmessagingwidget.h"
Edric Milaret627500d2015-03-27 16:41:40 -040032
33#include "callmodel.h"
34#include "video/renderer.h"
35#include "video/previewmanager.h"
Edric Milarete5afb072015-06-02 16:45:44 -040036#include "accountmodel.h"
Edric Milaret627500d2015-03-27 16:41:40 -040037#include "categorizedhistorymodel.h"
Edric Milaret00a32252016-01-19 10:37:13 -050038#include "media/textrecording.h"
Edric Milaret627500d2015-03-27 16:41:40 -040039
Edric Milareted0b2802015-10-01 15:10:02 -040040class SmartListDelegate;
Edric Milaretab12d022015-12-04 16:09:44 -050041class ImDelegate;
Nicolas Jagerca850292016-01-17 14:11:10 -050042class QPropertyAnimation;
Edric Milareted0b2802015-10-01 15:10:02 -040043
Edric Milaret627500d2015-03-27 16:41:40 -040044namespace Ui {
45class CallWidget;
46}
47
48class CallWidget : public NavWidget
49{
50 Q_OBJECT
51
52public:
Nicolas Jager97a21b42015-12-03 16:55:45 -050053 explicit CallWidget(QWidget* parent = 0);
Edric Milaret627500d2015-03-27 16:41:40 -040054 ~CallWidget();
55 void atExit();
Olivier SOLDANO2100f1c2017-09-06 16:45:20 -040056 bool findRingAccount();
Edric Milaret627500d2015-03-27 16:41:40 -040057
Edric Milaret33cb4832016-01-08 10:14:14 -050058public slots:
Nicolas Jager74fe46f2016-02-29 14:55:09 -050059 void settingsButtonClicked();
Nicolas Jager74fe46f2016-02-29 14:55:09 -050060 void showIMOutOfCall(const QModelIndex& nodeIdx);
61 void btnComBarVideoClicked();
62
Edric Milaret627500d2015-03-27 16:41:40 -040063//UI SLOTS
Nicolas Jager97a21b42015-12-03 16:55:45 -050064public slots:
Nicolas Jager97a21b42015-12-03 16:55:45 -050065 void on_ringContactLineEdit_returnPressed();
Olivier SOLDANO70279d32017-07-18 15:21:34 -040066 inline void on_entered(const QModelIndex& i){if (i.isValid()) highLightedIndex_ = i;}
Nicolas Jager97a21b42015-12-03 16:55:45 -050067
Edric Milaret627500d2015-03-27 16:41:40 -040068private slots:
69 void on_acceptButton_clicked();
70 void on_refuseButton_clicked();
Edric Milareted0b2802015-10-01 15:10:02 -040071 void on_cancelButton_clicked();
Nicolas Jager97a21b42015-12-03 16:55:45 -050072 void on_smartList_doubleClicked(const QModelIndex& index);
Edric Milaret6a785af2016-03-07 15:39:30 -050073 void on_sendIMButton_clicked();
74 void on_imMessageEdit_returnPressed();
Edric Milaret8001f6f2016-01-27 09:55:12 -050075 void on_ringContactLineEdit_textChanged(const QString& text);
Edric Milareta0ebd062016-01-13 12:18:23 -050076 void on_imBackButton_clicked();
Olivier SOLDANOdd878662017-03-27 16:00:06 -040077 void on_sendContactRequestPageButton_clicked();
78 void on_sendCRBackButton_clicked();
Edric Milaret6b68a482016-02-01 15:23:44 -050079 void on_smartList_clicked(const QModelIndex &index);
Edric Milaret1e598592016-09-02 10:10:01 -040080 void on_qrButton_toggled(bool checked);
Edric Milaret4097d2f2016-02-09 14:41:50 -050081 void on_shareButton_clicked();
Anthony Léonardd47179c2017-03-28 10:39:10 -040082 void on_pendingCRBackButton_clicked();
Edric Milaret627500d2015-03-27 16:41:40 -040083
84private slots:
Nicolas Jager97a21b42015-12-03 16:55:45 -050085 void callIncoming(Call* call);
Nicolas Jager97a21b42015-12-03 16:55:45 -050086 void callStateChanged(Call* call, Call::State previousState);
Olivier SOLDANO61065ec2016-11-11 16:31:34 -050087 void smartListCurrentChanged(const QModelIndex &currentIdx, const QModelIndex &previousIdx);
Anthony Léonardd47179c2017-03-28 10:39:10 -040088 void contactReqListCurrentChanged(const QModelIndex &currentIdx, const QModelIndex &previousIdx);
Edric Milaretab12d022015-12-04 16:09:44 -050089 void slotAccountMessageReceived(const QMap<QString,QString> message,ContactMethod* cm,Media::Media::Direction dir);
Edric Milaret00a32252016-01-19 10:37:13 -050090 void onIncomingMessage(::Media::TextRecording* t, ContactMethod* cm);
Edric Milaret00d34f22016-05-09 16:30:29 -040091 void callChangedSlot();
Anthony Léonardd47179c2017-03-28 10:39:10 -040092 void contactLineEdit_registeredNameFound(Account *account, NameDirectory::LookupStatus status, const QString& address, const QString& name);
Olivier SOLDANO47aa97f2017-04-04 10:40:00 -040093 void searchBtnClicked();
Anthony Léonardd47179c2017-03-28 10:39:10 -040094 void selectedAccountChanged(const QModelIndex &current, const QModelIndex &previous);
Olivier SOLDANO815d92f2017-07-13 14:05:36 -040095 void on_contactMethodComboBox_currentIndexChanged(int index);
Olivier SOLDANO8179e992017-07-19 15:59:19 -040096 void on_contactRequestList_clicked(const QModelIndex &index);
Edric Milaretd8528fa2015-07-07 14:13:51 -040097
Edric Milaret627500d2015-03-27 16:41:40 -040098private:
Nicolas Jager97a21b42015-12-03 16:55:45 -050099 Ui::CallWidget* ui;
Edric Milaret627500d2015-03-27 16:41:40 -0400100 Call* actualCall_;
101 Video::Renderer* videoRenderer_;
102 CallModel* callModel_;
103 int outputVolume_;
104 int inputVolume_;
Nicolas Jager97a21b42015-12-03 16:55:45 -0500105 QMenu* menu_;
Edric Milareted0b2802015-10-01 15:10:02 -0400106 SmartListDelegate* smartListDelegate_;
Edric Milaret6b68a482016-02-01 15:23:44 -0500107 QPersistentModelIndex highLightedIndex_;
Edric Milaretab12d022015-12-04 16:09:44 -0500108 ImDelegate* imDelegate_;
109 QMetaObject::Connection imConnection_;
Edric Milaret49130472016-01-22 10:39:37 -0500110 QMetaObject::Connection imVisibleConnection_;
Edric Milaret00d34f22016-05-09 16:30:29 -0400111 QMetaObject::Connection callChangedConnection_;
Edric Milaret70ae8782016-04-18 16:10:44 -0400112 QMetaObject::Connection imClickedConnection_;
Anthony Léonardd47179c2017-03-28 10:39:10 -0400113 QMetaObject::Connection crListSelectionConnection_;
Edric Milaret6b68a482016-02-01 15:23:44 -0500114 QPropertyAnimation* pageAnim_;
Edric Milarete19c4cd2016-02-12 10:19:44 -0500115 QMenu* shareMenu_;
Olivier SOLDANO19193412017-06-06 12:03:36 -0400116 QMovie* miniSpinner_;
Nicolas Jagerca850292016-01-17 14:11:10 -0500117
Edric Milaret6d0e5312016-04-04 16:30:22 -0400118 constexpr static int qrSize_ = 200;
Edric Milaret01f23842015-06-22 14:46:01 -0400119
Edric Milaret7d40a4a2015-05-13 13:01:15 -0400120private:
Nicolas Jager97a21b42015-12-03 16:55:45 -0500121 void setActualCall(Call* value);
Edric Milareted0b2802015-10-01 15:10:02 -0400122 void placeCall();
Edric Milareta0ebd062016-01-13 12:18:23 -0500123 void setupOutOfCallIM();
Olivier SOLDANOcc28a0d2017-07-21 13:53:31 -0400124 void setupSmartListMenu(const QPoint &pos);
Edric Milaret6b68a482016-02-01 15:23:44 -0500125 void slidePage(QWidget* widget, bool toRight = false);
126 void callStateToView(Call* value);
Anthony Léonarda86a8972016-12-15 10:33:47 -0500127 void setupQRCode(QString ringID);
Anthony Léonardaa90e1a2016-10-12 11:24:17 -0400128 void searchContactLineEditEntry(const URI &uri);
Olivier SOLDANOdd878662017-03-27 16:00:06 -0400129 bool uriNeedNameLookup(const URI uri_passed);
Olivier SOLDANO47aa97f2017-04-04 10:40:00 -0400130 void processContactLineEdit();
Anthony Léonard5cc76412017-04-21 16:52:25 -0400131 static Account* getSelectedAccount();
Anthony Léonard041ad392017-07-14 16:44:09 -0400132 static bool shouldDisplayInviteButton(ContactMethod& cm);
Olivier SOLDANO2bcdfd72017-05-02 14:37:19 -0400133 void backToWelcomePage();
Olivier SOLDANO19193412017-06-06 12:03:36 -0400134 void hideMiniSpinner();
Olivier SOLDANOcc28a0d2017-07-21 13:53:31 -0400135 void triggerDeleteContactDialog(ContactMethod *cm, Account *ac);
Edric Milaret627500d2015-03-27 16:41:40 -0400136};