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"
22 #include "BufferView.h"
25 using Liason::setMinibuffer;
27 FormCharacter::FormCharacter(LyXView *v, Dialogs *d)
28 : dialog_(0), lv_(v), d_(d), h_(0), u_(0)
30 // let the dialog be shown
31 // This is a permanent connection so we won't bother
32 // storing a copy because we won't be disconnecting.
33 d->showCharacter.connect(slot(this, &FormCharacter::show));
35 d->setUserFreeFont.connect(slot(this, &FormCharacter::apply));
39 FormCharacter::~FormCharacter()
45 void FormCharacter::apply()
47 if (!lv_->view()->available() || !dialog_)
50 LyXFont font = dialog_->getChar();
52 if (dialog_->langItem()==1)
53 font.setLanguage(lv_->buffer()->params.language);
55 ToggleAndShow(lv_->view(), font, dialog_->toggleAll());
56 lv_->view()->setState();
57 lv_->buffer()->markDirty();
58 setMinibuffer(lv_, _("Character set"));
61 void FormCharacter::show()
64 dialog_ = new CharDlgImpl(this, 0, _("Character Options"), false);
66 for (Languages::const_iterator cit = languages.begin();
67 cit != languages.end(); ++cit) {
68 const string language = (*cit).second.lang();
69 dialog_->lang->insertItem( tostr(language).c_str(), -1 );
73 if (!dialog_->isVisible()) {
74 h_ = d_->hideBufferDependent.connect(slot(this, &FormCharacter::hide));
75 u_ = d_->updateBufferDependent.connect(slot(this, &FormCharacter::update));
79 dialog_->setActiveWindow();
84 void FormCharacter::close()
90 void FormCharacter::hide()
96 void FormCharacter::update(bool)
98 if (!lv_->view()->available())
101 dialog_->setReadOnly(lv_->buffer()->isReadonly());