diff --git a/lib/bind/cua.bind b/lib/bind/cua.bind index 91f37c5150..93b42cfa19 100644 --- a/lib/bind/cua.bind +++ b/lib/bind/cua.bind @@ -112,6 +112,8 @@ \bind "M-x" "command-execute" +\bind "F11" "ui-toggle fullscreen" + # # Motion group # diff --git a/lib/ui/stdmenus.inc b/lib/ui/stdmenus.inc index 281564ee80..2213a9cc06 100644 --- a/lib/ui/stdmenus.inc +++ b/lib/ui/stdmenus.inc @@ -294,6 +294,7 @@ Menuset Submenu "Update|U" "view_update" ViewFormats Separator + Item "Fullscreen|l" "ui-toggle fullscreen" Submenu "Toolbars|b" "toolbars" Separator Documents diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 9236ae8d78..50d7f086f3 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -286,15 +286,16 @@ BufferView::~BufferView() delete d; } -// Put this user variable in lyxrc or pass it through setFullScreen() -static int const max_row_width = 700; int BufferView::rightMargin() const { - if (!full_screen_ || width_ < max_row_width + 20) - return 10; + // The additional test for the case the outliner is opened. + if (!full_screen_ || + !lyxrc.full_screen_limit || + width_ < lyxrc.full_screen_width + 20) + return 10; - return (width_ - max_row_width) / 2; + return (width_ - lyxrc.full_screen_width) / 2; } diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index e92f926f31..0473ca51ca 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -80,6 +80,11 @@ keyword_item lyxrcTags[] = { { "\\example_path", LyXRC::RC_EXAMPLEPATH }, { "\\font_encoding", LyXRC::RC_FONT_ENCODING }, { "\\format", LyXRC::RC_FORMAT }, + { "\\fullscreen_limit", LyXRC::RC_FULL_SCREEN_LIMIT }, + { "\\fullscreen_scrollbar", LyXRC::RC_FULL_SCREEN_SCROLLBAR }, + { "\\fullscreen_tabbar", LyXRC::RC_FULL_SCREEN_TABBAR }, + { "\\fullscreen_toolbars", LyXRC::RC_FULL_SCREEN_TOOLBARS }, + { "\\fullscreen_width", LyXRC::RC_FULL_SCREEN_WIDTH }, { "\\index_command", LyXRC::RC_INDEX_COMMAND }, { "\\input", LyXRC::RC_INPUT }, { "\\kbmap", LyXRC::RC_KBMAP }, @@ -275,6 +280,12 @@ void LyXRC::setDefaults() { use_tooltip = true; use_pixmap_cache = false; converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months + // Fullscreen settings + full_screen_limit = false; + full_screen_toolbars = true; + full_screen_tabbar = true; + full_screen_scrollbar = true; + full_screen_width = 700; user_name = to_utf8(support::user_name()); @@ -1195,6 +1206,26 @@ int LyXRC::read(Lexer & lexrc) if (lexrc.next()) sort_layouts = lexrc.getBool(); break; + case RC_FULL_SCREEN_LIMIT: + if (lexrc.next()) + full_screen_limit = lexrc.getBool(); + break; + case RC_FULL_SCREEN_TOOLBARS: + if (lexrc.next()) + full_screen_toolbars = lexrc.getBool(); + break; + case RC_FULL_SCREEN_SCROLLBAR: + if (lexrc.next()) + full_screen_scrollbar = lexrc.getBool(); + break; + case RC_FULL_SCREEN_TABBAR: + if (lexrc.next()) + full_screen_tabbar = lexrc.getBool(); + break; + case RC_FULL_SCREEN_WIDTH: + if (lexrc.next()) + full_screen_width = lexrc.getInteger(); + break; case RC_LAST: break; // this is just a dummy } @@ -1720,6 +1751,52 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c } if (tag != RC_LAST) break; + case RC_FULL_SCREEN_LIMIT: + if (ignore_system_lyxrc || + full_screen_limit != system_lyxrc.full_screen_limit) { + os << "\\fullscreen_limit " + << convert(full_screen_limit) + << '\n'; + } + if (tag != RC_LAST) + break; + case RC_FULL_SCREEN_TOOLBARS: + if (ignore_system_lyxrc || + full_screen_toolbars != system_lyxrc.full_screen_toolbars) { + os << "\\fullscreen_toolbars " + << convert(full_screen_toolbars) + << '\n'; + } + if (tag != RC_LAST) + break; + case RC_FULL_SCREEN_SCROLLBAR: + if (ignore_system_lyxrc || + full_screen_scrollbar != system_lyxrc.full_screen_scrollbar) { + os << "\\fullscreen_scrollbar " + << convert(full_screen_scrollbar) + << '\n'; + } + if (tag != RC_LAST) + break; + case RC_FULL_SCREEN_TABBAR: + if (ignore_system_lyxrc || + full_screen_tabbar != system_lyxrc.full_screen_tabbar) { + os << "\\fullscreen_tabbar " + << convert(full_screen_tabbar) + << '\n'; + } + if (tag != RC_LAST) + break; + case RC_FULL_SCREEN_WIDTH: + if (ignore_system_lyxrc || + full_screen_width != system_lyxrc.full_screen_width) { + os << "\\fullscreen_width " + << convert(full_screen_width) + << '\n'; + } + if (tag != RC_LAST) + break; + os << "\n#\n" << "# COLOR SECTION ###################################\n" diff --git a/src/LyXRC.h b/src/LyXRC.h index 3976a58f16..8b5896a3a2 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -66,6 +66,11 @@ public: RC_EXAMPLEPATH, RC_FONT_ENCODING, RC_FORMAT, + RC_FULL_SCREEN_LIMIT, + RC_FULL_SCREEN_SCROLLBAR, + RC_FULL_SCREEN_TABBAR, + RC_FULL_SCREEN_TOOLBARS, + RC_FULL_SCREEN_WIDTH, RC_INDEX_COMMAND, RC_INPUT, RC_KBMAP, @@ -394,6 +399,16 @@ public: unsigned int converter_cache_maxage; /// Sort layouts alphabetically bool sort_layouts; + /// Toggle toolbars in fullscreen mode? + bool full_screen_toolbars; + /// Toggle scrollbar in fullscreen mode? + bool full_screen_scrollbar; + /// Toggle tabbar in fullscreen mode? + bool full_screen_tabbar; + /// Limit the text width? + bool full_screen_limit; + /// Width of limited screen (in pixels) in fullscreen mode + int full_screen_width; }; diff --git a/src/ToolbarBackend.h b/src/ToolbarBackend.h index d25b59da5e..cd4828efa4 100644 --- a/src/ToolbarBackend.h +++ b/src/ToolbarBackend.h @@ -96,6 +96,8 @@ public: Items items; /// flags Flags flags; + /// store flags when coming to fullscreen mode + Flags before_fullscreen; /// read a toolbar from the file ToolbarInfo & read(Lexer &); diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 2de384edae..67b7cd2926 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -1652,6 +1652,16 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form, QWidget * parent) this, SIGNAL(changed())); connect(tooltipCB, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + connect(fullscreenLimitGB, SIGNAL(clicked()), + this, SIGNAL(changed())); + connect(fullscreenWidthSB, SIGNAL(valueChanged(int)), + this, SIGNAL(changed())); + connect(toggleTabbarCB, SIGNAL(toggled(bool)), + this, SIGNAL(changed())); + connect(toggleScrollbarCB, SIGNAL(toggled(bool)), + this, SIGNAL(changed())); + connect(toggleToolbarsCB, SIGNAL(toggled(bool)), + this, SIGNAL(changed())); lastfilesSB->setMaximum(maxlastfiles); } @@ -1673,6 +1683,11 @@ void PrefUserInterface::apply(LyXRC & rc) const rc.make_backup = autoSaveCB->isChecked(); rc.num_lastfiles = lastfilesSB->value(); rc.use_tooltip = tooltipCB->isChecked(); + rc.full_screen_toolbars = toggleToolbarsCB->isChecked(); + rc.full_screen_scrollbar = toggleScrollbarCB->isChecked(); + rc.full_screen_tabbar = toggleTabbarCB->isChecked(); + rc.full_screen_width = fullscreenWidthSB->value(); + rc.full_screen_limit = fullscreenLimitGB->isChecked(); } @@ -1693,6 +1708,12 @@ void PrefUserInterface::update(LyXRC const & rc) autoSaveCB->setChecked(rc.make_backup); lastfilesSB->setValue(rc.num_lastfiles); tooltipCB->setChecked(rc.use_tooltip); + toggleScrollbarCB->setChecked(rc.full_screen_scrollbar); + toggleToolbarsCB->setChecked(rc.full_screen_toolbars); + toggleTabbarCB->setChecked(rc.full_screen_tabbar); + fullscreenWidthSB->setValue(rc.full_screen_width); + fullscreenLimitGB->setChecked(rc.full_screen_limit); + } diff --git a/src/frontends/qt4/GuiToolbars.cpp b/src/frontends/qt4/GuiToolbars.cpp index 9a891d6a3e..dd89ae6943 100644 --- a/src/frontends/qt4/GuiToolbars.cpp +++ b/src/frontends/qt4/GuiToolbars.cpp @@ -221,6 +221,28 @@ void GuiToolbars::toggleToolbarState(string const & name, bool allowauto) } tbi->flags = static_cast(flags); } + + +void GuiToolbars::toggleFullScreen(bool start_full_screen) +{ + // extracts the toolbars from the backend + ToolbarBackend::Toolbars::iterator cit = toolbarbackend.begin(); + ToolbarBackend::Toolbars::iterator end = toolbarbackend.end(); + int flags; + + for (; cit != end; ++cit) { + + if (start_full_screen) { + flags = cit->before_fullscreen = cit->flags; + TurnOffFlag(ON); + TurnOffFlag(AUTO); + TurnOnFlag(OFF); + } else + flags = cit->before_fullscreen; + + cit->flags = static_cast(flags); + } +} #undef TurnOnFlag #undef TurnOffFlag diff --git a/src/frontends/qt4/GuiToolbars.h b/src/frontends/qt4/GuiToolbars.h index 29ec7b3092..d7015c8eb9 100644 --- a/src/frontends/qt4/GuiToolbars.h +++ b/src/frontends/qt4/GuiToolbars.h @@ -62,6 +62,8 @@ public: /// Show or hide the command buffer. void showCommandBuffer(bool show_it); + /// toggle visibility of toolbars and save its flags for return + void toggleFullScreen(bool start_full_screen); private: /// Add a new toolbar. if newline==true, start from a new line diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index fdf02687a6..456c3ffbed 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -395,10 +395,19 @@ void GuiView::closeEvent(QCloseEvent * close_event) // Make sure that no LFUN use this close to be closed View. theLyXFunc().setLyXView(0); + + // Save toolbars configuration + if (isFullScreen()) { + d.toolbars_->toggleFullScreen(!isFullScreen()); + updateToolbars(); + } + // Make sure the timer time out will not trigger a statusbar update. d.statusbar_timer_.stop(); - if (lyxrc.allow_geometry_session) { + // Saving fullscreen requires additional tweaks in the toolbar code. + // It wouldn't also work under linux natively. + if (lyxrc.allow_geometry_session && !isFullScreen()) { QSettings settings; QString const key = "view-" + QString::number(id_); #ifdef Q_WS_X11 @@ -1855,6 +1864,9 @@ void GuiView::lfunUiToggle(FuncRequest const & cmd) return; } + if (lyxrc.full_screen_toolbars) + d.toolbars_->toggleFullScreen(!isFullScreen()); + if (isFullScreen()) { showNormal(); #if QT_VERSION >= 0x040300 @@ -1864,7 +1876,13 @@ void GuiView::lfunUiToggle(FuncRequest const & cmd) d.tabWorkArea(i)->setFullScreen(false); menuBar()->show(); statusBar()->show(); + if (lyxrc.full_screen_scrollbar && d.current_work_area_) + d.current_work_area_-> + setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); } else { + if (lyxrc.full_screen_scrollbar && d.current_work_area_) + d.current_work_area_-> + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); statusBar()->hide(); menuBar()->hide(); for (int i = 0; i != d.splitter_->count(); ++i) diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index 5091037b22..0b2428f32e 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -1053,6 +1053,9 @@ void TabWorkArea::setFullScreen(bool full_screen) if (GuiWorkArea * wa = dynamic_cast(widget(i))) wa->setFullScreen(full_screen); } + + if (lyxrc.full_screen_tabbar) + showBar(!full_screen && count()>1); } diff --git a/src/frontends/qt4/ui/PrefUi.ui b/src/frontends/qt4/ui/PrefUi.ui index 3ed020782b..c406f7b8bb 100644 --- a/src/frontends/qt4/ui/PrefUi.ui +++ b/src/frontends/qt4/ui/PrefUi.ui @@ -5,14 +5,12 @@ 0 0 - 398 - 565 + 413 + 533 - - 0 - 0 + 0 0 @@ -21,26 +19,27 @@ - - 9 - - - 6 - - - - - Qt::Vertical + + + + &User interface file: - - - 204 - 101 - + + uiFileED - + - + + + + + + + Bro&wse... + + + + Automatic help @@ -52,12 +51,24 @@ true - + 9 - + + 0 + + + 9 + + + 9 + + 6 + + 4 + @@ -78,9 +89,7 @@ p, li { white-space: pre-wrap; } - - 0 - 0 + 0 0 @@ -92,11 +101,8 @@ p, li { white-space: pre-wrap; } true - - 9 - - - 6 + + 0 @@ -111,13 +117,6 @@ p, li { white-space: pre-wrap; } - - - - Load opened files from last session - - - @@ -125,30 +124,127 @@ p, li { white-space: pre-wrap; } + + + + Load opened files from last session + + + - - - - &User interface file: + + + + Documents - - uiFileED + + true + + + 1 + + + 13 + + + -1 + + + -1 + + + + + B&ackup documents, every + + + + + + + 1 + + + 300 + + + + + + + minutes + + + + + + + Qt::Horizontal + + + + 61 + 21 + + + + + + + + 6 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + &Maximum last files: + + + lastfilesSB + + + + + + + 9 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + - - - - - - - Bro&wse... - - - - + Editing @@ -160,11 +256,8 @@ p, li { white-space: pre-wrap; } true - - 9 - - - 6 + + 0 @@ -202,46 +295,112 @@ p, li { white-space: pre-wrap; } - - + + + + + 0 + 0 + + - Documents + Fullscreen + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop true - - 9 + + 2 - - 6 + + 4 + + + 2 - - - - 300 - - - 1 - - - - + + + + 0 + 0 + + - B&ackup documents, every + T&oggle toolbars - - + + + + &Limit text width + + + true + + + + 9 + + + 4 + + + -1 + + + + + + + Screen us&ed (pixels): + + + fullscreenWidthSB + + + + + + + 0 + + + 10000 + + + 10 + + + 700 + + + + + + + + + + - minutes + To&ggle scrollbar - + + + + Toggle tabba&r + + + + Qt::Horizontal @@ -254,51 +413,25 @@ p, li { white-space: pre-wrap; } - - - - 0 - - - 6 - - - - - &Maximum last files: - - - lastfilesSB - - - - - - - 9 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - + + + + Qt::Vertical + + + + 295 + 16 + + + + + uiFileED uiFilePB