mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 03:58:07 +02:00
adding initialization of qml when keyboard ready
This commit is contained in:
parent
ccebf3edef
commit
60bbcc7fc3
4 changed files with 41 additions and 20 deletions
|
@ -1775,11 +1775,15 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(offscreenUi.data(), &OffscreenUi::keyboardFocusActive, [this]() {
|
||||||
|
initializeQml();
|
||||||
|
});
|
||||||
|
|
||||||
// Make sure we don't time out during slow operations at startup
|
// Make sure we don't time out during slow operations at startup
|
||||||
updateHeartbeat();
|
updateHeartbeat();
|
||||||
QTimer* settingsTimer = new QTimer();
|
QTimer* settingsTimer = new QTimer();
|
||||||
moveToNewNamedThread(settingsTimer, "Settings Thread", [this, settingsTimer]{
|
moveToNewNamedThread(settingsTimer, "Settings Thread", [this, settingsTimer]{
|
||||||
// This needs to run on the settings thread, so we need to pass the `settingsTimer` as the
|
// This needs to run on the settings thread, so we need to pass the `settingsTimer` as the
|
||||||
// receiver object, otherwise it will run on the application thread and trigger a warning
|
// receiver object, otherwise it will run on the application thread and trigger a warning
|
||||||
// about trying to kill the timer on the main thread.
|
// about trying to kill the timer on the main thread.
|
||||||
connect(qApp, &Application::beforeAboutToQuit, settingsTimer, [this, settingsTimer]{
|
connect(qApp, &Application::beforeAboutToQuit, settingsTimer, [this, settingsTimer]{
|
||||||
|
@ -2327,15 +2331,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
connect(&AndroidHelper::instance(), &AndroidHelper::enterBackground, this, &Application::enterBackground);
|
connect(&AndroidHelper::instance(), &AndroidHelper::enterBackground, this, &Application::enterBackground);
|
||||||
connect(&AndroidHelper::instance(), &AndroidHelper::enterForeground, this, &Application::enterForeground);
|
connect(&AndroidHelper::instance(), &AndroidHelper::enterForeground, this, &Application::enterForeground);
|
||||||
AndroidHelper::instance().notifyLoadComplete();
|
AndroidHelper::instance().notifyLoadComplete();
|
||||||
#else
|
|
||||||
if (!accountManager->isLoggedIn()) {
|
|
||||||
Setting::Handle<bool>{"loginDialogPoppedUp", false}.set(true);
|
|
||||||
dialogsManager->showLoginDialog();
|
|
||||||
QJsonObject loginData = {};
|
|
||||||
loginData["action"] = "login dialog shown";
|
|
||||||
UserActivityLogger::getInstance().logAction("encourageLoginDialog", loginData);
|
|
||||||
}
|
|
||||||
Setting::Handle<bool>{"loginDialogPoppedUp", false}.set(false);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2883,6 +2878,25 @@ void Application::initializeRenderEngine() {
|
||||||
extern void setupPreferences();
|
extern void setupPreferences();
|
||||||
static void addDisplayPluginToMenu(const DisplayPluginPointer& displayPlugin, int index, bool active = false);
|
static void addDisplayPluginToMenu(const DisplayPluginPointer& displayPlugin, int index, bool active = false);
|
||||||
|
|
||||||
|
void Application::initializeQml() {
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
QMetaObject::invokeMethod(this, "initializeQml");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#if !defined(Q_OS_ANDROID)
|
||||||
|
auto accountManager = DependencyManager::get<AccountManager>();
|
||||||
|
auto dialogsManager = DependencyManager::get<DialogsManager>();
|
||||||
|
if (!accountManager->isLoggedIn()) {
|
||||||
|
Setting::Handle<bool>{"loginDialogPoppedUp", false}.set(true);
|
||||||
|
dialogsManager->showLoginDialog();
|
||||||
|
QJsonObject loginData = {};
|
||||||
|
loginData["action"] = "login dialog shown";
|
||||||
|
UserActivityLogger::getInstance().logAction("encourageLoginDialog", loginData);
|
||||||
|
}
|
||||||
|
Setting::Handle<bool>{"loginDialogPoppedUp", false}.set(false);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void Application::initializeUi() {
|
void Application::initializeUi() {
|
||||||
AddressBarDialog::registerType();
|
AddressBarDialog::registerType();
|
||||||
ErrorDialog::registerType();
|
ErrorDialog::registerType();
|
||||||
|
|
|
@ -149,6 +149,7 @@ public:
|
||||||
void initializeGL();
|
void initializeGL();
|
||||||
void initializeDisplayPlugins();
|
void initializeDisplayPlugins();
|
||||||
void initializeRenderEngine();
|
void initializeRenderEngine();
|
||||||
|
void initializeQml();
|
||||||
void initializeUi();
|
void initializeUi();
|
||||||
|
|
||||||
void updateSecondaryCameraViewFrustum();
|
void updateSecondaryCameraViewFrustum();
|
||||||
|
|
|
@ -637,24 +637,28 @@ public:
|
||||||
KeyboardFocusHack() {
|
KeyboardFocusHack() {
|
||||||
Q_ASSERT(_mainWindow);
|
Q_ASSERT(_mainWindow);
|
||||||
QTimer::singleShot(200, [=] {
|
QTimer::singleShot(200, [=] {
|
||||||
_hackWindow = new QWindow();
|
_window = new QWindow();
|
||||||
_hackWindow->setFlags(Qt::FramelessWindowHint);
|
_window->setFlags(Qt::FramelessWindowHint);
|
||||||
_hackWindow->setGeometry(_mainWindow->x(), _mainWindow->y(), 10, 10);
|
_window->setGeometry(_mainWindow->x(), _mainWindow->y(), 10, 10);
|
||||||
_hackWindow->show();
|
_window->show();
|
||||||
_hackWindow->requestActivate();
|
_window->requestActivate();
|
||||||
QTimer::singleShot(200, [=] {
|
QTimer::singleShot(200, [=] {
|
||||||
_hackWindow->hide();
|
_window->hide();
|
||||||
_hackWindow->deleteLater();
|
_window->deleteLater();
|
||||||
_hackWindow = nullptr;
|
_window = nullptr;
|
||||||
_mainWindow->requestActivate();
|
_mainWindow->requestActivate();
|
||||||
|
emit keyboardFocusActive();
|
||||||
this->deleteLater();
|
this->deleteLater();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void keyboardFocusActive();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWindow* const _mainWindow { MainWindow::findMainWindow() };
|
QWindow* const _mainWindow { MainWindow::findMainWindow() };
|
||||||
QWindow* _hackWindow { nullptr };
|
QWindow* _window { nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
void OffscreenUi::createDesktop(const QUrl& url) {
|
void OffscreenUi::createDesktop(const QUrl& url) {
|
||||||
|
@ -673,9 +677,10 @@ void OffscreenUi::createDesktop(const QUrl& url) {
|
||||||
menuInitializer(_vrMenu);
|
menuInitializer(_vrMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
// new KeyboardFocusHack();
|
auto keyboardFocus = new KeyboardFocusHack();
|
||||||
connect(_desktop, SIGNAL(showDesktop()), this, SIGNAL(showDesktop()));
|
connect(_desktop, SIGNAL(showDesktop()), this, SIGNAL(showDesktop()));
|
||||||
emit desktopReady();
|
emit desktopReady();
|
||||||
|
connect(keyboardFocus, SIGNAL(keyboardFocusActive()), this, SIGNAL(keyboardFocusActive()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -244,6 +244,7 @@ signals:
|
||||||
// void assetDialogResponse(QString response);
|
// void assetDialogResponse(QString response);
|
||||||
// void inputDialogResponse(QVariant response);
|
// void inputDialogResponse(QVariant response);
|
||||||
void desktopReady();
|
void desktopReady();
|
||||||
|
void keyboardFocusActive();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void removeModalDialog(QObject* modal);
|
void removeModalDialog(QObject* modal);
|
||||||
|
|
Loading…
Reference in a new issue