mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-14 11:46:34 +02:00
Refactor display/input disabling
This commit is contained in:
parent
ec29cfcd51
commit
b05dd3443d
3 changed files with 39 additions and 35 deletions
|
@ -1038,12 +1038,10 @@ Application::Application(
|
|||
DependencyManager::set<PathUtils>();
|
||||
}
|
||||
|
||||
void Application::initializePluginManager() {
|
||||
void Application::initializePluginManager(const QCommandLineParser& parser) {
|
||||
DependencyManager::set<PluginManager>();
|
||||
auto pluginManager = PluginManager::getInstance();
|
||||
|
||||
qWarning() << "Input plugins: " << getInputPlugins().size();
|
||||
|
||||
// To avoid any confusion: the getInputPlugins and getDisplayPlugins are not the ones
|
||||
// from PluginManager, but functions exported by input-plugins/InputPlugin.cpp and
|
||||
// display-plugins/DisplayPlugin.cpp.
|
||||
|
@ -1052,6 +1050,30 @@ void Application::initializePluginManager() {
|
|||
pluginManager->setInputPluginProvider([] { return getInputPlugins(); });
|
||||
pluginManager->setDisplayPluginProvider([] { return getDisplayPlugins(); });
|
||||
pluginManager->setInputPluginSettingsPersister([](const InputPluginList& plugins) { saveInputPluginSettings(plugins); });
|
||||
|
||||
|
||||
// This must be a member function -- PluginManager must exist, and for that
|
||||
// QApplication must exist, or it can't find the plugin path, as QCoreApplication:applicationDirPath
|
||||
// won't work yet.
|
||||
|
||||
if (parser.isSet("display")) {
|
||||
auto preferredDisplays = parser.value("display").split(',', Qt::SkipEmptyParts);
|
||||
qInfo() << "Setting prefered display plugins:" << preferredDisplays;
|
||||
PluginManager::getInstance()->setPreferredDisplayPlugins(preferredDisplays);
|
||||
}
|
||||
|
||||
if (parser.isSet("disableDisplays")) {
|
||||
auto disabledDisplays = parser.value("disableDisplays").split(',', Qt::SkipEmptyParts);
|
||||
qInfo() << "Disabling following display plugins:" << disabledDisplays;
|
||||
PluginManager::getInstance()->disableDisplays(disabledDisplays);
|
||||
}
|
||||
|
||||
if (parser.isSet("disableInputs")) {
|
||||
auto disabledInputs = parser.value("disableInputs").split(',', Qt::SkipEmptyParts);
|
||||
qInfo() << "Disabling following input plugins:" << disabledInputs;
|
||||
PluginManager::getInstance()->disableInputs(disabledInputs);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Application::initialize(const QCommandLineParser &parser) {
|
||||
|
@ -8818,31 +8840,6 @@ void Application::sendLambdaEvent(const std::function<void()>& f) {
|
|||
}
|
||||
}
|
||||
|
||||
void Application::configurePlugins(const QCommandLineParser& parser) {
|
||||
// This must be a member function -- PluginManager must exist, and for that
|
||||
// QApplication must exist, or it can't find the plugin path, as QCoreApplication:applicationDirPath
|
||||
// won't work yet.
|
||||
|
||||
if (parser.isSet("display")) {
|
||||
auto preferredDisplays = parser.value("display").split(',', Qt::SkipEmptyParts);
|
||||
qInfo() << "Setting prefered display plugins:" << preferredDisplays;
|
||||
PluginManager::getInstance()->setPreferredDisplayPlugins(preferredDisplays);
|
||||
}
|
||||
|
||||
if (parser.isSet("disable-displays")) {
|
||||
auto disabledDisplays = parser.value("disable-displays").split(',', Qt::SkipEmptyParts);
|
||||
qInfo() << "Disabling following display plugins:" << disabledDisplays;
|
||||
PluginManager::getInstance()->disableDisplays(disabledDisplays);
|
||||
}
|
||||
|
||||
if (parser.isSet("disable-inputs")) {
|
||||
auto disabledInputs = parser.value("disable-inputs").split(',', Qt::SkipEmptyParts);
|
||||
qInfo() << "Disabling following input plugins:" << disabledInputs;
|
||||
PluginManager::getInstance()->disableInputs(disabledInputs);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Application::shutdownPlugins() {
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,16 @@ class Application : public QApplication,
|
|||
|
||||
public:
|
||||
|
||||
void initializePluginManager();
|
||||
/**
|
||||
* @brief Initialize the plugin manager
|
||||
*
|
||||
* This both does the initial startup and parses arguments. This
|
||||
* is necessary because the plugin manager's options must be set
|
||||
* before any usage of it is made, or they won't apply.
|
||||
*
|
||||
* @param parser
|
||||
*/
|
||||
void initializePluginManager(const QCommandLineParser& parser);
|
||||
|
||||
/**
|
||||
* @brief Initialize everything
|
||||
|
@ -151,8 +160,6 @@ public:
|
|||
|
||||
virtual DisplayPluginPointer getActiveDisplayPlugin() const override;
|
||||
|
||||
// FIXME? Empty methods, do we still need them?
|
||||
void configurePlugins(const QCommandLineParser& parser);
|
||||
static void shutdownPlugins();
|
||||
|
||||
Application(
|
||||
|
|
|
@ -142,12 +142,12 @@ int main(int argc, const char* argv[]) {
|
|||
"displays"
|
||||
);
|
||||
QCommandLineOption disableDisplaysOption(
|
||||
"disable-displays",
|
||||
"disableDisplays",
|
||||
"Displays to disable. Valid options include \"OpenVR (Vive)\" and \"Oculus Rift\"",
|
||||
"string"
|
||||
);
|
||||
QCommandLineOption disableInputsOption(
|
||||
"disable-inputs",
|
||||
"disableInputs",
|
||||
"Inputs to disable. Valid options include \"OpenVR (Vive)\" and \"Oculus Rift\"",
|
||||
"string"
|
||||
);
|
||||
|
@ -365,7 +365,7 @@ int main(int argc, const char* argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
app.initializePluginManager();
|
||||
app.initializePluginManager(parser);
|
||||
|
||||
if (parser.isSet(getPluginsOption)) {
|
||||
auto pluginManager = PluginManager::getInstance();
|
||||
|
@ -648,7 +648,7 @@ int main(int argc, const char* argv[]) {
|
|||
// Oculus initialization MUST PRECEDE OpenGL context creation.
|
||||
// The nature of the Application constructor means this has to be either here,
|
||||
// or in the main window ctor, before GL startup.
|
||||
app.configurePlugins(parser);
|
||||
//app.configurePlugins(parser);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
// If we're running in steam mode, we need to do an explicit check to ensure we're up to the required min spec
|
||||
|
|
Loading…
Reference in a new issue