From 6fac185d818ce00dd13e875ef51724b7287c087b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Wed, 19 Mar 2008 13:11:14 +0000 Subject: [PATCH] * src/frontends/qt4/GuiPrefs.{cpp,h}: * src/frontends/qt4/PanelStack.cpp: - reintroduce panel categorization (bug 4153). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23826 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiPrefs.cpp | 46 +++++++++++++++++++------------- src/frontends/qt4/GuiPrefs.h | 6 +++-- src/frontends/qt4/PanelStack.cpp | 10 ++++++- 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index de3929ef84..985e948b01 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -210,6 +210,11 @@ QString browseRelFile(QString const & filename, QString const & refpath, 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 @@ static void setComboxFont(QComboBox * cb, string const & family, ///////////////////////////////////////////////////////////////////// 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 @@ void PrefPlaintext::update(LyXRC const & rc) ///////////////////////////////////////////////////////////////////// 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 @@ void PrefDate::update(LyXRC const & rc) ///////////////////////////////////////////////////////////////////// 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 @@ void PrefInput::on_keymapCB_toggled(bool keymap) ///////////////////////////////////////////////////////////////////// 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 @@ void PrefCompletion::update(LyXRC const & rc) ///////////////////////////////////////////////////////////////////// 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 @@ void PrefLatex::update(LyXRC const & rc) ///////////////////////////////////////////////////////////////////// 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 @@ struct ColorSorter } // 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 @@ void PrefColors::change_lyxObjects_selection() ///////////////////////////////////////////////////////////////////// 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 @@ void PrefDisplay::update(LyXRC const & rc) ///////////////////////////////////////////////////////////////////// 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 @@ void PrefPaths::select_lyxpipe() ///////////////////////////////////////////////////////////////////// PrefSpellchecker::PrefSpellchecker(GuiPreferences * form, QWidget * parent) - : PrefModule(qt_("Spellchecker"), form, parent) + : PrefModule(qt_(catLanguage), qt_("Spellchecker"), form, parent) { setupUi(this); @@ -1150,7 +1155,7 @@ void PrefSpellchecker::select_dict() PrefConverters::PrefConverters(GuiPreferences * form, QWidget * parent) - : PrefModule(qt_("Converters"), form, parent) + : PrefModule(qt_(catFiles), qt_("Converters"), form, parent) { setupUi(this); @@ -1420,7 +1425,7 @@ string FormatPrettynameValidator::str(Formats::const_iterator it) const 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 @@ void PrefFileformats::on_formatRemovePB_clicked() ///////////////////////////////////////////////////////////////////// PrefLanguage::PrefLanguage(QWidget * parent) - : PrefModule(qt_("Language"), 0, parent) + : PrefModule(qt_(catLanguage), qt_("Language"), 0, parent) { setupUi(this); @@ -1706,7 +1711,7 @@ void PrefLanguage::update(LyXRC const & rc) ///////////////////////////////////////////////////////////////////// PrefPrinter::PrefPrinter(QWidget * parent) - : PrefModule(qt_("Printer"), 0, parent) + : PrefModule(qt_(catOutput), qt_("Printer"), 0, parent) { setupUi(this); @@ -1804,7 +1809,7 @@ void PrefPrinter::update(LyXRC const & rc) ///////////////////////////////////////////////////////////////////// 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 @@ void PrefUserInterface::select_ui() ///////////////////////////////////////////////////////////////////// PrefEdit::PrefEdit(GuiPreferences * form, QWidget * parent) - : PrefModule(qt_("Editing"), form, parent) + : PrefModule(qt_(catLookAndFeel), qt_("Editing"), form, parent) { setupUi(this); @@ -1958,7 +1963,7 @@ GuiShortcutDialog::GuiShortcutDialog(QWidget * parent) : QDialog(parent) PrefShortcuts::PrefShortcuts(GuiPreferences * form, QWidget * parent) - : PrefModule(qt_("Shortcuts"), form, parent) + : PrefModule(qt_(catLookAndFeel), qt_("Shortcuts"), form, parent) { setupUi(this); @@ -2351,7 +2356,7 @@ void PrefShortcuts::shortcut_clearPB_pressed() ///////////////////////////////////////////////////////////////////// PrefIdentity::PrefIdentity(QWidget * parent) - : PrefModule(qt_("Identity"), 0, parent) + : PrefModule(QString(), qt_("Identity"), 0, parent) { setupUi(this); @@ -2441,7 +2446,10 @@ GuiPreferences::GuiPreferences(GuiView & lv) 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); } diff --git a/src/frontends/qt4/GuiPrefs.h b/src/frontends/qt4/GuiPrefs.h index b7e0afc794..afca6d4b42 100644 --- a/src/frontends/qt4/GuiPrefs.h +++ b/src/frontends/qt4/GuiPrefs.h @@ -67,17 +67,19 @@ class PrefModule : public QWidget { 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_; diff --git a/src/frontends/qt4/PanelStack.cpp b/src/frontends/qt4/PanelStack.cpp index eae495878a..08a24e7585 100644 --- a/src/frontends/qt4/PanelStack.cpp +++ b/src/frontends/qt4/PanelStack.cpp @@ -38,8 +38,8 @@ PanelStack::PanelStack(QWidget * parent) list_ = new QTreeWidget(this); stack_ = new QStackedWidget(this); - list_->setColumnCount(1); list_->setRootIsDecorated(false); + list_->setColumnCount(1); // Hide the pointless list header list_->header()->hide(); // QStringList HeaderLabels; @@ -73,11 +73,13 @@ void PanelStack::addCategory(QString const & name, QString const & parent) item = new QTreeWidgetItem(panel_map_.value(parent)); item->setText(0, name); depth = 2; + list_->setRootIsDecorated(true); } panel_map_[name] = item; QFontMetrics fm(list_->font()); + // calculate the real size the current item needs in the listview int itemsize = fm.width(name) + 10 + list_->indentation() * depth; @@ -113,6 +115,12 @@ void PanelStack::setCurrentPanel(QString const & name) 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); }