From 26dbfbcf89b92f9e8532dfdded630481af924ebb Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Thu, 19 Jun 2008 11:28:11 +0000 Subject: [PATCH] Present to Mac users: Session handling per document instead of per window when "open document in tabs" is disabled. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25320 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiApplication.cpp | 27 +++++++++++++++++++++------ src/frontends/qt4/GuiApplication.h | 5 ++++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 374480f6ee..c8fb616dae 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -104,6 +104,7 @@ #endif // Q_WS_WIN #include +#include #include #include @@ -840,8 +841,13 @@ bool GuiApplication::dispatch(FuncRequest const & cmd) case LFUN_FILE_OPEN: if (d->views_.empty() || (!lyxrc.open_buffers_in_tabs && current_view_->buffer() != 0)) { - createView(); - current_view_->openDocument(to_utf8(cmd.argument())); + string const fname = to_utf8(cmd.argument()); + // We want the ui session to be saved per document and not per + // window number. The filename crc is a good enough identifier. + boost::crc_32_type crc; + crc = for_each(fname.begin(), fname.end(), crc); + createView(crc.checksum()); + current_view_->openDocument(fname); if (!current_view_->buffer()) current_view_->close(); } else @@ -900,7 +906,14 @@ void GuiApplication::resetGui() } -void GuiApplication::createView(QString const & geometry_arg, bool autoShow) +void GuiApplication::createView(int view_id) +{ + createView(QString(), true, view_id); +} + + +void GuiApplication::createView(QString const & geometry_arg, bool autoShow, + int view_id) { // release the keyboard which might have been grabed by the global // menubar on Mac to catch shortcuts even without any GuiView. @@ -908,9 +921,11 @@ void GuiApplication::createView(QString const & geometry_arg, bool autoShow) d->global_menubar_->releaseKeyboard(); // create new view - int id = 0; - while (d->views_.find(id) != d->views_.end()) - id++; + int id = view_id > 0 ? view_id : 0; + if (id == 0) { + while (d->views_.find(id) != d->views_.end()) + id++; + } GuiView * view = new GuiView(id); // register view diff --git a/src/frontends/qt4/GuiApplication.h b/src/frontends/qt4/GuiApplication.h index f304fb9e5a..de343b9715 100644 --- a/src/frontends/qt4/GuiApplication.h +++ b/src/frontends/qt4/GuiApplication.h @@ -89,8 +89,11 @@ public: /// Create the main window with given geometry settings. /// \param geometry_arg: only for Windows platform. + /// \param optional id identifier. void createView(QString const & geometry_arg = QString(), - bool autoShow = true); + bool autoShow = true, int id = 0); + /// FIXME: this method and the one above are quite ugly. + void createView(int id); /// GuiView const * currentView() const { return current_view_; } /// -- 2.39.2