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"
22 using Liason::setMinibuffer;
24 FormCharacter::FormCharacter(LyXView *v, Dialogs *d)
25 : dialog_(0), lv_(v), d_(d), h_(0), u_(0)
27 // let the popup be shown
28 // This is a permanent connection so we won't bother
29 // storing a copy because we won't be disconnecting.
30 d->showLayoutCharacter.connect(slot(this, &FormCharacter::show));
32 d->setUserFreeFont.connect(slot(this, &FormCharacter::apply));
36 FormCharacter::~FormCharacter()
42 void FormCharacter::apply()
44 if (!lv_->view()->available() || !dialog_)
47 LyXFont font = dialog_->getChar();
49 if (dialog_->langItem()==1)
50 font.setLanguage(lv_->buffer()->params.language);
52 ToggleAndShow(lv_->view(), font, dialog_->toggleAll());
53 lv_->view()->setState();
54 lv_->buffer()->markDirty();
55 setMinibuffer(lv_, _("Character set"));
58 void FormCharacter::show()
61 dialog_ = new CharDlgImpl(this, 0, _("Character Options"), false);
63 for (Languages::const_iterator cit = languages.begin();
64 cit != languages.end(); ++cit) {
65 const string language = (*cit).second.lang();
66 dialog_->lang->insertItem( tostr(language).c_str(), -1 );
70 if (!dialog_->isVisible()) {
71 h_ = d_->hideBufferDependent.connect(slot(this, &FormCharacter::hide));
72 u_ = d_->updateBufferDependent.connect(slot(this, &FormCharacter::update));
76 dialog_->setActiveWindow();
81 void FormCharacter::close()
87 void FormCharacter::hide()
93 void FormCharacter::update(bool)
96 if (!lv_->view()->available())
99 dialog_->setReadOnly(lv_->buffer()->isReadonly());