mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
parent
36fcb5cb62
commit
4eab3dcbb8
|
@ -138,3 +138,8 @@ FriendWidget *Friend::getFriendWidget()
|
||||||
{
|
{
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const FriendWidget *Friend::getFriendWidget() const
|
||||||
|
{
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ public:
|
||||||
|
|
||||||
ChatForm *getChatForm();
|
ChatForm *getChatForm();
|
||||||
FriendWidget *getFriendWidget();
|
FriendWidget *getFriendWidget();
|
||||||
|
const FriendWidget *getFriendWidget() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void displayedNameChanged(FriendWidget* widget, Status s, int hasNewEvents);
|
void displayedNameChanged(FriendWidget* widget, Status s, int hasNewEvents);
|
||||||
|
|
|
@ -247,8 +247,8 @@ void ChatForm::onAvInvite(uint32_t FriendId, int CallId, bool video)
|
||||||
videoButton->disconnect();
|
videoButton->disconnect();
|
||||||
if (video)
|
if (video)
|
||||||
{
|
{
|
||||||
callConfirm = new CallConfirmWidget(videoButton);
|
callConfirm = new CallConfirmWidget(videoButton, *f);
|
||||||
if (isVisible())
|
if (Widget::getInstance()->isFriendWidgetCurActiveWidget(f))
|
||||||
callConfirm->show();
|
callConfirm->show();
|
||||||
|
|
||||||
connect(callConfirm, &CallConfirmWidget::accepted, this, &ChatForm::onAnswerCallTriggered);
|
connect(callConfirm, &CallConfirmWidget::accepted, this, &ChatForm::onAnswerCallTriggered);
|
||||||
|
@ -262,8 +262,8 @@ void ChatForm::onAvInvite(uint32_t FriendId, int CallId, bool video)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
callConfirm = new CallConfirmWidget(callButton);
|
callConfirm = new CallConfirmWidget(callButton, *f);
|
||||||
if (isVisible())
|
if (Widget::getInstance()->isFriendWidgetCurActiveWidget(f))
|
||||||
callConfirm->show();
|
callConfirm->show();
|
||||||
|
|
||||||
connect(callConfirm, &CallConfirmWidget::accepted, this, &ChatForm::onAnswerCallTriggered);
|
connect(callConfirm, &CallConfirmWidget::accepted, this, &ChatForm::onAnswerCallTriggered);
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "callconfirmwidget.h"
|
#include "callconfirmwidget.h"
|
||||||
#include "src/widget/gui.h"
|
#include "src/widget/gui.h"
|
||||||
|
#include "src/widget/widget.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
@ -31,8 +32,8 @@
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
|
|
||||||
CallConfirmWidget::CallConfirmWidget(const QWidget *Anchor) :
|
CallConfirmWidget::CallConfirmWidget(const QWidget *Anchor, const Friend& f) :
|
||||||
QWidget(GUI::getMainWidget()), anchor(Anchor),
|
QWidget(GUI::getMainWidget()), anchor(Anchor), f{f},
|
||||||
rectW{120}, rectH{85},
|
rectW{120}, rectH{85},
|
||||||
spikeW{30}, spikeH{15},
|
spikeW{30}, spikeH{15},
|
||||||
roundedFactor{20},
|
roundedFactor{20},
|
||||||
|
@ -110,6 +111,14 @@ void CallConfirmWidget::paintEvent(QPaintEvent*)
|
||||||
|
|
||||||
void CallConfirmWidget::showEvent(QShowEvent*)
|
void CallConfirmWidget::showEvent(QShowEvent*)
|
||||||
{
|
{
|
||||||
|
// If someone does show() from Widget or lower, the event will reach us
|
||||||
|
// because it's our parent, and we could show up in the wrong form.
|
||||||
|
// So check here if our friend's form is actually the active one.
|
||||||
|
if (!Widget::getInstance()->isFriendWidgetCurActiveWidget(&f))
|
||||||
|
{
|
||||||
|
QWidget::hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
reposition();
|
reposition();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
class QPaintEvent;
|
class QPaintEvent;
|
||||||
class QShowEvent;
|
class QShowEvent;
|
||||||
|
class Friend;
|
||||||
|
|
||||||
/// This is a widget with dialog buttons to accept/reject a call
|
/// This is a widget with dialog buttons to accept/reject a call
|
||||||
/// It tracks the position of another widget called the anchor
|
/// It tracks the position of another widget called the anchor
|
||||||
|
@ -36,7 +37,7 @@ class CallConfirmWidget final : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CallConfirmWidget(const QWidget *Anchor);
|
explicit CallConfirmWidget(const QWidget *Anchor, const Friend& f);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void accepted();
|
void accepted();
|
||||||
|
@ -44,13 +45,14 @@ signals:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void paintEvent(QPaintEvent* event) final override;
|
virtual void paintEvent(QPaintEvent* event) final override;
|
||||||
virtual void showEvent(QShowEvent * event) final override;
|
virtual void showEvent(QShowEvent* event) final override;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void reposition(); ///< Recalculate our positions to track the anchor
|
void reposition(); ///< Recalculate our positions to track the anchor
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QWidget* anchor; ///< The widget we're going to be tracking
|
const QWidget* anchor; ///< The widget we're going to be tracking
|
||||||
|
const Friend& f; ///< The friend on whose chat form we should appear
|
||||||
|
|
||||||
QRect mainRect;
|
QRect mainRect;
|
||||||
QPolygon spikePoly;
|
QPolygon spikePoly;
|
||||||
|
|
|
@ -715,12 +715,13 @@ void Widget::onFriendUsernameChanged(int friendId, const QString& username)
|
||||||
void Widget::onChatroomWidgetClicked(GenericChatroomWidget *widget)
|
void Widget::onChatroomWidgetClicked(GenericChatroomWidget *widget)
|
||||||
{
|
{
|
||||||
hideMainForms();
|
hideMainForms();
|
||||||
widget->setChatForm(*ui);
|
|
||||||
if (activeChatroomWidget != nullptr)
|
if (activeChatroomWidget != nullptr)
|
||||||
activeChatroomWidget->setAsInactiveChatroom();
|
activeChatroomWidget->setAsInactiveChatroom();
|
||||||
|
|
||||||
activeChatroomWidget = widget;
|
activeChatroomWidget = widget;
|
||||||
|
|
||||||
widget->setAsActiveChatroom();
|
widget->setAsActiveChatroom();
|
||||||
|
widget->setChatForm(*ui);
|
||||||
setWindowTitle(widget->getName());
|
setWindowTitle(widget->getName());
|
||||||
widget->resetEventFlags();
|
widget->resetEventFlags();
|
||||||
widget->updateStatusLight();
|
widget->updateStatusLight();
|
||||||
|
@ -779,8 +780,6 @@ void Widget::newMessageAlert(GenericChatroomWidget* chat)
|
||||||
|
|
||||||
if (Settings::getInstance().getShowWindow())
|
if (Settings::getInstance().getShowWindow())
|
||||||
{
|
{
|
||||||
if (activeChatroomWidget != chat)
|
|
||||||
onChatroomWidgetClicked(chat);
|
|
||||||
show();
|
show();
|
||||||
if (inactiveWindow && Settings::getInstance().getShowInFront())
|
if (inactiveWindow && Settings::getInstance().getShowInFront())
|
||||||
setWindowState(Qt::WindowActive);
|
setWindowState(Qt::WindowActive);
|
||||||
|
@ -1051,12 +1050,12 @@ void Widget::onEmptyGroupCreated(int groupId)
|
||||||
createGroup(groupId);
|
createGroup(groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Widget::isFriendWidgetCurActiveWidget(Friend* f)
|
bool Widget::isFriendWidgetCurActiveWidget(const Friend* f) const
|
||||||
{
|
{
|
||||||
if (!f)
|
if (!f)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return (activeChatroomWidget == static_cast<GenericChatroomWidget*>(f->getFriendWidget()));
|
return (activeChatroomWidget == static_cast<const GenericChatroomWidget*>(f->getFriendWidget()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Widget::event(QEvent * e)
|
bool Widget::event(QEvent * e)
|
||||||
|
|
|
@ -60,7 +60,7 @@ public:
|
||||||
Camera* getCamera();
|
Camera* getCamera();
|
||||||
static Widget* getInstance();
|
static Widget* getInstance();
|
||||||
void newMessageAlert(GenericChatroomWidget* chat);
|
void newMessageAlert(GenericChatroomWidget* chat);
|
||||||
bool isFriendWidgetCurActiveWidget(Friend* f);
|
bool isFriendWidgetCurActiveWidget(const Friend* f) const;
|
||||||
bool getIsWindowMinimized();
|
bool getIsWindowMinimized();
|
||||||
void updateIcons();
|
void updateIcons();
|
||||||
void clearContactsList();
|
void clearContactsList();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user