callwidget.h 6.28 KB
Newer Older
1
/**************************************************************************
2
* Copyright (C) 2015-2018 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 <QWidget>
26 27
#include <QVector>
#include <QString>
28
#include <QMenu>
29
#include <QItemSelection>
30
#include <QMovie>
31 32

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

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

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

class ConversationItemDelegate;
53
class QPropertyAnimation;
54

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

class CallWidget : public NavWidget
{
    Q_OBJECT

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

67
    int getLeftPanelWidth();
68

69
public slots:
70
    void on_ringContactLineEdit_returnPressed();
71

72
public slots:
73 74 75 76 77
    void settingsButtonClicked();
    void showIMOutOfCall(const QModelIndex& nodeIdx);
    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 83
    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);
    void update();
84

85 86 87
private slots:
    void on_acceptButton_clicked();
    void on_refuseButton_clicked();
88
    void on_cancelButton_clicked();
89
    void on_smartList_doubleClicked(const QModelIndex& index);
90
    void on_ringContactLineEdit_textChanged(const QString& text);
Edric Milaret's avatar
Edric Milaret committed
91
    void on_imBackButton_clicked();
92
    void on_sendContactRequestButton_clicked();
93
    void on_smartList_clicked(const QModelIndex &index);
94
    void on_qrButton_toggled(bool checked);
95
    void on_shareButton_clicked();
96
    void on_pendingCRBackButton_clicked();
97 98
    void on_btnAudioCall_clicked();
    void on_btnVideoCall_clicked();
99 100

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

104
private:
105 106 107 108 109 110 111 112 113 114 115 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();

    // lrc
    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();
    void selectSmartlistItem(const std::string& convUid);
    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();
130
    void updateComboBox();
131 132 133
    const std::string& selectedAccountId();
    const std::string& selectedConvUid();

134
    QMenu* menu_;
135 136

    Ui::CallWidget* ui;
137
    QMovie* miniSpinner_;
138

Edric Milaret's avatar
Edric Milaret committed
139
    constexpr static int qrSize_ = 200;
Edric Milaret's avatar
Edric Milaret committed
140

141 142 143 144 145
    // lrc
    Video::Renderer* videoRenderer_;
    std::string lastConvUid_ {};
    lrc::api::profile::Type currentTypeFilter_{};
    std::unique_ptr<SmartListModel> smartListModel_;
146 147 148 149 150 151

    QMetaObject::Connection imConnection_;
    QMetaObject::Connection imVisibleConnection_;
    QMetaObject::Connection callChangedConnection_;
    QMetaObject::Connection imClickedConnection_;
    QMetaObject::Connection crListSelectionConnection_;
152 153 154 155 156 157 158 159 160 161
    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_;
162
    QMetaObject::Connection interactionRemovedConnection_;
163
};