mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-15 11:38:49 -07:00
added admin tab; server status message update
This commit is contained in:
parent
714a0eee50
commit
bd9e142d1d
20 changed files with 242 additions and 65 deletions
|
|
@ -16,6 +16,7 @@ private:
|
|||
ResponseCode cmdDeckDel(Command_DeckDel * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckUpload(Command_DeckUpload * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckDownload(Command_DeckDownload * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdUpdateServerMessage(Command_UpdateServerMessage * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
public:
|
||||
LocalServerInterface(LocalServer *_server);
|
||||
~LocalServerInterface();
|
||||
|
|
|
|||
|
|
@ -43,15 +43,16 @@ void RemoteClient::slotConnected()
|
|||
|
||||
void RemoteClient::loginResponse(ProtocolResponse *response)
|
||||
{
|
||||
Response_Login *resp = qobject_cast<Response_Login *>(response);
|
||||
if (!resp)
|
||||
disconnectFromServer();
|
||||
|
||||
if (resp->getResponseCode() == RespOk) {
|
||||
if (response->getResponseCode() == RespOk) {
|
||||
Response_Login *resp = qobject_cast<Response_Login *>(response);
|
||||
if (!resp) {
|
||||
disconnectFromServer();
|
||||
return;
|
||||
}
|
||||
setStatus(StatusLoggedIn);
|
||||
emit userInfoChanged(resp->getUserInfo());
|
||||
} else {
|
||||
emit serverError(resp->getResponseCode());
|
||||
emit serverError(response->getResponseCode());
|
||||
setStatus(StatusDisconnecting);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
66
cockatrice/src/tab_admin.cpp
Normal file
66
cockatrice/src/tab_admin.cpp
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QGroupBox>
|
||||
#include <QMessageBox>
|
||||
#include "tab_admin.h"
|
||||
#include "abstractclient.h"
|
||||
#include "protocol_items.h"
|
||||
|
||||
TabAdmin::TabAdmin(AbstractClient *_client, QWidget *parent)
|
||||
: Tab(parent), client(_client)
|
||||
{
|
||||
updateServerMessageButton = new QPushButton;
|
||||
connect(updateServerMessageButton, SIGNAL(clicked()), this, SLOT(actUpdateServerMessage()));
|
||||
|
||||
QVBoxLayout *vbox = new QVBoxLayout;
|
||||
vbox->addWidget(updateServerMessageButton);
|
||||
vbox->addStretch();
|
||||
|
||||
adminGroupBox = new QGroupBox;
|
||||
adminGroupBox->setLayout(vbox);
|
||||
adminGroupBox->setEnabled(false);
|
||||
|
||||
unlockButton = new QPushButton;
|
||||
connect(unlockButton, SIGNAL(clicked()), this, SLOT(actUnlock()));
|
||||
lockButton = new QPushButton;
|
||||
lockButton->setEnabled(false);
|
||||
connect(lockButton, SIGNAL(clicked()), this, SLOT(actLock()));
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addWidget(adminGroupBox);
|
||||
mainLayout->addWidget(unlockButton);
|
||||
mainLayout->addWidget(lockButton);
|
||||
|
||||
retranslateUi();
|
||||
setLayout(mainLayout);
|
||||
}
|
||||
|
||||
void TabAdmin::retranslateUi()
|
||||
{
|
||||
updateServerMessageButton->setText(tr("Update server &message"));
|
||||
adminGroupBox->setTitle(tr("Server administration functions"));
|
||||
|
||||
unlockButton->setText(tr("&Unlock functions"));
|
||||
lockButton->setText(tr("&Lock functions"));
|
||||
}
|
||||
|
||||
void TabAdmin::actUpdateServerMessage()
|
||||
{
|
||||
client->sendCommand(new Command_UpdateServerMessage());
|
||||
}
|
||||
|
||||
void TabAdmin::actUnlock()
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Unlock administration functions"), tr("Do you really want to unlock the administration functions?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
||||
adminGroupBox->setEnabled(true);
|
||||
lockButton->setEnabled(true);
|
||||
unlockButton->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void TabAdmin::actLock()
|
||||
{
|
||||
adminGroupBox->setEnabled(false);
|
||||
lockButton->setEnabled(false);
|
||||
unlockButton->setEnabled(true);
|
||||
}
|
||||
29
cockatrice/src/tab_admin.h
Normal file
29
cockatrice/src/tab_admin.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef TAB_ADMIN_H
|
||||
#define TAB_ADMIN_H
|
||||
|
||||
#include "tab.h"
|
||||
|
||||
class AbstractClient;
|
||||
|
||||
class QGroupBox;
|
||||
class QPushButton;
|
||||
|
||||
class TabAdmin : public Tab {
|
||||
Q_OBJECT
|
||||
private:
|
||||
AbstractClient *client;
|
||||
QPushButton *updateServerMessageButton;
|
||||
QGroupBox *adminGroupBox;
|
||||
QPushButton *unlockButton, *lockButton;
|
||||
private slots:
|
||||
void actUpdateServerMessage();
|
||||
|
||||
void actUnlock();
|
||||
void actLock();
|
||||
public:
|
||||
TabAdmin(AbstractClient *_client, QWidget *parent = 0);
|
||||
void retranslateUi();
|
||||
QString getTabText() const { return tr("Administration"); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -163,6 +163,7 @@ void TabServer::retranslateUi()
|
|||
void TabServer::processServerMessageEvent(Event_ServerMessage *event)
|
||||
{
|
||||
serverInfoBox->setHtml(event->getMessage());
|
||||
emit userEvent();
|
||||
}
|
||||
|
||||
void TabServer::processListUsersResponse(ProtocolResponse *response)
|
||||
|
|
|
|||
|
|
@ -5,13 +5,14 @@
|
|||
#include "tab_room.h"
|
||||
#include "tab_game.h"
|
||||
#include "tab_deck_storage.h"
|
||||
#include "tab_admin.h"
|
||||
#include "tab_message.h"
|
||||
#include "protocol_items.h"
|
||||
#include "pixmapgenerator.h"
|
||||
#include <QDebug>
|
||||
|
||||
TabSupervisor:: TabSupervisor(QWidget *parent)
|
||||
: QTabWidget(parent), client(0), tabServer(0), tabDeckStorage(0)
|
||||
: QTabWidget(parent), client(0), tabServer(0), tabDeckStorage(0), tabAdmin(0)
|
||||
{
|
||||
tabChangedIcon = new QIcon(":/resources/icon_tab_changed.svg");
|
||||
setElideMode(Qt::ElideRight);
|
||||
|
|
@ -69,8 +70,17 @@ void TabSupervisor::start(AbstractClient *_client, ServerInfo_User *userInfo)
|
|||
myAddTab(tabServer);
|
||||
updatePingTime(0, -1);
|
||||
|
||||
tabDeckStorage = new TabDeckStorage(client);
|
||||
myAddTab(tabDeckStorage);
|
||||
if (userInfo->getUserLevel() & ServerInfo_User::IsRegistered) {
|
||||
tabDeckStorage = new TabDeckStorage(client);
|
||||
myAddTab(tabDeckStorage);
|
||||
} else
|
||||
tabDeckStorage = 0;
|
||||
|
||||
if (userInfo->getUserLevel() & ServerInfo_User::IsAdmin) {
|
||||
tabAdmin = new TabAdmin(client);
|
||||
myAddTab(tabAdmin);
|
||||
} else
|
||||
tabAdmin = 0;
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
|
@ -124,6 +134,8 @@ void TabSupervisor::updatePingTime(int value, int max)
|
|||
{
|
||||
if (!tabServer)
|
||||
return;
|
||||
if (tabServer->getContentsChanged())
|
||||
return;
|
||||
|
||||
setTabIcon(0, QIcon(PingPixmapGenerator::generatePixmap(15, value, max)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ class TabServer;
|
|||
class TabRoom;
|
||||
class TabGame;
|
||||
class TabDeckStorage;
|
||||
class TabAdmin;
|
||||
class TabMessage;
|
||||
class RoomEvent;
|
||||
class GameEventContainer;
|
||||
|
|
@ -28,6 +29,7 @@ private:
|
|||
QList<AbstractClient *> localClients;
|
||||
TabServer *tabServer;
|
||||
TabDeckStorage *tabDeckStorage;
|
||||
TabAdmin *tabAdmin;
|
||||
QMap<int, TabRoom *> roomTabs;
|
||||
QMap<int, TabGame *> gameTabs;
|
||||
QMap<QString, TabMessage *> messageTabs;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue