fix for
bug #91 - Make DELEGATE action available in frontend
--- a/QTfrontend/hwform.cpp Sun Oct 02 17:39:42 2016 +0200
+++ b/QTfrontend/hwform.cpp Sun Oct 02 18:29:55 2016 +0200
@@ -1263,6 +1263,8 @@
// chat widget actions
connect(ui.pageNetGame->chatWidget, SIGNAL(kick(const QString&)),
hwnet, SLOT(kickPlayer(const QString&)));
+ connect(ui.pageNetGame->chatWidget, SIGNAL(delegate(const QString&)),
+ hwnet, SLOT(delegateToPlayer(const QString&)));
connect(ui.pageNetGame->chatWidget, SIGNAL(ban(const QString&)),
hwnet, SLOT(banPlayer(const QString&)));
connect(ui.pageNetGame->chatWidget, SIGNAL(info(const QString&)),
--- a/QTfrontend/net/newnetclient.cpp Sun Oct 02 17:39:42 2016 +0200
+++ b/QTfrontend/net/newnetclient.cpp Sun Oct 02 18:29:55 2016 +0200
@@ -1012,6 +1012,11 @@
RawSendNet(QString("KICK%1%2").arg(delimiter).arg(nick));
}
+void HWNewNet::delegateToPlayer(const QString & nick)
+{
+ RawSendNet(QString("DELEGATE%1%2").arg(delimiter).arg(nick));
+}
+
void HWNewNet::infoPlayer(const QString & nick)
{
RawSendNet(QString("INFO%1%2").arg(delimiter).arg(nick));
--- a/QTfrontend/net/newnetclient.h Sun Oct 02 17:39:42 2016 +0200
+++ b/QTfrontend/net/newnetclient.h Sun Oct 02 18:29:55 2016 +0200
@@ -167,6 +167,7 @@
void gameFinished(bool correcly);
void banPlayer(const QString &);
void kickPlayer(const QString &);
+ void delegateToPlayer(const QString &);
void infoPlayer(const QString &);
void followPlayer(const QString &);
void consoleCommand(const QString &);
--- a/QTfrontend/ui/widget/chatwidget.cpp Sun Oct 02 17:39:42 2016 +0200
+++ b/QTfrontend/ui/widget/chatwidget.cpp Sun Oct 02 18:29:55 2016 +0200
@@ -270,6 +270,10 @@
acBan->setIcon(QIcon(":/res/ban.png"));
acBan->setData(QVariant(true));
connect(acBan, SIGNAL(triggered(bool)), this, SLOT(onBan()));
+ acDelegate = new QAction(QAction::tr("Delegate room control"), chatNicks);
+ acDelegate->setIcon(QIcon(":/res/chat/roomadmin.png"));
+ acDelegate->setData(QVariant(true));
+ connect(acDelegate, SIGNAL(triggered(bool)), this, SLOT(onDelegate()));
acFollow = new QAction(QAction::tr("Follow"), chatNicks);
acFollow->setIcon(QIcon(":/res/follow.png"));
acFollow->setData(QVariant(false));
@@ -624,6 +628,14 @@
emit ban(mil[0].data().toString());
}
+void HWChatWidget::onDelegate()
+{
+ QModelIndexList mil = chatNicks->selectionModel()->selectedRows();
+
+ if(mil.size())
+ emit delegate(mil[0].data().toString());
+}
+
void HWChatWidget::onInfo()
{
QModelIndexList mil = chatNicks->selectionModel()->selectedRows();
@@ -732,6 +744,7 @@
{
chatNicks->removeAction(acKick);
//chatNicks->removeAction(acBan);
+ chatNicks->removeAction(acDelegate);
m_isAdmin = b;
@@ -739,6 +752,7 @@
{
chatNicks->insertAction(0, acKick);
//chatNicks->insertAction(0, acBan);
+ chatNicks->insertAction(acFriend, acDelegate);
}
}
@@ -931,6 +945,7 @@
{
acKick->setVisible(!isSelf && isOnline);
acBan->setVisible(!isSelf);
+ acDelegate->setVisible(!isSelf && players->isFlagSet(m_userNick, PlayersListModel::InRoom));
}
m_nicksMenu->clear();
--- a/QTfrontend/ui/widget/chatwidget.h Sun Oct 02 17:39:42 2016 +0200
+++ b/QTfrontend/ui/widget/chatwidget.h Sun Oct 02 18:29:55 2016 +0200
@@ -128,6 +128,7 @@
void chatLine(const QString& str);
void kick(const QString & str);
void ban(const QString & str);
+ void delegate(const QString & str);
void info(const QString & str);
void follow(const QString &);
void nickCountUpdate(int cnt);
@@ -144,6 +145,7 @@
QAction * acInfo;
QAction * acKick;
QAction * acBan;
+ QAction * acDelegate;
QAction * acFollow;
QAction * acIgnore;
QAction * acFriend;
@@ -163,6 +165,7 @@
void returnPressed();
void onBan();
void onKick();
+ void onDelegate();
void onInfo();
void onFollow();
void onIgnore();