mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 02:23:57 +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
|
||||
updateHeartbeat();
|
||||
QTimer* settingsTimer = new QTimer();
|
||||
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
|
||||
// about trying to kill the timer on the main thread.
|
||||
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::enterForeground, this, &Application::enterForeground);
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -2883,6 +2878,25 @@ void Application::initializeRenderEngine() {
|
|||
extern void setupPreferences();
|
||||
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() {
|
||||
AddressBarDialog::registerType();
|
||||
ErrorDialog::registerType();
|
||||
|
|
|
@ -149,6 +149,7 @@ public:
|
|||
void initializeGL();
|
||||
void initializeDisplayPlugins();
|
||||
void initializeRenderEngine();
|
||||
void initializeQml();
|
||||
void initializeUi();
|
||||
|
||||
void updateSecondaryCameraViewFrustum();
|
||||
|
|
|
@ -637,24 +637,28 @@ public:
|
|||
KeyboardFocusHack() {
|
||||
Q_ASSERT(_mainWindow);
|
||||
QTimer::singleShot(200, [=] {
|
||||
_hackWindow = new QWindow();
|
||||
_hackWindow->setFlags(Qt::FramelessWindowHint);
|
||||
_hackWindow->setGeometry(_mainWindow->x(), _mainWindow->y(), 10, 10);
|
||||
_hackWindow->show();
|
||||
_hackWindow->requestActivate();
|
||||
_window = new QWindow();
|
||||
_window->setFlags(Qt::FramelessWindowHint);
|
||||
_window->setGeometry(_mainWindow->x(), _mainWindow->y(), 10, 10);
|
||||
_window->show();
|
||||
_window->requestActivate();
|
||||
QTimer::singleShot(200, [=] {
|
||||
_hackWindow->hide();
|
||||
_hackWindow->deleteLater();
|
||||
_hackWindow = nullptr;
|
||||
_window->hide();
|
||||
_window->deleteLater();
|
||||
_window = nullptr;
|
||||
_mainWindow->requestActivate();
|
||||
emit keyboardFocusActive();
|
||||
this->deleteLater();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
signals:
|
||||
void keyboardFocusActive();
|
||||
|
||||
private:
|
||||
QWindow* const _mainWindow { MainWindow::findMainWindow() };
|
||||
QWindow* _hackWindow { nullptr };
|
||||
QWindow* _window { nullptr };
|
||||
};
|
||||
|
||||
void OffscreenUi::createDesktop(const QUrl& url) {
|
||||
|
@ -673,9 +677,10 @@ void OffscreenUi::createDesktop(const QUrl& url) {
|
|||
menuInitializer(_vrMenu);
|
||||
}
|
||||
|
||||
// new KeyboardFocusHack();
|
||||
auto keyboardFocus = new KeyboardFocusHack();
|
||||
connect(_desktop, SIGNAL(showDesktop()), this, SIGNAL(showDesktop()));
|
||||
emit desktopReady();
|
||||
connect(keyboardFocus, SIGNAL(keyboardFocusActive()), this, SIGNAL(keyboardFocusActive()));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -244,6 +244,7 @@ signals:
|
|||
// void assetDialogResponse(QString response);
|
||||
// void inputDialogResponse(QVariant response);
|
||||
void desktopReady();
|
||||
void keyboardFocusActive();
|
||||
|
||||
public slots:
|
||||
void removeModalDialog(QObject* modal);
|
||||
|
|
Loading…
Reference in a new issue