1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

adapt groupinviteform to existing conventions

This commit is contained in:
sudden6 2016-02-22 00:29:12 +01:00
parent fca7972b86
commit 63326afe04
5 changed files with 35 additions and 19 deletions

View File

@ -287,13 +287,13 @@ void AddFriendForm::addFriendRequestWidget(const QString &friendAddress, const Q
QPushButton* acceptButton = new QPushButton(friendWidget);
acceptButtons.insert(acceptButton);
connect(acceptButton, &QPushButton::clicked, this, &AddFriendForm::onFriendRequestAccepted);
connect(acceptButton, &QPushButton::released, this, &AddFriendForm::onFriendRequestAccepted);
friendLayout->addWidget(acceptButton);
retranslateAcceptButton(acceptButton);
QPushButton* rejectButton = new QPushButton(friendWidget);
acceptButtons.insert(rejectButton);
connect(rejectButton, &QPushButton::clicked, this, &AddFriendForm::onFriendRequestRejected);
connect(rejectButton, &QPushButton::released, this, &AddFriendForm::onFriendRequestRejected);
friendLayout->addWidget(rejectButton);
retranslateRejectButton(rejectButton);

View File

@ -26,6 +26,7 @@
#include <QGroupBox>
#include <QDateTime>
#include <QLabel>
#include <QWindow>
#include "ui_mainwindow.h"
#include "src/widget/tool/croppinglabel.h"
#include "src/widget/translator.h"
@ -64,6 +65,17 @@ GroupInviteForm::GroupInviteForm()
Translator::registerHandler(std::bind(&GroupInviteForm::retranslateUi, this), this);
}
bool GroupInviteForm::isShown() const
{
if (this->isVisible())
{
headWidget->window()->windowHandle()->alert(0);
return true;
}
return false;
}
void GroupInviteForm::show(ContentLayout* contentLayout)
{
contentLayout->mainContent->layout()->addWidget(this);
@ -83,13 +95,13 @@ void GroupInviteForm::addGroupInvite(int32_t friendId, uint8_t type, QByteArray
QPushButton* acceptButton = new QPushButton(this);
acceptButtons.insert(acceptButton);
connect(acceptButton, &QPushButton::clicked, this, &GroupInviteForm::onGroupInviteAccepted);
connect(acceptButton, &QPushButton::released, this, &GroupInviteForm::onGroupInviteAccepted);
groupLayout->addWidget(acceptButton);
retranslateAcceptButton(acceptButton);
QPushButton* rejectButton = new QPushButton(this);
rejectButtons.insert(rejectButton);
connect(rejectButton, &QPushButton::clicked, this, &GroupInviteForm::onGroupInviteRejected);
connect(rejectButton, &QPushButton::released, this, &GroupInviteForm::onGroupInviteRejected);
groupLayout->addWidget(rejectButton);
retranslateRejectButton(rejectButton);

View File

@ -42,6 +42,7 @@ public:
void show(ContentLayout *contentLayout);
void addGroupInvite(int32_t friendId, uint8_t type, QByteArray invite);
bool isShown() const;
signals:
void groupCreate(uint8_t type);

View File

@ -721,11 +721,20 @@ void Widget::onAddClicked()
void Widget::onGroupClicked()
{
hideMainForms(nullptr);
groupInviteForm->show(contentLayout);
setWindowTitle(tr("Group invites"));
setActiveToolMenuButton(Widget::GroupButton);
activeChatroomWidget = nullptr;
if (Settings::getInstance().getSeparateWindow())
{
if (!groupInviteForm->isShown())
groupInviteForm->show(createContentDialog(GroupDialog));
setActiveToolMenuButton(Widget::None);
}
else
{
hideMainForms(nullptr);
groupInviteForm->show(contentLayout);
setWindowTitle(fromDialogType(GroupDialog));
setActiveToolMenuButton(Widget::GroupButton);
}
}
void Widget::onTransferClicked()
@ -1227,6 +1236,8 @@ QString Widget::fromDialogType(DialogType type)
{
case AddDialog:
return tr("Add friend");
case GroupDialog:
return tr("Group invites");
case TransferDialog:
return tr("File transfers");
case SettingDialog:
@ -1269,9 +1280,8 @@ bool Widget::newMessageAlert(QWidget* currentWindow, bool isActive, bool sound,
void Widget::onFriendRequestReceived(const QString& userId, const QString& message)
{
QApplication::alert(this);
eventFlag = true;
friendRequestRecieved(userId, message);
addFriendForm->addFriendRequest(userId, message);
friendRequestsUpdate();
}
void Widget::updateFriendActivity(Friend *frnd)
@ -2062,12 +2072,6 @@ void Widget::friendListContextMenu(const QPoint &pos)
Nexus::getCore()->createGroup();
}
void Widget::friendRequestRecieved(const QString& friendAddress, const QString& message)
{
addFriendForm->addFriendRequest(friendAddress, message);
friendRequestsUpdate();
}
void Widget::friendRequestsUpdate()
{
unsigned int unreadFriendRequests = Settings::getInstance().getUnreadFriendRequests();

View File

@ -184,7 +184,6 @@ private slots:
void onSplitterMoved(int pos, int index);
void processOfflineMsgs();
void friendListContextMenu(const QPoint &pos);
void friendRequestRecieved(const QString& friendAddress, const QString& message);
void friendRequestsUpdate();
void groupInvitesUpdate();
void groupInvitesClear();