mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Revert changes from merge of #2092 pull request
That pull request made qTox crash in a number of ways, with no quick fix available. Hopefully there will be a way to fix crash, so that this commit could be reverted, and fix applied.
This commit is contained in:
parent
9c74488325
commit
06611d618e
6
qtox.pro
6
qtox.pro
|
@ -495,8 +495,7 @@ SOURCES += \
|
||||||
src/widget/friendlistlayout.cpp \
|
src/widget/friendlistlayout.cpp \
|
||||||
src/widget/genericchatitemlayout.cpp \
|
src/widget/genericchatitemlayout.cpp \
|
||||||
src/widget/categorywidget.cpp \
|
src/widget/categorywidget.cpp \
|
||||||
src/widget/tool/removefrienddialog.cpp \
|
src/widget/tool/removefrienddialog.cpp
|
||||||
src/widget/form/groupinviteform.cpp
|
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/audio/audio.h \
|
src/audio/audio.h \
|
||||||
|
@ -540,5 +539,4 @@ HEADERS += \
|
||||||
src/widget/friendlistlayout.h \
|
src/widget/friendlistlayout.h \
|
||||||
src/widget/genericchatitemlayout.h \
|
src/widget/genericchatitemlayout.h \
|
||||||
src/widget/categorywidget.h \
|
src/widget/categorywidget.h \
|
||||||
src/widget/tool/removefrienddialog.h \
|
src/widget/tool/removefrienddialog.h
|
||||||
src/widget/form/groupinviteform.h
|
|
||||||
|
|
|
@ -1062,24 +1062,19 @@ void Core::groupInviteFriend(uint32_t friendId, int groupId)
|
||||||
tox_invite_friend(tox, friendId, groupId);
|
tox_invite_friend(tox, friendId, groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Core::createGroup(uint8_t type)
|
void Core::createGroup(uint8_t type)
|
||||||
{
|
{
|
||||||
if (type == TOX_GROUPCHAT_TYPE_TEXT)
|
if (type == TOX_GROUPCHAT_TYPE_TEXT)
|
||||||
{
|
{
|
||||||
int group = tox_add_groupchat(tox);
|
emit emptyGroupCreated(tox_add_groupchat(tox));
|
||||||
emit emptyGroupCreated(group);
|
|
||||||
return group;
|
|
||||||
}
|
}
|
||||||
else if (type == TOX_GROUPCHAT_TYPE_AV)
|
else if (type == TOX_GROUPCHAT_TYPE_AV)
|
||||||
{
|
{
|
||||||
int group = toxav_add_av_groupchat(tox, &Audio::playGroupAudioQueued, this);
|
emit emptyGroupCreated(toxav_add_av_groupchat(tox, &Audio::playGroupAudioQueued, this));
|
||||||
emit emptyGroupCreated(group);
|
|
||||||
return group;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qWarning() << "createGroup: Unknown type "<<type;
|
qWarning() << "createGroup: Unknown type "<<type;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ public slots:
|
||||||
void acceptFriendRequest(const QString& userId);
|
void acceptFriendRequest(const QString& userId);
|
||||||
void requestFriendship(const QString& friendAddress, const QString& message);
|
void requestFriendship(const QString& friendAddress, const QString& message);
|
||||||
void groupInviteFriend(uint32_t friendId, int groupId);
|
void groupInviteFriend(uint32_t friendId, int groupId);
|
||||||
int createGroup(uint8_t type = TOX_GROUPCHAT_TYPE_AV);
|
void createGroup(uint8_t type = TOX_GROUPCHAT_TYPE_AV);
|
||||||
|
|
||||||
void removeFriend(uint32_t friendId, bool fake = false);
|
void removeFriend(uint32_t friendId, bool fake = false);
|
||||||
void removeGroup(int groupId, bool fake = false);
|
void removeGroup(int groupId, bool fake = false);
|
||||||
|
|
|
@ -368,7 +368,7 @@ QSplitter:handle{
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="statusLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
@ -1085,7 +1085,7 @@ QSplitter:handle{
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>284</width>
|
<width>284</width>
|
||||||
<height>393</height>
|
<height>398</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5"/>
|
<layout class="QVBoxLayout" name="verticalLayout_5"/>
|
||||||
|
|
|
@ -301,21 +301,6 @@ void Settings::loadPersonnal(Profile* profile)
|
||||||
ps.endArray();
|
ps.endArray();
|
||||||
ps.endGroup();
|
ps.endGroup();
|
||||||
|
|
||||||
ps.beginGroup("Requests");
|
|
||||||
unreadFriendRequests = ps.value("unread", 0).toUInt();
|
|
||||||
size = ps.beginReadArray("Request");
|
|
||||||
friendLst.reserve(size);
|
|
||||||
for (int i = 0; i < size; i ++)
|
|
||||||
{
|
|
||||||
ps.setArrayIndex(i);
|
|
||||||
QPair<QString, QString> request;
|
|
||||||
request.first = ps.value("addr").toString();
|
|
||||||
request.second = ps.value("message").toString();
|
|
||||||
friendRequests.push_back(request);
|
|
||||||
}
|
|
||||||
ps.endArray();
|
|
||||||
ps.endGroup();
|
|
||||||
|
|
||||||
ps.beginGroup("General");
|
ps.beginGroup("General");
|
||||||
compactLayout = ps.value("compactLayout", false).toBool();
|
compactLayout = ps.value("compactLayout", false).toBool();
|
||||||
ps.endGroup();
|
ps.endGroup();
|
||||||
|
@ -482,22 +467,7 @@ void Settings::savePersonal(QString profileName, QString password)
|
||||||
if (getEnableLogging())
|
if (getEnableLogging())
|
||||||
ps.setValue("activity", frnd.activity);
|
ps.setValue("activity", frnd.activity);
|
||||||
|
|
||||||
++index;
|
index++;
|
||||||
}
|
|
||||||
ps.endArray();
|
|
||||||
ps.endGroup();
|
|
||||||
|
|
||||||
ps.beginGroup("Requests");
|
|
||||||
ps.setValue("unread", unreadFriendRequests);
|
|
||||||
ps.beginWriteArray("Request", friendRequests.size());
|
|
||||||
index = 0;
|
|
||||||
for (auto& request : friendRequests)
|
|
||||||
{
|
|
||||||
ps.setArrayIndex(index);
|
|
||||||
ps.setValue("addr", request.first);
|
|
||||||
ps.setValue("message", request.second);
|
|
||||||
|
|
||||||
++index;
|
|
||||||
}
|
}
|
||||||
ps.endArray();
|
ps.endArray();
|
||||||
ps.endGroup();
|
ps.endGroup();
|
||||||
|
@ -1409,48 +1379,6 @@ void Settings::setCircleExpanded(int id, bool expanded)
|
||||||
circleLst[id].expanded = expanded;
|
circleLst[id].expanded = expanded;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::addFriendRequest(const QString &friendAddress, const QString &message)
|
|
||||||
{
|
|
||||||
QMutexLocker locker{&bigLock};
|
|
||||||
QPair<QString, QString> request(friendAddress, message);
|
|
||||||
|
|
||||||
if (friendRequests.indexOf(request) != -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
friendRequests.push_back(request);
|
|
||||||
++unreadFriendRequests;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int Settings::getUnreadFriendRequests() const
|
|
||||||
{
|
|
||||||
QMutexLocker locker{&bigLock};
|
|
||||||
return unreadFriendRequests;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPair<QString, QString> Settings::getFriendRequest(int index) const
|
|
||||||
{
|
|
||||||
QMutexLocker locker{&bigLock};
|
|
||||||
return friendRequests.at(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
int Settings::getFriendRequestSize() const
|
|
||||||
{
|
|
||||||
QMutexLocker locker{&bigLock};
|
|
||||||
return friendRequests.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Settings::clearUnreadFriendRequests()
|
|
||||||
{
|
|
||||||
QMutexLocker locker{&bigLock};
|
|
||||||
unreadFriendRequests = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Settings::removeFriendRequest(int index)
|
|
||||||
{
|
|
||||||
QMutexLocker locker{&bigLock};
|
|
||||||
friendRequests.removeAt(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
int Settings::removeCircle(int id)
|
int Settings::removeCircle(int id)
|
||||||
{
|
{
|
||||||
// Replace index with last one and remove last one instead.
|
// Replace index with last one and remove last one instead.
|
||||||
|
|
|
@ -251,13 +251,6 @@ public:
|
||||||
bool getCircleExpanded(int id) const;
|
bool getCircleExpanded(int id) const;
|
||||||
void setCircleExpanded(int id, bool expanded);
|
void setCircleExpanded(int id, bool expanded);
|
||||||
|
|
||||||
void addFriendRequest(const QString &friendAddress, const QString &message);
|
|
||||||
unsigned int getUnreadFriendRequests() const;
|
|
||||||
QPair<QString, QString> getFriendRequest(int index) const;
|
|
||||||
int getFriendRequestSize() const;
|
|
||||||
void clearUnreadFriendRequests();
|
|
||||||
void removeFriendRequest(int index);
|
|
||||||
|
|
||||||
// Assume all widgets have unique names
|
// Assume all widgets have unique names
|
||||||
// Don't use it to save every single thing you want to save, use it
|
// Don't use it to save every single thing you want to save, use it
|
||||||
// for some general purpose widgets, such as MainWindows or Splitters,
|
// for some general purpose widgets, such as MainWindows or Splitters,
|
||||||
|
@ -334,9 +327,6 @@ private:
|
||||||
bool autoSaveEnabled;
|
bool autoSaveEnabled;
|
||||||
QString globalAutoAcceptDir;
|
QString globalAutoAcceptDir;
|
||||||
|
|
||||||
QList<QPair<QString, QString>> friendRequests;
|
|
||||||
unsigned int unreadFriendRequests;
|
|
||||||
|
|
||||||
// GUI
|
// GUI
|
||||||
QString smileyPack;
|
QString smileyPack;
|
||||||
int emojiFontPointSize;
|
int emojiFontPointSize;
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QErrorMessage>
|
#include <QErrorMessage>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QTabWidget>
|
|
||||||
#include <QSignalMapper>
|
|
||||||
#include <tox/tox.h>
|
#include <tox/tox.h>
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "src/nexus.h"
|
#include "src/nexus.h"
|
||||||
|
@ -37,20 +35,12 @@
|
||||||
|
|
||||||
AddFriendForm::AddFriendForm()
|
AddFriendForm::AddFriendForm()
|
||||||
{
|
{
|
||||||
tabWidget = new QTabWidget();
|
main = new QWidget(), head = new QWidget();
|
||||||
main = new QWidget(tabWidget), head = new QWidget();
|
|
||||||
QFont bold;
|
QFont bold;
|
||||||
bold.setBold(true);
|
bold.setBold(true);
|
||||||
headLabel.setFont(bold);
|
headLabel.setFont(bold);
|
||||||
|
|
||||||
tabWidget->addTab(main, QString());
|
retranslateUi();
|
||||||
QScrollArea* scrollArea = new QScrollArea(tabWidget);
|
|
||||||
QWidget* requestWidget = new QWidget(tabWidget);
|
|
||||||
scrollArea->setWidget(requestWidget);
|
|
||||||
scrollArea->setWidgetResizable(true);
|
|
||||||
requestsLayout = new QVBoxLayout(requestWidget);
|
|
||||||
requestsLayout->addStretch(1);
|
|
||||||
tabWidget->addTab(scrollArea, QString());
|
|
||||||
|
|
||||||
main->setLayout(&layout);
|
main->setLayout(&layout);
|
||||||
layout.addWidget(&toxIdLabel);
|
layout.addWidget(&toxIdLabel);
|
||||||
|
@ -62,35 +52,25 @@ AddFriendForm::AddFriendForm()
|
||||||
head->setLayout(&headLayout);
|
head->setLayout(&headLayout);
|
||||||
headLayout.addWidget(&headLabel);
|
headLayout.addWidget(&headLabel);
|
||||||
|
|
||||||
connect(tabWidget, &QTabWidget::currentChanged, this, &AddFriendForm::onCurrentChanged);
|
|
||||||
connect(&toxId,&QLineEdit::returnPressed, this, &AddFriendForm::onSendTriggered);
|
connect(&toxId,&QLineEdit::returnPressed, this, &AddFriendForm::onSendTriggered);
|
||||||
connect(&sendButton, SIGNAL(clicked()), this, SLOT(onSendTriggered()));
|
connect(&sendButton, SIGNAL(clicked()), this, SLOT(onSendTriggered()));
|
||||||
connect(Nexus::getCore(), &Core::usernameSet, this, &AddFriendForm::onUsernameSet);
|
connect(Nexus::getCore(), &Core::usernameSet, this, &AddFriendForm::onUsernameSet);
|
||||||
|
|
||||||
retranslateUi();
|
|
||||||
Translator::registerHandler(std::bind(&AddFriendForm::retranslateUi, this), this);
|
Translator::registerHandler(std::bind(&AddFriendForm::retranslateUi, this), this);
|
||||||
|
|
||||||
int size = Settings::getInstance().getFriendRequestSize();
|
|
||||||
|
|
||||||
for (int i = 0; i < size; ++i)
|
|
||||||
{
|
|
||||||
QPair<QString, QString> request = Settings::getInstance().getFriendRequest(i);
|
|
||||||
addFriendRequestWidget(request.first, request.second);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AddFriendForm::~AddFriendForm()
|
AddFriendForm::~AddFriendForm()
|
||||||
{
|
{
|
||||||
Translator::unregister(this);
|
Translator::unregister(this);
|
||||||
head->deleteLater();
|
head->deleteLater();
|
||||||
tabWidget->deleteLater();
|
main->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddFriendForm::show(Ui::MainWindow &ui)
|
void AddFriendForm::show(Ui::MainWindow &ui)
|
||||||
{
|
{
|
||||||
ui.mainContent->layout()->addWidget(tabWidget);
|
ui.mainContent->layout()->addWidget(main);
|
||||||
ui.mainHead->layout()->addWidget(head);
|
ui.mainHead->layout()->addWidget(head);
|
||||||
tabWidget->show();
|
main->show();
|
||||||
head->show();
|
head->show();
|
||||||
setIdFromClipboard();
|
setIdFromClipboard();
|
||||||
toxId.setFocus();
|
toxId.setFocus();
|
||||||
|
@ -102,18 +82,6 @@ QString AddFriendForm::getMessage() const
|
||||||
return !msg.isEmpty() ? msg : message.placeholderText();
|
return !msg.isEmpty() ? msg : message.placeholderText();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddFriendForm::setMode(Mode mode)
|
|
||||||
{
|
|
||||||
tabWidget->setCurrentIndex(mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddFriendForm::addFriendRequest(const QString &friendAddress, const QString &message)
|
|
||||||
{
|
|
||||||
addFriendRequestWidget(friendAddress, message);
|
|
||||||
Settings::getInstance().addFriendRequest(friendAddress, message);
|
|
||||||
onCurrentChanged(tabWidget->currentIndex());
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddFriendForm::onUsernameSet(const QString& username)
|
void AddFriendForm::onUsernameSet(const QString& username)
|
||||||
{
|
{
|
||||||
lastUsername = username;
|
lastUsername = username;
|
||||||
|
@ -173,37 +141,6 @@ void AddFriendForm::setIdFromClipboard()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddFriendForm::onFriendRequestAccepted()
|
|
||||||
{
|
|
||||||
QWidget* friendWidget = static_cast<QWidget*>(sender());
|
|
||||||
int index = requestsLayout->indexOf(friendWidget);
|
|
||||||
friendWidget->deleteLater();
|
|
||||||
requestsLayout->removeWidget(friendWidget);
|
|
||||||
emit friendRequestAccepted(Settings::getInstance().getFriendRequest(requestsLayout->count() - index - 1).first);
|
|
||||||
Settings::getInstance().removeFriendRequest(requestsLayout->count() - index - 1);
|
|
||||||
Settings::getInstance().savePersonal();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddFriendForm::onFriendRequestRejected()
|
|
||||||
{
|
|
||||||
QWidget* friendWidget = static_cast<QWidget*>(sender());
|
|
||||||
int index = requestsLayout->indexOf(friendWidget);
|
|
||||||
friendWidget->deleteLater();
|
|
||||||
requestsLayout->removeWidget(friendWidget);
|
|
||||||
Settings::getInstance().removeFriendRequest(requestsLayout->count() - index - 1);
|
|
||||||
Settings::getInstance().savePersonal();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddFriendForm::onCurrentChanged(int index)
|
|
||||||
{
|
|
||||||
if (index == FriendRequest && Settings::getInstance().getUnreadFriendRequests() != 0)
|
|
||||||
{
|
|
||||||
Settings::getInstance().clearUnreadFriendRequests();
|
|
||||||
Settings::getInstance().savePersonal();
|
|
||||||
emit friendRequestsSeen();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddFriendForm::retranslateUi()
|
void AddFriendForm::retranslateUi()
|
||||||
{
|
{
|
||||||
headLabel.setText(tr("Add Friends"));
|
headLabel.setText(tr("Add Friends"));
|
||||||
|
@ -213,54 +150,4 @@ void AddFriendForm::retranslateUi()
|
||||||
message.setPlaceholderText(tr("%1 here! Tox me maybe?",
|
message.setPlaceholderText(tr("%1 here! Tox me maybe?",
|
||||||
"Default message in friend requests if the field is left blank. Write something appropriate!")
|
"Default message in friend requests if the field is left blank. Write something appropriate!")
|
||||||
.arg(lastUsername));
|
.arg(lastUsername));
|
||||||
|
|
||||||
tabWidget->setTabText(0, tr("Add a friend"));
|
|
||||||
tabWidget->setTabText(1, tr("Friend requests"));
|
|
||||||
|
|
||||||
for (QPushButton* acceptButton : acceptButtons)
|
|
||||||
retranslateAcceptButton(acceptButton);
|
|
||||||
|
|
||||||
for (QPushButton* rejectButton : rejectButtons)
|
|
||||||
retranslateRejectButton(rejectButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddFriendForm::addFriendRequestWidget(const QString &friendAddress, const QString &message)
|
|
||||||
{
|
|
||||||
QWidget* friendWidget = new QWidget(tabWidget);
|
|
||||||
QHBoxLayout* friendLayout = new QHBoxLayout(friendWidget);
|
|
||||||
QVBoxLayout* horLayout = new QVBoxLayout();
|
|
||||||
horLayout->setMargin(0);
|
|
||||||
friendLayout->addLayout(horLayout);
|
|
||||||
|
|
||||||
CroppingLabel* friendLabel = new CroppingLabel(friendWidget);
|
|
||||||
friendLabel->setText("<b>" + friendAddress + "</b>");
|
|
||||||
horLayout->addWidget(friendLabel);
|
|
||||||
|
|
||||||
QLabel* messageLabel = new QLabel(message);
|
|
||||||
messageLabel->setWordWrap(true);
|
|
||||||
horLayout->addWidget(messageLabel, 1);
|
|
||||||
|
|
||||||
QPushButton* acceptButton = new QPushButton(friendWidget);
|
|
||||||
acceptButtons.insert(acceptButton);
|
|
||||||
connect(acceptButton, &QPushButton::released, this, &AddFriendForm::onFriendRequestAccepted);
|
|
||||||
friendLayout->addWidget(acceptButton);
|
|
||||||
retranslateAcceptButton(acceptButton);
|
|
||||||
|
|
||||||
QPushButton* rejectButton = new QPushButton(friendWidget);
|
|
||||||
acceptButtons.insert(acceptButton);
|
|
||||||
connect(acceptButton, &QPushButton::released, this, &AddFriendForm::onFriendRequestAccepted);
|
|
||||||
friendLayout->addWidget(rejectButton);
|
|
||||||
retranslateRejectButton(rejectButton);
|
|
||||||
|
|
||||||
requestsLayout->insertWidget(0, friendWidget);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddFriendForm::retranslateAcceptButton(QPushButton *acceptButton)
|
|
||||||
{
|
|
||||||
acceptButton->setText(tr("Accept"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddFriendForm::retranslateRejectButton(QPushButton *rejectButton)
|
|
||||||
{
|
|
||||||
rejectButton->setText(tr("Reject"));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,6 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSet>
|
|
||||||
|
|
||||||
class QTabWidget;
|
|
||||||
|
|
||||||
namespace Ui {class MainWindow;}
|
namespace Ui {class MainWindow;}
|
||||||
|
|
||||||
|
@ -35,13 +32,6 @@ class AddFriendForm : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum Mode
|
|
||||||
{
|
|
||||||
AddFriend = 0,
|
|
||||||
FriendRequest = 1,
|
|
||||||
GroupInvite = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
AddFriendForm();
|
AddFriendForm();
|
||||||
AddFriendForm(const AddFriendForm&) = delete;
|
AddFriendForm(const AddFriendForm&) = delete;
|
||||||
AddFriendForm& operator=(const AddFriendForm&) = delete;
|
AddFriendForm& operator=(const AddFriendForm&) = delete;
|
||||||
|
@ -49,29 +39,18 @@ public:
|
||||||
|
|
||||||
void show(Ui::MainWindow &ui);
|
void show(Ui::MainWindow &ui);
|
||||||
QString getMessage() const;
|
QString getMessage() const;
|
||||||
void setMode(Mode mode);
|
|
||||||
|
|
||||||
void addFriendRequest(const QString& friendAddress, const QString& message);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void friendRequested(const QString& friendAddress, const QString& message);
|
void friendRequested(const QString& friendAddress, const QString& message);
|
||||||
void friendRequestAccepted(const QString& friendAddress);
|
|
||||||
void friendRequestsSeen();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onUsernameSet(const QString& userName);
|
void onUsernameSet(const QString& userName);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onSendTriggered();
|
void onSendTriggered();
|
||||||
void onFriendRequestAccepted();
|
|
||||||
void onFriendRequestRejected();
|
|
||||||
void onCurrentChanged(int index);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void addFriendRequestWidget(const QString& friendAddress, const QString& message);
|
|
||||||
void retranslateAcceptButton(QPushButton* acceptButton);
|
|
||||||
void retranslateRejectButton(QPushButton* rejectButton);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setIdFromClipboard();
|
void setIdFromClipboard();
|
||||||
|
@ -82,10 +61,6 @@ private:
|
||||||
QVBoxLayout layout, headLayout;
|
QVBoxLayout layout, headLayout;
|
||||||
QWidget *head, *main;
|
QWidget *head, *main;
|
||||||
QString lastUsername; // Cached username so we can retranslate the invite message
|
QString lastUsername; // Cached username so we can retranslate the invite message
|
||||||
QTabWidget* tabWidget;
|
|
||||||
QVBoxLayout* requestsLayout;
|
|
||||||
QSet<QPushButton*> acceptButtons;
|
|
||||||
QSet<QPushButton*> rejectButtons;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ADDFRIENDFORM_H
|
#endif // ADDFRIENDFORM_H
|
||||||
|
|
|
@ -1,155 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright © 2015 by The qTox Project
|
|
||||||
|
|
||||||
This file is part of qTox, a Qt-based graphical interface for Tox.
|
|
||||||
|
|
||||||
qTox is libre 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.
|
|
||||||
|
|
||||||
qTox 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 qTox. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "groupinviteform.h"
|
|
||||||
|
|
||||||
#include <tox/tox.h>
|
|
||||||
#include <QSignalMapper>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QBoxLayout>
|
|
||||||
#include <QGroupBox>
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QLabel>
|
|
||||||
#include "ui_mainwindow.h"
|
|
||||||
#include "src/widget/tool/croppinglabel.h"
|
|
||||||
#include "src/widget/translator.h"
|
|
||||||
#include "src/nexus.h"
|
|
||||||
#include "src/core/core.h"
|
|
||||||
|
|
||||||
GroupInviteForm::GroupInviteForm()
|
|
||||||
{
|
|
||||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
|
||||||
createButton = new QPushButton(this);
|
|
||||||
connect(createButton, &QPushButton::released, [this]()
|
|
||||||
{
|
|
||||||
emit groupCreate(TOX_GROUPCHAT_TYPE_AV);
|
|
||||||
});
|
|
||||||
|
|
||||||
inviteBox = new QGroupBox(this);
|
|
||||||
inviteLayout = new QVBoxLayout(inviteBox);
|
|
||||||
inviteLayout->addStretch(1);
|
|
||||||
|
|
||||||
layout->addWidget(createButton);
|
|
||||||
layout->addWidget(inviteBox);
|
|
||||||
|
|
||||||
QFont bold;
|
|
||||||
bold.setBold(true);
|
|
||||||
|
|
||||||
headLabel = new QLabel(this);
|
|
||||||
headLabel->setFont(bold);
|
|
||||||
headWidget = new QWidget(this);
|
|
||||||
QHBoxLayout* headLayout = new QHBoxLayout(headWidget);
|
|
||||||
headLayout->addWidget(headLabel);
|
|
||||||
|
|
||||||
retranslateUi();
|
|
||||||
Translator::registerHandler(std::bind(&GroupInviteForm::retranslateUi, this), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GroupInviteForm::show(Ui::MainWindow &ui)
|
|
||||||
{
|
|
||||||
ui.mainContent->layout()->addWidget(this);
|
|
||||||
ui.mainHead->layout()->addWidget(headWidget);
|
|
||||||
QWidget::show();
|
|
||||||
headWidget->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GroupInviteForm::addGroupInvite(int32_t friendId, uint8_t type, QByteArray invite)
|
|
||||||
{
|
|
||||||
QWidget* groupWidget = new QWidget(this);
|
|
||||||
QHBoxLayout* groupLayout = new QHBoxLayout(groupWidget);
|
|
||||||
|
|
||||||
CroppingLabel* groupLabel = new CroppingLabel(this);
|
|
||||||
groupLabel->setText(tr("Invited by <b>%1</b> on %2.").arg(Nexus::getCore()->getFriendUsername(friendId), QDateTime::currentDateTime().toString()));
|
|
||||||
groupLayout->addWidget(groupLabel);
|
|
||||||
|
|
||||||
QPushButton* acceptButton = new QPushButton(this);
|
|
||||||
acceptButtons.insert(acceptButton);
|
|
||||||
connect(acceptButton, &QPushButton::released, this, &GroupInviteForm::onGroupInviteAccepted);
|
|
||||||
groupLayout->addWidget(acceptButton);
|
|
||||||
retranslateAcceptButton(acceptButton);
|
|
||||||
|
|
||||||
QPushButton* rejectButton = new QPushButton(this);
|
|
||||||
rejectButtons.insert(rejectButton);
|
|
||||||
connect(rejectButton, &QPushButton::released, this, &GroupInviteForm::onGroupInviteRejected);
|
|
||||||
groupLayout->addWidget(rejectButton);
|
|
||||||
retranslateRejectButton(rejectButton);
|
|
||||||
|
|
||||||
inviteLayout->insertWidget(0, groupWidget);
|
|
||||||
|
|
||||||
GroupInvite group;
|
|
||||||
group.friendId = friendId;
|
|
||||||
group.type = type;
|
|
||||||
group.invite = invite;
|
|
||||||
groupInvites.push_front(group);
|
|
||||||
|
|
||||||
if (isVisible())
|
|
||||||
emit groupInvitesSeen();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GroupInviteForm::showEvent(QShowEvent* event)
|
|
||||||
{
|
|
||||||
QWidget::showEvent(event);
|
|
||||||
emit groupInvitesSeen();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GroupInviteForm::onGroupInviteAccepted()
|
|
||||||
{
|
|
||||||
QWidget* groupWidget = static_cast<QWidget*>(sender());
|
|
||||||
int index = inviteLayout->indexOf(groupWidget);
|
|
||||||
GroupInvite invite = groupInvites.at(index);
|
|
||||||
groupInvites.removeAt(index);
|
|
||||||
|
|
||||||
groupWidget->deleteLater();
|
|
||||||
inviteLayout->removeWidget(groupWidget);
|
|
||||||
|
|
||||||
emit groupInviteAccepted(invite.friendId, invite.type, invite.invite);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GroupInviteForm::onGroupInviteRejected()
|
|
||||||
{
|
|
||||||
QWidget* groupWidget = static_cast<QWidget*>(sender());
|
|
||||||
int index = inviteLayout->indexOf(groupWidget);
|
|
||||||
groupInvites.removeAt(index);
|
|
||||||
|
|
||||||
groupWidget->deleteLater();
|
|
||||||
inviteLayout->removeWidget(groupWidget);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GroupInviteForm::retranslateUi()
|
|
||||||
{
|
|
||||||
headLabel->setText(tr("Groups"));
|
|
||||||
createButton->setText(tr("Create new group"));
|
|
||||||
inviteBox->setTitle(tr("Group invites"));
|
|
||||||
|
|
||||||
for (QPushButton* acceptButton : acceptButtons)
|
|
||||||
retranslateAcceptButton(acceptButton);
|
|
||||||
|
|
||||||
for (QPushButton* rejectButton : rejectButtons)
|
|
||||||
retranslateRejectButton(rejectButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GroupInviteForm::retranslateAcceptButton(QPushButton *acceptButton)
|
|
||||||
{
|
|
||||||
acceptButton->setText(tr("Join"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void GroupInviteForm::retranslateRejectButton(QPushButton *rejectButton)
|
|
||||||
{
|
|
||||||
rejectButton->setText(tr("Decline"));
|
|
||||||
}
|
|
|
@ -1,78 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright © 2015 by The qTox Project
|
|
||||||
|
|
||||||
This file is part of qTox, a Qt-based graphical interface for Tox.
|
|
||||||
|
|
||||||
qTox is libre 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.
|
|
||||||
|
|
||||||
qTox 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 qTox. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GROUPINVITEFORM_H
|
|
||||||
#define GROUPINVITEFORM_H
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QSet>
|
|
||||||
|
|
||||||
class QLabel;
|
|
||||||
class QVBoxLayout;
|
|
||||||
class QPushButton;
|
|
||||||
class QGroupBox;
|
|
||||||
class QSignalMapper;
|
|
||||||
|
|
||||||
namespace Ui {class MainWindow;}
|
|
||||||
|
|
||||||
class GroupInviteForm : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
GroupInviteForm();
|
|
||||||
|
|
||||||
void show(Ui::MainWindow &ui);
|
|
||||||
void addGroupInvite(int32_t friendId, uint8_t type, QByteArray invite);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void groupCreate(uint8_t type);
|
|
||||||
void groupInviteAccepted(int32_t friendId, uint8_t type, QByteArray invite);
|
|
||||||
void groupInvitesSeen();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void showEvent(QShowEvent* event) final override;
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onGroupInviteAccepted();
|
|
||||||
void onGroupInviteRejected();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void retranslateUi();
|
|
||||||
void retranslateAcceptButton(QPushButton* acceptButton);
|
|
||||||
void retranslateRejectButton(QPushButton* rejectButton);
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct GroupInvite
|
|
||||||
{
|
|
||||||
int32_t friendId;
|
|
||||||
uint8_t type;
|
|
||||||
QByteArray invite;
|
|
||||||
};
|
|
||||||
|
|
||||||
QWidget* headWidget;
|
|
||||||
QLabel* headLabel;
|
|
||||||
QPushButton* createButton;
|
|
||||||
QGroupBox* inviteBox;
|
|
||||||
QVBoxLayout* inviteLayout;
|
|
||||||
QSet<QPushButton*> acceptButtons;
|
|
||||||
QSet<QPushButton*> rejectButtons;
|
|
||||||
QList<GroupInvite> groupInvites;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // GROUPINVITEFORM_H
|
|
|
@ -68,16 +68,17 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
QString dir = Settings::getInstance().getAutoAcceptDir(id);
|
QString dir = Settings::getInstance().getAutoAcceptDir(id);
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
QMenu* inviteMenu = menu.addMenu(tr("Invite to group","Menu to invite a friend to a groupchat"));
|
QMenu* inviteMenu = menu.addMenu(tr("Invite to group","Menu to invite a friend to a groupchat"));
|
||||||
QAction* newGroupAction = inviteMenu->addAction(tr("To new group"));
|
|
||||||
inviteMenu->addSeparator();
|
|
||||||
QMap<QAction*, Group*> groupActions;
|
QMap<QAction*, Group*> groupActions;
|
||||||
|
|
||||||
for (Group* group : GroupList::getAllGroups())
|
for (Group* group : GroupList::getAllGroups())
|
||||||
{
|
{
|
||||||
QAction* groupAction = inviteMenu->addAction(tr("Invite to group '%1'").arg(group->getGroupWidget()->getName()));
|
QAction* groupAction = inviteMenu->addAction(group->getGroupWidget()->getName());
|
||||||
groupActions[groupAction] = group;
|
groupActions[groupAction] = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (groupActions.isEmpty())
|
||||||
|
inviteMenu->setEnabled(false);
|
||||||
|
|
||||||
int circleId = Settings::getInstance().getFriendCircleID(FriendList::findFriend(friendId)->getToxId());
|
int circleId = Settings::getInstance().getFriendCircleID(FriendList::findFriend(friendId)->getToxId());
|
||||||
CircleWidget *circleWidget = CircleWidget::getFromID(circleId);
|
CircleWidget *circleWidget = CircleWidget::getFromID(circleId);
|
||||||
|
|
||||||
|
@ -173,11 +174,6 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
Settings::getInstance().setAutoAcceptDir(id, dir);
|
Settings::getInstance().setAutoAcceptDir(id, dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (selectedItem == newGroupAction)
|
|
||||||
{
|
|
||||||
int groupId = Core::getInstance()->createGroup();
|
|
||||||
Core::getInstance()->groupInviteFriend(friendId, groupId);
|
|
||||||
}
|
|
||||||
else if (selectedItem == newCircleAction)
|
else if (selectedItem == newCircleAction)
|
||||||
{
|
{
|
||||||
if (circleWidget != nullptr)
|
if (circleWidget != nullptr)
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
#include "src/persistence/offlinemsgengine.h"
|
#include "src/persistence/offlinemsgengine.h"
|
||||||
#include "src/widget/translator.h"
|
#include "src/widget/translator.h"
|
||||||
#include "src/widget/form/addfriendform.h"
|
#include "src/widget/form/addfriendform.h"
|
||||||
#include "src/widget/form/groupinviteform.h"
|
|
||||||
#include "src/widget/form/filesform.h"
|
#include "src/widget/form/filesform.h"
|
||||||
#include "src/widget/form/profileform.h"
|
#include "src/widget/form/profileform.h"
|
||||||
#include "src/widget/form/settingswidget.h"
|
#include "src/widget/form/settingswidget.h"
|
||||||
|
@ -226,7 +225,6 @@ void Widget::init()
|
||||||
|
|
||||||
filesForm = new FilesForm();
|
filesForm = new FilesForm();
|
||||||
addFriendForm = new AddFriendForm;
|
addFriendForm = new AddFriendForm;
|
||||||
groupInviteForm = new GroupInviteForm;
|
|
||||||
profileForm = new ProfileForm();
|
profileForm = new ProfileForm();
|
||||||
settingsWidget = new SettingsWidget();
|
settingsWidget = new SettingsWidget();
|
||||||
|
|
||||||
|
@ -244,7 +242,6 @@ void Widget::init()
|
||||||
connect(ui->statusLabel, &CroppingLabel::editFinished, this, &Widget::onStatusMessageChanged);
|
connect(ui->statusLabel, &CroppingLabel::editFinished, this, &Widget::onStatusMessageChanged);
|
||||||
connect(ui->mainSplitter, &QSplitter::splitterMoved, this, &Widget::onSplitterMoved);
|
connect(ui->mainSplitter, &QSplitter::splitterMoved, this, &Widget::onSplitterMoved);
|
||||||
connect(addFriendForm, &AddFriendForm::friendRequested, this, &Widget::friendRequested);
|
connect(addFriendForm, &AddFriendForm::friendRequested, this, &Widget::friendRequested);
|
||||||
connect(groupInviteForm, &GroupInviteForm::groupCreate, Core::getInstance(), &Core::createGroup);
|
|
||||||
connect(timer, &QTimer::timeout, this, &Widget::onUserAwayCheck);
|
connect(timer, &QTimer::timeout, this, &Widget::onUserAwayCheck);
|
||||||
connect(timer, &QTimer::timeout, this, &Widget::onEventIconTick);
|
connect(timer, &QTimer::timeout, this, &Widget::onEventIconTick);
|
||||||
connect(timer, &QTimer::timeout, this, &Widget::onTryCreateTrayIcon);
|
connect(timer, &QTimer::timeout, this, &Widget::onTryCreateTrayIcon);
|
||||||
|
@ -337,7 +334,6 @@ void Widget::init()
|
||||||
addFriendForm->show(*ui);
|
addFriendForm->show(*ui);
|
||||||
setWindowTitle(tr("Add friend"));
|
setWindowTitle(tr("Add friend"));
|
||||||
ui->addButton->setCheckable(true);
|
ui->addButton->setCheckable(true);
|
||||||
ui->groupButton->setCheckable(true);
|
|
||||||
ui->transferButton->setCheckable(true);
|
ui->transferButton->setCheckable(true);
|
||||||
ui->settingsButton->setCheckable(true);
|
ui->settingsButton->setCheckable(true);
|
||||||
setActiveToolMenuButton(Widget::AddButton);
|
setActiveToolMenuButton(Widget::AddButton);
|
||||||
|
@ -349,15 +345,6 @@ void Widget::init()
|
||||||
AutoUpdater::checkUpdatesAsyncInteractive();
|
AutoUpdater::checkUpdatesAsyncInteractive();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
friendRequestsButton = nullptr;
|
|
||||||
groupInvitesButton = nullptr;
|
|
||||||
unreadGroupInvites = 0;
|
|
||||||
|
|
||||||
connect(addFriendForm, &AddFriendForm::friendRequestsSeen, this, &Widget::friendRequestsUpdate);
|
|
||||||
connect(addFriendForm, &AddFriendForm::friendRequestAccepted, this, &Widget::friendRequestAccepted);
|
|
||||||
connect(groupInviteForm, &GroupInviteForm::groupInvitesSeen, this, &Widget::groupInvitesClear);
|
|
||||||
connect(groupInviteForm, &GroupInviteForm::groupInviteAccepted, this, &Widget::onGroupInviteAccepted);
|
|
||||||
|
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
Translator::registerHandler(std::bind(&Widget::retranslateUi, this), this);
|
Translator::registerHandler(std::bind(&Widget::retranslateUi, this), this);
|
||||||
|
|
||||||
|
@ -422,7 +409,6 @@ Widget::~Widget()
|
||||||
delete profileForm;
|
delete profileForm;
|
||||||
delete settingsWidget;
|
delete settingsWidget;
|
||||||
delete addFriendForm;
|
delete addFriendForm;
|
||||||
delete groupInviteForm;
|
|
||||||
delete filesForm;
|
delete filesForm;
|
||||||
delete timer;
|
delete timer;
|
||||||
delete offlineMsgTimer;
|
delete offlineMsgTimer;
|
||||||
|
@ -549,7 +535,6 @@ void Widget::forceShow()
|
||||||
void Widget::onAddClicked()
|
void Widget::onAddClicked()
|
||||||
{
|
{
|
||||||
hideMainForms();
|
hideMainForms();
|
||||||
addFriendForm->setMode(AddFriendForm::AddFriend);
|
|
||||||
addFriendForm->show(*ui);
|
addFriendForm->show(*ui);
|
||||||
setWindowTitle(tr("Add friend"));
|
setWindowTitle(tr("Add friend"));
|
||||||
setActiveToolMenuButton(Widget::AddButton);
|
setActiveToolMenuButton(Widget::AddButton);
|
||||||
|
@ -558,11 +543,7 @@ void Widget::onAddClicked()
|
||||||
|
|
||||||
void Widget::onGroupClicked()
|
void Widget::onGroupClicked()
|
||||||
{
|
{
|
||||||
hideMainForms();
|
Nexus::getCore()->createGroup();
|
||||||
groupInviteForm->show(*ui);
|
|
||||||
setWindowTitle(tr("Group invites"));
|
|
||||||
setActiveToolMenuButton(Widget::GroupButton);
|
|
||||||
activeChatroomWidget = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::onTransferClicked()
|
void Widget::onTransferClicked()
|
||||||
|
@ -991,9 +972,10 @@ void Widget::playRingtone()
|
||||||
|
|
||||||
void Widget::onFriendRequestReceived(const QString& userId, const QString& message)
|
void Widget::onFriendRequestReceived(const QString& userId, const QString& message)
|
||||||
{
|
{
|
||||||
QApplication::alert(this);
|
FriendRequestDialog dialog(this, userId, message);
|
||||||
eventFlag = true;
|
|
||||||
friendRequestRecieved(userId, message);
|
if (dialog.exec() == QDialog::Accepted)
|
||||||
|
emit friendRequestAccepted(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::updateFriendActivity(Friend *frnd)
|
void Widget::updateFriendActivity(Friend *frnd)
|
||||||
|
@ -1073,9 +1055,15 @@ void Widget::onGroupInviteReceived(int32_t friendId, uint8_t type, QByteArray in
|
||||||
{
|
{
|
||||||
if (type == TOX_GROUPCHAT_TYPE_TEXT || type == TOX_GROUPCHAT_TYPE_AV)
|
if (type == TOX_GROUPCHAT_TYPE_TEXT || type == TOX_GROUPCHAT_TYPE_AV)
|
||||||
{
|
{
|
||||||
++unreadGroupInvites;
|
if (GUI::askQuestion(tr("Group invite", "popup title"), tr("%1 has invited you to a groupchat. Would you like to join?", "popup text").arg(Nexus::getCore()->getFriendUsername(friendId)), true, false))
|
||||||
groupInvitesUpdate();
|
{
|
||||||
groupInviteForm->addGroupInvite(friendId, type, invite);
|
int groupId = Nexus::getCore()->joinGroupchat(friendId, type, (uint8_t*)invite.data(), invite.length());
|
||||||
|
if (groupId < 0)
|
||||||
|
{
|
||||||
|
qWarning() << "onGroupInviteReceived: Unable to accept group invite";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1084,16 +1072,6 @@ void Widget::onGroupInviteReceived(int32_t friendId, uint8_t type, QByteArray in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::onGroupInviteAccepted(int32_t friendId, uint8_t type, QByteArray invite)
|
|
||||||
{
|
|
||||||
int groupId = Nexus::getCore()->joinGroupchat(friendId, type, (uint8_t*)invite.data(), invite.length());
|
|
||||||
if (groupId < 0)
|
|
||||||
{
|
|
||||||
qWarning() << "onGroupInviteAccepted: Unable to accept group invite";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Widget::onGroupMessageReceived(int groupnumber, int peernumber, const QString& message, bool isAction)
|
void Widget::onGroupMessageReceived(int groupnumber, int peernumber, const QString& message, bool isAction)
|
||||||
{
|
{
|
||||||
Group* g = GroupList::findGroup(groupnumber);
|
Group* g = GroupList::findGroup(groupnumber);
|
||||||
|
@ -1684,71 +1662,11 @@ bool Widget::groupsVisible() const
|
||||||
void Widget::friendListContextMenu(const QPoint &pos)
|
void Widget::friendListContextMenu(const QPoint &pos)
|
||||||
{
|
{
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
QAction *createGroupAction = menu.addAction(tr("Create new group..."));
|
|
||||||
QAction *addCircleAction = menu.addAction(tr("Add new circle..."));
|
QAction *addCircleAction = menu.addAction(tr("Add new circle..."));
|
||||||
QAction *chosenAction = menu.exec(ui->friendList->mapToGlobal(pos));
|
QAction *chosenAction = menu.exec(ui->friendList->mapToGlobal(pos));
|
||||||
|
|
||||||
if (chosenAction == addCircleAction)
|
if (chosenAction == addCircleAction)
|
||||||
contactListWidget->addCircleWidget();
|
contactListWidget->addCircleWidget();
|
||||||
else if (chosenAction == createGroupAction)
|
|
||||||
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();
|
|
||||||
|
|
||||||
if (unreadFriendRequests == 0)
|
|
||||||
{
|
|
||||||
delete friendRequestsButton;
|
|
||||||
friendRequestsButton = nullptr;
|
|
||||||
}
|
|
||||||
else if (!friendRequestsButton)
|
|
||||||
{
|
|
||||||
friendRequestsButton = new QPushButton(this);
|
|
||||||
friendRequestsButton->setObjectName("green");
|
|
||||||
ui->statusLayout->insertWidget(2, friendRequestsButton);
|
|
||||||
|
|
||||||
connect(friendRequestsButton, &QPushButton::released, [this]()
|
|
||||||
{
|
|
||||||
onGroupClicked();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (friendRequestsButton)
|
|
||||||
friendRequestsButton->setText(tr("%n New Friend Request(s)", "", unreadFriendRequests));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Widget::groupInvitesUpdate()
|
|
||||||
{
|
|
||||||
if (unreadGroupInvites == 0)
|
|
||||||
{
|
|
||||||
delete groupInvitesButton;
|
|
||||||
groupInvitesButton = nullptr;
|
|
||||||
}
|
|
||||||
else if (!groupInvitesButton)
|
|
||||||
{
|
|
||||||
groupInvitesButton = new QPushButton(this);
|
|
||||||
groupInvitesButton->setObjectName("green");
|
|
||||||
ui->statusLayout->insertWidget(2, groupInvitesButton);
|
|
||||||
|
|
||||||
connect(groupInvitesButton, &QPushButton::released, this, &Widget::onGroupClicked);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (groupInvitesButton)
|
|
||||||
groupInvitesButton->setText(tr("%n New Group Invite(s)", "", unreadGroupInvites));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Widget::groupInvitesClear()
|
|
||||||
{
|
|
||||||
unreadGroupInvites = 0;
|
|
||||||
groupInvitesUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::setActiveToolMenuButton(ActiveToolMenuButton newActiveButton)
|
void Widget::setActiveToolMenuButton(ActiveToolMenuButton newActiveButton)
|
||||||
|
@ -1785,9 +1703,6 @@ void Widget::retranslateUi()
|
||||||
statusAway->setText(tr("Away", "Button to set your status to 'Away'"));
|
statusAway->setText(tr("Away", "Button to set your status to 'Away'"));
|
||||||
statusBusy->setText(tr("Busy", "Button to set your status to 'Busy'"));
|
statusBusy->setText(tr("Busy", "Button to set your status to 'Busy'"));
|
||||||
setWindowTitle(tr("Settings"));
|
setWindowTitle(tr("Settings"));
|
||||||
|
|
||||||
friendRequestsUpdate();
|
|
||||||
groupInvitesUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
|
|
|
@ -49,10 +49,8 @@ class FilesForm;
|
||||||
class ProfileForm;
|
class ProfileForm;
|
||||||
class SettingsWidget;
|
class SettingsWidget;
|
||||||
class AddFriendForm;
|
class AddFriendForm;
|
||||||
class GroupInviteForm;
|
|
||||||
class CircleWidget;
|
class CircleWidget;
|
||||||
class QActionGroup;
|
class QActionGroup;
|
||||||
class QPushButton;
|
|
||||||
|
|
||||||
class Widget final : public QMainWindow
|
class Widget final : public QMainWindow
|
||||||
{
|
{
|
||||||
|
@ -113,7 +111,6 @@ public slots:
|
||||||
void onReceiptRecieved(int friendId, int receipt);
|
void onReceiptRecieved(int friendId, int receipt);
|
||||||
void onEmptyGroupCreated(int groupId);
|
void onEmptyGroupCreated(int groupId);
|
||||||
void onGroupInviteReceived(int32_t friendId, uint8_t type, QByteArray invite);
|
void onGroupInviteReceived(int32_t friendId, uint8_t type, QByteArray invite);
|
||||||
void onGroupInviteAccepted(int32_t friendId, uint8_t type, QByteArray invite);
|
|
||||||
void onGroupMessageReceived(int groupnumber, int peernumber, const QString& message, bool isAction);
|
void onGroupMessageReceived(int groupnumber, int peernumber, const QString& message, bool isAction);
|
||||||
void onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t change);
|
void onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t change);
|
||||||
void onGroupTitleChanged(int groupnumber, const QString& author, const QString& title);
|
void onGroupTitleChanged(int groupnumber, const QString& author, const QString& title);
|
||||||
|
@ -162,10 +159,6 @@ private slots:
|
||||||
void onSplitterMoved(int pos, int index);
|
void onSplitterMoved(int pos, int index);
|
||||||
void processOfflineMsgs();
|
void processOfflineMsgs();
|
||||||
void friendListContextMenu(const QPoint &pos);
|
void friendListContextMenu(const QPoint &pos);
|
||||||
void friendRequestRecieved(const QString& friendAddress, const QString& message);
|
|
||||||
void friendRequestsUpdate();
|
|
||||||
void groupInvitesUpdate();
|
|
||||||
void groupInvitesClear();
|
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
void bringAllToFront();
|
void bringAllToFront();
|
||||||
|
@ -233,7 +226,6 @@ private:
|
||||||
QSplitter *centralLayout;
|
QSplitter *centralLayout;
|
||||||
QPoint dragPosition;
|
QPoint dragPosition;
|
||||||
AddFriendForm *addFriendForm;
|
AddFriendForm *addFriendForm;
|
||||||
GroupInviteForm* groupInviteForm;
|
|
||||||
ProfileForm *profileForm;
|
ProfileForm *profileForm;
|
||||||
SettingsWidget *settingsWidget;
|
SettingsWidget *settingsWidget;
|
||||||
FilesForm *filesForm;
|
FilesForm *filesForm;
|
||||||
|
@ -249,9 +241,6 @@ private:
|
||||||
bool eventFlag;
|
bool eventFlag;
|
||||||
bool eventIcon;
|
bool eventIcon;
|
||||||
bool wasMaximized = false;
|
bool wasMaximized = false;
|
||||||
QPushButton* friendRequestsButton;
|
|
||||||
QPushButton* groupInvitesButton;
|
|
||||||
unsigned int unreadGroupInvites;
|
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
QAction* fullscreenAction;
|
QAction* fullscreenAction;
|
||||||
|
|
|
@ -25,26 +25,6 @@ QToolButton::menu-indicator {
|
||||||
image: none
|
image: none
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton#green {
|
|
||||||
background: none;
|
|
||||||
background-color: #6bc260;
|
|
||||||
color: white;
|
|
||||||
border-style: none;
|
|
||||||
border-radius: 4px;
|
|
||||||
padding: 4px;
|
|
||||||
margin: 4px 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPushButton#green:hover
|
|
||||||
{
|
|
||||||
background-color: #79c76f;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPushButton#green:pressed
|
|
||||||
{
|
|
||||||
background-color: #51b244;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Uncomment this after https://github.com/tux3/qTox/pull/1640
|
Uncomment this after https://github.com/tux3/qTox/pull/1640
|
||||||
is merged!
|
is merged!
|
||||||
|
@ -116,4 +96,3 @@ QListView {
|
||||||
position: relative;
|
position: relative;
|
||||||
bottom: 2px;
|
bottom: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user