callwidget.h 6.82 KB
Newer Older
1
/**************************************************************************
2
* Copyright (C) 2015-2019 by Savoir-faire Linux                           *
3 4 5
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* Author: Anthony Léonard <anthony.leonard@savoirfairelinux.com>          *
* Author: Olivier Soldano <olivier.soldano@savoirfairelinux.com>          *
6
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>          *
7
* Author: Isa Nanic <isa.nanic@savoirfairelinux.com>                      *
8 9 10 11 12 13 14 15 16 17 18 19 20 21
*                                                                         *
* 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/>.   *
**************************************************************************/
22

Edric Milaret's avatar
Edric Milaret committed
23
#pragma once
24

25
#include <QClipboard>
26
#include <QItemSelection>
27
#include <QMenu>
28
#include <QMovie>
29 30 31
#include <QString>
#include <QVector>
#include <QWidget>
32 33

#include "navwidget.h"
34
#include "smartlistmodel.h"
35

36
// old LRC
37
#include "accountmodel.h"
38
#include "media/textrecording.h"
39 40
#include "video/previewmanager.h"
#include "video/renderer.h"
41

42 43 44 45
// new LRC
#include "api/account.h"
#include "api/contact.h"
#include "api/contactmodel.h"
46 47
#include "api/conversationmodel.h"
#include "api/newaccountmodel.h"
48
#include "api/newcallmodel.h"
49
#include "globalinstances.h"
50 51

class ConversationItemDelegate;
52
class QPropertyAnimation;
53

54 55 56 57 58 59 60 61 62
namespace Ui {
class CallWidget;
}

class CallWidget : public NavWidget
{
    Q_OBJECT

public:
63
    explicit CallWidget(QWidget* parent = 0);
64 65
    ~CallWidget();

66
    int getLeftPanelWidth();
67

68 69
    // NavWidget
    virtual void navigated(bool to);
Andreas Traczyk's avatar
Andreas Traczyk committed
70
    virtual void updateCustomUI();
71 72
public slots:
    virtual void slotAccountOnBoarded();
73

74
public slots:
75
    void on_ringContactLineEdit_returnPressed();
76

77
public slots:
78
    void settingsButtonClicked();
79 80 81
    void showChatView(const QModelIndex& nodeIdx);
    void showChatView(const std::string & accountId, const lrc::api::conversation::Info & convInfo);
    void setupChatView(const lrc::api::conversation::Info& convInfo);
82 83 84
    void slotAcceptInviteClicked(const QModelIndex& index);
    void slotBlockInviteClicked(const QModelIndex& index);
    void slotIgnoreInviteClicked(const QModelIndex& index);
85
    void slotCustomContextMenuRequested(const QPoint & pos);
86
    void slotAccountChanged(int index);
87 88 89
    void slotShowCallView(const std::string & accountId, const lrc::api::conversation::Info & convInfo);
    void slotShowIncomingCallView(const std::string & accountId, const lrc::api::conversation::Info & convInfo);
    void slotShowChatView(const std::string & accountId, const lrc::api::conversation::Info & convInfo);
90 91
    void slotToggleFullScreenClicked();
    void slotVideoViewDestroyed(const std::string& callid);
92
    void update();
93 94 95
    void ShowContextMenu(const QPoint& pos);
    void Paste();
    void Copy();
96

97 98 99
private slots:
    void on_acceptButton_clicked();
    void on_refuseButton_clicked();
100
    void on_cancelButton_clicked();
101
    void on_smartList_doubleClicked(const QModelIndex& index);
102
    void on_ringContactLineEdit_textChanged(const QString& text);
Edric Milaret's avatar
Edric Milaret committed
103
    void on_imBackButton_clicked();
104
    void on_sendContactRequestButton_clicked();
105
    void on_smartList_clicked(const QModelIndex &index);
106
    void on_qrButton_toggled(bool checked);
107
    void on_shareButton_clicked();
108 109
    void on_btnAudioCall_clicked();
    void on_btnVideoCall_clicked();
110 111

private slots:
112 113
    void smartListSelectionChanged(const QItemSelection  &selected, const QItemSelection  &deselected);
    void onIncomingMessage(const std::string & convUid, uint64_t interactionId, const lrc::api::interaction::Info & interaction);
114

115
private:
116 117 118 119 120 121 122 123 124 125 126 127 128 129
    void placeCall();
    void conversationsButtonClicked();
    void invitationsButtonClicked();
    void setupSmartListContextMenu(const QPoint &pos);
    void setupQRCode(QString ringID);
    void backToWelcomePage();

    void selectConversation(const QModelIndex& index);
    bool selectConversation(const lrc::api::conversation::Info& item,
        lrc::api::ConversationModel& convModel);
    void deselectConversation();
    bool connectConversationModel();
    void updateConversationView(const std::string& convUid);
    void showConversationView();
130
    bool selectSmartlistItem(const std::string& convUid);
131 132 133 134 135 136 137 138 139
    QImage imageForConv(const std::string & convUid);
    void processContactLineEdit();
    void hideMiniSpinner();
    void updateConversationForNewContact(const std::string& convUid);
    void updateSmartList();
    void setSelectedAccount(const std::string & accountId);
    void setConversationFilter(const QString& filter);
    void setConversationFilter(lrc::api::profile::Type filter);
    void updateConversationsFilterWidget();
140
    void updateComboBox();
141
    void connectAccount(const std::string& accId);
142
    void setCallPanelVisibility(bool visible);
143

144
    QMenu* menu_;
145
    QClipboard* clipboard_;
146 147

    Ui::CallWidget* ui;
148
    QMovie* miniSpinner_;
149

Edric Milaret's avatar
Edric Milaret committed
150
    constexpr static int qrSize_ = 200;
Edric Milaret's avatar
Edric Milaret committed
151

152 153 154 155 156
    // lrc
    Video::Renderer* videoRenderer_;
    std::string lastConvUid_ {};
    lrc::api::profile::Type currentTypeFilter_{};
    std::unique_ptr<SmartListModel> smartListModel_;
157 158 159 160 161 162

    QMetaObject::Connection imConnection_;
    QMetaObject::Connection imVisibleConnection_;
    QMetaObject::Connection callChangedConnection_;
    QMetaObject::Connection imClickedConnection_;
    QMetaObject::Connection crListSelectionConnection_;
163 164 165 166 167 168 169 170 171 172
    QMetaObject::Connection modelSortedConnection_;
    QMetaObject::Connection modelUpdatedConnection_;
    QMetaObject::Connection filterChangedConnection_;
    QMetaObject::Connection newConversationConnection_;
    QMetaObject::Connection conversationRemovedConnection_;
    QMetaObject::Connection newInteractionConnection_;
    QMetaObject::Connection interactionStatusUpdatedConnection_;
    QMetaObject::Connection conversationClearedConnection;
    QMetaObject::Connection selectedCallChanged_;
    QMetaObject::Connection smartlistSelectionConnection_;
173
    QMetaObject::Connection interactionRemovedConnection_;
174
    QMetaObject::Connection contactAddedConnection_;
175
    QMetaObject::Connection callStatusChangedConnection_;
176

177
};