]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiApplication.cpp
* LyX::addFileToLoad(): new method for double-clicked file icons on MacOS.
[lyx.git] / src / frontends / qt4 / GuiApplication.cpp
index 971cf53e9efd00a3d55f9198c6904264175e187b..3574188e86e27240fd8e553f27ef82ec235c4019 100644 (file)
 
 #include "graphics/LoaderQueue.h"
 
+#include "support/FileName.h"
 #include "support/lstrings.h"
 #include "support/os.h"
 #include "support/Package.h"
 
 #include "BufferView.h"
-#include "color.h"
+#include "Color.h"
 #include "debug.h"
 #include "FuncRequest.h"
 #include "LyX.h"
@@ -75,6 +76,8 @@ int getDPI()
 
 namespace lyx {
 
+using support::FileName;
+
 frontend::Application * createApplication(int & argc, char * argv[])
 {
        return new frontend::GuiApplication(argc, argv);
@@ -207,8 +210,18 @@ bool GuiApplication::event(QEvent * e)
        case QEvent::FileOpen: {
                // Open a file; this happens only on Mac OS X for now
                QFileOpenEvent * foe = static_cast<QFileOpenEvent *>(e);
-               lyx::dispatch(FuncRequest(LFUN_FILE_OPEN,
-                                         fromqstr(foe->file())));
+
+               if (!currentView() || !currentView()->view())
+                       // The application is not properly initialized yet.
+                       // So we acknowledge the event and delay the file opening
+                       // until LyX is ready.
+                       // FIXME UNICODE: FileName accept an utf8 encoded string.
+                       LyX::ref().addFileToLoad(FileName(fromqstr(foe->file())));
+               else
+                       lyx::dispatch(FuncRequest(LFUN_FILE_OPEN,
+                               qstring_to_ucs4(foe->file())));
+
+               e->accept();
                return true;
        }
        default: