blob: bfce156f554c615d1be965ea5e77313903bad790 [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:
58 void contactButton_clicked(bool checked);
59 void settingsButton_clicked();
60 void historicButton_clicked(bool checked);
Edric Milaret627500d2015-03-27 16:41:40 -040061//UI SLOTS
Nicolas Jager97a21b42015-12-03 16:55:45 -050062public slots:
Nicolas Jager97a21b42015-12-03 16:55:45 -050063 void on_ringContactLineEdit_returnPressed();
64 void on_btnCall_clicked();
65 void on_btnvideo_clicked();
Edric Milaret6816fd72016-01-29 16:36:24 -050066 void showIMOutOfCall();
Nicolas Jager97a21b42015-12-03 16:55:45 -050067 inline void on_entered(const QModelIndex& i){highLightedIndex_ = i;};
68
69//UI SLOTS
Edric Milaret627500d2015-03-27 16:41:40 -040070private slots:
71 void on_acceptButton_clicked();
72 void on_refuseButton_clicked();
Nicolas Jager97a21b42015-12-03 16:55:45 -050073 void on_contactView_doubleClicked(const QModelIndex& index);
Edric Milareted0b2802015-10-01 15:10:02 -040074 void on_cancelButton_clicked();
Nicolas Jager97a21b42015-12-03 16:55:45 -050075 void on_smartList_doubleClicked(const QModelIndex& index);
76 void on_historyList_doubleClicked(const QModelIndex& index);
Edric Milaretab12d022015-12-04 16:09:44 -050077 void on_sendButton_clicked();
78 void on_messageEdit_returnPressed();
79 void on_contactMethodComboBox_currentIndexChanged(const QString& number);
Edric Milaret8001f6f2016-01-27 09:55:12 -050080 void on_ringContactLineEdit_textChanged(const QString& text);
Edric Milareta0ebd062016-01-13 12:18:23 -050081 void on_imBackButton_clicked();
Edric Milaret7cf39e22016-02-02 12:44:03 -050082 void on_copyCMButton_clicked();
Edric Milaret627500d2015-03-27 16:41:40 -040083
84private slots:
Nicolas Jager97a21b42015-12-03 16:55:45 -050085 void callIncoming(Call* call);
86 void addedCall(Call* call, Call* parent);
87 void callStateChanged(Call* call, Call::State previousState);
Edric Milaret67007d12015-05-07 09:40:09 -040088 void findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec);
Nicolas Jager97a21b42015-12-03 16:55:45 -050089 void smartListSelectionChanged(const QItemSelection& newSel, const QItemSelection& oldSel);
Edric Milaretab12d022015-12-04 16:09:44 -050090 void slotAccountMessageReceived(const QMap<QString,QString> message,ContactMethod* cm,Media::Media::Direction dir);
Edric Milaret00a32252016-01-19 10:37:13 -050091 void onIncomingMessage(::Media::TextRecording* t, ContactMethod* cm);
Edric Milaretd8528fa2015-07-07 14:13:51 -040092
Edric Milaret627500d2015-03-27 16:41:40 -040093private:
Nicolas Jager97a21b42015-12-03 16:55:45 -050094 Ui::CallWidget* ui;
Edric Milaret627500d2015-03-27 16:41:40 -040095 Call* actualCall_;
96 Video::Renderer* videoRenderer_;
97 CallModel* callModel_;
98 int outputVolume_;
99 int inputVolume_;
Nicolas Jager97a21b42015-12-03 16:55:45 -0500100 QMenu* menu_;
101 ContactDelegate* contactDelegate_;
102 HistoryDelegate* historyDelegate_;
Edric Milareted0b2802015-10-01 15:10:02 -0400103 SmartListDelegate* smartListDelegate_;
Nicolas Jager97a21b42015-12-03 16:55:45 -0500104 QModelIndex highLightedIndex_;
Edric Milaretab12d022015-12-04 16:09:44 -0500105 ImDelegate* imDelegate_;
106 QMetaObject::Connection imConnection_;
Edric Milaret49130472016-01-22 10:39:37 -0500107 QMetaObject::Connection imVisibleConnection_;
Nicolas Jagerca850292016-01-17 14:11:10 -0500108 QPropertyAnimation* messagingPageAnim_;
109 QPropertyAnimation* welcomePageAnim_;
110
111 constexpr static int animDuration_ = 200; //msecs
Edric Milaret01f23842015-06-22 14:46:01 -0400112
Edric Milaret7d40a4a2015-05-13 13:01:15 -0400113private:
Edric Milaret627500d2015-03-27 16:41:40 -0400114 void findRingAccount();
Nicolas Jager97a21b42015-12-03 16:55:45 -0500115 void setActualCall(Call* value);
Edric Milareted0b2802015-10-01 15:10:02 -0400116 void placeCall();
Edric Milareta0ebd062016-01-13 12:18:23 -0500117 void setupOutOfCallIM();
118 void setupSmartListMenu();
Nicolas Jagerca850292016-01-17 14:11:10 -0500119 void slideToLeft(QPropertyAnimation* anim, QWidget* widget);
120 void slideToRight(QPropertyAnimation* anim, QWidget* widget);
Edric Milaret627500d2015-03-27 16:41:40 -0400121};
122