]> 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 b8011a88112f0d67822e759bdfc816e7e1921b2e..3574188e86e27240fd8e553f27ef82ec235c4019 100644 (file)
 
 #include "graphics/LoaderQueue.h"
 
+#include "support/FileName.h"
 #include "support/lstrings.h"
 #include "support/os.h"
-#include "support/package.h"
+#include "support/Package.h"
 
 #include "BufferView.h"
 #include "Color.h"
 #include "debug.h"
-#include "funcrequest.h"
-#include "lyx_main.h"
-#include "lyxfunc.h"
-#include "lyxrc.h"
+#include "FuncRequest.h"
+#include "LyX.h"
+#include "LyXFunc.h"
+#include "LyXRC.h"
 
 #include <QApplication>
 #include <QClipboard>
@@ -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:
@@ -248,7 +261,7 @@ void GuiApplication::syncEvents()
 }
 
 
-bool GuiApplication::getRgbColor(LColor_color col,
+bool GuiApplication::getRgbColor(Color_color col,
        RGBColor & rgbcol)
 {
        QColor const & qcol = color_cache_.get(col);
@@ -265,13 +278,13 @@ bool GuiApplication::getRgbColor(LColor_color col,
 }
 
 
-string const GuiApplication::hexName(LColor_color col)
+string const GuiApplication::hexName(Color_color col)
 {
        return lyx::support::ltrim(fromqstr(color_cache_.get(col).name()), "#");
 }
 
 
-void GuiApplication::updateColor(LColor_color)
+void GuiApplication::updateColor(Color_color)
 {
        // FIXME: Bleh, can't we just clear them all at once ?
        color_cache_.clear();