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;
|
||||
}
|
||||
|
||||
const FriendWidget *Friend::getFriendWidget() const
|
||||
{
|
||||
return widget;
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
|
||||
ChatForm *getChatForm();
|
||||
FriendWidget *getFriendWidget();
|
||||
const FriendWidget *getFriendWidget() const;
|
||||
|
||||
signals:
|
||||
void displayedNameChanged(FriendWidget* widget, Status s, int hasNewEvents);
|
||||
|
|
|
@ -247,8 +247,8 @@ void ChatForm::onAvInvite(uint32_t FriendId, int CallId, bool video)
|
|||
videoButton->disconnect();
|
||||
if (video)
|
||||
{
|
||||
callConfirm = new CallConfirmWidget(videoButton);
|
||||
if (isVisible())
|
||||
callConfirm = new CallConfirmWidget(videoButton, *f);
|
||||
if (Widget::getInstance()->isFriendWidgetCurActiveWidget(f))
|
||||
callConfirm->show();
|
||||
|
||||
connect(callConfirm, &CallConfirmWidget::accepted, this, &ChatForm::onAnswerCallTriggered);
|
||||
|
@ -262,8 +262,8 @@ void ChatForm::onAvInvite(uint32_t FriendId, int CallId, bool video)
|
|||
}
|
||||
else
|
||||
{
|
||||
callConfirm = new CallConfirmWidget(callButton);
|
||||
if (isVisible())
|
||||
callConfirm = new CallConfirmWidget(callButton, *f);
|
||||
if (Widget::getInstance()->isFriendWidgetCurActiveWidget(f))
|
||||
callConfirm->show();
|
||||
|
||||
connect(callConfirm, &CallConfirmWidget::accepted, this, &ChatForm::onAnswerCallTriggered);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "callconfirmwidget.h"
|
||||
#include "src/widget/gui.h"
|
||||
#include "src/widget/widget.h"
|
||||
#include <assert.h>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
|
@ -31,8 +32,8 @@
|
|||
#include <QRect>
|
||||
#include <QPalette>
|
||||
|
||||
CallConfirmWidget::CallConfirmWidget(const QWidget *Anchor) :
|
||||
QWidget(GUI::getMainWidget()), anchor(Anchor),
|
||||
CallConfirmWidget::CallConfirmWidget(const QWidget *Anchor, const Friend& f) :
|
||||
QWidget(GUI::getMainWidget()), anchor(Anchor), f{f},
|
||||
rectW{120}, rectH{85},
|
||||
spikeW{30}, spikeH{15},
|
||||
roundedFactor{20},
|
||||
|
@ -110,6 +111,14 @@ void CallConfirmWidget::paintEvent(QPaintEvent*)
|
|||
|
||||
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();
|
||||
update();
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
class QPaintEvent;
|
||||
class QShowEvent;
|
||||
class Friend;
|
||||
|
||||
/// This is a widget with dialog buttons to accept/reject a call
|
||||
/// It tracks the position of another widget called the anchor
|
||||
|
@ -36,7 +37,7 @@ class CallConfirmWidget final : public QWidget
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CallConfirmWidget(const QWidget *Anchor);
|
||||
explicit CallConfirmWidget(const QWidget *Anchor, const Friend& f);
|
||||
|
||||
signals:
|
||||
void accepted();
|
||||
|
@ -44,13 +45,14 @@ signals:
|
|||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent* event) final override;
|
||||
virtual void showEvent(QShowEvent * event) final override;
|
||||
virtual void showEvent(QShowEvent* event) final override;
|
||||
|
||||
protected slots:
|
||||
void reposition(); ///< Recalculate our positions to track the anchor
|
||||
|
||||
private:
|
||||
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;
|
||||
QPolygon spikePoly;
|
||||
|
|
|
@ -715,12 +715,13 @@ void Widget::onFriendUsernameChanged(int friendId, const QString& username)
|
|||
void Widget::onChatroomWidgetClicked(GenericChatroomWidget *widget)
|
||||
{
|
||||
hideMainForms();
|
||||
widget->setChatForm(*ui);
|
||||
|
||||
if (activeChatroomWidget != nullptr)
|
||||
activeChatroomWidget->setAsInactiveChatroom();
|
||||
|
||||
activeChatroomWidget = widget;
|
||||
|
||||
widget->setAsActiveChatroom();
|
||||
widget->setChatForm(*ui);
|
||||
setWindowTitle(widget->getName());
|
||||
widget->resetEventFlags();
|
||||
widget->updateStatusLight();
|
||||
|
@ -779,8 +780,6 @@ void Widget::newMessageAlert(GenericChatroomWidget* chat)
|
|||
|
||||
if (Settings::getInstance().getShowWindow())
|
||||
{
|
||||
if (activeChatroomWidget != chat)
|
||||
onChatroomWidgetClicked(chat);
|
||||
show();
|
||||
if (inactiveWindow && Settings::getInstance().getShowInFront())
|
||||
setWindowState(Qt::WindowActive);
|
||||
|
@ -1051,12 +1050,12 @@ void Widget::onEmptyGroupCreated(int groupId)
|
|||
createGroup(groupId);
|
||||
}
|
||||
|
||||
bool Widget::isFriendWidgetCurActiveWidget(Friend* f)
|
||||
bool Widget::isFriendWidgetCurActiveWidget(const Friend* f) const
|
||||
{
|
||||
if (!f)
|
||||
return false;
|
||||
|
||||
return (activeChatroomWidget == static_cast<GenericChatroomWidget*>(f->getFriendWidget()));
|
||||
return (activeChatroomWidget == static_cast<const GenericChatroomWidget*>(f->getFriendWidget()));
|
||||
}
|
||||
|
||||
bool Widget::event(QEvent * e)
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
Camera* getCamera();
|
||||
static Widget* getInstance();
|
||||
void newMessageAlert(GenericChatroomWidget* chat);
|
||||
bool isFriendWidgetCurActiveWidget(Friend* f);
|
||||
bool isFriendWidgetCurActiveWidget(const Friend* f) const;
|
||||
bool getIsWindowMinimized();
|
||||
void updateIcons();
|
||||
void clearContactsList();
|
||||
|
|
Loading…
Reference in New Issue
Block a user