2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiCharacter.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Edwin Leuven
|
|
|
|
* \author John Levon
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiCharacter.h"
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
#include "ControlCharacter.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "qt_helpers.h"
|
2007-08-31 22:16:11 +00:00
|
|
|
#include "frontend_helpers.h"
|
2007-04-26 17:34:20 +00:00
|
|
|
#include "Color.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-04-25 10:57:54 +00:00
|
|
|
#include <QCloseEvent>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
using std::vector;
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
GuiCharacterDialog::GuiCharacterDialog(LyXView & lv)
|
|
|
|
: GuiDialog(lv, "character")
|
2007-04-25 10:57:54 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
2007-09-05 20:33:29 +00:00
|
|
|
setController(new ControlCharacter(*this));
|
|
|
|
setViewTitle(_("Text Style"));
|
|
|
|
|
|
|
|
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
|
|
|
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
|
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
2007-04-25 10:57:54 +00:00
|
|
|
|
|
|
|
connect(miscCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
|
|
|
|
connect(sizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
|
|
|
|
connect(familyCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
|
|
|
|
connect(seriesCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
|
|
|
|
connect(shapeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
|
|
|
|
connect(colorCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
|
|
|
|
connect(langCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
|
|
|
|
connect(toggleallCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
family = getFamilyData();
|
|
|
|
series = getSeriesData();
|
|
|
|
shape = getShapeData();
|
|
|
|
size = getSizeData();
|
|
|
|
bar = getBarData();
|
|
|
|
color = getColorData();
|
|
|
|
language = getLanguageData(true);
|
|
|
|
|
|
|
|
for (vector<FamilyPair>::const_iterator cit = family.begin();
|
|
|
|
cit != family.end(); ++cit) {
|
2007-09-05 20:33:29 +00:00
|
|
|
familyCO->addItem(toqstr(cit->first));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (vector<SeriesPair>::const_iterator cit = series.begin();
|
|
|
|
cit != series.end(); ++cit) {
|
2007-09-05 20:33:29 +00:00
|
|
|
seriesCO->addItem(toqstr(cit->first));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
for (vector<ShapePair>::const_iterator cit = shape.begin();
|
|
|
|
cit != shape.end(); ++cit) {
|
2007-09-05 20:33:29 +00:00
|
|
|
shapeCO->addItem(toqstr(cit->first));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
for (vector<SizePair>::const_iterator cit = size.begin();
|
|
|
|
cit != size.end(); ++cit) {
|
2007-09-05 20:33:29 +00:00
|
|
|
sizeCO->addItem(toqstr(cit->first));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
for (vector<BarPair>::const_iterator cit = bar.begin();
|
|
|
|
cit != bar.end(); ++cit) {
|
2007-09-05 20:33:29 +00:00
|
|
|
miscCO->addItem(toqstr(cit->first));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
for (vector<ColorPair>::const_iterator cit = color.begin();
|
|
|
|
cit != color.end(); ++cit) {
|
2007-09-05 20:33:29 +00:00
|
|
|
colorCO->addItem(toqstr(cit->first));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
for (vector<LanguagePair>::const_iterator cit = language.begin();
|
|
|
|
cit != language.end(); ++cit) {
|
2007-09-05 20:33:29 +00:00
|
|
|
langCO->addItem(toqstr(cit->first));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
|
|
|
|
bc().setOK(okPB);
|
|
|
|
bc().setApply(applyPB);
|
|
|
|
bc().setCancel(closePB);
|
|
|
|
bc().addReadOnly(familyCO);
|
|
|
|
bc().addReadOnly(seriesCO);
|
|
|
|
bc().addReadOnly(sizeCO);
|
|
|
|
bc().addReadOnly(shapeCO);
|
|
|
|
bc().addReadOnly(miscCO);
|
|
|
|
bc().addReadOnly(langCO);
|
|
|
|
bc().addReadOnly(colorCO);
|
|
|
|
bc().addReadOnly(toggleallCB);
|
|
|
|
bc().addReadOnly(autoapplyCB);
|
2006-12-24 11:38:19 +00:00
|
|
|
|
|
|
|
// FIXME: hack to work around resizing bug in Qt >= 4.2
|
2007-03-26 14:06:20 +00:00
|
|
|
// bug verified with Qt 4.2.{0-3} (JSpitzm)
|
|
|
|
#if QT_VERSION >= 0x040200
|
2006-12-24 11:38:19 +00:00
|
|
|
// qt resizes the comboboxes only after show(), so ...
|
2007-09-05 20:33:29 +00:00
|
|
|
QDialog::show();
|
2006-12-24 11:38:19 +00:00
|
|
|
#endif
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
ControlCharacter & GuiCharacterDialog::controller() const
|
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
return static_cast<ControlCharacter &>(GuiDialog::controller());
|
2007-09-05 20:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiCharacterDialog::change_adaptor()
|
|
|
|
{
|
|
|
|
changed();
|
|
|
|
|
|
|
|
if (!autoapplyCB->isChecked())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// to be really good here, we should set the combos to the values of
|
|
|
|
// the current text, and make it appear as "no change" if the values
|
|
|
|
// stay the same between applys. Might be difficult though wrt to a
|
|
|
|
// moved cursor - jbl
|
|
|
|
slotApply();
|
|
|
|
familyCO->setCurrentIndex(0);
|
|
|
|
seriesCO->setCurrentIndex(0);
|
|
|
|
sizeCO->setCurrentIndex(0);
|
|
|
|
shapeCO->setCurrentIndex(0);
|
|
|
|
miscCO->setCurrentIndex(0);
|
|
|
|
langCO->setCurrentIndex(0);
|
|
|
|
colorCO->setCurrentIndex(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiCharacterDialog::closeEvent(QCloseEvent * e)
|
|
|
|
{
|
|
|
|
slotWMHide();
|
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
template<class A, class B>
|
2007-09-05 20:33:29 +00:00
|
|
|
static int findPos2nd(vector<std::pair<A,B> > const & vec, B const & val)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
typedef typename vector<std::pair<A, B> >::const_iterator
|
|
|
|
const_iterator;
|
|
|
|
|
|
|
|
const_iterator cit = vec.begin();
|
|
|
|
for (; cit != vec.end(); ++cit) {
|
|
|
|
if (cit->second == val)
|
|
|
|
return int(cit - vec.begin());
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
void GuiCharacterDialog::update_contents()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
ControlCharacter const & ctrl = controller();
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
familyCO->setCurrentIndex(findPos2nd(family,
|
2006-03-05 17:24:44 +00:00
|
|
|
ctrl.getFamily()));
|
2007-09-05 20:33:29 +00:00
|
|
|
seriesCO->setCurrentIndex(findPos2nd(series,
|
2006-03-05 17:24:44 +00:00
|
|
|
ctrl.getSeries()));
|
2007-09-05 20:33:29 +00:00
|
|
|
shapeCO->setCurrentIndex(findPos2nd(shape, ctrl.getShape()));
|
|
|
|
sizeCO->setCurrentIndex(findPos2nd(size, ctrl.getSize()));
|
|
|
|
miscCO->setCurrentIndex(findPos2nd(bar, ctrl.getBar()));
|
|
|
|
colorCO->setCurrentIndex(findPos2nd(color, ctrl.getColor()));
|
|
|
|
langCO->setCurrentIndex(findPos2nd(language,
|
2006-03-05 17:24:44 +00:00
|
|
|
ctrl.getLanguage()));
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
toggleallCB->setChecked(ctrl.getToggleAll());
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
void GuiCharacterDialog::applyView()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
ControlCharacter & ctrl = controller();
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
ctrl.setFamily(family[familyCO->currentIndex()].second);
|
|
|
|
ctrl.setSeries(series[seriesCO->currentIndex()].second);
|
|
|
|
ctrl.setShape(shape[shapeCO->currentIndex()].second);
|
|
|
|
ctrl.setSize(size[sizeCO->currentIndex()].second);
|
|
|
|
ctrl.setBar(bar[miscCO->currentIndex()].second);
|
|
|
|
ctrl.setColor(color[colorCO->currentIndex()].second);
|
|
|
|
ctrl.setLanguage(language[langCO->currentIndex()].second);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
ctrl.setToggleAll(toggleallCB->isChecked());
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-04-25 10:57:54 +00:00
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiCharacter_moc.cpp"
|