actOnUpdatedPrefs(lyxrc_orig, lyxrc);
+ if (lyx_view_ && lyx_view_->buffer())
+ lyx_view_->updateLayoutChoice(true);
+
/// We force the redraw in any case because there might be
/// some screen font changes.
/// FIXME: only the current view will be updated. the Gui
theSelection().haveSelection(view()->cursor().selection());
if (view()->cursor().inTexted()) {
- lyx_view_->updateLayoutChoice();
+ lyx_view_->updateLayoutChoice(false);
}
}
}
case LyXRC::RC_USE_PIXMAP_CACHE:
case LyXRC::RC_USE_SPELL_LIB:
case LyXRC::RC_VIEWDVI_PAPEROPTION:
+ case LyXRC::RC_SORT_LAYOUTS:
case LyXRC::RC_VIEWER:
case LyXRC::RC_LAST:
break;
{ "\\language_global_options", LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS },
{ "\\language_package", LyXRC::RC_LANGUAGE_PACKAGE },
{ "\\language_use_babel", LyXRC::RC_LANGUAGE_USE_BABEL },
+ { "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS },
{ "\\load_session", LyXRC::RC_LOADSESSION },
{ "\\make_backup", LyXRC::RC_MAKE_BACKUP },
{ "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
language_package = "\\usepackage{babel}";
language_command_begin = "\\selectlanguage{$$lang}";
language_command_local = "\\foreignlanguage{$$lang}{";
+ sort_layouts = false;
default_language = "english";
show_banner = true;
windows_style_tex_paths = false;
convert<unsigned int>(lexrc.getString());
break;
+ case RC_SORT_LAYOUTS:
+ if (lexrc.next())
+ sort_layouts = lexrc.getBool();
+ break;
+
case RC_LAST: break; // this is just a dummy
}
}
}
if (tag != RC_LAST)
break;
-
+ case RC_SORT_LAYOUTS:
+ if (ignore_system_lyxrc ||
+ sort_layouts != system_lyxrc.sort_layouts) {
+ os << "# Sort layouts alphabetically.\n"
+ << "\\sort_layouts " << convert<string>(sort_layouts) << '\n';
+ }
+ if (tag != RC_LAST)
+ break;
case RC_VIEWDVI_PAPEROPTION:
if (ignore_system_lyxrc ||
view_dvi_paper_option
RC_LANGUAGE_GLOBAL_OPTIONS,
RC_LANGUAGE_PACKAGE,
RC_LANGUAGE_USE_BABEL,
+ RC_SORT_LAYOUTS,
RC_USELASTFILEPOS,
RC_LOADSESSION,
RC_MAKE_BACKUP,
bool use_converter_cache;
/// The maximum age of cache files in seconds
unsigned int converter_cache_maxage;
+ /// Sort layouts alphabetically
+ bool sort_layouts;
};
void setBuffer(Buffer * b); ///< \c Buffer to set.
/// updates the possible layouts selectable
- virtual void updateLayoutChoice() = 0;
+ virtual void updateLayoutChoice(bool force) = 0;
/// update the toolbar
virtual void updateToolbars() = 0;
// Skip these when selecting
if (cmd.action != LFUN_MOUSE_MOTION) {
- lyx_view_->updateLayoutChoice();
+ lyx_view_->updateLayoutChoice(false);
lyx_view_->updateToolbars();
}
// We are already inside a paint event.
lyx_view_->setBusy(true);
buffer_view_->resize(width(), height());
- lyx_view_->updateLayoutChoice();
+ lyx_view_->updateLayoutChoice(false);
lyx_view_->setBusy(false);
}
this, SIGNAL(changed()));
connect(cursorFollowsCB, SIGNAL(clicked()),
this, SIGNAL(changed()));
+ connect(sortEnvironmentsCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
connect(autoSaveSB, SIGNAL(valueChanged(int)),
this, SIGNAL(changed()));
connect(autoSaveCB, SIGNAL(clicked()),
}
rc.geometry_xysaved = loadWindowLocationCB->isChecked();
rc.cursor_follows_scrollbar = cursorFollowsCB->isChecked();
+ rc.sort_layouts = sortEnvironmentsCB->isChecked();
rc.autosave = autoSaveSB->value() * 60;
rc.make_backup = autoSaveCB->isChecked();
rc.num_lastfiles = lastfilesSB->value();
}
loadWindowLocationCB->setChecked(rc.geometry_xysaved);
cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar);
+ sortEnvironmentsCB->setChecked(rc.sort_layouts);
// convert to minutes
int mins(rc.autosave / 60);
if (rc.autosave && !mins)
#include "Action.h"
#include "qt_helpers.h"
#include "InsertTableWidget.h"
+#include "LyXRC.h"
#include "support/filetools.h"
#include "support/lstrings.h"
}
+void GuiLayoutBox::addItemSort(QString const & item, bool sorted)
+{
+ int const end = count();
+ if (!sorted || end < 2 || item[0].category() != QChar::Letter_Uppercase) {
+ addItem(item);
+ return;
+ }
+
+ // Let the default one be at the beginning
+ int i = 1;
+ for (setCurrentIndex(i); currentText() < item;) {
+ // e.g. --Separator--
+ if (currentText()[0].category() != QChar::Letter_Uppercase)
+ break;
+ if (++i == end)
+ break;
+ setCurrentIndex(i);
+ }
+
+ insertItem(i, item);
+}
+
+
void GuiLayoutBox::updateContents()
{
TextClass const & tc = textClass(owner_);
TextClass::const_iterator const end = tc.end();
for (; it != end; ++it) {
// ignore obsolete entries
- addItem(toqstr(translateIfPossible((*it)->name())));
+ addItemSort(toqstr(translateIfPossible((*it)->name())), lyxrc.sort_layouts);
}
+ setCurrentIndex(0);
+
// needed to recalculate size hint
hide();
setMinimumWidth(sizeHint().width());
void set(docstring const & layout);
/// Populate the layout combobox.
void updateContents();
+ /// Add Item to Layout box according to sorting settings from preferences
+ void addItemSort(QString const & item, bool sorted);
private Q_SLOTS:
void selected(const QString & str);
}
-bool GuiToolbars::updateLayoutList(TextClassPtr textclass)
+bool GuiToolbars::updateLayoutList(TextClassPtr textclass, bool force)
{
// update the layout display
- if (last_textclass_ != textclass) {
+ if (last_textclass_ != textclass || force) {
if (layout_)
layout_->updateContents();
last_textclass_ = textclass;
/** Populate the layout combox - returns whether we did a full
* update or not
*/
- bool updateLayoutList(TextClassPtr textclass);
+ bool updateLayoutList(TextClassPtr textclass, bool force);
/// Drop down the layout list.
void openLayoutList();
// require bv_->text.
getDialogs().updateBufferDependent(true);
updateToolbars();
- updateLayoutChoice();
+ updateLayoutChoice(false);
updateWindowTitle();
updateStatusBar();
}
}
-void GuiView::updateLayoutChoice()
+void GuiView::updateLayoutChoice(bool force)
{
// Don't show any layouts without a buffer
if (!buffer()) {
}
// Update the layout display
- if (d.toolbars_->updateLayoutList(buffer()->params().getTextClassPtr())) {
+ if (d.toolbars_->updateLayoutList(buffer()->params().getTextClassPtr(), force)) {
d.current_layout = buffer()->params().getTextClass().defaultLayoutName();
}
void showMiniBuffer(bool);
void openMenu(docstring const &);
void openLayoutList();
- void updateLayoutChoice();
+ void updateLayoutChoice(bool force);
bool isToolbarVisible(std::string const & id);
void updateToolbars();
ToolbarInfo * getToolbarInfo(std::string const & name);
if (lyxrc.cursor_follows_scrollbar) {
buffer_view_->setCursorFromScrollbar();
- lyx_view_->updateLayoutChoice();
+ lyx_view_->updateLayoutChoice(false);
}
// Show the cursor immediately after any operation.
startBlinkingCursor();
<item row="3" column="0" colspan="3" >
<widget class="QGroupBox" name="scrollGB" >
<property name="title" >
- <string>Scrolling</string>
+ <string>Editing</string>
</property>
<property name="alignment" >
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
+ <item row="1" column="0" >
+ <widget class="QCheckBox" name="sortEnvironmentsCB" >
+ <property name="text" >
+ <string>Sort &Environments alphabetically</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>