blob: 4fa3414ff9c7d47520ff16bfb227f2dbaea9989d [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 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 Milareta0ebd062016-01-13 12:18:23 -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 Milaretfa05d972016-01-13 16:22:04 -050080 void on_ringContactLineEdit_textEdited(const QString& text);
Edric Milareta0ebd062016-01-13 12:18:23 -050081 void on_imBackButton_clicked();
Edric Milaret627500d2015-03-27 16:41:40 -040082
83private slots:
Nicolas Jager97a21b42015-12-03 16:55:45 -050084 void callIncoming(Call* call);
85 void addedCall(Call* call, Call* parent);
86 void callStateChanged(Call* call, Call::State previousState);
Edric Milaret67007d12015-05-07 09:40:09 -040087 void findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec);
Nicolas Jager97a21b42015-12-03 16:55:45 -050088 void smartListSelectionChanged(const QItemSelection& newSel, const QItemSelection& oldSel);
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 Milaretd8528fa2015-07-07 14:13:51 -040091
Edric Milaret627500d2015-03-27 16:41:40 -040092private:
Nicolas Jager97a21b42015-12-03 16:55:45 -050093 Ui::CallWidget* ui;
Edric Milaret627500d2015-03-27 16:41:40 -040094 Call* actualCall_;
95 Video::Renderer* videoRenderer_;
96 CallModel* callModel_;
97 int outputVolume_;
98 int inputVolume_;
Nicolas Jager97a21b42015-12-03 16:55:45 -050099 QMenu* menu_;
100 ContactDelegate* contactDelegate_;
101 HistoryDelegate* historyDelegate_;
Edric Milareted0b2802015-10-01 15:10:02 -0400102 SmartListDelegate* smartListDelegate_;
Nicolas Jager97a21b42015-12-03 16:55:45 -0500103 QModelIndex highLightedIndex_;
Edric Milaretab12d022015-12-04 16:09:44 -0500104 ImDelegate* imDelegate_;
105 QMetaObject::Connection imConnection_;
Nicolas Jagerca850292016-01-17 14:11:10 -0500106 QPropertyAnimation* messagingPageAnim_;
107 QPropertyAnimation* welcomePageAnim_;
108
109 constexpr static int animDuration_ = 200; //msecs
Edric Milaret01f23842015-06-22 14:46:01 -0400110
Edric Milaret7d40a4a2015-05-13 13:01:15 -0400111private:
Edric Milaret627500d2015-03-27 16:41:40 -0400112 void findRingAccount();
Nicolas Jager97a21b42015-12-03 16:55:45 -0500113 void setActualCall(Call* value);
Edric Milareted0b2802015-10-01 15:10:02 -0400114 void placeCall();
Edric Milareta0ebd062016-01-13 12:18:23 -0500115 void setupOutOfCallIM();
116 void setupSmartListMenu();
Nicolas Jagerca850292016-01-17 14:11:10 -0500117 void slideToLeft(QPropertyAnimation* anim, QWidget* widget);
118 void slideToRight(QPropertyAnimation* anim, QWidget* widget);
Edric Milaret627500d2015-03-27 16:41:40 -0400119};
120