Beispiel #1
0
HMDToolsDialog::HMDToolsDialog(QWidget* parent) :
    QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint | Qt::WindowStaysOnTopHint) ,
    _previousScreen(NULL),
    _hmdScreen(NULL),
    _hmdScreenNumber(-1),
    _switchModeButton(NULL),
    _debugDetails(NULL),
    _previousDialogScreen(NULL),
    _inHDMMode(false)
{
    this->setWindowTitle("HMD Tools");

    // Create layouter
    QFormLayout* form = new QFormLayout();
    const int WIDTH = 350;

    // Add a button to enter
    _switchModeButton = new QPushButton("Enter HMD Mode");
    _switchModeButton->setFixedWidth(WIDTH);
    form->addRow("", _switchModeButton);
    connect(_switchModeButton,SIGNAL(clicked(bool)),this,SLOT(switchModeClicked(bool)));

    // Create a label with debug details...
    _debugDetails = new QLabel();
    _debugDetails->setText(getDebugDetails());
    const int HEIGHT = 100;
    _debugDetails->setFixedSize(WIDTH, HEIGHT);
    form->addRow("", _debugDetails);
    
    this->QDialog::setLayout(form);

    _wasMoved = false;
    _previousRect = Application::getInstance()->getWindow()->rect();
    Application::getInstance()->getWindow()->activateWindow();

    // watch for our application window moving screens. If it does we want to update our screen details
    QWindow* mainWindow = Application::getInstance()->getWindow()->windowHandle();
    connect(mainWindow, &QWindow::screenChanged, this, &HMDToolsDialog::applicationWindowScreenChanged);

    // watch for our dialog window moving screens. If it does we want to enforce our rules about
    // what screens we're allowed on
    watchWindow(windowHandle());
    auto dialogsManager = DependencyManager::get<DialogsManager>();
    if (Application::getInstance()->getRunningScriptsWidget()) {
        watchWindow(Application::getInstance()->getRunningScriptsWidget()->windowHandle());
    }
    if (Application::getInstance()->getToolWindow()) {
        watchWindow(Application::getInstance()->getToolWindow()->windowHandle());
    }
    if (dialogsManager->getBandwidthDialog()) {
        watchWindow(dialogsManager->getBandwidthDialog()->windowHandle());
    }
    if (dialogsManager->getOctreeStatsDialog()) {
        watchWindow(dialogsManager->getOctreeStatsDialog()->windowHandle());
    }
    if (dialogsManager->getLodToolsDialog()) {
        watchWindow(dialogsManager->getLodToolsDialog()->windowHandle());
    }
    
    // when the application is about to quit, leave HDM mode
    connect(Application::getInstance(), SIGNAL(beforeAboutToQuit()), this, SLOT(aboutToQuit()));

    // keep track of changes to the number of screens
    connect(QApplication::desktop(), &QDesktopWidget::screenCountChanged, this, &HMDToolsDialog::screenCountChanged);
}
Beispiel #2
0
HMDToolsDialog::HMDToolsDialog(QWidget* parent) :
    QDialog(parent, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowStaysOnTopHint)
{
    // FIXME do we want to support more than one connected HMD?  It seems like a pretty corner case
    foreach(auto displayPlugin, PluginManager::getInstance()->getDisplayPlugins()) {
        // The first plugin is always the standard 2D display, by convention
        if (_defaultPluginName.isEmpty()) {
            _defaultPluginName = displayPlugin->getName();
            continue;
        }
        
        if (displayPlugin->isHmd()) {
            // Not all HMD's have corresponding screens
            if (displayPlugin->getHmdScreen() >= 0) {
                _hmdScreenNumber = displayPlugin->getHmdScreen();
            }
            _hmdPluginName = displayPlugin->getName();
            break;
        }
    }

    setWindowTitle("HMD Tools");

    // Create layouter
    {
        QFormLayout* form = new QFormLayout();
        // Add a button to enter
        _switchModeButton = new QPushButton("Toggle HMD Mode");
        if (_hmdPluginName.isEmpty()) {
            _switchModeButton->setEnabled(false);
        }
        // Add a button to enter
        _switchModeButton->setFixedWidth(WIDTH);
        form->addRow("", _switchModeButton);
        // Create a label with debug details...
        _debugDetails = new QLabel();
        _debugDetails->setFixedSize(WIDTH, HEIGHT);
        form->addRow("", _debugDetails);
        setLayout(form);
    }

    qApp->getWindow()->activateWindow();

    // watch for our dialog window moving screens. If it does we want to enforce our rules about
    // what screens we're allowed on
    watchWindow(windowHandle());
    auto dialogsManager = DependencyManager::get<DialogsManager>();
    if (Application::getInstance()->getRunningScriptsWidget()) {
        watchWindow(Application::getInstance()->getRunningScriptsWidget()->windowHandle());
    }
    if (Application::getInstance()->getToolWindow()) {
        watchWindow(Application::getInstance()->getToolWindow()->windowHandle());
    }
    if (dialogsManager->getBandwidthDialog()) {
        watchWindow(dialogsManager->getBandwidthDialog()->windowHandle());
    }
    if (dialogsManager->getOctreeStatsDialog()) {
        watchWindow(dialogsManager->getOctreeStatsDialog()->windowHandle());
    }
    if (dialogsManager->getLodToolsDialog()) {
        watchWindow(dialogsManager->getLodToolsDialog()->windowHandle());
    }
    
    connect(_switchModeButton, &QPushButton::clicked, [this]{
        toggleHMDMode();
    });
    
    // when the application is about to quit, leave HDM mode
    connect(qApp, &Application::beforeAboutToQuit, [this]{
        // FIXME this is ineffective because it doesn't trigger the menu to
        // save the fact that VR Mode is not checked.
        leaveHMDMode();
    });

    connect(qApp, &Application::activeDisplayPluginChanged, [this]{
        updateUi();
    });

    // watch for our application window moving screens. If it does we want to update our screen details
    QWindow* mainWindow = Application::getInstance()->getWindow()->windowHandle();
    connect(mainWindow, &QWindow::screenChanged, [this]{
        updateUi();
    });

    // keep track of changes to the number of screens
    connect(QApplication::desktop(), &QDesktopWidget::screenCountChanged, this, &HMDToolsDialog::screenCountChanged);
    
    updateUi();
}
AllegroEventSource::AllegroEventSource(std::shared_ptr<EventDispatcher> &_new, Window &w)
{
    init();
    dispatcher(_new);
    watchWindow(w);
}