Jürgen Spitzmüller wrote:
> If done the first now (own completion pane), and I'm gonna have a look at
> the second.
Here is a patch that reintroduces the categories. It thus reverts rev. 19914
and fixes bug 4153, but it also fixes the original problems with the tree
view described in bug 4153, which rev. 19914 set out to fix.
In other words: it throws out the bath water (bug 4153), but keeps the baby
(categories).
Jürgen
Index: src/frontends/qt4/GuiPrefs.cpp
===================================================================
--- src/frontends/qt4/GuiPrefs.cpp (Revision 23811)
+++ src/frontends/qt4/GuiPrefs.cpp (Arbeitskopie)
@@ -210,6 +210,11 @@
namespace frontend {
+string const catOutput = N_("Output");
+string const catLookAndFeel = N_("Look & Feel");
+string const catLanguage = N_("Language Settings");
+string const catFiles = N_("File Handling");
+
static int findPos_helper(QStringList const & vec, QString const & val)
{
for (int i = 0; i != vec.size(); ++i)
@@ -322,7 +327,7 @@
/////////////////////////////////////////////////////////////////////
PrefPlaintext::PrefPlaintext(QWidget * parent)
- : PrefModule(qt_("Plain text"), 0, parent)
+ : PrefModule(qt_(catOutput), qt_("Plain text"), 0, parent)
{
setupUi(this);
connect(plaintextLinelengthSB, SIGNAL(valueChanged(int)),
@@ -353,7 +358,7 @@
/////////////////////////////////////////////////////////////////////
PrefDate::PrefDate(QWidget * parent)
- : PrefModule(qt_("Date format"), 0, parent)
+ : PrefModule(qt_(catOutput), qt_("Date format"), 0, parent)
{
setupUi(this);
connect(DateED, SIGNAL(textChanged(QString)),
@@ -380,7 +385,7 @@
/////////////////////////////////////////////////////////////////////
PrefInput::PrefInput(GuiPreferences * form, QWidget * parent)
- : PrefModule(qt_("Keyboard/Mouse"), form, parent)
+ : PrefModule(qt_(catLookAndFeel), qt_("Keyboard/Mouse"), form, parent)
{
setupUi(this);
@@ -455,7 +460,7 @@
/////////////////////////////////////////////////////////////////////
PrefCompletion::PrefCompletion(GuiPreferences * form, QWidget * parent)
- : PrefModule(qt_("Input Completion"), form, parent)
+ : PrefModule(qt_(catLookAndFeel), qt_("Input Completion"), form, parent)
{
setupUi(this);
@@ -517,7 +522,7 @@
/////////////////////////////////////////////////////////////////////
PrefLatex::PrefLatex(GuiPreferences * form, QWidget * parent)
- : PrefModule(qt_("LaTeX"), form, parent)
+ : PrefModule(qt_(catOutput), qt_("LaTeX"), form, parent)
{
setupUi(this);
connect(latexEncodingED, SIGNAL(textChanged(QString)),
@@ -584,7 +589,7 @@
/////////////////////////////////////////////////////////////////////
PrefScreenFonts::PrefScreenFonts(GuiPreferences * form, QWidget * parent)
- : PrefModule(qt_("Screen fonts"), form, parent)
+ : PrefModule(qt_(catLookAndFeel), qt_("Screen fonts"), form, parent)
{
setupUi(this);
@@ -758,7 +763,7 @@
} // namespace anon
PrefColors::PrefColors(GuiPreferences * form, QWidget * parent)
- : PrefModule(qt_("Colors"), form, parent)
+ : PrefModule(qt_(catLookAndFeel), qt_("Colors"), form, parent)
{
setupUi(this);
@@ -857,7 +862,7 @@
/////////////////////////////////////////////////////////////////////
PrefDisplay::PrefDisplay(QWidget * parent)
- : PrefModule(qt_("Graphics"), 0, parent)
+ : PrefModule(qt_(catLookAndFeel), qt_("Graphics"), 0, parent)
{
setupUi(this);
connect(instantPreviewCO, SIGNAL(activated(int)),
@@ -928,7 +933,7 @@
/////////////////////////////////////////////////////////////////////
PrefPaths::PrefPaths(GuiPreferences * form, QWidget * parent)
- : PrefModule(qt_("Paths"), form, parent)
+ : PrefModule(QString(), qt_("Paths"), form, parent)
{
setupUi(this);
connect(exampleDirPB, SIGNAL(clicked()), this, SLOT(select_exampledir()));
@@ -1041,7 +1046,7 @@
/////////////////////////////////////////////////////////////////////
PrefSpellchecker::PrefSpellchecker(GuiPreferences * form, QWidget * parent)
- : PrefModule(qt_("Spellchecker"), form, parent)
+ : PrefModule(qt_(catLanguage), qt_("Spellchecker"), form, parent)
{
setupUi(this);
@@ -1150,7 +1155,7 @@
PrefConverters::PrefConverters(GuiPreferences * form, QWidget * parent)
- : PrefModule(qt_("Converters"), form, parent)
+ : PrefModule(qt_(catFiles), qt_("Converters"), form, parent)
{
setupUi(this);
@@ -1420,7 +1425,7 @@
PrefFileformats::PrefFileformats(GuiPreferences * form, QWidget * parent)
- : PrefModule(qt_("File formats"), form, parent)
+ : PrefModule(qt_(catFiles), qt_("File formats"), form, parent)
{
setupUi(this);
formatED->setValidator(new FormatNameValidator(formatsCB, form_->formats()));
@@ -1619,7 +1624,7 @@
/////////////////////////////////////////////////////////////////////
PrefLanguage::PrefLanguage(QWidget * parent)
- : PrefModule(qt_("Language"), 0, parent)
+ : PrefModule(qt_(catLanguage), qt_("Language"), 0, parent)
{
setupUi(this);
@@ -1706,7 +1711,7 @@
/////////////////////////////////////////////////////////////////////
PrefPrinter::PrefPrinter(QWidget * parent)
- : PrefModule(qt_("Printer"), 0, parent)
+ : PrefModule(qt_(catOutput), qt_("Printer"), 0, parent)
{
setupUi(this);
@@ -1804,7 +1809,7 @@
/////////////////////////////////////////////////////////////////////
PrefUserInterface::PrefUserInterface(GuiPreferences * form, QWidget * parent)
- : PrefModule(qt_("User interface"), form, parent)
+ : PrefModule(qt_(catLookAndFeel), qt_("User interface"), form, parent)
{
setupUi(this);
@@ -1886,7 +1891,7 @@
/////////////////////////////////////////////////////////////////////
PrefEdit::PrefEdit(GuiPreferences * form, QWidget * parent)
- : PrefModule(qt_("Editing"), form, parent)
+ : PrefModule(qt_(catLookAndFeel), qt_("Editing"), form, parent)
{
setupUi(this);
@@ -1958,7 +1963,7 @@
PrefShortcuts::PrefShortcuts(GuiPreferences * form, QWidget * parent)
- : PrefModule(qt_("Shortcuts"), form, parent)
+ : PrefModule(qt_(catLookAndFeel), qt_("Shortcuts"), form, parent)
{
setupUi(this);
@@ -2351,7 +2356,7 @@
/////////////////////////////////////////////////////////////////////
PrefIdentity::PrefIdentity(QWidget * parent)
- : PrefModule(qt_("Identity"), 0, parent)
+ : PrefModule(QString(), qt_("Identity"), 0, parent)
{
setupUi(this);
@@ -2441,7 +2446,10 @@
void GuiPreferences::add(PrefModule * module)
{
BOOST_ASSERT(module);
- prefsPS->addPanel(module, module->title());
+ if (module->category().isEmpty())
+ prefsPS->addPanel(module, module->title());
+ else
+ prefsPS->addPanel(module, module->title(), module->category());
connect(module, SIGNAL(changed()), this, SLOT(change_adaptor()));
modules_.push_back(module);
}
Index: src/frontends/qt4/PanelStack.cpp
===================================================================
--- src/frontends/qt4/PanelStack.cpp (Revision 23810)
+++ src/frontends/qt4/PanelStack.cpp (Arbeitskopie)
@@ -38,8 +38,8 @@
list_ = new QTreeWidget(this);
stack_ = new QStackedWidget(this);
+ list_->setRootIsDecorated(false);
list_->setColumnCount(1);
- list_->setRootIsDecorated(false);
// Hide the pointless list header
list_->header()->hide();
// QStringList HeaderLabels;
@@ -94,6 +94,8 @@
widget_map_[item] = panel;
stack_->addWidget(panel);
stack_->setMinimumSize(panel->minimumSize());
+ if (!parent.isEmpty())
+ list_->setRootIsDecorated(true);
}
@@ -113,6 +115,12 @@
void PanelStack::switchPanel(QTreeWidgetItem * item,
QTreeWidgetItem * /*previous*/)
{
+ // if we have a category, expand the tree and go to the
+ // first item
+ if (item->childCount() > 0) {
+ item->setExpanded(true);
+ list_->setCurrentItem(item->child(0));
+ }
if (QWidget * w = widget_map_.value(item, 0))
stack_->setCurrentWidget(w);
}
Index: src/frontends/qt4/GuiPrefs.h
===================================================================
--- src/frontends/qt4/GuiPrefs.h (Revision 23811)
+++ src/frontends/qt4/GuiPrefs.h (Arbeitskopie)
@@ -67,17 +67,19 @@
{
Q_OBJECT
public:
- PrefModule(QString const & t,
+ PrefModule(QString const & cat, QString const & t,
GuiPreferences * form = 0, QWidget * parent = 0)
- : QWidget(parent), title_(t), form_(form)
+ : QWidget(parent), category_(cat), title_(t), form_(form)
{}
virtual void apply(LyXRC & rc) const = 0;
virtual void update(LyXRC const & rc) = 0;
+ QString const & category() const { return category_; }
QString const & title() const { return title_; }
protected:
+ QString category_;
QString title_;
GuiPreferences * form_;