From a0f23d409ed711587ecc078c322eef93b3bc8433 Mon Sep 17 00:00:00 2001 From: stojce Date: Sat, 28 Sep 2013 13:16:50 +0200 Subject: [PATCH] Merging changes --- interface/src/Application.cpp | 1 + interface/src/Application.h | 4 +++- libraries/shared/src/NodeList.cpp | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 533a4b4246..f10f98c3b3 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3423,6 +3423,7 @@ void Application::attachNewHeadToNode(Node* newNode) { } void Application::domainChanged(QString domain) { + qDebug("Application title set to: %s.\n", domain.toStdString().c_str()); _window->setWindowTitle(domain); } diff --git a/interface/src/Application.h b/interface/src/Application.h index a8e84e5c2a..620d6d57f5 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -77,7 +77,7 @@ static const float NODE_KILLED_RED = 1.0f; static const float NODE_KILLED_GREEN = 0.0f; static const float NODE_KILLED_BLUE = 0.0f; -class Application : public QApplication, public NodeListHook, public PacketSenderNotify { +class Application : public QApplication, public NodeListHook, public PacketSenderNotify, public DomainChangeListener { Q_OBJECT friend class VoxelPacketProcessor; @@ -146,6 +146,8 @@ public: virtual void nodeKilled(Node* node); virtual void packetSentNotification(ssize_t length); + virtual void domainChanged(QString domain); + VoxelShader& getVoxelShader() { return _voxelShader; } public slots: diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index 8901ca3271..7b31a2de15 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -109,6 +109,7 @@ void NodeList::setDomainHostname(const QString& domainHostname) { // reset our _domainIP to the null address so that a lookup happens on next check in _domainIP.clear(); + notifyDomainChanged(); } void NodeList::timePingReply(sockaddr *nodeAddress, unsigned char *packetData) { @@ -585,6 +586,7 @@ void NodeList::loadData(QSettings *settings) { if (domainServerHostname.size() > 0) { _domainHostname = domainServerHostname; + notifyDomainChanged(); } settings->endGroup(); @@ -678,6 +680,21 @@ void NodeListIterator::skipDeadAndStopIncrement() { } } +void NodeList::addDomainListener(DomainChangeListener* listener) { + _domainListeners.push_back(listener); + QString domain = _domainHostname.isEmpty() ? _domainIP.toString() : _domainHostname; + listener->domainChanged(domain); +} + +void NodeList::removeDomainListener(DomainChangeListener* listener) { + for (int i = 0; i < _domainListeners.size(); i++) { + if (_domainListeners[i] == listener) { + _domainListeners.erase(_domainListeners.begin() + i); + return; + } + } +} + void NodeList::addHook(NodeListHook* hook) { _hooks.push_back(hook); } @@ -704,3 +721,9 @@ void NodeList::notifyHooksOfKilledNode(Node* node) { _hooks[i]->nodeKilled(node); } } + +void NodeList::notifyDomainChanged() { + for (int i = 0; i < _domainListeners.size(); i++) { + _domainListeners[i]->domainChanged(_domainHostname); + } +}