diff --git a/src/core/UBApplication.cpp b/src/core/UBApplication.cpp index d1ef381c..479f07a1 100644 --- a/src/core/UBApplication.cpp +++ b/src/core/UBApplication.cpp @@ -81,6 +81,8 @@ const QString UBApplication::mimeTypeUniboardPage = QString("application/vnd.mne const QString UBApplication::mimeTypeUniboardPageItem = QString("application/vnd.mnemis-uniboard-page-item"); const QString UBApplication::mimeTypeUniboardPageThumbnail = QString("application/vnd.mnemis-uniboard-thumbnail"); +QString UBApplication::fileToOpen = ""; + #if defined(Q_OS_OSX) || defined(Q_OS_LINUX) bool bIsMinimized = false; #endif @@ -309,6 +311,14 @@ int UBApplication::exec(const QString& pFileToImport) boardController->paletteManager()->rightPalette()); + if (!UBApplication::fileToOpen.isEmpty()) + { + if (!UBApplication::fileToOpen.endsWith("ubx")) + applicationController->importFile(UBApplication::fileToOpen); + else + applicationController->showMessage(tr("Cannot open your UBX file directly. Please import it in Documents mode instead"), false); + } + connect(applicationController, SIGNAL(mainModeChanged(UBApplicationController::MainMode)), boardController->paletteManager(), SLOT(slot_changeMainMode(UBApplicationController::MainMode))); @@ -575,10 +585,21 @@ bool UBApplication::eventFilter(QObject *obj, QEvent *event) UBPlatformUtils::setFrontProcess(); - if (!fileToOpenEvent->file().endsWith("ubx")) - applicationController->importFile(fileToOpenEvent->file()); + if (applicationController) + { + if (!fileToOpenEvent->file().endsWith("ubx")) + applicationController->importFile(fileToOpenEvent->file()); + else + applicationController->showMessage(tr("Cannot open your UBX file directly. Please import it in Documents mode instead"), false); + } else - applicationController->showMessage(tr("Cannot open your UBX file directly. Please import it in Documents mode instead"), false); + { + //startup : progressdialog.exec() is called and fileOpenEvent is consumed too early + // we store the file and will import it when the documents tree is ready + + UBApplication::fileToOpen = fileToOpenEvent->file(); + return true; + } } if (event->type() == QEvent::TabletLeaveProximity) diff --git a/src/core/UBApplication.h b/src/core/UBApplication.h index 5f9442d7..5473804c 100644 --- a/src/core/UBApplication.h +++ b/src/core/UBApplication.h @@ -86,6 +86,8 @@ class UBApplication : public SingleApplication static const QString mimeTypeUniboardPageItem; static const QString mimeTypeUniboardPageThumbnail; + static QString fileToOpen; + static void showMessage(const QString& message, bool showSpinningWheel = false); static void setDisabled(bool disable);