예제 #1
0
void ChatForm::onCallTriggered()
{
    qDebug() << "onCallTriggered";

    disableCallButtons();
    if (coreav->startCall(f->getFriendID(), false))
        showOutgoingCall(false);
    else
        enableCallButtons();
}
예제 #2
0
void ChatForm::show(ContentLayout* contentLayout)
{
    GenericChatForm::show(contentLayout);

    // Disable call buttons if friend is offline
    if(f->getStatus() == Status::Offline)
        disableCallButtons();
    else
        onEnableCallButtons();

    if (callConfirm)
        callConfirm->show();
}
예제 #3
0
파일: chatform.cpp 프로젝트: Pik-9/qTox
void ChatForm::onAvInvite(uint32_t FriendId, bool video)
{
    if (FriendId != f->getFriendID())
        return;

    qDebug() << "onAvInvite";
    disableCallButtons();
    insertChatMessage(ChatMessage::createChatInfoMessage(tr("%1 calling").arg(f->getDisplayedName()),
                                                         ChatMessage::INFO,
                                                         QDateTime::currentDateTime()));
    /* AutoAcceptCall is set for this friend */
    if ((video && Settings::getInstance().getAutoAcceptCall(f->getToxId()).testFlag(Settings::AutoAcceptCall::Video)) ||
       (!video && Settings::getInstance().getAutoAcceptCall(f->getToxId()).testFlag(Settings::AutoAcceptCall::Audio)))
    {
        uint32_t friendId = f->getFriendID();
        qDebug() << "automatic call answer";
        QMetaObject::invokeMethod(coreav, "answerCall", Qt::QueuedConnection, Q_ARG(uint32_t, friendId));
        onAvStart(friendId,video);
    }
    else
    {
        if (video)
        {
            callConfirm = new CallConfirmWidget(videoButton, *f);
            videoButton->setObjectName("yellow");
            videoButton->setToolTip(tr("Accept video call"));
            videoButton->style()->polish(videoButton);
            connect(videoButton, &QPushButton::clicked, this, &ChatForm::onAnswerCallTriggered);
        }
        else
        {
            callConfirm = new CallConfirmWidget(callButton, *f);
            callButton->setObjectName("yellow");
            callButton->setToolTip(tr("Accept audio call"));
            callButton->style()->polish(callButton);
            connect(callButton, &QPushButton::clicked, this, &ChatForm::onAnswerCallTriggered);
        }

        if (f->getFriendWidget()->chatFormIsSet(false))
            callConfirm->show();

        connect(callConfirm, &CallConfirmWidget::accepted, this, &ChatForm::onAnswerCallTriggered);
        connect(callConfirm, &CallConfirmWidget::rejected, this, &ChatForm::onRejectCallTriggered);

        Widget::getInstance()->newFriendMessageAlert(FriendId, false);
        Audio& audio = Audio::getInstance();
        audio.startLoop();
        audio.playMono16Sound(QStringLiteral(":/audio/ToxicIncomingCall.pcm"));
    }
}
예제 #4
0
파일: chatform.cpp 프로젝트: Pik-9/qTox
void ChatForm::onFriendStatusChanged(uint32_t friendId, Status status)
{
    // Disable call buttons if friend is offline
    if(friendId != f->getFriendID())
        return;

    Status old = oldStatus.value(friendId, Status::Offline);

    if (old != Status::Offline && status == Status::Offline)
        disableCallButtons();
    else if (old == Status::Offline && status != Status::Offline)
        enableCallButtons();

    oldStatus[friendId] = status;
}
예제 #5
0
파일: chatform.cpp 프로젝트: TheNain38/qTox
void ChatForm::onAvStart(uint32_t FriendId, bool video)
{
    if (FriendId != f->getFriendID())
        return;

    qDebug() << "onAvStart";

    audioInputFlag = true;
    audioOutputFlag = true;
    disableCallButtons();

    if (video)
    {
        videoButton->setObjectName("red");
        videoButton->setToolTip(tr("End video call"));
        videoButton->style()->polish(videoButton);
        connect(videoButton, SIGNAL(clicked()),
                this, SLOT(onHangupCallTriggered()));

        showNetcam();
    }
    else
    {
        callButton->setObjectName("red");
        callButton->setToolTip(tr("End audio call"));
        callButton->style()->polish(callButton);
        connect(callButton, SIGNAL(clicked()),
                this, SLOT(onHangupCallTriggered()));
        hideNetcam();
    }

    micButton->setObjectName("green");
    micButton->style()->polish(micButton);
    micButton->setToolTip(tr("Mute microphone"));
    volButton->setObjectName("green");
    volButton->style()->polish(volButton);
    volButton->setToolTip(tr("Mute call"));

    connect(micButton, SIGNAL(clicked()),
            this, SLOT(onMicMuteToggle()));
    connect(volButton, SIGNAL(clicked()),
            this, SLOT(onVolMuteToggle()));

    startCounter();
}
예제 #6
0
파일: chatform.cpp 프로젝트: Pik-9/qTox
void ChatForm::enableCallButtons()
{
    qDebug() << "enableCallButtons";

    audioInputFlag = false;
    audioOutputFlag = false;

    disableCallButtons();

    if (disableCallButtonsTimer == nullptr)
    {
        disableCallButtonsTimer = new QTimer();
        connect(disableCallButtonsTimer, SIGNAL(timeout()),
                this, SLOT(onEnableCallButtons()));
        disableCallButtonsTimer->start(1500); // 1.5sec
        qDebug() << "timer started!!";
    }
}
예제 #7
0
파일: chatform.cpp 프로젝트: TheNain38/qTox
void ChatForm::onAvInvite(uint32_t FriendId, bool video)
{
    if (FriendId != f->getFriendID())
        return;

    qDebug() << "onAvInvite";

    disableCallButtons();
    if (video)
    {
        callConfirm = new CallConfirmWidget(videoButton, *f);
        videoButton->setObjectName("yellow");
        videoButton->setToolTip(tr("Accept video call"));
        videoButton->style()->polish(videoButton);
        connect(videoButton, &QPushButton::clicked, this, &ChatForm::onAnswerCallTriggered);
    }
    else
    {
        callConfirm = new CallConfirmWidget(callButton, *f);
        callButton->setObjectName("yellow");
        callButton->setToolTip(tr("Accept audio call"));
        callButton->style()->polish(callButton);
        connect(callButton, &QPushButton::clicked, this, &ChatForm::onAnswerCallTriggered);
    }

    if (f->getFriendWidget()->chatFormIsSet(false))
        callConfirm->show();

    connect(callConfirm, &CallConfirmWidget::accepted, this, &ChatForm::onAnswerCallTriggered);
    connect(callConfirm, &CallConfirmWidget::rejected, this, &ChatForm::onRejectCallTriggered);

    insertChatMessage(ChatMessage::createChatInfoMessage(tr("%1 calling").arg(f->getDisplayedName()),
                                                         ChatMessage::INFO,
                                                         QDateTime::currentDateTime()));

    Widget::getInstance()->newFriendMessageAlert(FriendId, false);
    Audio& audio = Audio::getInstance();
    audio.startLoop();
    audio.playMono16Sound(":audio/ToxicIncomingCall.pcm");
}
예제 #8
0
파일: chatform.cpp 프로젝트: TheNain38/qTox
void ChatForm::onAnswerCallTriggered()
{
    qDebug() << "onAnswerCallTriggered";

    if (callConfirm)
    {
        delete callConfirm;
        callConfirm = nullptr;
    }

    Audio::getInstance().stopLoop();

    disableCallButtons();

    if (!coreav->answerCall(f->getFriendID()))
    {
        enableCallButtons();
        stopCounter();
        hideNetcam();
        return;
    }

    onAvStart(f->getFriendID(), coreav->isCallVideoEnabled(f->getFriendID()));
}
예제 #9
0
파일: chatform.cpp 프로젝트: Pik-9/qTox
ChatForm::ChatForm(Friend* chatFriend)
    : f(chatFriend)
    , isTyping(false)
{
    Core* core = Core::getInstance();
    coreav = core->getAv();

    nameLabel->setText(f->getDisplayedName());

    avatar->setPixmap(QPixmap(":/img/contact_dark.svg"));

    statusMessageLabel = new CroppingLabel();
    statusMessageLabel->setObjectName("statusLabel");
    statusMessageLabel->setFont(Style::getFont(Style::Medium));
    statusMessageLabel->setMinimumHeight(Style::getFont(Style::Medium).pixelSize());
    statusMessageLabel->setTextFormat(Qt::PlainText);
    statusMessageLabel->setContextMenuPolicy(Qt::CustomContextMenu);

    callConfirm = nullptr;
    offlineEngine = new OfflineMsgEngine(f);

    typingTimer.setSingleShot(true);

    callDurationTimer = nullptr;
    disableCallButtonsTimer = nullptr;

    chatWidget->setTypingNotification(ChatMessage::createTypingNotification());

    headTextLayout->addWidget(statusMessageLabel);
    headTextLayout->addStretch();
    callDuration = new QLabel();
    headTextLayout->addWidget(callDuration, 1, Qt::AlignCenter);
    callDuration->hide();

    chatWidget->setMinimumHeight(50);
    connect(this, &GenericChatForm::messageInserted, this, &ChatForm::onMessageInserted);

    loadHistoryAction = menu.addAction(QString(), this, SLOT(onLoadHistory()));
    copyStatusAction = statusMessageMenu.addAction(QString(), this, SLOT(onCopyStatusMessage()));

    connect(core, &Core::fileSendStarted, this, &ChatForm::startFileSend);
    connect(sendButton, &QPushButton::clicked, this, &ChatForm::onSendTriggered);
    connect(fileButton, &QPushButton::clicked, this, &ChatForm::onAttachClicked);
    connect(screenshotButton, &QPushButton::clicked, this, &ChatForm::onScreenshotClicked);
    connect(callButton, &QPushButton::clicked, this, &ChatForm::onCallTriggered);
    connect(videoButton, &QPushButton::clicked, this, &ChatForm::onVideoCallTriggered);
    connect(msgEdit, &ChatTextEdit::enterPressed, this, &ChatForm::onSendTriggered);
    connect(msgEdit, &ChatTextEdit::textChanged, this, &ChatForm::onTextEditChanged);
    connect(core, &Core::fileSendFailed, this, &ChatForm::onFileSendFailed);
    connect(core, &Core::friendStatusChanged, this, &ChatForm::onFriendStatusChanged);
    connect(this, &ChatForm::chatAreaCleared, getOfflineMsgEngine(), &OfflineMsgEngine::removeAllReceipts);
    connect(statusMessageLabel, &CroppingLabel::customContextMenuRequested, this, [&](const QPoint& pos)
    {
        if (!statusMessageLabel->text().isEmpty())
        {
            QWidget* sender = static_cast<QWidget*>(this->sender());

            statusMessageMenu.exec(sender->mapToGlobal(pos));
        }
    } );
    connect(&typingTimer, &QTimer::timeout, this, [=]{
        Core::getInstance()->sendTyping(f->getFriendID(), false);
        isTyping = false;
    } );
    connect(nameLabel, &CroppingLabel::editFinished, this, [=](const QString& newName)
    {
        nameLabel->setText(newName);
        emit aliasChanged(newName);
    } );

    setAcceptDrops(true);
    disableCallButtons();
    retranslateUi();
    Translator::registerHandler(std::bind(&ChatForm::retranslateUi, this), this);
}