blob: 374ad5635e18f0c4e31e9543445d631fcc6f3898 [file] [log] [blame]
Olivier SOLDANO47aa97f2017-04-04 10:40:00 -04001/**************************************************************************
2* Copyright (C) 2015-2016 by Savoir-faire Linux *
3* 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();
Anthony Léonard314c2a42016-10-20 10:39:56 -040056 void 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);
Olivier SOLDANOdd878662017-03-27 16:00:06 -040061 void configureSendCRPageButton(const QModelIndex& nodeIdx);
Nicolas Jager74fe46f2016-02-29 14:55:09 -050062 void btnComBarVideoClicked();
63
Edric Milaret627500d2015-03-27 16:41:40 -040064//UI SLOTS
Nicolas Jager97a21b42015-12-03 16:55:45 -050065public slots:
Nicolas Jager97a21b42015-12-03 16:55:45 -050066 void on_ringContactLineEdit_returnPressed();
Olivier SOLDANO47aa97f2017-04-04 10:40:00 -040067 inline void on_entered(const QModelIndex& i){highLightedIndex_ = i;}
Nicolas Jager97a21b42015-12-03 16:55:45 -050068
Edric Milaret627500d2015-03-27 16:41:40 -040069private slots:
70 void on_acceptButton_clicked();
71 void on_refuseButton_clicked();
Edric Milareted0b2802015-10-01 15:10:02 -040072 void on_cancelButton_clicked();
Nicolas Jager97a21b42015-12-03 16:55:45 -050073 void on_smartList_doubleClicked(const QModelIndex& index);
Edric Milaret6a785af2016-03-07 15:39:30 -050074 void on_sendIMButton_clicked();
75 void on_imMessageEdit_returnPressed();
Edric Milaretab12d022015-12-04 16:09:44 -050076 void on_contactMethodComboBox_currentIndexChanged(const QString& number);
Edric Milaret8001f6f2016-01-27 09:55:12 -050077 void on_ringContactLineEdit_textChanged(const QString& text);
Edric Milareta0ebd062016-01-13 12:18:23 -050078 void on_imBackButton_clicked();
Edric Milaret7cf39e22016-02-02 12:44:03 -050079 void on_copyCMButton_clicked();
Olivier SOLDANOdd878662017-03-27 16:00:06 -040080 void on_sendContactRequestPageButton_clicked();
81 void on_sendCRBackButton_clicked();
Edric Milaret6b68a482016-02-01 15:23:44 -050082 void on_smartList_clicked(const QModelIndex &index);
Edric Milaret1e598592016-09-02 10:10:01 -040083 void on_qrButton_toggled(bool checked);
Edric Milaret4097d2f2016-02-09 14:41:50 -050084 void on_shareButton_clicked();
Anthony Léonardd47179c2017-03-28 10:39:10 -040085 void on_pendingCRBackButton_clicked();
Edric Milaret627500d2015-03-27 16:41:40 -040086
87private slots:
Nicolas Jager97a21b42015-12-03 16:55:45 -050088 void callIncoming(Call* call);
Nicolas Jager97a21b42015-12-03 16:55:45 -050089 void callStateChanged(Call* call, Call::State previousState);
Olivier SOLDANO61065ec2016-11-11 16:31:34 -050090 void smartListCurrentChanged(const QModelIndex &currentIdx, const QModelIndex &previousIdx);
Anthony Léonardd47179c2017-03-28 10:39:10 -040091 void contactReqListCurrentChanged(const QModelIndex &currentIdx, const QModelIndex &previousIdx);
Edric Milaretab12d022015-12-04 16:09:44 -050092 void slotAccountMessageReceived(const QMap<QString,QString> message,ContactMethod* cm,Media::Media::Direction dir);
Edric Milaret00a32252016-01-19 10:37:13 -050093 void onIncomingMessage(::Media::TextRecording* t, ContactMethod* cm);
Edric Milaret00d34f22016-05-09 16:30:29 -040094 void callChangedSlot();
Anthony Léonardd47179c2017-03-28 10:39:10 -040095 void contactLineEdit_registeredNameFound(Account *account, NameDirectory::LookupStatus status, const QString& address, const QString& name);
Olivier SOLDANO47aa97f2017-04-04 10:40:00 -040096 void searchBtnClicked();
Anthony Léonardd47179c2017-03-28 10:39:10 -040097 void selectedAccountChanged(const QModelIndex &current, const QModelIndex &previous);
Edric Milaretd8528fa2015-07-07 14:13:51 -040098
Edric Milaret627500d2015-03-27 16:41:40 -040099private:
Nicolas Jager97a21b42015-12-03 16:55:45 -0500100 Ui::CallWidget* ui;
Edric Milaret627500d2015-03-27 16:41:40 -0400101 Call* actualCall_;
102 Video::Renderer* videoRenderer_;
103 CallModel* callModel_;
104 int outputVolume_;
105 int inputVolume_;
Nicolas Jager97a21b42015-12-03 16:55:45 -0500106 QMenu* menu_;
Edric Milareted0b2802015-10-01 15:10:02 -0400107 SmartListDelegate* smartListDelegate_;
Edric Milaret6b68a482016-02-01 15:23:44 -0500108 QPersistentModelIndex highLightedIndex_;
Edric Milaretab12d022015-12-04 16:09:44 -0500109 ImDelegate* imDelegate_;
110 QMetaObject::Connection imConnection_;
Edric Milaret49130472016-01-22 10:39:37 -0500111 QMetaObject::Connection imVisibleConnection_;
Edric Milaret00d34f22016-05-09 16:30:29 -0400112 QMetaObject::Connection callChangedConnection_;
Edric Milaret70ae8782016-04-18 16:10:44 -0400113 QMetaObject::Connection imClickedConnection_;
Anthony Léonardd47179c2017-03-28 10:39:10 -0400114 QMetaObject::Connection crListSelectionConnection_;
Edric Milaret6b68a482016-02-01 15:23:44 -0500115 QPropertyAnimation* pageAnim_;
Edric Milarete19c4cd2016-02-12 10:19:44 -0500116 QMenu* shareMenu_;
Nicolas Jagerca850292016-01-17 14:11:10 -0500117
118 constexpr static int animDuration_ = 200; //msecs
Edric Milaret6d0e5312016-04-04 16:30:22 -0400119 constexpr static int qrSize_ = 200;
Edric Milaret01f23842015-06-22 14:46:01 -0400120
Edric Milaret7d40a4a2015-05-13 13:01:15 -0400121private:
Nicolas Jager97a21b42015-12-03 16:55:45 -0500122 void setActualCall(Call* value);
Edric Milareted0b2802015-10-01 15:10:02 -0400123 void placeCall();
Edric Milareta0ebd062016-01-13 12:18:23 -0500124 void setupOutOfCallIM();
125 void setupSmartListMenu();
Edric Milaret6b68a482016-02-01 15:23:44 -0500126 void slidePage(QWidget* widget, bool toRight = false);
127 void callStateToView(Call* value);
Anthony Léonarda86a8972016-12-15 10:33:47 -0500128 void setupQRCode(QString ringID);
Anthony Léonardaa90e1a2016-10-12 11:24:17 -0400129 void searchContactLineEditEntry(const URI &uri);
Olivier SOLDANOdd878662017-03-27 16:00:06 -0400130 bool uriNeedNameLookup(const URI uri_passed);
Olivier SOLDANO47aa97f2017-04-04 10:40:00 -0400131 void processContactLineEdit();
Edric Milaret627500d2015-03-27 16:41:40 -0400132};