]> git.lyx.org Git - features.git/commitdiff
* LyX::addFileToLoad(): new method for double-clicked file icons on MacOS.
authorAbdelrazak Younes <younes@lyx.org>
Fri, 4 May 2007 17:20:53 +0000 (17:20 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Fri, 4 May 2007 17:20:53 +0000 (17:20 +0000)
* GuiApplication::event():
  special case for FileOpen events: memorize the filenames if LyX is not properly started yet.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18201 a592a061-630c-0410-9148-cb99ea01b6c8

src/LyX.cpp
src/LyX.h
src/frontends/qt4/GuiApplication.cpp

index 807efc06188ceee2d91269c98cb42673b1914a92..48f30df4d1344cb594dd00ff99001cd65f3e6c37 100644 (file)
@@ -62,6 +62,7 @@
 #include <boost/bind.hpp>
 #include <boost/filesystem/operations.hpp>
 
+#include <algorithm>
 #include <iostream>
 #include <csignal>
 #include <map>
@@ -552,6 +553,17 @@ int LyX::init(int & argc, char * argv[])
 }
 
 
+void LyX::addFileToLoad(FileName const & fname)
+{
+       vector<FileName>::const_iterator cit = std::find(
+               pimpl_->files_to_load_.begin(), pimpl_->files_to_load_.end(),
+               fname);
+
+       if (cit == pimpl_->files_to_load_.end())
+               pimpl_->files_to_load_.push_back(fname);
+}
+
+
 void LyX::loadFiles()
 {
        vector<FileName>::const_iterator it = pimpl_->files_to_load_.begin();
index 6444bed8865da9d58d48b718c3247ca59d124183..0a0602e3864f98de5562a1656a32a7c94fded661 100644 (file)
--- a/src/LyX.h
+++ b/src/LyX.h
 
 namespace lyx {
 
+namespace support {
+class FileName;
+}
+
 class Buffer;
 class BufferList;
 class Converters;
@@ -102,6 +106,9 @@ public:
        /// Execute batch commands if available.
        void execBatchCommands();
 
+       ///
+       void addFileToLoad(support::FileName const &);
+
 private:
        /// Do some cleanup in preparation of an exit.
        void prepareExit();
index 86dd43e9b308fdf4f58065d226de31dfec3c41dc..3574188e86e27240fd8e553f27ef82ec235c4019 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "graphics/LoaderQueue.h"
 
+#include "support/FileName.h"
 #include "support/lstrings.h"
 #include "support/os.h"
 #include "support/Package.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: