Add the ability to friend/ignore an offline user
This commit is contained in:
parent
6913f2bb4e
commit
b749ddbc45
2 changed files with 72 additions and 8 deletions
|
@ -4,6 +4,8 @@
|
||||||
#include "abstractclient.h"
|
#include "abstractclient.h"
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
#include "pending_command.h"
|
#include "pending_command.h"
|
||||||
#include "pb/session_commands.pb.h"
|
#include "pb/session_commands.pb.h"
|
||||||
|
@ -41,14 +43,70 @@ TabUserLists::TabUserLists(TabSupervisor *_tabSupervisor, AbstractClient *_clien
|
||||||
vbox->addWidget(userInfoBox);
|
vbox->addWidget(userInfoBox);
|
||||||
vbox->addWidget(allUsersList);
|
vbox->addWidget(allUsersList);
|
||||||
|
|
||||||
|
QHBoxLayout *addToBuddyList = new QHBoxLayout;
|
||||||
|
addBuddyEdit = new QLineEdit;
|
||||||
|
addBuddyEdit->setPlaceholderText(tr("Add to Buddy List"));
|
||||||
|
connect(addBuddyEdit, SIGNAL(returnPressed()), this, SLOT(addToBuddyList()));
|
||||||
|
QPushButton *addBuddyButton = new QPushButton("Add");
|
||||||
|
connect(addBuddyButton, SIGNAL(clicked()), this, SLOT(addToBuddyList()));
|
||||||
|
addToBuddyList->addWidget(addBuddyEdit);
|
||||||
|
addToBuddyList->addWidget(addBuddyButton);
|
||||||
|
|
||||||
|
QHBoxLayout *addToIgnoreList = new QHBoxLayout;
|
||||||
|
addIgnoreEdit = new QLineEdit;
|
||||||
|
addIgnoreEdit->setPlaceholderText(tr("Add to Ignore List"));
|
||||||
|
connect(addIgnoreEdit, SIGNAL(returnPressed()), this, SLOT(addToIgnoreList()));
|
||||||
|
QPushButton *addIgnoreButton = new QPushButton("Add");
|
||||||
|
connect(addIgnoreButton, SIGNAL(clicked()), this, SLOT(addToIgnoreList()));
|
||||||
|
addToIgnoreList->addWidget(addIgnoreEdit);
|
||||||
|
addToIgnoreList->addWidget(addIgnoreButton);
|
||||||
|
|
||||||
|
QVBoxLayout *buddyPanel = new QVBoxLayout;
|
||||||
|
buddyPanel->addWidget(buddyList);
|
||||||
|
buddyPanel->addLayout(addToBuddyList);
|
||||||
|
|
||||||
|
QVBoxLayout *ignorePanel = new QVBoxLayout;
|
||||||
|
ignorePanel->addWidget(ignoreList);
|
||||||
|
ignorePanel->addLayout(addToIgnoreList);
|
||||||
|
|
||||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||||
mainLayout->addWidget(buddyList);
|
mainLayout->addLayout(buddyPanel);
|
||||||
mainLayout->addWidget(ignoreList);
|
mainLayout->addLayout(ignorePanel);
|
||||||
mainLayout->addLayout(vbox);
|
mainLayout->addLayout(vbox);
|
||||||
|
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabUserLists::addToBuddyList()
|
||||||
|
{
|
||||||
|
QString userName = addBuddyEdit->text();
|
||||||
|
if (userName.length() < 1) return;
|
||||||
|
|
||||||
|
std::string listName = "buddy";
|
||||||
|
addToList(listName, userName);
|
||||||
|
addBuddyEdit->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabUserLists::addToIgnoreList()
|
||||||
|
{
|
||||||
|
QString userName = addIgnoreEdit->text();
|
||||||
|
if (userName.length() < 1) return;
|
||||||
|
|
||||||
|
std::string listName = "ignore";
|
||||||
|
addToList(listName, userName);
|
||||||
|
addIgnoreEdit->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabUserLists::addToList(const std::string &listName, const QString &userName)
|
||||||
|
{
|
||||||
|
Command_AddToList cmd;
|
||||||
|
cmd.set_list(listName);
|
||||||
|
cmd.set_user_name(userName.toStdString());
|
||||||
|
|
||||||
|
client->sendCommand(client->prepareSessionCommand(cmd));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TabUserLists::retranslateUi()
|
void TabUserLists::retranslateUi()
|
||||||
{
|
{
|
||||||
allUsersList->retranslateUi();
|
allUsersList->retranslateUi();
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "tab.h"
|
#include "tab.h"
|
||||||
#include "pb/serverinfo_user.pb.h"
|
#include "pb/serverinfo_user.pb.h"
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
class AbstractClient;
|
class AbstractClient;
|
||||||
class UserList;
|
class UserList;
|
||||||
|
@ -30,12 +31,17 @@ private slots:
|
||||||
void ignoreListReceived(const QList<ServerInfo_User> &_ignoreList);
|
void ignoreListReceived(const QList<ServerInfo_User> &_ignoreList);
|
||||||
void processAddToListEvent(const Event_AddToList &event);
|
void processAddToListEvent(const Event_AddToList &event);
|
||||||
void processRemoveFromListEvent(const Event_RemoveFromList &event);
|
void processRemoveFromListEvent(const Event_RemoveFromList &event);
|
||||||
|
void addToIgnoreList();
|
||||||
|
void addToBuddyList();
|
||||||
private:
|
private:
|
||||||
AbstractClient *client;
|
AbstractClient *client;
|
||||||
UserList *allUsersList;
|
UserList *allUsersList;
|
||||||
UserList *buddyList;
|
UserList *buddyList;
|
||||||
UserList *ignoreList;
|
UserList *ignoreList;
|
||||||
UserInfoBox *userInfoBox;
|
UserInfoBox *userInfoBox;
|
||||||
|
QLineEdit *addBuddyEdit;
|
||||||
|
QLineEdit *addIgnoreEdit;
|
||||||
|
void addToList(const std::string &listName, const QString &userName);
|
||||||
public:
|
public:
|
||||||
TabUserLists(TabSupervisor *_tabSupervisor, AbstractClient *_client, const ServerInfo_User &userInfo, QWidget *parent = 0);
|
TabUserLists(TabSupervisor *_tabSupervisor, AbstractClient *_client, const ServerInfo_User &userInfo, QWidget *parent = 0);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
|
Loading…
Reference in a new issue