blob: 559b1327f7ccb44b9d549ae6e36915e5a3e61076 [file] [log] [blame]
Edric Milaret627500d2015-03-27 16:41:40 -04001/***************************************************************************
Edric Milaretbab169d2016-01-07 15:13:33 -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 Milaret627500d2015-03-27 16:41:40 -040036
Edric Milareted0b2802015-10-01 15:10:02 -040037class ContactDelegate;
38class HistoryDelegate;
39class SmartListDelegate;
Edric Milaretab12d022015-12-04 16:09:44 -050040class ImDelegate;
Nicolas Jagerca850292016-01-17 14:11:10 -050041class QPropertyAnimation;
Edric Milareted0b2802015-10-01 15:10:02 -040042
Edric Milaret627500d2015-03-27 16:41:40 -040043namespace Ui {
44class CallWidget;
45}
46
47class CallWidget : public NavWidget
48{
49 Q_OBJECT
50
51public:
Nicolas Jager97a21b42015-12-03 16:55:45 -050052 explicit CallWidget(QWidget* parent = 0);
Edric Milaret627500d2015-03-27 16:41:40 -040053 ~CallWidget();
54 void atExit();
55
Edric Milaret33cb4832016-01-08 10:14:14 -050056public slots:
57 void contactButton_clicked(bool checked);
58 void settingsButton_clicked();
59 void historicButton_clicked(bool checked);
Edric Milaret627500d2015-03-27 16:41:40 -040060//UI SLOTS
Nicolas Jager97a21b42015-12-03 16:55:45 -050061public slots:
Nicolas Jager97a21b42015-12-03 16:55:45 -050062 void on_ringContactLineEdit_returnPressed();
63 void on_btnCall_clicked();
64 void on_btnvideo_clicked();
Edric Milareta0ebd062016-01-13 12:18:23 -050065 void showIMOutOfCall();
Nicolas Jager97a21b42015-12-03 16:55:45 -050066 inline void on_entered(const QModelIndex& i){highLightedIndex_ = i;};
67
68//UI SLOTS
Edric Milaret627500d2015-03-27 16:41:40 -040069private slots:
70 void on_acceptButton_clicked();
71 void on_refuseButton_clicked();
Nicolas Jager97a21b42015-12-03 16:55:45 -050072 void on_contactView_doubleClicked(const QModelIndex& index);
Edric Milareted0b2802015-10-01 15:10:02 -040073 void on_cancelButton_clicked();
Nicolas Jager97a21b42015-12-03 16:55:45 -050074 void on_smartList_doubleClicked(const QModelIndex& index);
75 void on_historyList_doubleClicked(const QModelIndex& index);
Edric Milaretab12d022015-12-04 16:09:44 -050076 void on_sendButton_clicked();
77 void on_messageEdit_returnPressed();
78 void on_contactMethodComboBox_currentIndexChanged(const QString& number);
Edric Milaretfa05d972016-01-13 16:22:04 -050079 void on_ringContactLineEdit_textEdited(const QString& text);
Edric Milareta0ebd062016-01-13 12:18:23 -050080 void on_imBackButton_clicked();
Edric Milaret627500d2015-03-27 16:41:40 -040081
82private slots:
Nicolas Jager97a21b42015-12-03 16:55:45 -050083 void callIncoming(Call* call);
84 void addedCall(Call* call, Call* parent);
85 void callStateChanged(Call* call, Call::State previousState);
Edric Milaret67007d12015-05-07 09:40:09 -040086 void findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec);
Nicolas Jager97a21b42015-12-03 16:55:45 -050087 void smartListSelectionChanged(const QItemSelection& newSel, const QItemSelection& oldSel);
Edric Milaretab12d022015-12-04 16:09:44 -050088 void slotAccountMessageReceived(const QMap<QString,QString> message,ContactMethod* cm,Media::Media::Direction dir);
Edric Milaretd8528fa2015-07-07 14:13:51 -040089
Edric Milaret627500d2015-03-27 16:41:40 -040090private:
Nicolas Jager97a21b42015-12-03 16:55:45 -050091 Ui::CallWidget* ui;
Edric Milaret627500d2015-03-27 16:41:40 -040092 Call* actualCall_;
93 Video::Renderer* videoRenderer_;
94 CallModel* callModel_;
95 int outputVolume_;
96 int inputVolume_;
Nicolas Jager97a21b42015-12-03 16:55:45 -050097 QMenu* menu_;
98 ContactDelegate* contactDelegate_;
99 HistoryDelegate* historyDelegate_;
Edric Milareted0b2802015-10-01 15:10:02 -0400100 SmartListDelegate* smartListDelegate_;
Nicolas Jager97a21b42015-12-03 16:55:45 -0500101 QModelIndex highLightedIndex_;
Edric Milaretab12d022015-12-04 16:09:44 -0500102 ImDelegate* imDelegate_;
103 QMetaObject::Connection imConnection_;
Nicolas Jagerca850292016-01-17 14:11:10 -0500104 QPropertyAnimation* messagingPageAnim_;
105 QPropertyAnimation* welcomePageAnim_;
106
107 constexpr static int animDuration_ = 200; //msecs
Edric Milaret01f23842015-06-22 14:46:01 -0400108
Edric Milaret7d40a4a2015-05-13 13:01:15 -0400109private:
Edric Milaret627500d2015-03-27 16:41:40 -0400110 void findRingAccount();
Nicolas Jager97a21b42015-12-03 16:55:45 -0500111 void setActualCall(Call* value);
Edric Milareted0b2802015-10-01 15:10:02 -0400112 void placeCall();
Edric Milareta0ebd062016-01-13 12:18:23 -0500113 void setupOutOfCallIM();
114 void setupSmartListMenu();
Nicolas Jagerca850292016-01-17 14:11:10 -0500115 void slideToLeft(QPropertyAnimation* anim, QWidget* widget);
116 void slideToRight(QPropertyAnimation* anim, QWidget* widget);
Edric Milaret627500d2015-03-27 16:41:40 -0400117};
118