callwidget.h 7.02 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 "navwidget.h"
26
#include "smartlistmodel.h"
27
#include "videoview.h"
28

29 30 31
#include "api/account.h"
#include "api/contact.h"
#include "api/contactmodel.h"
32 33
#include "api/conversationmodel.h"
#include "api/newaccountmodel.h"
34
#include "api/newcallmodel.h"
35
#include "globalinstances.h"
36

37 38 39 40 41 42 43 44
#include <QClipboard>
#include <QItemSelection>
#include <QMenu>
#include <QMovie>
#include <QString>
#include <QVector>
#include <QWidget>

45
class ConversationItemDelegate;
46
class QPropertyAnimation;
47

48 49 50 51 52 53 54 55 56
namespace Ui {
class CallWidget;
}

class CallWidget : public NavWidget
{
    Q_OBJECT

public:
57
    explicit CallWidget(QWidget* parent = 0);
58 59
    ~CallWidget();

60
    int getLeftPanelWidth();
61

62 63
    // NavWidget
    virtual void navigated(bool to);
Andreas Traczyk's avatar
Andreas Traczyk committed
64
    virtual void updateCustomUI();
65
public slots:
66
    virtual void slotAccountListChanged();
67

68
private slots:
69 70
    void on_ringContactLineEdit_returnPressed();
    void settingsButtonClicked();
71 72
    void showChatView(const QModelIndex& nodeIdx);
    void showChatView(const std::string & accountId, const lrc::api::conversation::Info & convInfo);
73
    void setConversationProfileData(const lrc::api::conversation::Info & convInfo);
74
    void setupChatView(const lrc::api::conversation::Info& convInfo);
75 76 77
    void slotAcceptInviteClicked(const QModelIndex& index);
    void slotBlockInviteClicked(const QModelIndex& index);
    void slotIgnoreInviteClicked(const QModelIndex& index);
78
    void slotCustomContextMenuRequested(const QPoint & pos);
79
    void slotAccountChanged(int index);
80 81 82
    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);
83
    void slotNewTrustRequest(const std::string& accountId, const std::string& contactUri);
84
    void slotToggleFullScreenClicked();
85
    void update();
86 87 88
    void ShowContextMenu(const QPoint& pos);
    void Paste();
    void Copy();
89
    void CreateCopyPasteContextMenu();
90 91
    void on_acceptButton_clicked();
    void on_refuseButton_clicked();
92
    void on_cancelButton_clicked();
93
    void on_smartList_doubleClicked(const QModelIndex& index);
94
    void on_ringContactLineEdit_textChanged(const QString& text);
Edric Milaret's avatar
Edric Milaret committed
95
    void on_imBackButton_clicked();
96
    void on_sendContactRequestButton_clicked();
97
    void on_smartList_clicked(const QModelIndex &index);
98
    void on_qrButton_toggled(bool checked);
99
    void on_shareButton_clicked();
100 101
    void on_btnAudioCall_clicked();
    void on_btnVideoCall_clicked();
102
    void smartListSelectionChanged(const QItemSelection  &selected, const QItemSelection  &deselected);
103
    void slotSetChatVisibility(bool visible);
104
    void slotVideoDeviceListChanged();
105

106
private:
107
    void callTerminating(const std::string& callid);
108
    void onNewInteraction(const std::string& accountId, const std::string& convUid,
109
                           uint64_t interactionId, const lrc::api::interaction::Info& interaction);
110 111 112 113 114 115 116 117 118 119 120 121 122
    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();
123
    bool selectSmartlistItem(const std::string& convUid);
124 125 126 127 128 129 130 131 132
    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();
133
    void updateComboBox();
134
    void connectAccount(const std::string& accId);
135
    void setCallPanelVisibility(bool visible);
136
    void updateChatviewFrame();
137

138
    QMenu* menu_;
139
    QClipboard* clipboard_;
140 141

    Ui::CallWidget* ui;
142
    QMovie* miniSpinner_;
143

Edric Milaret's avatar
Edric Milaret committed
144
    constexpr static int qrSize_ = 200;
Edric Milaret's avatar
Edric Milaret committed
145

146 147 148
    std::string lastConvUid_ {};
    lrc::api::profile::Type currentTypeFilter_{};
    std::unique_ptr<SmartListModel> smartListModel_;
149 150 151 152 153 154

    QMetaObject::Connection imConnection_;
    QMetaObject::Connection imVisibleConnection_;
    QMetaObject::Connection callChangedConnection_;
    QMetaObject::Connection imClickedConnection_;
    QMetaObject::Connection crListSelectionConnection_;
155 156 157 158 159 160 161 162 163 164
    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_;
165
    QMetaObject::Connection interactionRemovedConnection_;
166
    QMetaObject::Connection contactAddedConnection_;
167
    QMetaObject::Connection callStatusChangedConnection_;
168
    QMetaObject::Connection addedToConferenceConnection_;
169

170
};