callwidget.h 4.31 KB
Newer Older
1
/***************************************************************************
2
 * Copyright (C) 2015-2016 by Savoir-faire Linux                           *
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
 *                                                                         *
 * This program is free software; you can redistribute it and/or modify    *
 * it under the terms of the GNU General Public License as published by    *
 * the Free Software Foundation; either version 3 of the License, or       *
 * (at your option) any later version.                                     *
 *                                                                         *
 * This program is distributed in the hope that it will be useful,         *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
 * GNU General Public License for more details.                            *
 *                                                                         *
 * You should have received a copy of the GNU General Public License       *
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
 **************************************************************************/

Edric Milaret's avatar
Edric Milaret committed
19
#pragma once
20 21

#include <QWidget>
22 23
#include <QVector>
#include <QString>
24
#include <QMenu>
25
#include <QItemSelection>
26
#include <QMovie>
27 28

#include "navwidget.h"
29
#include "instantmessagingwidget.h"
30 31 32 33

#include "callmodel.h"
#include "video/renderer.h"
#include "video/previewmanager.h"
34
#include "accountmodel.h"
35
#include "categorizedhistorymodel.h"
36
#include "media/textrecording.h"
37

38 39 40
class ContactDelegate;
class HistoryDelegate;
class SmartListDelegate;
41
class ImDelegate;
42
class QPropertyAnimation;
43

44 45 46 47 48 49 50 51 52
namespace Ui {
class CallWidget;
}

class CallWidget : public NavWidget
{
    Q_OBJECT

public:
53
    explicit CallWidget(QWidget* parent = 0);
54 55 56
    ~CallWidget();
    void atExit();

57 58 59 60
public slots:
    void contactButton_clicked(bool checked);
    void settingsButton_clicked();
    void historicButton_clicked(bool checked);
61 62 63 64 65
//UI SLOTS
public slots:
    void on_ringContactLineEdit_returnPressed();
    void on_btnCall_clicked();
    void on_btnvideo_clicked();
66
    void showIMOutOfCall();
67 68
    inline void on_entered(const QModelIndex& i){highLightedIndex_ = i;};

69 70 71 72
//UI SLOTS
private slots:
    void on_acceptButton_clicked();
    void on_refuseButton_clicked();
73
    void on_contactView_doubleClicked(const QModelIndex& index);
74
    void on_cancelButton_clicked();
75 76
    void on_smartList_doubleClicked(const QModelIndex& index);
    void on_historyList_doubleClicked(const QModelIndex& index);
77 78 79
    void on_sendButton_clicked();
    void on_messageEdit_returnPressed();
    void on_contactMethodComboBox_currentIndexChanged(const QString& number);
80
    void on_ringContactLineEdit_textChanged(const QString& text);
Edric Milaret's avatar
Edric Milaret committed
81
    void on_imBackButton_clicked();
82
    void on_copyCMButton_clicked();
83 84

private slots:
85 86 87
    void callIncoming(Call* call);
    void addedCall(Call* call, Call* parent);
    void callStateChanged(Call* call, Call::State previousState);
88
    void findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec);
89
    void smartListSelectionChanged(const QItemSelection& newSel, const QItemSelection& oldSel);
90
    void slotAccountMessageReceived(const QMap<QString,QString> message,ContactMethod* cm,Media::Media::Direction dir);
91
    void onIncomingMessage(::Media::TextRecording* t, ContactMethod* cm);
92

93
private:
94
    Ui::CallWidget* ui;
95 96 97 98 99
    Call* actualCall_;
    Video::Renderer* videoRenderer_;
    CallModel* callModel_;
    int outputVolume_;
    int inputVolume_;
100 101 102
    QMenu* menu_;
    ContactDelegate* contactDelegate_;
    HistoryDelegate* historyDelegate_;
103
    SmartListDelegate* smartListDelegate_;
104
    QModelIndex highLightedIndex_;
105 106
    ImDelegate* imDelegate_;
    QMetaObject::Connection imConnection_;
Edric Milaret's avatar
Edric Milaret committed
107
    QMetaObject::Connection imVisibleConnection_;
108 109 110 111
    QPropertyAnimation* messagingPageAnim_;
    QPropertyAnimation* welcomePageAnim_;

    constexpr static int animDuration_ = 200; //msecs
Edric Milaret's avatar
Edric Milaret committed
112

113
private:
114
    void findRingAccount();
115
    void setActualCall(Call* value);
116
    void placeCall();
Edric Milaret's avatar
Edric Milaret committed
117 118
    void setupOutOfCallIM();
    void setupSmartListMenu();
119 120
    void slideToLeft(QPropertyAnimation* anim, QWidget* widget);
    void slideToRight(QPropertyAnimation* anim, QWidget* widget);
121 122
};