Merge pull request #8368 from huffman/feat/domain-connection-display

Automatically show address bar after disconnected for X seconds
This commit is contained in:
Brad Hefta-Gaub 2016-08-08 15:56:29 -07:00 committed by GitHub
commit 55c690d016
6 changed files with 96 additions and 0 deletions

View file

@ -818,6 +818,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
}
UserActivityLogger::getInstance().logAction("launch", properties);
_connectionMonitor.init();
// Tell our entity edit sender about our known jurisdictions
_entityEditSender.setServerJurisdictions(&_entityServerJurisdictions);

View file

@ -47,6 +47,7 @@
#include "avatar/MyAvatar.h"
#include "Bookmarks.h"
#include "Camera.h"
#include "ConnectionMonitor.h"
#include "FileLogger.h"
#include "gpu/Context.h"
#include "Menu.h"
@ -562,6 +563,9 @@ private:
bool _recentlyClearedDomain { false };
QString _returnFromFullScreenMirrorTo;
ConnectionMonitor _connectionMonitor;
};
#endif // hifi_Application_h

View file

@ -0,0 +1,52 @@
//
// ConnectionMonitor.cpp
// interface/src
//
// Created by Ryan Huffman on 8/4/15.
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "ConnectionMonitor.h"
#include "ui/DialogsManager.h"
#include <NodeList.h>
#include <DependencyManager.h>
#include <DomainHandler.h>
#include <AddressManager.h>
static const int DISPLAY_AFTER_DISCONNECTED_FOR_X_MS = 5000;
void ConnectionMonitor::init() {
// Connect to domain disconnected message
auto nodeList = DependencyManager::get<NodeList>();
const DomainHandler& domainHandler = nodeList->getDomainHandler();
connect(&domainHandler, &DomainHandler::disconnectedFromDomain, this, &ConnectionMonitor::disconnectedFromDomain);
connect(&domainHandler, &DomainHandler::connectedToDomain, this, &ConnectionMonitor::connectedToDomain);
// Connect to AddressManager::hostChanged
auto addressManager = DependencyManager::get<AddressManager>();
connect(addressManager.data(), &AddressManager::hostChanged, this, &ConnectionMonitor::hostChanged);
_timer.setSingleShot(true);
_timer.setInterval(DISPLAY_AFTER_DISCONNECTED_FOR_X_MS);
_timer.start();
auto dialogsManager = DependencyManager::get<DialogsManager>();
connect(&_timer, &QTimer::timeout, dialogsManager.data(), &DialogsManager::showAddressBar);
}
void ConnectionMonitor::disconnectedFromDomain() {
_timer.start();
}
void ConnectionMonitor::connectedToDomain(const QString& name) {
_timer.stop();
}
void ConnectionMonitor::hostChanged(const QString& name) {
_timer.start();
}

View file

@ -0,0 +1,34 @@
//
// ConnectionMonitor.h
// interface/src
//
// Created by Ryan Huffman on 8/4/15.
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_ConnectionMonitor_h
#define hifi_ConnectionMonitor_h
#include <QObject>
#include <QTimer>
class QString;
class ConnectionMonitor : public QObject {
Q_OBJECT
public:
void init();
private slots:
void disconnectedFromDomain();
void connectedToDomain(const QString& name);
void hostChanged(const QString& name);
private:
QTimer _timer;
};
#endif // hifi_ConnectionMonitor_h

View file

@ -50,6 +50,10 @@ void DialogsManager::toggleAddressBar() {
emit addressBarToggled();
}
void DialogsManager::showAddressBar() {
AddressBarDialog::show();
}
void DialogsManager::toggleDiskCacheEditor() {
maybeCreateDialog(_diskCacheEditor);
_diskCacheEditor->toggle();

View file

@ -44,6 +44,7 @@ public:
public slots:
void toggleAddressBar();
void showAddressBar();
void toggleDiskCacheEditor();
void toggleLoginDialog();
void showLoginDialog();