mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Added StandAloneJSConsole class
Moved _jsConsole out of Menu to a global class of it's own
This commit is contained in:
parent
bfceaf2838
commit
21a3705b48
5 changed files with 78 additions and 22 deletions
|
@ -116,6 +116,7 @@
|
|||
#include "ui/DataWebDialog.h"
|
||||
#include "ui/InfoView.h"
|
||||
#include "ui/Snapshot.h"
|
||||
#include "ui/StandAloneJSConsole.h"
|
||||
#include "ui/Stats.h"
|
||||
|
||||
|
||||
|
@ -175,6 +176,7 @@ bool setupEssentials(int& argc, char** argv) {
|
|||
auto modelBlender = DependencyManager::set<ModelBlender>();
|
||||
auto audioToolBox = DependencyManager::set<AudioToolBox>();
|
||||
auto lodManager = DependencyManager::set<LODManager>();
|
||||
auto jsConsole = DependencyManager::set<StandAloneJSConsole>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
#include "ui/MetavoxelNetworkSimulator.h"
|
||||
#include "ui/ModelsBrowser.h"
|
||||
#include "ui/NodeBounds.h"
|
||||
#include "ui/StandAloneJSConsole.h"
|
||||
|
||||
Menu* Menu::_instance = NULL;
|
||||
|
||||
|
@ -214,7 +215,7 @@ Menu::Menu() {
|
|||
addActionToQMenuAndActionHash(toolsMenu,
|
||||
MenuOption::Console,
|
||||
Qt::CTRL | Qt::ALT | Qt::Key_J,
|
||||
this,
|
||||
DependencyManager::get<StandAloneJSConsole>().data(),
|
||||
SLOT(toggleConsole()));
|
||||
|
||||
addActionToQMenuAndActionHash(toolsMenu,
|
||||
|
@ -1318,25 +1319,6 @@ void Menu::toggleChat() {
|
|||
#endif
|
||||
}
|
||||
|
||||
void Menu::toggleConsole() {
|
||||
QMainWindow* mainWindow = Application::getInstance()->getWindow();
|
||||
if (!_jsConsole) {
|
||||
QDialog* dialog = new QDialog(mainWindow, Qt::WindowStaysOnTopHint);
|
||||
QVBoxLayout* layout = new QVBoxLayout(dialog);
|
||||
dialog->setLayout(new QVBoxLayout(dialog));
|
||||
|
||||
dialog->resize(QSize(CONSOLE_WIDTH, CONSOLE_HEIGHT));
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(new JSConsole(dialog));
|
||||
dialog->setWindowOpacity(CONSOLE_WINDOW_OPACITY);
|
||||
dialog->setWindowTitle(CONSOLE_TITLE);
|
||||
|
||||
_jsConsole = dialog;
|
||||
}
|
||||
_jsConsole->setVisible(!_jsConsole->isVisible());
|
||||
}
|
||||
|
||||
void Menu::toggleToolWindow() {
|
||||
QMainWindow* toolWindow = Application::getInstance()->getToolWindow();
|
||||
toolWindow->setVisible(!toolWindow->isVisible());
|
||||
|
|
|
@ -187,7 +187,6 @@ private slots:
|
|||
void showMetavoxelNetworkSimulator();
|
||||
void showScriptEditor();
|
||||
void showChat();
|
||||
void toggleConsole();
|
||||
void toggleToolWindow();
|
||||
void toggleChat();
|
||||
void audioMuteToggled();
|
||||
|
@ -196,7 +195,6 @@ private slots:
|
|||
void loadRSSDKFile();
|
||||
|
||||
private:
|
||||
QDialog* _jsConsole = nullptr;
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||
SpeechRecognizer _speechRecognizer;
|
||||
#endif
|
||||
|
|
39
interface/src/ui/StandAloneJSConsole.cpp
Normal file
39
interface/src/ui/StandAloneJSConsole.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
//
|
||||
// StandAloneJSConsole.cpp
|
||||
//
|
||||
//
|
||||
// Created by Clement on 1/17/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 <QMainWindow>
|
||||
#include <QDialog>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <Application.h>
|
||||
#include <MainWindow.h>
|
||||
|
||||
#include "StandAloneJSConsole.h"
|
||||
|
||||
void StandAloneJSConsole::toggleConsole() {
|
||||
QMainWindow* mainWindow = qApp->getWindow();
|
||||
if (!_jsConsole) {
|
||||
QDialog* dialog = new QDialog(mainWindow, Qt::WindowStaysOnTopHint);
|
||||
QVBoxLayout* layout = new QVBoxLayout(dialog);
|
||||
dialog->setLayout(layout);
|
||||
|
||||
dialog->resize(QSize(CONSOLE_WIDTH, CONSOLE_HEIGHT));
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(new JSConsole(dialog));
|
||||
dialog->setWindowOpacity(CONSOLE_WINDOW_OPACITY);
|
||||
dialog->setWindowTitle(CONSOLE_TITLE);
|
||||
|
||||
_jsConsole = dialog;
|
||||
}
|
||||
_jsConsole->setVisible(!_jsConsole->isVisible());
|
||||
}
|
||||
|
35
interface/src/ui/StandAloneJSConsole.h
Normal file
35
interface/src/ui/StandAloneJSConsole.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
//
|
||||
// StandAloneJSConsole.h
|
||||
//
|
||||
//
|
||||
// Created by Clement on 1/17/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_StandAloneJSConsole_h
|
||||
#define hifi_StandAloneJSConsole_h
|
||||
|
||||
#include <QPointer>
|
||||
#include <DependencyManager.h>
|
||||
|
||||
#include "JSConsole.h"
|
||||
|
||||
class QDialog;
|
||||
|
||||
class StandAloneJSConsole : public QObject, public Dependency {
|
||||
Q_OBJECT
|
||||
SINGLETON_DEPENDENCY
|
||||
|
||||
public slots:
|
||||
void toggleConsole();
|
||||
|
||||
private:
|
||||
StandAloneJSConsole() {}
|
||||
|
||||
QPointer<QDialog> _jsConsole;
|
||||
};
|
||||
|
||||
#endif // hifi_StandAloneJSConsole_h
|
Loading…
Reference in a new issue