mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 15:43:50 +02:00
allow setting of custom port via domainHostname setting
This commit is contained in:
parent
ab85c4109d
commit
9fa695b71c
3 changed files with 47 additions and 13 deletions
|
@ -711,6 +711,24 @@ void updateDSHostname(const QString& domainServerHostname) {
|
|||
}
|
||||
}
|
||||
|
||||
const int QLINE_MINIMUM_WIDTH = 400;
|
||||
|
||||
|
||||
QLineEdit* lineEditForDomainHostname() {
|
||||
QString currentDomainHostname = NodeList::getInstance()->getDomainHostname();
|
||||
|
||||
if (NodeList::getInstance()->getDomainPort() != DEFAULT_DOMAIN_SERVER_PORT) {
|
||||
// add the port to the currentDomainHostname string if it is custom
|
||||
currentDomainHostname.append(QString(":%1").arg(NodeList::getInstance()->getDomainPort()));
|
||||
}
|
||||
|
||||
QLineEdit* domainServerLineEdit = new QLineEdit(currentDomainHostname);
|
||||
domainServerLineEdit->setPlaceholderText(DEFAULT_DOMAIN_HOSTNAME);
|
||||
domainServerLineEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
||||
|
||||
return domainServerLineEdit;
|
||||
}
|
||||
|
||||
void Menu::editPreferences() {
|
||||
Application* applicationInstance = Application::getInstance();
|
||||
QDialog dialog(applicationInstance->getGLWidget());
|
||||
|
@ -721,11 +739,8 @@ void Menu::editPreferences() {
|
|||
QFormLayout* form = new QFormLayout();
|
||||
layout->addLayout(form, 1);
|
||||
|
||||
const int QLINE_MINIMUM_WIDTH = 400;
|
||||
|
||||
QLineEdit* domainServerHostname = new QLineEdit(QString(NodeList::getInstance()->getDomainHostname()));
|
||||
domainServerHostname->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
||||
form->addRow("Domain server:", domainServerHostname);
|
||||
QLineEdit* domainServerLineEdit = lineEditForDomainHostname();
|
||||
form->addRow("Domain server:", domainServerLineEdit);
|
||||
|
||||
QLineEdit* avatarURL = new QLineEdit(applicationInstance->getAvatar()->getVoxels()->getVoxelURL().toString());
|
||||
avatarURL->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
||||
|
@ -762,7 +777,7 @@ void Menu::editPreferences() {
|
|||
return;
|
||||
}
|
||||
|
||||
updateDSHostname(domainServerHostname->text());
|
||||
updateDSHostname(domainServerLineEdit->text());
|
||||
|
||||
QUrl url(avatarURL->text());
|
||||
applicationInstance->getAvatar()->getVoxels()->setVoxelURL(url);
|
||||
|
@ -791,12 +806,10 @@ void Menu::goToDomain() {
|
|||
|
||||
QFormLayout* form = new QFormLayout();
|
||||
layout->addLayout(form, 1);
|
||||
|
||||
|
||||
const int QLINE_MINIMUM_WIDTH = 400;
|
||||
|
||||
QLineEdit* domainServerHostname = new QLineEdit(QString(NodeList::getInstance()->getDomainHostname()));
|
||||
domainServerHostname->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
||||
form->addRow("Domain server:", domainServerHostname);
|
||||
QLineEdit* domainServerLineEdit = lineEditForDomainHostname();
|
||||
form->addRow("Domain server:", domainServerLineEdit);
|
||||
|
||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept()));
|
||||
|
@ -809,7 +822,7 @@ void Menu::goToDomain() {
|
|||
return;
|
||||
}
|
||||
|
||||
updateDSHostname(domainServerHostname->text());
|
||||
updateDSHostname(domainServerLineEdit->text());
|
||||
}
|
||||
|
||||
void Menu::goToLocation() {
|
||||
|
|
|
@ -85,7 +85,25 @@ NodeList::~NodeList() {
|
|||
}
|
||||
|
||||
void NodeList::setDomainHostname(const QString& domainHostname) {
|
||||
_domainHostname = domainHostname;
|
||||
|
||||
int colonIndex = domainHostname.indexOf(':');
|
||||
|
||||
if (colonIndex > 0) {
|
||||
// the user has included a custom DS port with the hostname
|
||||
|
||||
// the new hostname is everything up to the colon
|
||||
_domainHostname = domainHostname.left(colonIndex);
|
||||
|
||||
// grab the port by reading the string after the colon
|
||||
_domainPort = atoi(domainHostname.mid(colonIndex + 1, domainHostname.size()).toLocal8Bit().constData());
|
||||
|
||||
qDebug() << "Updated hostname to" << _domainHostname << "and port to" << _domainPort << "\n";
|
||||
|
||||
} else {
|
||||
// no port included with the hostname, simply set the member variable and reset the domain server port to default
|
||||
_domainHostname = domainHostname;
|
||||
_domainPort = DEFAULT_DOMAIN_SERVER_PORT;
|
||||
}
|
||||
|
||||
// reset our _domainIP to the null address so that a lookup happens on next check in
|
||||
_domainIP = QHostAddress();
|
||||
|
|
|
@ -74,6 +74,9 @@ public:
|
|||
const QHostAddress& getDomainIP() const { return _domainIP; }
|
||||
void setDomainIP(const QHostAddress& domainIP) { _domainIP = domainIP; }
|
||||
void setDomainIPToLocalhost() { _domainIP = QHostAddress(INADDR_LOOPBACK); }
|
||||
|
||||
unsigned short getDomainPort() const { return _domainPort; }
|
||||
void setDomainPort(unsigned short domainPort) { _domainPort = domainPort; }
|
||||
|
||||
uint16_t getLastNodeID() const { return _lastNodeID; }
|
||||
void increaseNodeID() { (++_lastNodeID == UNKNOWN_NODE_ID) ? ++_lastNodeID : _lastNodeID; }
|
||||
|
|
Loading…
Reference in a new issue