mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-15 07:29:39 +02:00
46 lines
1.4 KiB
C++
46 lines
1.4 KiB
C++
//
|
|
// 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);
|
|
|
|
_timer.setSingleShot(true);
|
|
_timer.setInterval(DISPLAY_AFTER_DISCONNECTED_FOR_X_MS);
|
|
if (!domainHandler.isConnected()) {
|
|
_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();
|
|
}
|