Improve fullscreen mode (bug 4146).

- added toolbars/tabbar/scrollbar toggling
- added text width control
- added GUI preferences & menu & shortcut

Known problems:
- Outliner in Mac is seeking some Mac devie to fix (see hints here:
  http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg135382.html ) 
- Toolbars visibility is shared between windows (views)
  (needs toolbars overhaul).
- Adding new tab items does not reflect fullscreen mode
  (i.e. margins and tabbar get visible)



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23069 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Pavel Sanda 2008-02-19 21:51:55 +00:00
parent 1ab314f8e6
commit 72b270ab4b
12 changed files with 427 additions and 130 deletions

View File

@ -112,6 +112,8 @@
\bind "M-x" "command-execute"
\bind "F11" "ui-toggle fullscreen"
#
# Motion group
#

View File

@ -294,6 +294,7 @@ Menuset
Submenu "Update|U" "view_update"
ViewFormats
Separator
Item "Fullscreen|l" "ui-toggle fullscreen"
Submenu "Toolbars|b" "toolbars"
Separator
Documents

View File

@ -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;
}

View File

@ -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<string>(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<string>(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<string>(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<string>(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<string>(full_screen_width)
<< '\n';
}
if (tag != RC_LAST)
break;
os << "\n#\n"
<< "# COLOR SECTION ###################################\n"

View File

@ -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;
};

View File

@ -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 &);

View File

@ -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);
}

View File

@ -221,6 +221,28 @@ void GuiToolbars::toggleToolbarState(string const & name, bool allowauto)
}
tbi->flags = static_cast<ToolbarInfo::Flags>(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<ToolbarInfo::Flags>(flags);
}
}
#undef TurnOnFlag
#undef TurnOffFlag

View File

@ -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

View File

@ -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)

View File

@ -1053,6 +1053,9 @@ void TabWorkArea::setFullScreen(bool full_screen)
if (GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(widget(i)))
wa->setFullScreen(full_screen);
}
if (lyxrc.full_screen_tabbar)
showBar(!full_screen && count()>1);
}

View File

