From 1becd845c1d78b0ff93736d7596be88414c5cbb4 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Fri, 4 May 2007 17:20:53 +0000 Subject: [PATCH] * LyX::addFileToLoad(): new method for double-clicked file icons on MacOS. * 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 | 12 ++++++++++++ src/LyX.h | 7 +++++++ src/frontends/qt4/GuiApplication.cpp | 17 +++++++++++++++-- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/LyX.cpp b/src/LyX.cpp index 807efc0618..48f30df4d1 100644 --- a/src/LyX.cpp +++ b/src/LyX.cpp @@ -62,6 +62,7 @@ #include #include +#include #include #include #include @@ -552,6 +553,17 @@ int LyX::init(int & argc, char * argv[]) } +void LyX::addFileToLoad(FileName const & fname) +{ + vector::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::const_iterator it = pimpl_->files_to_load_.begin(); diff --git a/src/LyX.h b/src/LyX.h index 6444bed886..0a0602e386 100644 --- a/src/LyX.h +++ b/src/LyX.h @@ -21,6 +21,10 @@ 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(); diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 86dd43e9b3..3574188e86 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -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(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: