2 * \file FormCharacter.C
3 * Copyright 2001 The LyX Team.
4 * See the file COPYING.
6 * \author Edwin Leuven, leuven@fee.uva.nl
11 #include "chardlgimpl.h"
12 #include "FormCharacter.h"
13 #include "bufferview_funcs.h"
16 #include "QtLyXView.h"
20 #include "support/lstrings.h"
23 using Liason::setMinibuffer;
25 FormCharacter::FormCharacter(LyXView *v, Dialogs *d)
26 : dialog_(0), lv_(v), d_(d), h_(0), u_(0)
28 // let the dialog be shown
29 // This is a permanent connection so we won't bother
30 // storing a copy because we won't be disconnecting.
31 d->showLayoutCharacter.connect(slot(this, &FormCharacter::show));
33 d->setUserFreeFont.connect(slot(this, &FormCharacter::apply));
37 FormCharacter::~FormCharacter()
43 void FormCharacter::apply()
45 if (!lv_->view()->available() || !dialog_)
48 LyXFont font = dialog_->getChar();
50 if (dialog_->langItem()==1)
51 font.setLanguage(lv_->buffer()->params.language);
53 ToggleAndShow(lv_->view(), font, dialog_->toggleAll());
54 lv_->view()->setState();
55 lv_->buffer()->markDirty();
56 setMinibuffer(lv_, _("Character set"));
59 void FormCharacter::show()
62 dialog_ = new CharDlgImpl(this, 0, _("Character Options"), false);
64 for (Languages::const_iterator cit = languages.begin();
65 cit != languages.end(); ++cit) {
66 const string language = (*cit).second.lang();
67 dialog_->lang->insertItem( tostr(language).c_str(), -1 );
71 if (!dialog_->isVisible()) {
72 h_ = d_->hideBufferDependent.connect(slot(this, &FormCharacter::hide));
73 u_ = d_->updateBufferDependent.connect(slot(this, &FormCharacter::update));
77 dialog_->setActiveWindow();
82 void FormCharacter::close()
88 void FormCharacter::hide()
94 void FormCharacter::update(bool)
97 if (!lv_->view()->available())
100 dialog_->setReadOnly(lv_->buffer()->isReadonly());