27 #include "serverapi/playerslist.h" 28 #include "serverapi/server.h" 31 #include "serverapi/tooltips/tooltipgenerator.h" 32 #include "serverdetailsdock.h" 33 #include "ui_serverdetailsdock.h" 35 DClass<ServerDetailsDock> :
public Ui::ServerDetailsDock
44 this->toggleViewAction()->setIcon(QIcon(
":/icons/server_details.png"));
49 ServerDetailsDock::~ServerDetailsDock()
53 void ServerDetailsDock::clear()
55 d->lblServer->setText(
"");
56 d->sbArea->setText(
"");
57 d->detailsArea->setText(
"");
60 void ServerDetailsDock::displaySelection(QList<ServerPtr> &selectedServers)
62 ServerPtr server = selectServer(selectedServers);
63 if (server ==
nullptr)
69 d->lblServer->setText(server->name());
71 if (server->players().numClients() != 0)
74 d->sbArea->setText(QString());
75 d->detailsArea->setText(QString(
"<div>%1</div>%2").arg(server->customDetails()).arg(tooltipGenerator->
dmflagsHTML()));
76 delete tooltipGenerator;
79 void ServerDetailsDock::reorientContentsBasingOnDimensions()
81 const int TOPTOBOTTOM_PREFERENCE_THRESHOLD = 100;
82 if (height() + TOPTOBOTTOM_PREFERENCE_THRESHOLD > width())
83 static_cast<QBoxLayout *
>(d->dataLayout)->setDirection(QBoxLayout::TopToBottom);
85 static_cast<QBoxLayout *
>(d->dataLayout)->setDirection(QBoxLayout::LeftToRight);
88 void ServerDetailsDock::resizeEvent(QResizeEvent *event)
91 reorientContentsBasingOnDimensions();
94 ServerPtr ServerDetailsDock::selectServer(QList<ServerPtr> &selectedServers)
96 if (selectedServers.count() == 0)
98 if (!selectedServers[0]->isKnown())
100 return selectedServers[0];