*
* \author Edwin Leuven
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
-#include "gettext.h"
+#include "debug.h"
+#include "qt_helpers.h"
-#include "ControlPrefs.h"
+#include "QPrefsDialog.h"
#include "QPrefs.h"
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "QPrefsDialog.h"
+#include "panelstack.h"
+#include "qcoloritem.h"
+#include "qfontexample.h"
#include "ui/QPrefAsciiModule.h"
#include "ui/QPrefDateModule.h"
#include "ui/QPrefPathsModule.h"
#include "ui/QPrefSpellcheckerModule.h"
#include "ui/QPrefConvertersModule.h"
+#include "ui/QPrefCopiersModule.h"
#include "ui/QPrefFileformatsModule.h"
#include "ui/QPrefLanguageModule.h"
#include "ui/QPrefPrinterModule.h"
#include "ui/QPrefUIModule.h"
+#include "ui/QPrefIdentityModule.h"
-#include "support/lstrings.h"
-#include "lyxrc.h"
-#include "debug.h"
+#include "gettext.h"
+#include "LColor.h"
+
+#include "controllers/ControlPrefs.h"
-#include <qwidgetstack.h>
-#include <qpushbutton.h>
-#include <qlistview.h>
-#include <qlistbox.h>
-#include <qspinbox.h>
-#include <qlineedit.h>
#include <qcheckbox.h>
-#include <qcombobox.h>
-#include <qfontdialog.h>
#include <qcolordialog.h>
-#include <qcolor.h>
-#include "qcoloritem.h"
+#include <qcombobox.h>
+#include <qfontdatabase.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qspinbox.h>
-using std::map;
-using std::endl;
+using std::string;
+
+namespace lyx {
+namespace frontend {
QPrefsDialog::QPrefsDialog(QPrefs * form)
: QPrefsDialogBase(0, 0, false, 0), form_(form)
connect(restorePB, SIGNAL(clicked()),
form, SLOT(slotRestore()));
- prefsLV->setSorting(-1);
-
- // OK, Qt is REALLY broken. We have to hard
- // code the menu structure here.
-
- QListViewItem * lnf(new QListViewItem(prefsLV, _("Look and feel")));
- lnf->setSelectable(false);
- lnf->setOpen(true);
- QListViewItem * lan(new QListViewItem(prefsLV, lnf, _("Language settings")));
- lan->setSelectable(false);
- QListViewItem * out(new QListViewItem(prefsLV, lan, _("Outputs")));
- out->setSelectable(false);
-
- asciiModule = new QPrefAsciiModule(prefsWS);
- dateModule = new QPrefDateModule(prefsWS);
- keyboardModule = new QPrefKeyboardModule(prefsWS);
- latexModule = new QPrefLatexModule(prefsWS);
- screenfontsModule = new QPrefScreenFontsModule(prefsWS);
- colorsModule = new QPrefColorsModule(prefsWS);
- displayModule = new QPrefDisplayModule(prefsWS);
- pathsModule = new QPrefPathsModule(prefsWS);
- spellcheckerModule = new QPrefSpellcheckerModule(prefsWS);
- convertersModule = new QPrefConvertersModule(prefsWS);
- fileformatsModule = new QPrefFileformatsModule(prefsWS);
- languageModule = new QPrefLanguageModule(prefsWS);
- printerModule = new QPrefPrinterModule(prefsWS);
- uiModule = new QPrefUIModule(prefsWS);
-
- prefsWS->addWidget(asciiModule, 0);
- prefsWS->addWidget(dateModule, 1);
- prefsWS->addWidget(keyboardModule, 2);
- prefsWS->addWidget(latexModule, 3);
- prefsWS->addWidget(screenfontsModule, 4);
- prefsWS->addWidget(colorsModule, 5);
- prefsWS->addWidget(displayModule, 6);
- prefsWS->addWidget(pathsModule, 7);
- prefsWS->addWidget(spellcheckerModule, 8);
- prefsWS->addWidget(convertersModule, 9);
- prefsWS->addWidget(fileformatsModule, 10);
- prefsWS->addWidget(languageModule, 11);
- prefsWS->addWidget(printerModule, 12);
- prefsWS->addWidget(uiModule, 13);
-
- QListViewItem * i;
-
- // language settings
-
- i = new QListViewItem(lan, _("Language"));
- pane_map_[i] = languageModule;
- i = new QListViewItem(lan, i, _("Spellchecker"));
- pane_map_[i] = spellcheckerModule;
-
- // UI
-
- i = new QListViewItem(lnf, _("User interface"));
- pane_map_[i] = uiModule;
- prefsLV->setCurrentItem(i);
-
- i = new QListViewItem(lnf, i, _("Screen fonts"));
- pane_map_[i] = screenfontsModule;
- i = new QListViewItem(lnf, i, _("Colors"));
- pane_map_[i] = colorsModule;
- i = new QListViewItem(lnf, i, _("Graphics"));
- pane_map_[i] = displayModule;
- i = new QListViewItem(lnf, i, _("Keyboard"));
- pane_map_[i] = keyboardModule;
-
- // output
-
- i = new QListViewItem(out, _("Ascii"));
- pane_map_[i] = asciiModule;
- i = new QListViewItem(out, i, _("Date format"));
- pane_map_[i] = dateModule;
- i = new QListViewItem(out, i, _("LaTeX"));
- pane_map_[i] = latexModule;
- i = new QListViewItem(out, i, _("Printer"));
- pane_map_[i] = printerModule;
-
- i = new QListViewItem(prefsLV, out, _("Paths"));
- pane_map_[i] = pathsModule;
- i = new QListViewItem(prefsLV, i, _("Converters"));
- pane_map_[i] = convertersModule;
- i = new QListViewItem(prefsLV, i, _("File formats"));
- pane_map_[i] = fileformatsModule;
-
- prefsLV->setMinimumSize(prefsLV->sizeHint());
-
- // Qt sucks
- resize(minimumSize());
-
- // FIXME: put in controller
+ asciiModule = new QPrefAsciiModule(this);
+ dateModule = new QPrefDateModule(this);
+ keyboardModule = new QPrefKeyboardModule(this);
+ latexModule = new QPrefLatexModule(this);
+ screenfontsModule = new QPrefScreenFontsModule(this);
+ colorsModule = new QPrefColorsModule(this);
+ displayModule = new QPrefDisplayModule(this);
+ pathsModule = new QPrefPathsModule(this);
+ spellcheckerModule = new QPrefSpellcheckerModule(this);
+ convertersModule = new QPrefConvertersModule(this);
+ copiersModule = new QPrefCopiersModule(this);
+ fileformatsModule = new QPrefFileformatsModule(this);
+ languageModule = new QPrefLanguageModule(this);
+ printerModule = new QPrefPrinterModule(this);
+ uiModule = new QPrefUIModule(this);
+ identityModule = new QPrefIdentityModule(this);
+
+ string const laf = _("Look and feel");
+ prefsPS->addCategory(laf);
+ prefsPS->addPanel(uiModule, _("User interface"), laf);
+ prefsPS->addPanel(screenfontsModule, _("Screen fonts"), laf);
+ prefsPS->addPanel(colorsModule, _("Colors"), laf);
+ prefsPS->addPanel(displayModule, _("Graphics"), laf);
+ prefsPS->addPanel(keyboardModule, _("Keyboard"), laf);
+
+ string const ls = _("Language settings");
+ prefsPS->addCategory(ls);
+ prefsPS->addPanel(languageModule, _("Language"), ls);
+ prefsPS->addPanel(spellcheckerModule, _("Spell-checker"), ls);
+
+ string const op = _("Outputs");
+ prefsPS->addCategory(op);
+ prefsPS->addPanel(asciiModule, _("ASCII"), op);
+ prefsPS->addPanel(dateModule, _("Date format"), op);
+ prefsPS->addPanel(latexModule, _("LaTeX"), op);
+ prefsPS->addPanel(printerModule, _("Printer"), op);
+
+ prefsPS->addPanel(identityModule, _("Identity"));
+ prefsPS->addPanel(pathsModule, _("Paths"));
+ prefsPS->addPanel(fileformatsModule, _("File formats"));
+ prefsPS->addPanel(convertersModule, _("Converters"));
+ prefsPS->addPanel(copiersModule, _("Copiers"));
+
+ prefsPS->setCurrentPanel(_("User interface"));
+
+ // FIXME: put in controller
for (int i = 0; i < LColor::ignore; ++i) {
LColor::color lc = static_cast<LColor::color>(i);
if (lc == LColor::none
colors_.push_back(lc);
string const x11name(lcolor.getX11Name(lc));
string const guiname(lcolor.getGUIName(lc));
- QColorItem * ci(new QColorItem(QColor(x11name.c_str()), guiname.c_str()));
+ QColorItem * ci(new QColorItem(QColor(toqstr(x11name)),
+ toqstr(guiname)));
colorsModule->lyxObjectsLB->insertItem(ci);
}
+ QFontDatabase fontdb;
+ QStringList families(fontdb.families());
+
+ connect(screenfontsModule->screenRomanCO, SIGNAL(activated(const QString&)), this, SLOT(select_roman(const QString&)));
+ connect(screenfontsModule->screenSansCO, SIGNAL(activated(const QString&)), this, SLOT(select_sans(const QString&)));
+ connect(screenfontsModule->screenTypewriterCO, SIGNAL(activated(const QString&)), this, SLOT(select_typewriter(const QString&)));
+
+ for (QStringList::Iterator it = families.begin(); it != families.end(); ++it) {
+ screenfontsModule->screenRomanCO->insertItem(*it);
+ screenfontsModule->screenSansCO->insertItem(*it);
+ screenfontsModule->screenTypewriterCO->insertItem(*it);
+ }
+
connect(uiModule->uiFilePB, SIGNAL(clicked()), this, SLOT(select_ui()));
connect(uiModule->bindFilePB, SIGNAL(clicked()), this, SLOT(select_bind()));
-
+
connect(keyboardModule->firstKeymapPB, SIGNAL(clicked()), this, SLOT(select_keymap1()));
connect(keyboardModule->secondKeymapPB, SIGNAL(clicked()), this, SLOT(select_keymap2()));
-
+
connect(spellcheckerModule->persDictionaryPB, SIGNAL(clicked()), this, SLOT(select_dict()));
connect(pathsModule->templateDirPB, SIGNAL(clicked()), this, SLOT(select_templatedir()));
connect(pathsModule->backupDirPB, SIGNAL(clicked()), this, SLOT(select_backupdir()));
connect(pathsModule->workingDirPB, SIGNAL(clicked()), this, SLOT(select_workingdir()));
connect(pathsModule->lyxserverDirPB, SIGNAL(clicked()), this, SLOT(select_lyxpipe()));
-
- connect(screenfontsModule->screenRomanPB, SIGNAL(clicked()), this, SLOT(change_roman()));
- connect(screenfontsModule->screenSansPB, SIGNAL(clicked()), this, SLOT(change_sans()));
- connect(screenfontsModule->screenTypewriterPB, SIGNAL(clicked()), this, SLOT(change_typewriter()));
-
+
connect(colorsModule->colorChangePB, SIGNAL(clicked()), this, SLOT(change_color()));
connect(colorsModule->lyxObjectsLB, SIGNAL(selected(int)), this, SLOT(change_color()));
-
+
connect(fileformatsModule->formatNewPB, SIGNAL(clicked()), this, SLOT(new_format()));
connect(fileformatsModule->formatRemovePB, SIGNAL(clicked()), this, SLOT(remove_format()));
connect(fileformatsModule->formatModifyPB, SIGNAL(clicked()), this, SLOT(modify_format()));
connect(convertersModule->converterRemovePB, SIGNAL(clicked()), this, SLOT(remove_converter()));
connect(convertersModule->converterModifyPB, SIGNAL(clicked()), this, SLOT(modify_converter()));
connect(convertersModule->convertersLB, SIGNAL(highlighted(int)), this, SLOT(switch_converter(int)));
-
+
// Qt really sucks. This is as ugly as it looks, but the alternative
// means having to derive every module == bloat
-
+
connect(convertersModule->converterNewPB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(convertersModule->converterRemovePB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(convertersModule->converterModifyPB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+
+ connect(copiersModule->copierNewPB, SIGNAL(clicked()), this, SLOT(new_copier()));
+ connect(copiersModule->copierRemovePB, SIGNAL(clicked()), this, SLOT(remove_copier()));
+ connect(copiersModule->copierModifyPB, SIGNAL(clicked()), this, SLOT(modify_copier()));
+ connect(copiersModule->AllCopiersLB, SIGNAL(highlighted(int)), this, SLOT(switch_copierLB(int)));
+ connect(copiersModule->copierFormatCO, SIGNAL(activated(int)), this, SLOT(switch_copierCO(int)));
+ connect(copiersModule->copierNewPB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(copiersModule->copierRemovePB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+ connect(copiersModule->copierModifyPB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+
connect(fileformatsModule->formatNewPB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(fileformatsModule->formatRemovePB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(fileformatsModule->formatModifyPB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(dateModule->DateED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(latexModule->latexEncodingED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(latexModule->latexChecktexED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
+ connect(latexModule->latexBibtexED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
+ connect(latexModule->latexIndexED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(latexModule->latexAutoresetCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
connect(latexModule->latexDviPaperED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(latexModule->latexPaperSizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
- connect(displayModule->previewCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
+ connect(displayModule->instantPreviewCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
connect(displayModule->displayGraphicsCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
connect(pathsModule->workingDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(pathsModule->templateDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(pathsModule->backupDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
- connect(pathsModule->tempDirCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
connect(pathsModule->tempDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(pathsModule->lyxserverDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(spellcheckerModule->spellCommandCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
connect(printerModule->printerExtraED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(printerModule->printerSpoolPrefixED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(printerModule->printerPaperSizeED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
- connect(screenfontsModule->screenRomanED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
- connect(screenfontsModule->screenSansED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
- connect(screenfontsModule->screenTypewriterED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
+ connect(screenfontsModule->screenRomanCO, SIGNAL(activated(const QString&)), this, SLOT(change_adaptor()));
+ connect(screenfontsModule->screenSansCO, SIGNAL(activated(const QString&)), this, SLOT(change_adaptor()));
+ connect(screenfontsModule->screenTypewriterCO, SIGNAL(activated(const QString&)), this, SLOT(change_adaptor()));
connect(screenfontsModule->screenZoomSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
connect(screenfontsModule->screenDpiSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
connect(screenfontsModule->screenTinyED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(screenfontsModule->screenLargestED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(screenfontsModule->screenHugeED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(screenfontsModule->screenHugerED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
+ connect(identityModule->nameED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
+ connect(identityModule->emailED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
}
}
-void QPrefsDialog::switchPane(QListViewItem * i)
-{
- prefsWS->raiseWidget(pane_map_[i]);
-}
-
-
void QPrefsDialog::change_adaptor()
{
form_->changed();
void QPrefsDialog::updateConverters()
-{
+{
QPrefConvertersModule * convertmod(convertersModule);
-
+
convertmod->converterFromCO->clear();
convertmod->converterToCO->clear();
-
- Formats::const_iterator cit = form_->formats_.begin();
- Formats::const_iterator end = form_->formats_.end();
+
+ Formats::const_iterator cit = form_->formats().begin();
+ Formats::const_iterator end = form_->formats().end();
for (; cit != end; ++cit) {
- convertmod->converterFromCO->insertItem(cit->prettyname().c_str());
- convertmod->converterToCO->insertItem(cit->prettyname().c_str());
+ convertmod->converterFromCO->insertItem(toqstr(cit->prettyname()));
+ convertmod->converterToCO->insertItem(toqstr(cit->prettyname()));
}
-
- convertmod->convertersLB->clear();
- Converters::const_iterator ccit = form_->converters_.begin();
- Converters::const_iterator cend = form_->converters_.end();
+ convertmod->convertersLB->clear();
+
+ Converters::const_iterator ccit = form_->converters().begin();
+ Converters::const_iterator cend = form_->converters().end();
for (; ccit != cend; ++ccit) {
string const name(ccit->From->prettyname() + " -> " +
- ccit->To->prettyname());
- convertmod->convertersLB->insertItem(name.c_str());
+ ccit->To->prettyname());
+ convertmod->convertersLB->insertItem(toqstr(name));
}
+
+ if (convertmod->convertersLB->currentItem() == -1)
+ convertmod->convertersLB->setCurrentItem(0);
}
-
+
void QPrefsDialog::switch_converter(int nr)
{
- Converter const & c(form_->converters_.get(nr));
- convertersModule->converterFromCO->setCurrentItem(form_->formats_.getNumber(c.from));
- convertersModule->converterToCO->setCurrentItem(form_->formats_.getNumber(c.to));
- convertersModule->converterED->setText(c.command.c_str());
- convertersModule->converterFlagED->setText(c.flags.c_str());
+ Converter const & c(form_->converters().get(nr));
+ convertersModule->converterFromCO->setCurrentItem(form_->formats().getNumber(c.from));
+ convertersModule->converterToCO->setCurrentItem(form_->formats().getNumber(c.to));
+ convertersModule->converterED->setText(toqstr(c.command));
+ convertersModule->converterFlagED->setText(toqstr(c.flags));
}
-
+
// FIXME: user must
// specify unique from/to or it doesn't appear. This is really bad UI
void QPrefsDialog::new_converter()
-{
- Format const & from(form_->formats_.get(convertersModule->converterFromCO->currentItem()));
- Format const & to(form_->formats_.get(convertersModule->converterToCO->currentItem()));
-
- Converter const * old = form_->converters_.getConverter(from.name(), to.name());
- form_->converters_.add(from.name(), to.name(), "", "");
+{
+ Format const & from(form_->formats().get(convertersModule->converterFromCO->currentItem()));
+ Format const & to(form_->formats().get(convertersModule->converterToCO->currentItem()));
+
+ Converter const * old = form_->converters().getConverter(from.name(), to.name());
+ form_->converters().add(from.name(), to.name(), "", "");
if (!old) {
- form_->converters_.updateLast(form_->formats_);
+ form_->converters().updateLast(form_->formats());
}
updateConverters();
- convertersModule->convertersLB->setCurrentItem(convertersModule->convertersLB->count() - 1);
+ convertersModule->convertersLB->setCurrentItem(convertersModule->convertersLB->count() - 1);
}
void QPrefsDialog::modify_converter()
{
- Format const & from(form_->formats_.get(convertersModule->converterFromCO->currentItem()));
- Format const & to(form_->formats_.get(convertersModule->converterToCO->currentItem()));
- string flags(convertersModule->converterFlagED->text().latin1());
- string name(convertersModule->converterED->text().latin1());
-
- Converter const * old = form_->converters_.getConverter(from.name(), to.name());
- form_->converters_.add(from.name(), to.name(), name, flags);
+ Format const & from(form_->formats().get(convertersModule->converterFromCO->currentItem()));
+ Format const & to(form_->formats().get(convertersModule->converterToCO->currentItem()));
+ string flags(fromqstr(convertersModule->converterFlagED->text()));
+ string name(fromqstr(convertersModule->converterED->text()));
+
+ Converter const * old = form_->converters().getConverter(from.name(), to.name());
+ form_->converters().add(from.name(), to.name(), name, flags);
if (!old) {
- form_->converters_.updateLast(form_->formats_);
+ form_->converters().updateLast(form_->formats());
}
updateConverters();
}
void QPrefsDialog::remove_converter()
{
- Format const & from(form_->formats_.get(convertersModule->converterFromCO->currentItem()));
- Format const & to(form_->formats_.get(convertersModule->converterToCO->currentItem()));
- form_->converters_.erase(from.name(), to.name());
+ Format const & from(form_->formats().get(convertersModule->converterFromCO->currentItem()));
+ Format const & to(form_->formats().get(convertersModule->converterToCO->currentItem()));
+ form_->converters().erase(from.name(), to.name());
updateConverters();
}
-
+
+void QPrefsDialog::updateCopiers()
+{
+ // The choice widget
+ copiersModule->copierFormatCO->clear();
+
+ for (Formats::const_iterator it = form_->formats().begin(),
+ end = form_->formats().end();
+ it != end; ++it) {
+ copiersModule->copierFormatCO->insertItem(toqstr(it->prettyname()));
+ }
+
+ // The browser widget
+ copiersModule->AllCopiersLB->clear();
+
+ for (Movers::iterator it = form_->movers().begin(),
+ end = form_->movers().end();
+ it != end; ++it) {
+ std::string const & command = it->second.command();
+ if (command.empty())
+ continue;
+ std::string const & fmt = it->first;
+ std::string const & pretty = form_->formats().prettyName(fmt);
+
+ copiersModule->AllCopiersLB->insertItem(toqstr(pretty));
+ }
+
+ if (copiersModule->AllCopiersLB->currentItem() == -1)
+ copiersModule->AllCopiersLB->setCurrentItem(0);
+}
+
+
+namespace {
+
+struct SamePrettyName {
+ SamePrettyName(string const & n) : pretty_name_(n) {}
+
+ bool operator()(::Format const & fmt) const {
+ return fmt.prettyname() == pretty_name_;
+ }
+
+private:
+ string const pretty_name_;
+};
+
+
+Format const * getFormat(std::string const & prettyname)
+{
+ Formats::const_iterator it = ::formats.begin();
+ Formats::const_iterator const end = ::formats.end();
+ it = std::find_if(it, end, SamePrettyName(prettyname));
+ return it == end ? 0 : &*it;
+}
+
+} // namespace anon
+
+
+void QPrefsDialog::switch_copierLB(int nr)
+{
+ std::string const browser_text =
+ fromqstr(copiersModule->AllCopiersLB->currentText());
+ lyxerr << "switch_copierLB(" << nr << ")\n"
+ << "browser_text " << browser_text << std::endl;
+ Format const * fmt = getFormat(browser_text);
+ if (fmt == 0)
+ return;
+
+ string const & fmt_name = fmt->name();
+ string const & gui_name = fmt->prettyname();
+ string const & command = form_->movers().command(fmt_name);
+
+ lyxerr << "switch_copierLB(" << nr << ")\n"
+ << "fmt_name " << fmt_name << '\n'
+ << "gui_name " << gui_name << '\n'
+ << "command " << command << std::endl;
+
+ copiersModule->copierED->clear();
+ int const combo_size = copiersModule->copierFormatCO->count();
+ for (int i = 0; i < combo_size; ++i) {
+ QString const qtext = copiersModule->copierFormatCO->text(i);
+ std::string const text = fromqstr(qtext);
+ if (text == gui_name) {
+ copiersModule->copierFormatCO->setCurrentItem(i);
+ copiersModule->copierED->setText(toqstr(command));
+ lyxerr << "found combo item " << i << std::endl;
+ break;
+ }
+ }
+}
+
+
+void QPrefsDialog::switch_copierCO(int nr)
+{
+ std::string const combo_text =
+ fromqstr(copiersModule->copierFormatCO->currentText());
+ lyxerr << "switch_copierCO(" << nr << ")\n"
+ << "combo_text " << combo_text << std::endl;
+ Format const * fmt = getFormat(combo_text);
+ if (fmt == 0)
+ return;
+
+ string const & fmt_name = fmt->name();
+ string const & gui_name = fmt->prettyname();
+ string const & command = form_->movers().command(fmt_name);
+
+ lyxerr << "switch_copierCO(" << nr << ")\n"
+ << "fmt_name " << fmt_name << '\n'
+ << "gui_name " << gui_name << '\n'
+ << "command " << command << std::endl;
+
+ copiersModule->copierED->setText(toqstr(command));
+
+ int const index = copiersModule->AllCopiersLB->currentItem();
+ if (index >= 0)
+ copiersModule->AllCopiersLB->setSelected(index, false);
+
+ int const browser_size = copiersModule->AllCopiersLB->count();
+ for (int i = 0; i < browser_size; ++i) {
+ QString const qtext = copiersModule->AllCopiersLB->text(i);
+ std::string const text = fromqstr(qtext);
+ if (text == gui_name) {
+ copiersModule->AllCopiersLB->setSelected(i, true);
+ int top = std::max(i - 5, 0);
+ copiersModule->AllCopiersLB->setTopItem(top);
+ break;
+ }
+ }
+}
+
+
+void QPrefsDialog::new_copier()
+{
+ std::string const combo_text =
+ fromqstr(copiersModule->copierFormatCO->currentText());
+ Format const * fmt = getFormat(combo_text);
+ if (fmt == 0)
+ return;
+
+ string const command = fromqstr(copiersModule->copierED->text());
+ if (command.empty())
+ return;
+
+ form_->movers().set(fmt->name(), command);
+
+ updateCopiers();
+ int const last = copiersModule->AllCopiersLB->count() - 1;
+ copiersModule->AllCopiersLB->setCurrentItem(last);
+}
+
+
+void QPrefsDialog::modify_copier()
+{
+ std::string const combo_text =
+ fromqstr(copiersModule->copierFormatCO->currentText());
+ Format const * fmt = getFormat(combo_text);
+ if (fmt == 0)
+ return;
+
+ string const command = fromqstr(copiersModule->copierED->text());
+ form_->movers().set(fmt->name(), command);
+
+ updateCopiers();
+}
+
+
+void QPrefsDialog::remove_copier()
+{
+ std::string const combo_text =
+ fromqstr(copiersModule->copierFormatCO->currentText());
+ Format const * fmt = getFormat(combo_text);
+ if (fmt == 0)
+ return;
+
+ string const & fmt_name = fmt->name();
+ form_->movers().set(fmt_name, string());
+
+ updateCopiers();
+}
+
+
void QPrefsDialog::updateFormats()
{
QPrefFileformatsModule * formatmod(fileformatsModule);
formatmod->formatsLB->clear();
-
- Formats::const_iterator cit = form_->formats_.begin();
- Formats::const_iterator end = form_->formats_.end();
+
+ Formats::const_iterator cit = form_->formats().begin();
+ Formats::const_iterator end = form_->formats().end();
for (; cit != end; ++cit) {
- formatmod->formatsLB->insertItem(cit->prettyname().c_str());
+ formatmod->formatsLB->insertItem(toqstr(cit->prettyname()));
}
+
+ if (formatmod->formatsLB->currentItem() == -1)
+ formatmod->formatsLB->setCurrentItem(0);
}
void QPrefsDialog::switch_format(int nr)
{
- Format const & f(form_->formats_.get(nr));
- fileformatsModule->formatED->setText(f.name().c_str());
- fileformatsModule->guiNameED->setText(f.prettyname().c_str());
- fileformatsModule->extensionED->setText(f.extension().c_str());
- fileformatsModule->shortcutED->setText(f.shortcut().c_str());
- fileformatsModule->viewerED->setText(f.viewer().c_str());
+ Format const & f(form_->formats().get(nr));
+ fileformatsModule->formatED->setText(toqstr(f.name()));
+ fileformatsModule->guiNameED->setText(toqstr(f.prettyname()));
+ fileformatsModule->extensionED->setText(toqstr(f.extension()));
+ fileformatsModule->shortcutED->setText(toqstr(f.shortcut()));
+ fileformatsModule->viewerED->setText(toqstr(f.viewer()));
+ fileformatsModule->editorED->setText(toqstr(f.editor()));
fileformatsModule->formatRemovePB->setEnabled(
- !form_->converters_.formatIsUsed(f.name()));
+ !form_->converters().formatIsUsed(f.name()));
}
-
+
void QPrefsDialog::new_format()
{
- form_->formats_.add(_("New"));
- form_->formats_.sort();
+ form_->formats().add(_("New"));
+ form_->formats().sort();
updateFormats();
- fileformatsModule->formatsLB->setCurrentItem(form_->formats_.getNumber(_("New")));
+ fileformatsModule->formatsLB->setCurrentItem(form_->formats().getNumber(_("New")));
updateConverters();
}
void QPrefsDialog::modify_format()
{
- Format const & oldformat(form_->formats_.get(fileformatsModule->formatsLB->currentItem()));
+ Format const & oldformat(form_->formats().get(fileformatsModule->formatsLB->currentItem()));
string const oldpretty(oldformat.prettyname());
- string const name(fileformatsModule->formatED->text().latin1());
- form_->formats_.erase(oldformat.name());
-
- string const prettyname = fileformatsModule->guiNameED->text().latin1();
- string const extension = fileformatsModule->extensionED->text().latin1();
- string const shortcut = fileformatsModule->shortcutED->text().latin1();
- string const viewer = fileformatsModule->viewerED->text().latin1();
-
- form_->formats_.add(name, extension, prettyname, shortcut);
- form_->formats_.sort();
- form_->formats_.setViewer(name, viewer);
+ string const name(fromqstr(fileformatsModule->formatED->text()));
+ form_->formats().erase(oldformat.name());
+
+ string const prettyname = fromqstr(fileformatsModule->guiNameED->text());
+ string const extension = fromqstr(fileformatsModule->extensionED->text());
+ string const shortcut = fromqstr(fileformatsModule->shortcutED->text());
+ string const viewer = fromqstr(fileformatsModule->viewerED->text());
+ string const editor = fromqstr(fileformatsModule->editorED->text());
+
+ form_->formats().add(name, extension, prettyname, shortcut, viewer, editor);
+ form_->formats().sort();
fileformatsModule->formatsLB->setUpdatesEnabled(false);
- updateFormats();
+ updateFormats();
fileformatsModule->formatsLB->setUpdatesEnabled(true);
fileformatsModule->formatsLB->update();
-
+
updateConverters();
}
int const nr(fileformatsModule->formatsLB->currentItem());
if (nr < 0)
return;
- form_->formats_.erase(form_->formats_.get(nr).name());
+ form_->formats().erase(form_->formats().get(nr).name());
updateFormats();
updateConverters();
}
return;
QListBoxItem * ib(lb->item(lb->currentItem()));
QColorItem * ci(static_cast<QColorItem*>(ib));
- QColor c(QColorDialog::getColor(ci->color()));
+ QColor c(QColorDialog::getColor(ci->color(), qApp->focusWidget() ? qApp->focusWidget() : qApp->mainWidget()));
if (c.isValid()) {
ci->color(c);
lb->update();
void QPrefsDialog::select_ui()
{
- string file(form_->controller().browseUI(uiModule->uiFileED->text().latin1()));
+ string file(form_->controller().browseUI(fromqstr(uiModule->uiFileED->text())));
if (!file.empty())
- uiModule->uiFileED->setText(file.c_str());
+ uiModule->uiFileED->setText(toqstr(file));
}
void QPrefsDialog::select_bind()
{
- string file(form_->controller().browsebind(uiModule->bindFileED->text().latin1()));
+ string file(form_->controller().browsebind(fromqstr(uiModule->bindFileED->text())));
if (!file.empty())
- uiModule->bindFileED->setText(file.c_str());
+ uiModule->bindFileED->setText(toqstr(file));
}
-
+
void QPrefsDialog::select_keymap1()
{
- string file(form_->controller().browsekbmap(keyboardModule->firstKeymapED->text().latin1()));
+ string file(form_->controller().browsekbmap(fromqstr(keyboardModule->firstKeymapED->text())));
if (!file.empty())
- keyboardModule->firstKeymapED->setText(file.c_str());
+ keyboardModule->firstKeymapED->setText(toqstr(file));
}
-
+
void QPrefsDialog::select_keymap2()
{
- string file(form_->controller().browsekbmap(keyboardModule->secondKeymapED->text().latin1()));
+ string file(form_->controller().browsekbmap(fromqstr(keyboardModule->secondKeymapED->text())));
if (!file.empty())
- keyboardModule->secondKeymapED->setText(file.c_str());
+ keyboardModule->secondKeymapED->setText(toqstr(file));
}
void QPrefsDialog::select_dict()
{
- string file(form_->controller().browsedict(spellcheckerModule->persDictionaryED->text().latin1()));
+ string file(form_->controller().browsedict(fromqstr(spellcheckerModule->persDictionaryED->text())));
if (!file.empty())
- spellcheckerModule->persDictionaryED->setText(file.c_str());
+ spellcheckerModule->persDictionaryED->setText(toqstr(file));
}
-
+
+// NB: the _() is OK here because it gets passed back and we toqstr() them
+
void QPrefsDialog::select_templatedir()
{
- string file(form_->controller().browse(pathsModule->templateDirED->text().latin1(), _("Select a document templates directory")));
+ string file(form_->controller().browsedir(fromqstr(pathsModule->templateDirED->text()), _("Select a document templates directory")));
if (!file.empty())
- pathsModule->templateDirED->setText(file.c_str());
+ pathsModule->templateDirED->setText(toqstr(file));
}
-
+
void QPrefsDialog::select_tempdir()
{
- string file(form_->controller().browse(pathsModule->tempDirED->text().latin1(), _("Select a temporary directory")));
+ string file(form_->controller().browsedir(fromqstr(pathsModule->tempDirED->text()), _("Select a temporary directory")));
if (!file.empty())
- pathsModule->tempDirED->setText(file.c_str());
+ pathsModule->tempDirED->setText(toqstr(file));
}
-
+
void QPrefsDialog::select_backupdir()
{
- string file(form_->controller().browse(pathsModule->backupDirED->text().latin1(), _("Select a backups directory")));
+ string file(form_->controller().browsedir(fromqstr(pathsModule->backupDirED->text()), _("Select a backups directory")));
if (!file.empty())
- pathsModule->backupDirED->setText(file.c_str());
+ pathsModule->backupDirED->setText(toqstr(file));
}
-
+
void QPrefsDialog::select_workingdir()
{
- string file(form_->controller().browse(pathsModule->workingDirED->text().latin1(), _("Selection a documents directory")));
+ string file(form_->controller().browsedir(fromqstr(pathsModule->workingDirED->text()), _("Select a document directory")));
if (!file.empty())
- pathsModule->workingDirED->setText(file.c_str());
+ pathsModule->workingDirED->setText(toqstr(file));
}
-
+
void QPrefsDialog::select_lyxpipe()
{
- string file(form_->controller().browse(pathsModule->lyxserverDirED->text().latin1(), _("Give a filename for the LyX server pipe")));
+ string file(form_->controller().browse(fromqstr(pathsModule->lyxserverDirED->text()), _("Give a filename for the LyX server pipe")));
if (!file.empty())
- pathsModule->lyxserverDirED->setText(file.c_str());
+ pathsModule->lyxserverDirED->setText(toqstr(file));
}
-void QPrefsDialog::change_roman()
+void QPrefsDialog::select_roman(const QString& name)
{
-#if QT_VERSION >= 300
- QFont f;
- f.fromString(screenfontsModule->screenRomanED->text());
-
- // Qt designers hadn't heard of references
- bool ok;
- QFontDialog::getFont(&ok, f);
- if (ok)
- screenfontsModule->screenRomanED->setText(f.toString());
-#else
- // ??
-#endif
+ screenfontsModule->screenRomanFE->set(QFont(name), name);
}
-void QPrefsDialog::change_sans()
+void QPrefsDialog::select_sans(const QString& name)
{
-#if QT_VERSION >= 300
- QFont f;
- f.fromString(screenfontsModule->screenSansED->text());
-
- // Qt designers hadn't heard of references
- bool ok;
- QFontDialog::getFont(&ok, f);
- if (ok)
- screenfontsModule->screenSansED->setText(f.toString());
-#else
- // ?? rawName is no good
-#endif
+ screenfontsModule->screenSansFE->set(QFont(name), name);
}
-void QPrefsDialog::change_typewriter()
+void QPrefsDialog::select_typewriter(const QString& name)
{
-#if QT_VERSION >= 300
- QFont f;
- f.fromString(screenfontsModule->screenTypewriterED->text());
-
- // Qt designers hadn't heard of references
- bool ok;
- QFontDialog::getFont(&ok, f);
- if (ok)
- screenfontsModule->screenTypewriterED->setText(f.toString());
-#else
- // ?? rawName is no good
-#endif
+ screenfontsModule->screenTypewriterFE->set(QFont(name), name);
}
+
+} // namespace frontend
+} // namespace lyx