mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
A new LFUN_LYXRC_APPLY lfun, together with a bit of a clean-up of the
preferences dialog code. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8570 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2baeac64ff
commit
931a49cc87
@ -1,3 +1,13 @@
|
||||
2004-03-31 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* lfuns.h:
|
||||
* LyXAction.C: new lfun LFUN_LYXRC_APPLY.
|
||||
|
||||
* lyxrc.[Ch] (read, write): overloaded member functions taking
|
||||
a std::[io]stream arguments.
|
||||
|
||||
* lyxfunc.C (getStatus, dispatch): handle LFUN_LYXRC_APPLY.
|
||||
|
||||
2004-03-31 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* lyxfunc.C (loadTextclass): new helper function, invoked by two of
|
||||
|
@ -334,6 +334,7 @@ void LyXAction::init()
|
||||
{ LFUN_TEXTCLASS_LOAD, "textclass-load", Noop },
|
||||
{ LFUN_SAVE_AS_DEFAULT, "buffer-save-as-default", Noop },
|
||||
{ LFUN_BUFFERPARAMS_APPLY, "buffer-params-apply", Noop },
|
||||
{ LFUN_LYXRC_APPLY, "lyxrc-apply", NoBuffer },
|
||||
{ LFUN_NOACTION, "", Noop }
|
||||
};
|
||||
|
||||
|
@ -1,3 +1,11 @@
|
||||
2004-03-31 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* ControlPrefs.C: a bit of an overhaul, moving the local Converters
|
||||
and Formats variables out of the various frontends to here,
|
||||
and ensuring that nothing is actually dispatched to the core except
|
||||
from apply().
|
||||
Also use the new LFUN_LYXRC_APPLY lfun.
|
||||
|
||||
2004-03-30 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* ControlDocument.[Ch]: converted to the dialog-based scheme.
|
||||
|
@ -16,12 +16,9 @@
|
||||
#include "ViewBase.h"
|
||||
|
||||
#include "bufferlist.h"
|
||||
#include "converter.h"
|
||||
#include "format.h"
|
||||
#include "gettext.h"
|
||||
#include "funcrequest.h"
|
||||
#include "LColor.h"
|
||||
#include "lfuns.h"
|
||||
|
||||
#include "frontends/Dialogs.h"
|
||||
#include "frontends/LyXView.h"
|
||||
@ -30,6 +27,8 @@
|
||||
#include "support/globbing.h"
|
||||
#include "support/path_defines.h"
|
||||
|
||||
#include "support/std_sstream.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
using lyx::support::AddName;
|
||||
@ -37,30 +36,66 @@ using lyx::support::FileFilterList;
|
||||
using lyx::support::system_lyxdir;
|
||||
using lyx::support::user_lyxdir;
|
||||
|
||||
using std::ostringstream;
|
||||
using std::pair;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
|
||||
extern BufferList bufferlist;
|
||||
|
||||
ControlPrefs::ControlPrefs(LyXView & lv, Dialogs & d)
|
||||
: ControlDialogBI(lv, d)
|
||||
: ControlDialogBI(lv, d),
|
||||
redraw_gui_(false),
|
||||
update_screen_font_(false)
|
||||
{}
|
||||
|
||||
|
||||
void ControlPrefs::setParams()
|
||||
{
|
||||
rc_ = lyxrc;
|
||||
formats_ = ::formats;
|
||||
converters_ = ::converters;
|
||||
converters_.update(formats_);
|
||||
colors_.clear();
|
||||
redraw_gui_ = false;
|
||||
update_screen_font_ = false;
|
||||
}
|
||||
|
||||
|
||||
void ControlPrefs::apply()
|
||||
{
|
||||
view().apply();
|
||||
lyxrc = rc_;
|
||||
|
||||
ostringstream ss;
|
||||
rc_.write(ss);
|
||||
lv_.dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str()));
|
||||
|
||||
// FIXME: these need lfuns
|
||||
bufferlist.setCurrentAuthor(rc_.user_name, rc_.user_email);
|
||||
|
||||
::formats = formats_;
|
||||
|
||||
::converters = converters_;
|
||||
::converters.update(::formats);
|
||||
::converters.buildGraph();
|
||||
|
||||
vector<string>::const_iterator it = colors_.begin();
|
||||
vector<string>::const_iterator const end = colors_.end();
|
||||
for (; it != end; ++it)
|
||||
lv_.dispatch(FuncRequest(LFUN_SET_COLOR, *it));
|
||||
colors_.clear();
|
||||
|
||||
if (redraw_gui_) {
|
||||
lv_.getDialogs().redrawGUI();
|
||||
redraw_gui_ = false;
|
||||
}
|
||||
|
||||
if (update_screen_font_) {
|
||||
lv_.dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
|
||||
update_screen_font_ = false;
|
||||
}
|
||||
|
||||
// The Save button has been pressed
|
||||
if (isClosing()) {
|
||||
lv_.dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
|
||||
@ -68,17 +103,31 @@ void ControlPrefs::apply()
|
||||
}
|
||||
|
||||
|
||||
void ControlPrefs::redrawGUI()
|
||||
{
|
||||
redraw_gui_ = true;
|
||||
}
|
||||
|
||||
|
||||
void ControlPrefs::setColor(LColor_color col, string const & hex)
|
||||
{
|
||||
colors_.push_back(lcolor.getLyXName(col) + ' ' + hex);
|
||||
}
|
||||
|
||||
|
||||
void ControlPrefs::updateScreenFonts()
|
||||
{
|
||||
update_screen_font_ = true;
|
||||
}
|
||||
|
||||
|
||||
string const ControlPrefs::browsebind(string const & file) const
|
||||
{
|
||||
string dir = AddName(system_lyxdir(), "bind");
|
||||
// FIXME: stupid name
|
||||
string name = _("System Bind|#S#s");
|
||||
pair<string,string> dir1(name, dir);
|
||||
pair<string,string> dir1(_("System Bind|#S#s"),
|
||||
AddName(system_lyxdir(), "bind"));
|
||||
|
||||
dir = AddName(user_lyxdir(), "bind");
|
||||
// FIXME: stupid name
|
||||
name = _("User Bind|#U#u");
|
||||
pair<string,string> dir2(name, dir);
|
||||
pair<string,string> dir2(_("User Bind|#U#u"),
|
||||
AddName(user_lyxdir(), "bind"));
|
||||
|
||||
return browseFile(file, _("Choose bind file"),
|
||||
FileFilterList("*.bind"), false, dir1, dir2);
|
||||
@ -87,15 +136,11 @@ string const ControlPrefs::browsebind(string const & file) const
|
||||
|
||||
string const ControlPrefs::browseUI(string const & file) const
|
||||
{
|
||||
string dir = AddName(system_lyxdir(), "ui");
|
||||
// FIXME: stupid name
|
||||
string name = _("Sys UI|#S#s");
|
||||
pair<string,string> dir1(name, dir);
|
||||
pair<string,string> const dir1(_("Sys UI|#S#s"),
|
||||
AddName(system_lyxdir(), "ui"));
|
||||
|
||||
dir = AddName(user_lyxdir(), "ui");
|
||||
// FIXME: stupid name
|
||||
name = _("User UI|#U#u");
|
||||
pair<string,string> dir2(name, dir);
|
||||
pair<string,string> const dir2(_("User UI|#U#u"),
|
||||
AddName(user_lyxdir(), "ui"));
|
||||
|
||||
return browseFile(file, _("Choose UI file"),
|
||||
FileFilterList("*.ui"), false, dir1, dir2);
|
||||
@ -104,12 +149,11 @@ string const ControlPrefs::browseUI(string const & file) const
|
||||
|
||||
string const ControlPrefs::browsekbmap(string const & file) const
|
||||
{
|
||||
string const dir = AddName(system_lyxdir(), "kbd");
|
||||
string const name = _("Key maps|#K#k");
|
||||
pair<string, string> dir1(name, dir);
|
||||
pair<string, string> dir(_("Key maps|#K#k"),
|
||||
AddName(system_lyxdir(), "kbd"));
|
||||
|
||||
return browseFile(file, _("Choose keyboard map"),
|
||||
FileFilterList("*.kmap"), false, dir1);
|
||||
FileFilterList("*.kmap"), false, dir);
|
||||
}
|
||||
|
||||
|
||||
@ -132,42 +176,3 @@ string const ControlPrefs::browsedir(string const & path,
|
||||
{
|
||||
return browseDir(path, title);
|
||||
}
|
||||
|
||||
|
||||
void ControlPrefs::redrawGUI()
|
||||
{
|
||||
// we must be sure to get the new values first
|
||||
lyxrc = rc_;
|
||||
|
||||
lv_.getDialogs().redrawGUI();
|
||||
}
|
||||
|
||||
|
||||
void ControlPrefs::setColor(LColor_color col, string const & hex)
|
||||
{
|
||||
string const s = lcolor.getLyXName(col) + ' ' + hex;
|
||||
lv_.dispatch(FuncRequest(LFUN_SET_COLOR, s));
|
||||
}
|
||||
|
||||
|
||||
void ControlPrefs::updateScreenFonts()
|
||||
{
|
||||
// we must be sure to get the new values first
|
||||
lyxrc = rc_;
|
||||
|
||||
lv_.dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
|
||||
}
|
||||
|
||||
|
||||
void ControlPrefs::setConverters(Converters const & conv)
|
||||
{
|
||||
converters = conv;
|
||||
converters.update(formats);
|
||||
converters.buildGraph();
|
||||
}
|
||||
|
||||
|
||||
void ControlPrefs::setFormats(Formats const & form)
|
||||
{
|
||||
formats = form;
|
||||
}
|
||||
|
@ -12,27 +12,30 @@
|
||||
#ifndef CONTROLPREFS_H
|
||||
#define CONTROLPREFS_H
|
||||
|
||||
|
||||
#include "ControlDialog_impl.h"
|
||||
#include "converter.h"
|
||||
#include "format.h"
|
||||
#include "lyxrc.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class Converters;
|
||||
class LColor_color;
|
||||
class Formats;
|
||||
|
||||
|
||||
class ControlPrefs : public ControlDialogBI {
|
||||
public:
|
||||
ControlPrefs(LyXView &, Dialogs &);
|
||||
|
||||
// FIXME: we should probably devolve the individual
|
||||
// settings to methods here. But for now, this will
|
||||
// do
|
||||
|
||||
LyXRC & rc() { return rc_; }
|
||||
|
||||
LyXRC const & rc() const { return rc_; }
|
||||
|
||||
Converters & converters() { return converters_; }
|
||||
Converters const & converters() const { return converters_; }
|
||||
|
||||
Formats & formats() { return formats_; }
|
||||
Formats const & formats() const { return formats_; }
|
||||
|
||||
/// various file pickers
|
||||
std::string const browsebind(std::string const & file) const;
|
||||
std::string const browseUI(std::string const & file) const;
|
||||
@ -56,12 +59,6 @@ public:
|
||||
/// update the screen fonts after change
|
||||
void updateScreenFonts();
|
||||
|
||||
/// set global converters
|
||||
void setConverters(Converters const & conv);
|
||||
|
||||
/// set global formats
|
||||
void setFormats(Formats const & form);
|
||||
|
||||
private:
|
||||
/// get current lyxrc
|
||||
virtual void setParams();
|
||||
@ -71,6 +68,18 @@ private:
|
||||
|
||||
/// temporary lyxrc
|
||||
LyXRC rc_;
|
||||
|
||||
/// temporary converters
|
||||
Converters converters_;
|
||||
|
||||
/// temporary formats
|
||||
Formats formats_;
|
||||
|
||||
/// A list of colors to be dispatched
|
||||
std::vector<std::string> colors_;
|
||||
|
||||
bool redraw_gui_;
|
||||
bool update_screen_font_;
|
||||
};
|
||||
|
||||
#endif // CONTROLPREFS_H
|
||||
|
@ -1,3 +1,8 @@
|
||||
2004-03-31 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* QPrefs.[Ch]:
|
||||
* QPrefsDialog.C: changes due to the changed ControlPrefs interface.
|
||||
|
||||
2004-03-30 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* Dialogs.C (build): added document dialog.
|
||||
|
@ -73,6 +73,18 @@ QPrefs::QPrefs()
|
||||
}
|
||||
|
||||
|
||||
Converters & QPrefs::converters()
|
||||
{
|
||||
return controller().converters();
|
||||
}
|
||||
|
||||
|
||||
Formats & QPrefs::formats()
|
||||
{
|
||||
return controller().formats();
|
||||
}
|
||||
|
||||
|
||||
void QPrefs::build_dialog()
|
||||
{
|
||||
dialog_.reset(new QPrefsDialog(this));
|
||||
@ -287,9 +299,6 @@ void QPrefs::apply()
|
||||
controller().updateScreenFonts();
|
||||
}
|
||||
|
||||
controller().setFormats(formats_);
|
||||
controller().setConverters(converters_);
|
||||
|
||||
QPrefColorsModule * colmod(dialog_->colorsModule);
|
||||
|
||||
unsigned int i;
|
||||
@ -582,11 +591,7 @@ void QPrefs::update_contents()
|
||||
fontmod->screenHugeED->setText(toqstr(tostr(rc.font_sizes[LyXFont::SIZE_HUGE])));
|
||||
fontmod->screenHugerED->setText(toqstr(tostr(rc.font_sizes[LyXFont::SIZE_HUGER])));
|
||||
|
||||
formats_ = formats;
|
||||
|
||||
dialog_->updateFormats();
|
||||
|
||||
converters_ = converters;
|
||||
|
||||
dialog_->updateConverters();
|
||||
}
|
||||
|
@ -13,8 +13,6 @@
|
||||
#define QPREFS_H
|
||||
|
||||
|
||||
#include "converter.h"
|
||||
#include "format.h"
|
||||
#include "ControlPrefs.h"
|
||||
|
||||
#include "Qt2Base.h"
|
||||
@ -22,6 +20,8 @@
|
||||
#include <vector>
|
||||
|
||||
class QPrefsDialog;
|
||||
class Controllers;
|
||||
class Formats;
|
||||
|
||||
class QPrefs
|
||||
: public Qt2CB<ControlPrefs, Qt2DB<QPrefsDialog> >
|
||||
@ -42,14 +42,11 @@ private:
|
||||
/// build the dialog
|
||||
virtual void build_dialog();
|
||||
|
||||
Converters & converters();
|
||||
Formats & formats();
|
||||
|
||||
/// languages
|
||||
std::vector<std::string> lang_;
|
||||
|
||||
/// converters
|
||||
Converters converters_;
|
||||
|
||||
/// formats
|
||||
Formats formats_;
|
||||
};
|
||||
|
||||
#endif // QPREFS_H
|
||||
|
@ -282,8 +282,8 @@ void QPrefsDialog::updateConverters()
|
||||
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(toqstr(cit->prettyname()));
|
||||
convertmod->converterToCO->insertItem(toqstr(cit->prettyname()));
|
||||
@ -291,8 +291,8 @@ void QPrefsDialog::updateConverters()
|
||||
|
||||
convertmod->convertersLB->clear();
|
||||
|
||||
Converters::const_iterator ccit = form_->converters_.begin();
|
||||
Converters::const_iterator cend = form_->converters_.end();
|
||||
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());
|
||||
@ -306,9 +306,9 @@ void QPrefsDialog::updateConverters()
|
||||
|
||||
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));
|
||||
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));
|
||||
}
|
||||
@ -318,13 +318,13 @@ void QPrefsDialog::switch_converter(int nr)
|
||||
// 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()));
|
||||
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(), "", "");
|
||||
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);
|
||||
@ -333,15 +333,15 @@ void QPrefsDialog::new_converter()
|
||||
|
||||
void QPrefsDialog::modify_converter()
|
||||
{
|
||||
Format const & from(form_->formats_.get(convertersModule->converterFromCO->currentItem()));
|
||||
Format const & to(form_->formats_.get(convertersModule->converterToCO->currentItem()));
|
||||
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);
|
||||
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();
|
||||
}
|
||||
@ -349,9 +349,9 @@ void QPrefsDialog::modify_converter()
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@ -362,8 +362,8 @@ void QPrefsDialog::updateFormats()
|
||||
|
||||
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(toqstr(cit->prettyname()));
|
||||
}
|
||||
@ -375,42 +375,42 @@ void QPrefsDialog::updateFormats()
|
||||
|
||||
void QPrefsDialog::switch_format(int nr)
|
||||
{
|
||||
Format const & f(form_->formats_.get(nr));
|
||||
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->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(fromqstr(fileformatsModule->formatED->text()));
|
||||
form_->formats_.erase(oldformat.name());
|
||||
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());
|
||||
|
||||
form_->formats_.add(name, extension, prettyname, shortcut);
|
||||
form_->formats_.sort();
|
||||
form_->formats_.setViewer(name, viewer);
|
||||
form_->formats().add(name, extension, prettyname, shortcut);
|
||||
form_->formats().sort();
|
||||
form_->formats().setViewer(name, viewer);
|
||||
|
||||
fileformatsModule->formatsLB->setUpdatesEnabled(false);
|
||||
updateFormats();
|
||||
@ -426,7 +426,7 @@ void QPrefsDialog::remove_format()
|
||||
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();
|
||||
}
|
||||
|
@ -1,3 +1,8 @@
|
||||
2004-03-31 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* FormPreferences.[Ch]: changes due to the changed ControlPrefs
|
||||
interface.
|
||||
|
||||
2004-03-30 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* Dialogs.C (build): added document dialog.
|
||||
|
@ -24,8 +24,6 @@
|
||||
#include "controllers/helper_funcs.h" // getSecond
|
||||
|
||||
#include "buffer.h"
|
||||
#include "converter.h"
|
||||
#include "format.h"
|
||||
#include "LColor.h"
|
||||
#include "lyxfont.h"
|
||||
|
||||
@ -58,10 +56,6 @@ using std::string;
|
||||
|
||||
namespace {
|
||||
|
||||
// These should probably go inside the class definition...
|
||||
Formats local_formats;
|
||||
Converters local_converters;
|
||||
|
||||
string makeFontName(string const & family, string const & foundry)
|
||||
{
|
||||
if (foundry.empty())
|
||||
@ -291,8 +285,6 @@ void FormPreferences::apply()
|
||||
LyXRC & rc(controller().rc());
|
||||
|
||||
colors_.apply();
|
||||
formats_.apply(); // Must be before converters_.apply()
|
||||
converters_.apply();
|
||||
inputs_misc_.apply(rc);
|
||||
interface_.apply(rc);
|
||||
language_.apply(rc);
|
||||
@ -716,9 +708,15 @@ FD_preferences_converters const * FormPreferences::Converters::dialog()
|
||||
}
|
||||
|
||||
|
||||
void FormPreferences::Converters::apply() const
|
||||
::Converters & FormPreferences::Converters::converters()
|
||||
{
|
||||
parent_.controller().setConverters(local_converters);
|
||||
return parent_.controller().converters();
|
||||
}
|
||||
|
||||
|
||||
::Formats & FormPreferences::Converters::formats()
|
||||
{
|
||||
return parent_.controller().formats();
|
||||
}
|
||||
|
||||
|
||||
@ -802,20 +800,18 @@ bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
|
||||
|
||||
void FormPreferences::Converters::update()
|
||||
{
|
||||
local_converters = converters;
|
||||
local_converters.update(local_formats);
|
||||
UpdateBrowser();
|
||||
}
|
||||
|
||||
|
||||
void FormPreferences::Converters::UpdateBrowser()
|
||||
{
|
||||
local_converters.sort();
|
||||
converters().sort();
|
||||
|
||||
fl_freeze_form(dialog_->form);
|
||||
fl_clear_browser(dialog_->browser_all);
|
||||
for (::Converters::const_iterator cit = local_converters.begin();
|
||||
cit != local_converters.end(); ++cit) {
|
||||
for (::Converters::const_iterator cit = converters().begin();
|
||||
cit != converters().end(); ++cit) {
|
||||
string const name = cit->From->prettyname() + " -> "
|
||||
+ cit->To->prettyname();
|
||||
fl_addto_browser(dialog_->browser_all, name.c_str());
|
||||
@ -832,10 +828,10 @@ bool FormPreferences::Converters::Add()
|
||||
string const command = fl_get_input(dialog_->input_converter);
|
||||
string const flags = fl_get_input(dialog_->input_flags);
|
||||
|
||||
Converter const * old = local_converters.getConverter(from, to);
|
||||
local_converters.add(from, to, command, flags);
|
||||
Converter const * old = converters().getConverter(from, to);
|
||||
converters().add(from, to, command, flags);
|
||||
if (!old) {
|
||||
local_converters.updateLast(local_formats);
|
||||
converters().updateLast(formats());
|
||||
UpdateBrowser();
|
||||
}
|
||||
setEnabled(dialog_->button_add, false);
|
||||
@ -851,12 +847,12 @@ bool FormPreferences::Converters::Browser()
|
||||
|
||||
fl_freeze_form(dialog_->form);
|
||||
|
||||
Converter const & c = local_converters.get(i - 1);
|
||||
int j = local_formats.getNumber(c.from);
|
||||
Converter const & c = converters().get(i - 1);
|
||||
int j = formats().getNumber(c.from);
|
||||
if (j >= 0)
|
||||
fl_set_choice(dialog_->choice_from, j + 1);
|
||||
|
||||
j = local_formats.getNumber(c.to);
|
||||
j = formats().getNumber(c.to);
|
||||
if (j >= 0)
|
||||
fl_set_choice(dialog_->choice_to, j + 1);
|
||||
|
||||
@ -880,7 +876,7 @@ bool FormPreferences::Converters::erase()
|
||||
string const from = GetFrom();
|
||||
string const to = GetTo();
|
||||
|
||||
local_converters.erase(from, to);
|
||||
converters().erase(from, to);
|
||||
UpdateBrowser();
|
||||
return true;
|
||||
}
|
||||
@ -890,7 +886,7 @@ bool FormPreferences::Converters::Input()
|
||||
{
|
||||
string const from = GetFrom();
|
||||
string const to = GetTo();
|
||||
int const sel = local_converters.getNumber(from, to);
|
||||
int const sel = converters().getNumber(from, to);
|
||||
|
||||
fl_freeze_form(dialog_->form);
|
||||
|
||||
@ -924,37 +920,37 @@ bool FormPreferences::Converters::Input()
|
||||
}
|
||||
|
||||
|
||||
string const FormPreferences::Converters::GetFrom() const
|
||||
string const FormPreferences::Converters::GetFrom()
|
||||
{
|
||||
::Formats::FormatList::size_type const i =
|
||||
fl_get_choice(dialog_->choice_from);
|
||||
|
||||
if (i > 0 && i <= local_formats.size())
|
||||
return local_formats.get(i - 1).name();
|
||||
if (i > 0 && i <= formats().size())
|
||||
return formats().get(i - 1).name();
|
||||
|
||||
lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
|
||||
return "???";
|
||||
}
|
||||
|
||||
|
||||
string const FormPreferences::Converters::GetTo() const
|
||||
string const FormPreferences::Converters::GetTo()
|
||||
{
|
||||
::Formats::FormatList::size_type const i =
|
||||
fl_get_choice(dialog_->choice_to);
|
||||
|
||||
if (i > 0 && i <= local_formats.size())
|
||||
return local_formats.get(i - 1).name();
|
||||
if (i > 0 && i <= formats().size())
|
||||
return formats().get(i - 1).name();
|
||||
|
||||
lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
|
||||
return "???";
|
||||
}
|
||||
|
||||
|
||||
void FormPreferences::Converters::UpdateChoices() const
|
||||
void FormPreferences::Converters::UpdateChoices()
|
||||
{
|
||||
string choice;
|
||||
for (::Formats::const_iterator cit = local_formats.begin();
|
||||
cit != local_formats.end(); ++cit) {
|
||||
for (::Formats::const_iterator cit = formats().begin();
|
||||
cit != formats().end(); ++cit) {
|
||||
if (!choice.empty())
|
||||
choice += " | ";
|
||||
else
|
||||
@ -982,9 +978,15 @@ FD_preferences_formats const * FormPreferences::Formats::dialog()
|
||||
}
|
||||
|
||||
|
||||
void FormPreferences::Formats::apply() const
|
||||
::Converters & FormPreferences::Formats::converters()
|
||||
{
|
||||
parent_.controller().setFormats(local_formats);
|
||||
return parent_.controller().converters();
|
||||
}
|
||||
|
||||
|
||||
::Formats & FormPreferences::Formats::formats()
|
||||
{
|
||||
return parent_.controller().formats();
|
||||
}
|
||||
|
||||
|
||||
@ -1075,20 +1077,19 @@ bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
|
||||
|
||||
void FormPreferences::Formats::update()
|
||||
{
|
||||
local_formats = formats;
|
||||
UpdateBrowser();
|
||||
}
|
||||
|
||||
|
||||
void FormPreferences::Formats::UpdateBrowser()
|
||||
{
|
||||
local_formats.sort();
|
||||
formats().sort();
|
||||
|
||||
fl_freeze_form(dialog_->form);
|
||||
fl_deselect_browser(dialog_->browser_all);
|
||||
fl_clear_browser(dialog_->browser_all);
|
||||
for (::Formats::const_iterator cit = local_formats.begin();
|
||||
cit != local_formats.end(); ++cit)
|
||||
for (::Formats::const_iterator cit = formats().begin();
|
||||
cit != formats().end(); ++cit)
|
||||
fl_addto_browser(dialog_->browser_all,
|
||||
cit->prettyname().c_str());
|
||||
|
||||
@ -1097,7 +1098,7 @@ void FormPreferences::Formats::UpdateBrowser()
|
||||
|
||||
// Mustn't forget to update the Formats available to the converters_
|
||||
parent_.converters_.UpdateChoices();
|
||||
local_converters.update(local_formats);
|
||||
converters().update(formats());
|
||||
}
|
||||
|
||||
|
||||
@ -1109,10 +1110,10 @@ bool FormPreferences::Formats::Add()
|
||||
string const shortcut = fl_get_input(dialog_->input_shrtcut);
|
||||
string const viewer = fl_get_input(dialog_->input_viewer);
|
||||
|
||||
Format const * old = local_formats.getFormat(name);
|
||||
Format const * old = formats().getFormat(name);
|
||||
string const old_prettyname = old ? old->prettyname() : string();
|
||||
local_formats.add(name, extension, prettyname, shortcut);
|
||||
local_formats.setViewer(name, viewer);
|
||||
formats().add(name, extension, prettyname, shortcut);
|
||||
formats().setViewer(name, viewer);
|
||||
if (!old || prettyname != old_prettyname) {
|
||||
UpdateBrowser();
|
||||
if (old)
|
||||
@ -1132,7 +1133,7 @@ bool FormPreferences::Formats::Browser()
|
||||
|
||||
fl_freeze_form(dialog_->form);
|
||||
|
||||
Format const & f = local_formats.get(i - 1);
|
||||
Format const & f = formats().get(i - 1);
|
||||
|
||||
fl_set_input(dialog_->input_format, f.name().c_str());
|
||||
fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
|
||||
@ -1157,14 +1158,14 @@ bool FormPreferences::Formats::erase()
|
||||
{
|
||||
string const name = fl_get_input(dialog_->input_format);
|
||||
|
||||
if (local_converters.formatIsUsed(name)) {
|
||||
if (converters().formatIsUsed(name)) {
|
||||
parent_.postWarning(_("Cannot remove a Format used by a Converter. "
|
||||
"Remove the converter first."));
|
||||
setEnabled(dialog_->button_delete, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
local_formats.erase(name);
|
||||
formats().erase(name);
|
||||
UpdateBrowser();
|
||||
return true;
|
||||
}
|
||||
@ -1173,7 +1174,7 @@ bool FormPreferences::Formats::erase()
|
||||
bool FormPreferences::Formats::Input()
|
||||
{
|
||||
string const name = fl_get_input(dialog_->input_format);
|
||||
int const sel = local_formats.getNumber(name);
|
||||
int const sel = formats().getNumber(name);
|
||||
fl_freeze_form(dialog_->form);
|
||||
|
||||
if (sel < 0) {
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
class ControlPrefs;
|
||||
class Converters;
|
||||
class Formats;
|
||||
|
||||
class Dialogs;
|
||||
class FormColorpicker;
|
||||
@ -142,8 +144,6 @@ private:
|
||||
///
|
||||
FD_preferences_converters const * dialog();
|
||||
///
|
||||
void apply() const;
|
||||
///
|
||||
void build();
|
||||
///
|
||||
std::string const feedback(FL_OBJECT const * const) const;
|
||||
@ -154,7 +154,7 @@ private:
|
||||
///
|
||||
void UpdateBrowser();
|
||||
///
|
||||
void UpdateChoices() const;
|
||||
void UpdateChoices();
|
||||
|
||||
private:
|
||||
///
|
||||
@ -166,9 +166,12 @@ private:
|
||||
///
|
||||
bool Input();
|
||||
///
|
||||
std::string const GetFrom() const;
|
||||
std::string const GetFrom();
|
||||
///
|
||||
std::string const GetTo() const;
|
||||
std::string const GetTo();
|
||||
///
|
||||
::Converters & converters();
|
||||
::Formats & formats();
|
||||
|
||||
///
|
||||
FormPreferences & parent_;
|
||||
@ -186,8 +189,6 @@ private:
|
||||
///
|
||||
FD_preferences_formats const * dialog();
|
||||
///
|
||||
void apply() const;
|
||||
///
|
||||
void build();
|
||||
///
|
||||
std::string const feedback(FL_OBJECT const * const) const;
|
||||
@ -207,6 +208,9 @@ private:
|
||||
bool erase();
|
||||
///
|
||||
bool Input();
|
||||
//
|
||||
::Converters & converters();
|
||||
::Formats & formats();
|
||||
|
||||
///
|
||||
FormPreferences & parent_;
|
||||
|
@ -347,6 +347,7 @@ enum kb_action {
|
||||
LFUN_SAVE_AS_DEFAULT,
|
||||
LFUN_BUFFERPARAMS_APPLY,
|
||||
// 265
|
||||
LFUN_LYXRC_APPLY,
|
||||
|
||||
LFUN_LASTACTION // end of the table
|
||||
};
|
||||
|
@ -506,6 +506,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
||||
case LFUN_TEXTCLASS_LOAD:
|
||||
case LFUN_SAVE_AS_DEFAULT:
|
||||
case LFUN_BUFFERPARAMS_APPLY:
|
||||
case LFUN_LYXRC_APPLY:
|
||||
|
||||
// these are handled in our dispatch()
|
||||
break;
|
||||
@ -1367,6 +1368,18 @@ void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose)
|
||||
loadTextclass(argument);
|
||||
break;
|
||||
|
||||
case LFUN_LYXRC_APPLY: {
|
||||
istringstream ss(argument);
|
||||
bool const success = lyxrc.read(ss) == 0;
|
||||
|
||||
if (!success) {
|
||||
lyxerr << "Warning in LFUN_LYXRC_APPLY!\n"
|
||||
<< "Unable to read lyxrc data"
|
||||
<< endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
DispatchResult res = view()->cursor().dispatch(cmd);
|
||||
if (!res.dispatched());
|
||||
|
33
src/lyxrc.C
33
src/lyxrc.C
@ -303,6 +303,29 @@ int LyXRC::read(string const & filename)
|
||||
|
||||
lyxerr[Debug::LYXRC] << "Reading '" << filename << "'..." << endl;
|
||||
|
||||
return read(lexrc);
|
||||
}
|
||||
|
||||
|
||||
int LyXRC::read(std::istream & is)
|
||||
{
|
||||
LyXLex lexrc(lyxrcTags, lyxrcCount);
|
||||
if (lyxerr.debugging(Debug::PARSER))
|
||||
lexrc.printTable(lyxerr);
|
||||
|
||||
lexrc.setStream(is);
|
||||
if (!lexrc.isOK()) return -2;
|
||||
|
||||
lyxerr[Debug::LYXRC] << "Reading istream..." << endl;
|
||||
|
||||
return read(lexrc);
|
||||
}
|
||||
|
||||
|
||||
int LyXRC::read(LyXLex & lexrc)
|
||||
{
|
||||
if (!lexrc.isOK()) return -2;
|
||||
|
||||
while (lexrc.isOK()) {
|
||||
// By using two switches we take advantage of the compiler
|
||||
// telling us if we have missed a LyXRCTags element in
|
||||
@ -569,7 +592,7 @@ int LyXRC::read(string const & filename)
|
||||
dpi = lexrc.getInteger();
|
||||
}
|
||||
break;
|
||||
|
||||
1G
|
||||
case RC_SCREEN_ZOOM:
|
||||
if (lexrc.next()) {
|
||||
zoom = lexrc.getInteger();
|
||||
@ -1052,20 +1075,20 @@ void LyXRC::write(string const & filename) const
|
||||
{
|
||||
ofstream ofs(filename.c_str());
|
||||
if (ofs)
|
||||
output(ofs);
|
||||
write(ofs);
|
||||
}
|
||||
|
||||
|
||||
void LyXRC::print() const
|
||||
{
|
||||
if (lyxerr.debugging())
|
||||
output(lyxerr);
|
||||
write(lyxerr);
|
||||
else
|
||||
output(cout);
|
||||
write(cout);
|
||||
}
|
||||
|
||||
|
||||
void LyXRC::output(ostream & os) const
|
||||
void LyXRC::write(ostream & os) const
|
||||
{
|
||||
os << "### This file is part of\n"
|
||||
<< "### ========================================================\n"
|
||||
|
12
src/lyxrc.h
12
src/lyxrc.h
@ -21,8 +21,10 @@
|
||||
#include "paper.h"
|
||||
#include "graphics/GraphicsTypes.h"
|
||||
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
|
||||
class LyXLex;
|
||||
|
||||
/// This contains the runtime configuration of LyX
|
||||
class LyXRC //: public noncopyable {
|
||||
@ -139,12 +141,18 @@ enum LyXRCTags {
|
||||
void setDefaults();
|
||||
///
|
||||
int read(std::string const & filename);
|
||||
///
|
||||
int read(std::istream &);
|
||||
private:
|
||||
///
|
||||
int read(LyXLex &);
|
||||
public:
|
||||
///
|
||||
void write(std::string const & filename) const;
|
||||
///
|
||||
void print() const;
|
||||
void write(std::ostream & os) const;
|
||||
///
|
||||
void output(std::ostream & os) const;
|
||||
void print() const;
|
||||
///
|
||||
static std::string const getDescription(LyXRCTags);
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user