From 0ba2a1e6f88214a1ba126c30b3b75fa0497cf2dd Mon Sep 17 00:00:00 2001 From: Stefan Schimanski Date: Fri, 14 Mar 2008 23:24:45 +0000 Subject: [PATCH] * preference option to open buffers in tabs or new windows * moved the open/new file dispatches into GuiApplication to make them GuiView independent git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23729 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LyXFunc.cpp | 11 +--------- src/LyXFunc.h | 2 +- src/LyXRC.cpp | 20 +++++++++++++++++- src/LyXRC.h | 3 +++ src/frontends/qt4/GuiApplication.cpp | 31 +++++++++++++++++++++++++++- src/frontends/qt4/GuiPrefs.cpp | 5 ++++- src/frontends/qt4/GuiView.cpp | 4 ---- src/frontends/qt4/ui/PrefUi.ui | 8 +++++++ 8 files changed, 66 insertions(+), 18 deletions(-) diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 7836b7cf98..7b538c6c35 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -815,16 +815,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd) } // --- Menus ----------------------------------------------- - case LFUN_BUFFER_NEW: - lyx_view_->newDocument(argument, false); - updateFlags = Update::None; - break; - - case LFUN_BUFFER_NEW_TEMPLATE: - lyx_view_->newDocument(argument, true); - updateFlags = Update::None; - break; - case LFUN_BUFFER_CLOSE: lyx_view_->closeBuffer(); updateFlags = Update::None; @@ -1987,6 +1977,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_SERVERPIPE: case LyXRC::RC_SET_COLOR: case LyXRC::RC_SHOW_BANNER: + case LyXRC::RC_SINGLE_WINDOW: case LyXRC::RC_SPELL_COMMAND: case LyXRC::RC_TEMPDIRPATH: case LyXRC::RC_TEMPLATEPATH: diff --git a/src/LyXFunc.h b/src/LyXFunc.h index 3b062b8f53..7c75b52198 100644 --- a/src/LyXFunc.h +++ b/src/LyXFunc.h @@ -55,7 +55,7 @@ public: /// void setLyXView(frontend::LyXView * lv); - + /// void initKeySequences(KeyMap * kb); diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 0b1aafae7c..7eed1d7f8a 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -153,6 +153,7 @@ keyword_item lyxrcTags[] = { { "\\serverpipe", LyXRC::RC_SERVERPIPE }, { "\\set_color", LyXRC::RC_SET_COLOR }, { "\\show_banner", LyXRC::RC_SHOW_BANNER }, + { "\\single_window", LyXRC::RC_SINGLE_WINDOW }, { "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS }, { "\\spell_command", LyXRC::RC_SPELL_COMMAND }, { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH }, @@ -292,6 +293,11 @@ void LyXRC::setDefaults() { converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months user_name = to_utf8(support::user_name()); user_email = to_utf8(support::user_email()); +#ifdef __APPLE_CC__ + single_window = false; +#else + single_window = true; +#endif // Fullscreen settings full_screen_limit = false; @@ -1296,6 +1302,10 @@ int LyXRC::read(Lexer & lexrc) if (lexrc.next()) full_screen_width = lexrc.getInteger(); break; + case RC_SINGLE_WINDOW: + if (lexrc.next()) + single_window = lexrc.getBool(); + break; case RC_LAST: break; // this is just a dummy } @@ -1874,7 +1884,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c } if (tag != RC_LAST) break; - + case RC_SINGLE_WINDOW: + if (ignore_system_lyxrc || + single_window != system_lyxrc.single_window) { + os << "\\single_window " + << convert(single_window) + << '\n'; + } + if (tag != RC_LAST) + break; os << "\n#\n" << "# COLOR SECTION ###################################\n" diff --git a/src/LyXRC.h b/src/LyXRC.h index 2b1148724e..96623b6ad5 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -138,6 +138,7 @@ public: RC_SERVERPIPE, RC_SET_COLOR, RC_SHOW_BANNER, + RC_SINGLE_WINDOW, RC_SORT_LAYOUTS, RC_SPELL_COMMAND, RC_TEMPDIRPATH, @@ -436,6 +437,8 @@ public: bool completion_popup_text; /// bool completion_popup_after_complete; + /// Open new buffers in the current window as tab. + bool single_window; }; diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index c4bbcf46f7..704533d4af 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -284,6 +284,35 @@ bool GuiApplication::dispatch(FuncRequest const & cmd) break; } + case LFUN_BUFFER_NEW: + if (viewCount() == 0 + || (!lyxrc.single_window && current_view_->buffer() != 0)) + createView(); + current_view_->newDocument(to_utf8(cmd.argument()), false); + break; + + case LFUN_BUFFER_NEW_TEMPLATE: + if (viewCount() == 0 + || (!lyxrc.single_window && current_view_->buffer() != 0)) { + createView(); + current_view_->newDocument(to_utf8(cmd.argument()), true); + if (!current_view_->buffer()) + current_view_->close(); + } else + current_view_->newDocument(to_utf8(cmd.argument()), true); + break; + + case LFUN_FILE_OPEN: + if (viewCount() == 0 + || (!lyxrc.single_window && current_view_->buffer() != 0)) { + createView(); + current_view_->openDocument(to_utf8(cmd.argument())); + if (!current_view_->buffer()) + current_view_->close(); + } else + current_view_->openDocument(to_utf8(cmd.argument())); + break; + default: // Notify the caller that the action has not been dispatched. return false; @@ -346,7 +375,7 @@ void GuiApplication::createView(QString const & geometry_arg) #endif } view->setFocus(); - + setActiveWindow(view); setCurrentView(*view); } diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 855ac0b517..3b56370af2 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -1783,6 +1783,8 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form, QWidget * parent) autoSaveSB, SLOT(setEnabled(bool))); connect(autoSaveCB, SIGNAL(toggled(bool)), TextLabel1, SLOT(setEnabled(bool))); + connect(openDocumentsInTabsCB, SIGNAL(clicked()), + this, SIGNAL(changed())); connect(uiFilePB, SIGNAL(clicked()), this, SLOT(select_ui())); connect(uiFileED, SIGNAL(textChanged(QString)), @@ -1846,6 +1848,7 @@ void PrefUserInterface::apply(LyXRC & rc) const rc.full_screen_tabbar = toggleTabbarCB->isChecked(); rc.full_screen_width = fullscreenWidthSB->value(); rc.full_screen_limit = fullscreenLimitGB->isChecked(); + rc.single_window = openDocumentsInTabsCB->isChecked(); } @@ -1872,7 +1875,7 @@ void PrefUserInterface::update(LyXRC const & rc) toggleTabbarCB->setChecked(rc.full_screen_tabbar); fullscreenWidthSB->setValue(rc.full_screen_width); fullscreenLimitGB->setChecked(rc.full_screen_limit); - + openDocumentsInTabsCB->setChecked(rc.single_window); } diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 704dca576d..d03842cd8f 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -1639,10 +1639,6 @@ bool GuiView::dispatch(FuncRequest const & cmd) bv->cursor().updateFlags(Update::None); switch(cmd.action) { - case LFUN_FILE_OPEN: - openDocument(to_utf8(cmd.argument())); - break; - case LFUN_BUFFER_IMPORT: importDocument(to_utf8(cmd.argument())); break; diff --git a/src/frontends/qt4/ui/PrefUi.ui b/src/frontends/qt4/ui/PrefUi.ui index 2f3651724d..8645dc0016 100644 --- a/src/frontends/qt4/ui/PrefUi.ui +++ b/src/frontends/qt4/ui/PrefUi.ui @@ -332,6 +332,13 @@ + + + + Open documents in &tabs + + + @@ -412,6 +419,7 @@ autoSaveCB autoSaveSB lastfilesSB + openDocumentsInTabsCB cursorFollowsCB sortEnvironmentsCB groupEnvironmentsCB