2 * \file FormCharacter.C
3 * Copyright 2001 The LyX Team.
4 * See the file COPYING.
6 * \author Edwin Leuven, leuven@fee.uva.nl
12 #include "chardlgimpl.h"
13 #include "FormCharacter.h"
14 #include "bufferview_funcs.h"
17 #include "QtLyXView.h"
21 #include "support/lstrings.h"
24 using Liason::setMinibuffer;
26 FormCharacter::FormCharacter(LyXView *v, Dialogs *d)
27 : dialog_(0), lv_(v), d_(d), h_(0), u_(0)
29 // let the dialog be shown
30 // This is a permanent connection so we won't bother
31 // storing a copy because we won't be disconnecting.
32 d->showLayoutCharacter.connect(slot(this, &FormCharacter::show));
34 d->setUserFreeFont.connect(slot(this, &FormCharacter::apply));
38 FormCharacter::~FormCharacter()
44 void FormCharacter::apply()
46 if (!lv_->view()->available() || !dialog_)
49 LyXFont font = dialog_->getChar();
51 if (dialog_->langItem()==1)
52 font.setLanguage(lv_->buffer()->params.language);
54 ToggleAndShow(lv_->view(), font, dialog_->toggleAll());
55 lv_->view()->setState();
56 lv_->buffer()->markDirty();
57 setMinibuffer(lv_, _("Character set"));
60 void FormCharacter::show()
63 dialog_ = new CharDlgImpl(this, 0, _("Character Options"), false);
65 for (Languages::const_iterator cit = languages.begin();
66 cit != languages.end(); ++cit) {
67 const string language = (*cit).second.lang();
68 dialog_->lang->insertItem( tostr(language).c_str(), -1 );
72 if (!dialog_->isVisible()) {
73 h_ = d_->hideBufferDependent.connect(slot(this, &FormCharacter::hide));
74 u_ = d_->updateBufferDependent.connect(slot(this, &FormCharacter::update));
78 dialog_->setActiveWindow();
83 void FormCharacter::close()
89 void FormCharacter::hide()
95 void FormCharacter::update(bool)
98 if (!lv_->view()->available())
101 dialog_->setReadOnly(lv_->buffer()->isReadonly());