diff --git a/apps/browser/MainWindow.cpp b/apps/browser/MainWindow.cpp index 1edc8a606..0d896986b 100644 --- a/apps/browser/MainWindow.cpp +++ b/apps/browser/MainWindow.cpp @@ -125,6 +125,15 @@ void MainWindow::play() QStringList arguments; arguments.append(QLatin1String("--connect=") + sm->myData[sourceId].addr.toLatin1()); + if(sm->myData[sourceId].needPassw) + { + bool ok; + QString passw = QInputDialog::getText(this, "Connecting to: " + sm->myData[sourceId].addr, "Password: ", QLineEdit::Password, "", &ok); + if(!ok) + return; + arguments.append(QLatin1String("--password=") + passw.toLatin1()); + } + if (mGameInvoker->startProcess(QLatin1String("tes3mp"), arguments, true)) return qApp->quit(); } diff --git a/apps/browser/NetController.cpp b/apps/browser/NetController.cpp index d09d01083..e15c57800 100644 --- a/apps/browser/NetController.cpp +++ b/apps/browser/NetController.cpp @@ -80,6 +80,10 @@ void NetController::setData(QString address, QJsonObject server, ServerModel *mo mi = model->index(0, ServerData::VERSION); model->setData(mi, server["version"].toString()); + + mi = model->index(0, ServerData::PASSW); + model->setData(mi, server["passw"].toBool()); + mi = model->index(0, ServerData::PING); QStringList addr = address.split(":"); @@ -152,6 +156,7 @@ bool NetController::downloadInfo(QAbstractItemModel *pModel, QModelIndex index) qDebug() << server["players"].toInt(); qDebug() << server["max_players"].toInt(); qDebug() << server["version"].toString(); + qDebug() << server["passw"].toBool(); QVector::Iterator value = std::find_if(model->myData.begin(), model->myData.end(), pattern(iter.key())); if(value == model->myData.end()) @@ -213,6 +218,7 @@ void NetController::updateInfo() qDebug() << map["players"].toInt(); qDebug() << map["max_players"].toInt(); qDebug() << map["version"].toString(); + qDebug() << map["passw"].toBool(); sd->hostName = map["hostname"].toString(); sd->modName = map["modname"].toString(); diff --git a/apps/browser/ServerModel.cpp b/apps/browser/ServerModel.cpp index 865ee3c2f..8d3a5a710 100644 --- a/apps/browser/ServerModel.cpp +++ b/apps/browser/ServerModel.cpp @@ -33,6 +33,9 @@ QVariant ServerModel::data(const QModelIndex &index, int role) const case ServerData::ADDR: var = sd.addr; break; + case ServerData::PASSW: + var = sd.needPassw; + break; case ServerData::VERSION: var = sd.version; break; @@ -78,6 +81,9 @@ QVariant ServerModel::headerData(int section, Qt::Orientation orientation, int r case ServerData::ADDR: var = "Address"; break; + case ServerData::PASSW: + var = "P"; + break; case ServerData::VERSION: var = "Version"; break; @@ -126,6 +132,9 @@ bool ServerModel::setData(const QModelIndex &index, const QVariant &value, int r sd.addr = value.toString(); ok = !sd.addr.isEmpty(); break; + case ServerData::PASSW: + sd.needPassw = value.toBool(); + break; case ServerData::VERSION: sd.version = value.toString(); ok = !sd.addr.isEmpty(); @@ -162,7 +171,7 @@ bool ServerModel::insertRows(int position, int count, const QModelIndex &index) beginInsertRows(QModelIndex(), position, position + count - 1); for (int row = 0; row < count; ++row) { - ServerData sd {"", -1, -1, -1, "", ""}; + ServerData sd {"", -1, -1, -1, "", "", false, 0}; myData.insert(position, sd); } diff --git a/apps/browser/ServerModel.hpp b/apps/browser/ServerModel.hpp index 55e78b0b0..eee958e63 100644 --- a/apps/browser/ServerModel.hpp +++ b/apps/browser/ServerModel.hpp @@ -13,10 +13,12 @@ struct ServerData int ping; QString hostName; QString modName; + bool needPassw; QString version; enum IDS { ADDR, + PASSW, HOSTNAME, PLAYERS, MAX_PLAYERS,