@ -5,14 +5,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>398</width>
<height>565</height>
<width>413</width>
<height>533</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -21,26 +19,27 @@
<string/>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="6" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
<item row="0" column="0" >
<widget class="QLabel" name="uiFileLA" >
<property name="text" >
<string>&amp;User interface file:</string>
</property>
<property name="sizeHint" >
<size>
<width>204</width>
<height>101</height>
</size>
<property name="buddy" >
<cstring>uiFileED</cstring>
</property>
</spacer>
</widget>
</item>
<item row="1" column="0" colspan="3" >
<item row="0" column="1" >
<widget class="QLineEdit" name="uiFileED" />
</item>
<item row="0" column="2" colspan="2" >
<widget class="QPushButton" name="uiFilePB" >
<property name="text" >
<string>Bro&amp;wse...</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="4" >
<widget class="QGroupBox" name="pixmapCacheGB_2" >
<property name="title" >
<string>Automatic help</string>
@ -52,12 +51,24 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<property name="leftMargin" >
<number>9</number>
</property>
<property name="spacing" >
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<number>4</number>
</property>
<item row="0" column="0" >
<widget class="QCheckBox" name="tooltipCB" >
<property name="toolTip" >
@ -78,9 +89,7 @@ p, li { white-space: pre-wrap; }
<item row="2" column="0" colspan="3" >
<widget class="QGroupBox" name="GeometryGB" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -92,11 +101,8 @@ p, li { white-space: pre-wrap; }
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
<property name="topMargin" >
<number>0</number>
</property>
<item row="0" column="0" >
<widget class="QCheckBox" name="allowGeometrySessionCB" >
@ -111,13 +117,6 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QCheckBox" name="loadSessionCB" >
<property name="text" >
<string>Load opened files from last session</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QCheckBox" name="restoreCursorCB" >
<property name="text" >
@ -125,30 +124,127 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QCheckBox" name="loadSessionCB" >
<property name="text" >
<string>Load opened files from last session</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="uiFileLA" >
<property name="text" >
<string>&amp;User interface file:</string>
<item row="3" column="0" colspan="4" >
<widget class="QGroupBox" name="documentsGB" >
<property name="title" >
<string>Documents</string>
</property>
<property name="buddy" >
<cstring>uiFileED</cstring>
<property name="flat" >
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="topMargin" >
<number>1</number>
</property>
<property name="bottomMargin" >
<number>13</number>
</property>
<property name="horizontalSpacing" >
<number>-1</number>
</property>
<property name="verticalSpacing" >
<number>-1</number>
</property>
<item row="0" column="0" >
<widget class="QCheckBox" name="autoSaveCB" >
<property name="text" >
<string>B&amp;ackup documents, every</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QSpinBox" name="autoSaveSB" >
<property name="minimum" >
<number>1</number>
</property>
<property name="maximum" >
<number>300</number>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QLabel" name="TextLabel1" >
<property name="text" >
<string>minutes</string>
</property>
</widget>
</item>
<item row="0" column="3" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>61</width>
<height>21</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="4" >
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item>
<widget class="QLabel" name="lastfilesLA" >
<property name="text" >
<string>&amp;Maximum last files:</string>
</property>
<property name="buddy" >
<cstring>lastfilesSB</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="lastfilesSB" >
<property name="maximum" >
<number>9</number>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="uiFileED" />
</item>
<item row="0" column="2" >
<widget class="QPushButton" name="uiFilePB" >
<property name="text" >
<string>Bro&amp;wse...</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="3" >
<item row="4" column="0" colspan="4" >
<widget class="QGroupBox" name="scrollGB" >
<property name="title" >
<string>Editing</string>
@ -160,11 +256,8 @@ p, li { white-space: pre-wrap; }
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
<property name="topMargin" >
<number>0</number>
</property>
<item row="0" column="0" >
<widget class="QCheckBox" name="cursorFollowsCB" >
@ -202,46 +295,112 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
<item row="3" column="0" colspan="3" >
<widget class="QGroupBox" name="documentsGB" >
<item row="5" column="0" colspan="4" >
<widget class="QGroupBox" name="fullscreenGB" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title" >
<string>Documents</string>
<string>Fullscreen</string>
</property>
<property name="alignment" >
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="flat" >
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
<property name="topMargin" >
<number>2</number>
</property>
<property name="spacing" >
<number>6</number>
<property name="horizontalSpacing" >
<number>4</number>
</property>
<property name="verticalSpacing" >
<number>2</number>
</property>
<item row="0" column="1" >
<widget class="QSpinBox" name="autoSaveSB" >
<property name="maximum" >
<number>300</number>
</property>
<property name="minimum" >
<number>1</number>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QCheckBox" name="autoSaveCB" >
<widget class="QCheckBox" name="toggleToolbarsCB" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>B&amp;ackup documents, every</string>
<string>T&amp;oggle toolbars</string>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QLabel" name="TextLabel1" >
<item rowspan="3" row="0" column="2" >
<widget class="QGroupBox" name="fullscreenLimitGB" >
<property name="title" >
<string>&amp;Limit text width</string>
</property>
<property name="checkable" >
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>4</number>
</property>
<property name="verticalSpacing" >
<number>-1</number>
</property>
<item row="0" column="0" >
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Screen us&amp;ed (pixels):</string>
</property>
<property name="buddy" >
<cstring>fullscreenWidthSB</cstring>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QSpinBox" name="fullscreenWidthSB" >
<property name="minimum" >
<number>0</number>
</property>
<property name="maximum" >
<number>10000</number>
</property>
<property name="singleStep" >
<number>10</number>
</property>
<property name="value" >
<number>700</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" >
<widget class="QCheckBox" name="toggleScrollbarCB" >
<property name="text" >
<string>minutes</string>
<string>To&amp;ggle scrollbar</string>
</property>
</widget>
</item>
<item row="0" column="3" >
<item row="2" column="0" >
<widget class="QCheckBox" name="toggleTabbarCB" >
<property name="text" >
<string>Toggle tabba&amp;r</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
@ -254,51 +413,25 @@ p, li { white-space: pre-wrap; }
</property>
</spacer>
</item>
<item row="1" column="0" colspan="4" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="lastfilesLA" >
<property name="text" >
<string>&amp;Maximum last files:</string>
</property>
<property name="buddy" >
<cstring>lastfilesSB</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="lastfilesSB" >
<property name="maximum" >
<number>9</number>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="6" column="0" colspan="4" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>295</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="4" margin="9" />
<tabstops>
<tabstop>uiFileED</tabstop>
<tabstop>uiFilePB</tabstop>