Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
d0f3ae6c
Commit
d0f3ae6c
authored
Jun 17, 2014
by
Gavin Bisesi
Browse files
Merge pull request #87 from Daenyth/offline-buddy
Add the ability to friend/ignore an offline user
parents
74163dba
b749ddbc
Changes
2
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/tab_userlists.cpp
View file @
d0f3ae6c
...
...
@@ -4,6 +4,8 @@
#include
"abstractclient.h"
#include
<QHBoxLayout>
#include
<QVBoxLayout>
#include
<QPushButton>
#include
<QLineEdit>
#include
"pending_command.h"
#include
"pb/session_commands.pb.h"
...
...
@@ -21,34 +23,90 @@ TabUserLists::TabUserLists(TabSupervisor *_tabSupervisor, AbstractClient *_clien
ignoreList
=
new
UserList
(
_tabSupervisor
,
client
,
UserList
::
IgnoreList
);
userInfoBox
=
new
UserInfoBox
(
client
,
false
);
userInfoBox
->
updateInfo
(
userInfo
);
connect
(
allUsersList
,
SIGNAL
(
openMessageDialog
(
const
QString
&
,
bool
)),
this
,
SIGNAL
(
openMessageDialog
(
const
QString
&
,
bool
)));
connect
(
buddyList
,
SIGNAL
(
openMessageDialog
(
const
QString
&
,
bool
)),
this
,
SIGNAL
(
openMessageDialog
(
const
QString
&
,
bool
)));
connect
(
ignoreList
,
SIGNAL
(
openMessageDialog
(
const
QString
&
,
bool
)),
this
,
SIGNAL
(
openMessageDialog
(
const
QString
&
,
bool
)));
connect
(
client
,
SIGNAL
(
userJoinedEventReceived
(
const
Event_UserJoined
&
)),
this
,
SLOT
(
processUserJoinedEvent
(
const
Event_UserJoined
&
)));
connect
(
client
,
SIGNAL
(
userLeftEventReceived
(
const
Event_UserLeft
&
)),
this
,
SLOT
(
processUserLeftEvent
(
const
Event_UserLeft
&
)));
connect
(
client
,
SIGNAL
(
buddyListReceived
(
const
QList
<
ServerInfo_User
>
&
)),
this
,
SLOT
(
buddyListReceived
(
const
QList
<
ServerInfo_User
>
&
)));
connect
(
client
,
SIGNAL
(
ignoreListReceived
(
const
QList
<
ServerInfo_User
>
&
)),
this
,
SLOT
(
ignoreListReceived
(
const
QList
<
ServerInfo_User
>
&
)));
connect
(
client
,
SIGNAL
(
addToListEventReceived
(
const
Event_AddToList
&
)),
this
,
SLOT
(
processAddToListEvent
(
const
Event_AddToList
&
)));
connect
(
client
,
SIGNAL
(
removeFromListEventReceived
(
const
Event_RemoveFromList
&
)),
this
,
SLOT
(
processRemoveFromListEvent
(
const
Event_RemoveFromList
&
)));
PendingCommand
*
pend
=
client
->
prepareSessionCommand
(
Command_ListUsers
());
connect
(
pend
,
SIGNAL
(
finished
(
Response
,
CommandContainer
,
QVariant
)),
this
,
SLOT
(
processListUsersResponse
(
const
Response
&
)));
client
->
sendCommand
(
pend
);
QVBoxLayout
*
vbox
=
new
QVBoxLayout
;
vbox
->
addWidget
(
userInfoBox
);
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
;
mainLayout
->
add
Widge
t
(
buddy
List
);
mainLayout
->
add
Widge
t
(
ignore
List
);
mainLayout
->
add
Layou
t
(
buddy
Panel
);
mainLayout
->
add
Layou
t
(
ignore
Panel
);
mainLayout
->
addLayout
(
vbox
);
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
()
{
allUsersList
->
retranslateUi
();
...
...
cockatrice/src/tab_userlists.h
View file @
d0f3ae6c
...
...
@@ -3,6 +3,7 @@
#include
"tab.h"
#include
"pb/serverinfo_user.pb.h"
#include
<QLineEdit>
class
AbstractClient
;
class
UserList
;
...
...
@@ -30,12 +31,17 @@ private slots:
void
ignoreListReceived
(
const
QList
<
ServerInfo_User
>
&
_ignoreList
);
void
processAddToListEvent
(
const
Event_AddToList
&
event
);
void
processRemoveFromListEvent
(
const
Event_RemoveFromList
&
event
);
void
addToIgnoreList
();
void
addToBuddyList
();
private:
AbstractClient
*
client
;
UserList
*
allUsersList
;
UserList
*
buddyList
;
UserList
*
ignoreList
;
UserInfoBox
*
userInfoBox
;
QLineEdit
*
addBuddyEdit
;
QLineEdit
*
addIgnoreEdit
;
void
addToList
(
const
std
::
string
&
listName
,
const
QString
&
userName
);
public:
TabUserLists
(
TabSupervisor
*
_tabSupervisor
,
AbstractClient
*
_client
,
const
ServerInfo_User
&
userInfo
,
QWidget
*
parent
=
0
);
void
retranslateUi
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment