Interface changes
-----------------
+Whenever the user closes a (tabbed) view on a document, either by
+clicking on the tab close button, or by using the File->Close menu,
+LyX now closes exclusively that specific view. If there are other
+views showing the same document, they are not closed. When the user
+closes the last view, LyX can be configured for either closing the
+document, or keeping it into memory as a hidden document (that can be
+shown again through the View->Hidden-> submenu).
+
+A new configurable preference option has been added, allowing for either
+(close_buffer_with_last_view)
+
There have been some changes to the LyX command line. The following new
options have been added:
The following pref variables were changed in 2.1:
+- \\close_buffer_with_last_view [yes|no|ask]
+ When user closes the last view on a document, close the document
+ as well ("yes"), or hide the document ("no"), or ask the user
+ ("ask").
+
The following pref variables are obsoleted in 2.1:
- \\default_language
This is also available through a new menu voice within the
[Edit]->[Paste Special...] sub-menu.
+- LFUN_VIEW_CLOSE
+ Close the current document view only, if there are no more views
+ on the document, either close or hide it (see the new preference
+ option \\close_buffer_with_last_view)
The following LyX functions have been removed:
\bind "C-n" "buffer-new"
\bind "C-S-N" "buffer-new-template"
\bind "C-o" "file-open"
-\bind "C-w" "buffer-close"
+\bind "C-w" "view-close"
\bind "C-s" "buffer-write"
\bind "C-S-S" "buffer-write-as"
\bind "C-p" "dialog-show print"
LFUN_IN_IPA, // spitz, 20120520
LFUN_IPAMACRO_INSERT, // spitz, 20120822
// 355
+ LFUN_VIEW_CLOSE, // Tommaso, 20120915
LFUN_LASTACTION // end of the table
};
* \endvar
*/
{ LFUN_CLOSE_TAB_GROUP, "close-tab-group", ReadOnly, Buffer },
+
+/*!
+ * \var lyx::FuncCode lyx::LFUN_VIEW_CLOSE
+ * \li Action: Close the current document work area.
+ * \li Notion: Close the current work area. If no other work areas are showing the buffer,
+ then close the associated buffer as well.
+ * \li Syntax: view-close
+ * \li Origin: Tommaso, 15 Sep 2012
+ * \endvar
+ */
+ { LFUN_VIEW_CLOSE, "view-close", ReadOnly, Buffer },
+
/*!
* \var lyx::FuncCode lyx::LFUN_DIALOG_SHOW
* \li Action: Shows hidden dialog or creates new one for a given function/inset settings etc.
{ "\\viewer", LyXRC::RC_VIEWER},
{ "\\viewer_alternatives", LyXRC::RC_VIEWER_ALTERNATIVES },
{ "\\visual_cursor", LyXRC::RC_VISUAL_CURSOR },
+ { "\\close_buffer_with_last_view", LyXRC::RC_CLOSE_BUFFER_WITH_LAST_VIEW },
{ "format", LyXRC::RC_LYXRCFORMAT }
};
default_decimal_point = ".";
default_length_unit = Length::CM;
cursor_width = 1;
+ close_buffer_with_last_view = "yes";
}
case RC_VISUAL_CURSOR:
lexrc >> visual_cursor;
break;
+ case RC_CLOSE_BUFFER_WITH_LAST_VIEW:
+ lexrc >> close_buffer_with_last_view;
+ break;
case RC_AUTO_NUMBER:
lexrc >> auto_number;
break;
}
if (tag != RC_LAST)
break;
+ case RC_CLOSE_BUFFER_WITH_LAST_VIEW:
+ if (ignore_system_lyxrc ||
+ close_buffer_with_last_view != system_lyxrc.close_buffer_with_last_view) {
+ os << "# When closing last view, buffer closes (yes), hides (no), or ask the user (ask)\n";
+ os << "\\close_buffer_with_last_view " << close_buffer_with_last_view << '\n';
+ }
+ if (tag != RC_LAST)
+ break;
case RC_LANGUAGE_CUSTOM_PACKAGE:
if (ignore_system_lyxrc ||
language_custom_package != system_lyxrc.language_custom_package) {
case LyXRC::RC_FULL_SCREEN_TOOLBARS:
case LyXRC::RC_FULL_SCREEN_WIDTH:
case LyXRC::RC_VISUAL_CURSOR:
+ case LyXRC::RC_CLOSE_BUFFER_WITH_LAST_VIEW:
case LyXRC::RC_VIEWER:
case LyXRC::RC_VIEWER_ALTERNATIVES:
case LyXRC::RC_FORWARD_SEARCH_DVI:
str = _("Select to have visual bidi cursor movement, unselect for logical movement.");
break;
+ case RC_CLOSE_BUFFER_WITH_LAST_VIEW:
+ str = _("Specify whether, closing the last view of an open document, LyX should close the document (yes), hide it (no), or ask the user (ask).");
+ break;
+
case RC_SCREEN_DPI:
str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
break;
RC_VIEWER,
RC_VIEWER_ALTERNATIVES,
RC_VISUAL_CURSOR,
+ RC_CLOSE_BUFFER_WITH_LAST_VIEW,
RC_LAST
};
bool force_paint_single_char;
///
int cursor_width;
+ /// One of: yes, no, ask
+ std::string close_buffer_with_last_view;
};
this, SIGNAL(changed()));
connect(iconSetCO, SIGNAL(activated(int)),
this, SIGNAL(changed()));
+ connect(closeLastViewCO, SIGNAL(activated(int)),
+ this, SIGNAL(changed()));
connect(restoreCursorCB, SIGNAL(clicked()),
this, SIGNAL(changed()));
connect(loadSessionCB, SIGNAL(clicked()),
#if QT_VERSION < 0x040500
rc.single_close_tab_button = true;
#endif
+ switch (closeLastViewCO->currentIndex()) {
+ case 0:
+ rc.close_buffer_with_last_view = "yes";
+ break;
+ case 1:
+ rc.close_buffer_with_last_view = "no";
+ break;
+ case 2:
+ rc.close_buffer_with_last_view = "ask";
+ break;
+ default:
+ ;
+ }
}
singleInstanceCB->setChecked(rc.single_instance && !rc.lyxpipes.empty());
singleInstanceCB->setEnabled(!rc.lyxpipes.empty());
singleCloseTabButtonCB->setChecked(rc.single_close_tab_button);
+ if (rc.close_buffer_with_last_view == "yes")
+ closeLastViewCO->setCurrentIndex(0);
+ else if (rc.close_buffer_with_last_view == "no")
+ closeLastViewCO->setCurrentIndex(1);
+ else if (rc.close_buffer_with_last_view == "ask")
+ closeLastViewCO->setCurrentIndex(2);
}
return tabWorkArea(0);
}
+ int countWorkAreasOf(Buffer & buf)
+ {
+ int areas = tabWorkAreaCount();
+ int count = 0;
+ for (int i = 0; i != areas; ++i) {
+ TabWorkArea * twa = tabWorkArea(i);
+ if (twa->workArea(buf))
+ ++count;
+ }
+ return count;
+ }
+
#if (QT_VERSION >= 0x040400)
void setPreviewFuture(QFuture<Buffer::ExportStatus> const & f)
{
break;
case LFUN_BUFFER_CLOSE:
+ case LFUN_VIEW_CLOSE:
enable = doc_buffer;
break;
}
+// We only want to close the buffer if it is not visible in other workareas
+// of the same view, nor in other views, and if this is not a child
bool GuiView::closeWorkArea(GuiWorkArea * wa)
{
Buffer & buf = wa->bufferView().buffer();
- return closeWorkArea(wa, !buf.parent());
+
+ bool last_wa = d.countWorkAreasOf(buf) == 1
+ && !inOtherView(buf) && !buf.parent();
+
+ bool close_buffer = last_wa;
+
+ if (last_wa) {
+ if (lyxrc.close_buffer_with_last_view == "yes")
+ ; // Nothing to do
+ else if (lyxrc.close_buffer_with_last_view == "no")
+ close_buffer = false;
+ else {
+ docstring file;
+ if (buf.isUnnamed())
+ file = from_utf8(buf.fileName().onlyFileName());
+ else
+ file = buf.fileName().displayName(30);
+ docstring const text = bformat(
+ _("Last view on document %1$s is being closed.\n"
+ "Would you like to close or hide the document?\n"
+ "\n"
+ "Hidden documents can be displayed back through\n"
+ "the menu: View->Hidden->...\n"
+ "\n"
+ "To remove this question, set your preference in:\n"
+ " Tools->Preferences->Look&Feel->UserInterface\n"
+ ), file);
+ int ret = Alert::prompt(_("Close or hide document?"),
+ text, 0, 1, _("&Close"), _("&Hide"));
+ close_buffer = (ret == 0);
+ }
+ }
+
+ return closeWorkArea(wa, close_buffer);
}
}
break;
+ case LFUN_VIEW_CLOSE:
+ if (TabWorkArea * twa = d.currentTabWorkArea()) {
+ closeWorkArea(twa->currentWorkArea());
+ d.current_work_area_ = 0;
+ twa = d.currentTabWorkArea();
+ // Switch to the next GuiWorkArea in the found TabWorkArea.
+ if (twa) {
+ // Make sure the work area is up to date.
+ setCurrentWorkArea(twa->currentWorkArea());
+ } else {
+ setCurrentWorkArea(0);
+ }
+ }
+ break;
+
case LFUN_COMPLETION_INLINE:
if (d.current_work_area_)
d.current_work_area_->completer().showInline();
/// hides the workarea and makes sure it is clean
bool hideWorkArea(GuiWorkArea * wa);
- /// closes the workarea
+ /// closes workarea; close buffer only if no other workareas point to it
bool closeWorkArea(GuiWorkArea * wa);
/// closes the buffer
bool closeBuffer(Buffer & buf);
+<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PrefUi</class>
<widget class="QWidget" name="PrefUi">
<rect>
<x>0</x>
<y>0</y>
- <width>413</width>
- <height>408</height>
+ <width>604</width>
+ <height>559</height>
</rect>
</property>
<property name="sizePolicy">
</property>
</spacer>
</item>
- <item row="1" column="0" >
- <widget class="QLabel" name="iconSetLA" >
- <property name="text" >
+ <item row="1" column="0">
+ <widget class="QLabel" name="iconSetLA">
+ <property name="text">
<string>&Icon Set:</string>
</property>
- <property name="buddy" >
+ <property name="buddy">
<cstring>iconSetCO</cstring>
</property>
</widget>
</item>
- <item row="1" column="1" >
- <widget class="QComboBox" name="iconSetCO" >
- <property name="toolTip" >
- <string>The icon set to use. Warning: normal size of icons may be
wrong until you save the preferences and restart LyX.</string>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="iconSetCO">
+ <property name="toolTip">
+ <string>The icon set to use. Warning: normal size of icons may be
+wrong until you save the preferences and restart LyX.</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="singleInstanceCB">
<property name="toolTip">
- <string>Whether to open documents in an already running instance of LyX.
(Set the LyXServer pipe path and restart LyX to enable this feature)</string>
+ <string>Whether to open documents in an already running instance of LyX.
+(Set the LyXServer pipe path and restart LyX to enable this feature)</string>
</property>
<property name="text">
<string>S&ingle instance</string>
</property>
</widget>
</item>
+ <item row="7" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Closing last view:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="1" colspan="4">
+ <widget class="QComboBox" name="closeLastViewCO">
+ <item>
+ <property name="text">
+ <string>Closes document</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Hides document</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Ask the user</string>
+ </property>
+ </item>
+ </widget>
+ </item>
</layout>
</widget>
</item>