blob: d9e769c6b236a9c7477691236610a04fbdab7c07 [file] [log] [blame]
Edric Milaret627500d2015-03-27 16:41:40 -04001/***************************************************************************
Nicolas Jager45bf7c02016-01-20 09:53:02 -05002 * Copyright (C) 2015-2016 by Savoir-faire Linux *
Edric Milaret627500d2015-03-27 16:41:40 -04003 * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17 **************************************************************************/
18
Edric Milaret5f316da2015-09-28 11:57:42 -040019#pragma once
Edric Milaret627500d2015-03-27 16:41:40 -040020
21#include <QWidget>
Edric Milaret67007d12015-05-07 09:40:09 -040022#include <QVector>
23#include <QString>
Edric Milaret7d40a4a2015-05-13 13:01:15 -040024#include <QMenu>
Edric Milaret029b95a2015-06-09 09:51:44 -040025#include <QItemSelection>
Edric Milaretc7ab5502015-06-15 11:18:02 -040026#include <QMovie>
Edric Milaret627500d2015-03-27 16:41:40 -040027
28#include "navwidget.h"
Edric Milaretcdc978b2015-06-04 11:25:12 -040029#include "instantmessagingwidget.h"
Edric Milaret627500d2015-03-27 16:41:40 -040030
31#include "callmodel.h"
32#include "video/renderer.h"
33#include "video/previewmanager.h"
Edric Milarete5afb072015-06-02 16:45:44 -040034#include "accountmodel.h"
Edric Milaret627500d2015-03-27 16:41:40 -040035#include "categorizedhistorymodel.h"
Edric Milaret00a32252016-01-19 10:37:13 -050036#include "media/textrecording.h"
Edric Milaret627500d2015-03-27 16:41:40 -040037
Edric Milareted0b2802015-10-01 15:10:02 -040038class ContactDelegate;
39class HistoryDelegate;
40class 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();
56
Edric Milaret33cb4832016-01-08 10:14:14 -050057public slots:
Nicolas Jager74fe46f2016-02-29 14:55:09 -050058 void contactButtonClicked(bool checked);
59 void settingsButtonClicked();
60 void historicButtonClicked(bool checked);
61 void showIMOutOfCall(const QModelIndex& nodeIdx);
62 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();
67 void on_btnCall_clicked();
Nicolas Jager97a21b42015-12-03 16:55:45 -050068 inline void on_entered(const QModelIndex& i){highLightedIndex_ = i;};
69
70//UI SLOTS
Edric Milaret627500d2015-03-27 16:41:40 -040071private slots:
72 void on_acceptButton_clicked();
73 void on_refuseButton_clicked();
Nicolas Jager97a21b42015-12-03 16:55:45 -050074 void on_contactView_doubleClicked(const QModelIndex& index);
Edric Milareted0b2802015-10-01 15:10:02 -040075 void on_cancelButton_clicked();
Nicolas Jager97a21b42015-12-03 16:55:45 -050076 void on_smartList_doubleClicked(const QModelIndex& index);
77 void on_historyList_doubleClicked(const QModelIndex& index);
Edric Milaret6a785af2016-03-07 15:39:30 -050078 void on_sendIMButton_clicked();
79 void on_imMessageEdit_returnPressed();
Edric Milaretab12d022015-12-04 16:09:44 -050080 void on_contactMethodComboBox_currentIndexChanged(const QString& number);
Edric Milaret8001f6f2016-01-27 09:55:12 -050081 void on_ringContactLineEdit_textChanged(const QString& text);
Edric Milareta0ebd062016-01-13 12:18:23 -050082 void on_imBackButton_clicked();
Edric Milaret7cf39e22016-02-02 12:44:03 -050083 void on_copyCMButton_clicked();
Edric Milaret6b68a482016-02-01 15:23:44 -050084 void on_smartList_clicked(const QModelIndex &index);
Edric Milaret4097d2f2016-02-09 14:41:50 -050085 void on_shareButton_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);
Edric Milaret67007d12015-05-07 09:40:09 -040090 void findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec);
Nicolas Jager97a21b42015-12-03 16:55:45 -050091 void smartListSelectionChanged(const QItemSelection& newSel, const QItemSelection& oldSel);
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();
Edric Milaretd8528fa2015-07-07 14:13:51 -040095
Edric Milaret627500d2015-03-27 16:41:40 -040096private:
Nicolas Jager97a21b42015-12-03 16:55:45 -050097 Ui::CallWidget* ui;
Edric Milaret627500d2015-03-27 16:41:40 -040098 Call* actualCall_;
99 Video::Renderer* videoRenderer_;
100 CallModel* callModel_;
101 int outputVolume_;
102 int inputVolume_;
Nicolas Jager97a21b42015-12-03 16:55:45 -0500103 QMenu* menu_;
104 ContactDelegate* contactDelegate_;
105 HistoryDelegate* historyDelegate_;
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 Milaret6b68a482016-02-01 15:23:44 -0500112 QPropertyAnimation* pageAnim_;
Edric Milarete19c4cd2016-02-12 10:19:44 -0500113 QMenu* shareMenu_;
Nicolas Jagerca850292016-01-17 14:11:10 -0500114
115 constexpr static int animDuration_ = 200; //msecs
Edric Milaret6d0e5312016-04-04 16:30:22 -0400116 constexpr static int qrSize_ = 200;
Edric Milaret01f23842015-06-22 14:46:01 -0400117
Edric Milaret7d40a4a2015-05-13 13:01:15 -0400118private:
Edric Milaret627500d2015-03-27 16:41:40 -0400119 void findRingAccount();
Nicolas Jager97a21b42015-12-03 16:55:45 -0500120 void setActualCall(Call* value);
Edric Milareted0b2802015-10-01 15:10:02 -0400121 void placeCall();
Edric Milareta0ebd062016-01-13 12:18:23 -0500122 void setupOutOfCallIM();
123 void setupSmartListMenu();
Edric Milaret6b68a482016-02-01 15:23:44 -0500124 void slidePage(QWidget* widget, bool toRight = false);
125 void callStateToView(Call* value);
Edric Milarete19c4cd2016-02-12 10:19:44 -0500126 void setupShareMenu();
127 void setupQRCode();
Edric Milaret627500d2015-03-27 16:41:40 -0400128};
129