Gui is not setup yet when the file is opened from clicking on it in Finder
  with a closed LyX. We have to wait until the batch commands are executed.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27264 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Stefan Schimanski 2008-11-05 14:04:37 +00:00
parent 32521599f5
commit 5d9b126c96
3 changed files with 35 additions and 7 deletions

View File

@ -176,7 +176,18 @@ vector<string> loadableImageFormats()
return fmts;
}
class FuncRequestEvent : public QEvent
{
public:
FuncRequestEvent(FuncRequest const & req)
: QEvent(QEvent::User), request(req) {}
FuncRequest const request;
};
////////////////////////////////////////////////////////////////////////
// Icon loading support code.
////////////////////////////////////////////////////////////////////////
@ -1023,7 +1034,11 @@ ColorCache & GuiApplication::colorCache()
int GuiApplication::exec()
{
QTimer::singleShot(1, this, SLOT(execBatchCommands()));
// asynchronously handle batch commands. This event will be in
// the event queue in front of other asynchronous events. Hence,
// we can assume in the latter that the gui is setup already.
QTimer::singleShot(0, this, SLOT(execBatchCommands()));
return QApplication::exec();
}
@ -1177,14 +1192,25 @@ void GuiApplication::handleRegularEvents()
}
void GuiApplication::customEvent(QEvent * event)
{
FuncRequestEvent * reqEv = static_cast<FuncRequestEvent *>(event);
lyx::dispatch(reqEv->request);
}
bool GuiApplication::event(QEvent * e)
{
switch(e->type()) {
case QEvent::FileOpen: {
// Open a file; this happens only on Mac OS X for now
// Open a file; this happens only on Mac OS X for now.
//
// We do this asynchronously because on startup the batch
// commands are not executed here yet and the gui is not ready
// therefore.
QFileOpenEvent * foe = static_cast<QFileOpenEvent *>(e);
lyx::dispatch(FuncRequest(LFUN_FILE_OPEN,
qstring_to_ucs4(foe->file())));
postEvent(this, new FuncRequestEvent(FuncRequest(LFUN_FILE_OPEN,
qstring_to_ucs4(foe->file()))));
e->accept();
return true;
}

View File

@ -66,6 +66,7 @@ public:
FontLoader & fontLoader();
int exec();
void exit(int status);
void customEvent(QEvent * event);
bool event(QEvent * e);
bool getRgbColor(ColorCode col, RGBColor & rgbcol);
std::string const hexName(ColorCode col);

View File

@ -330,10 +330,11 @@ GuiView::GuiView(int id)
return;
}
// No session handling, default to a sane size.
// no session handling, default to a sane size.
setGeometry(50, 50, 690, 510);
initToolbars();
// This enables to clear session data if any.
// clear session data if any.
QSettings settings;
settings.remove("views");
}