#include "support/lstrings.h"
#include <QAbstractItemModel>
+#include <QPushButton>
#include <QComboBox>
+#include <QMenu>
#include <QModelIndex>
#include <QSettings>
#include <QVariant>
static QList<SizePair> sizeData()
{
QList<SizePair> sizes;
- sizes << SizePair(qt_("No change"), FONT_SIZE_IGNORE);
- sizes << SizePair(qt_("Default"), FONT_SIZE_INHERIT);
- sizes << SizePair(qt_("Tiny"), FONT_SIZE_TINY);
- sizes << SizePair(qt_("Smallest"), FONT_SIZE_SCRIPT);
- sizes << SizePair(qt_("Smaller"), FONT_SIZE_FOOTNOTE);
- sizes << SizePair(qt_("Small"), FONT_SIZE_SMALL);
- sizes << SizePair(qt_("Normal"), FONT_SIZE_NORMAL);
- sizes << SizePair(qt_("Large"), FONT_SIZE_LARGE);
- sizes << SizePair(qt_("Larger"), FONT_SIZE_LARGER);
- sizes << SizePair(qt_("Largest"), FONT_SIZE_LARGEST);
- sizes << SizePair(qt_("Huge"), FONT_SIZE_HUGE);
- sizes << SizePair(qt_("Huger"), FONT_SIZE_HUGER);
- sizes << SizePair(qt_("Increase"), FONT_SIZE_INCREASE);
- sizes << SizePair(qt_("Decrease"), FONT_SIZE_DECREASE);
+ sizes << SizePair(qt_("No change"), IGNORE_SIZE);
+ sizes << SizePair(qt_("Default"), INHERIT_SIZE);
+ sizes << SizePair(qt_("Tiny"), TINY_SIZE);
+ sizes << SizePair(qt_("Smallest"), SCRIPT_SIZE);
+ sizes << SizePair(qt_("Smaller"), FOOTNOTE_SIZE);
+ sizes << SizePair(qt_("Small"), SMALL_SIZE);
+ sizes << SizePair(qt_("Normal"), NORMAL_SIZE);
+ sizes << SizePair(qt_("Large"), LARGE_SIZE);
+ sizes << SizePair(qt_("Larger"), LARGER_SIZE);
+ sizes << SizePair(qt_("Largest"), LARGEST_SIZE);
+ sizes << SizePair(qt_("Huge"), HUGE_SIZE);
+ sizes << SizePair(qt_("Huger"), HUGER_SIZE);
+ sizes << SizePair(qt_("Increase"), INCREASE_SIZE);
+ sizes << SizePair(qt_("Decrease"), DECREASE_SIZE);
return sizes;
}
{
setupUi(this);
+ // fix height to minimum
+ setFixedHeight(sizeHint().height());
+
connect(buttonBox, SIGNAL(clicked(QAbstractButton *)),
this, SLOT(slotButtonBox(QAbstractButton *)));
connect(autoapplyCB, SIGNAL(stateChanged(int)), this,
bc().setOK(buttonBox->button(QDialogButtonBox::Ok));
bc().setApply(buttonBox->button(QDialogButtonBox::Apply));
bc().setCancel(buttonBox->button(QDialogButtonBox::Cancel));
+ bc().setRestore(buttonBox->button(QDialogButtonBox::Reset));
bc().setAutoApply(autoapplyCB);
bc().addReadOnly(familyCO);
bc().addReadOnly(seriesCO);
bc().addReadOnly(colorCO);
bc().addReadOnly(autoapplyCB);
+ // Add button menu to restore button to reset
+ // all widgets to "Defaults" or "No Change"
+ resetdefault_ = new QAction(qt_("Reset All To &Default"), this);
+ resetnochange_ = new QAction(qt_("Reset All To No Chan&ge"), this);
+ QMenu * resetmenu = new QMenu();
+ resetmenu->addAction(resetdefault_);
+ resetmenu->addAction(resetnochange_);
+ buttonBox->button(QDialogButtonBox::RestoreDefaults)->setMenu(resetmenu);
+ buttonBox->button(QDialogButtonBox::RestoreDefaults)->setText(qt_("&Reset All Fields"));
+ connect(resetdefault_, SIGNAL(triggered()), this, SLOT(resetToDefault()));
+ connect(resetnochange_, SIGNAL(triggered()), this, SLOT(resetToNoChange()));
+
#ifdef Q_OS_MAC
// On Mac it's common to have tool windows which are always in the
// foreground and are hidden when the main window is not focused.
}
-
-void GuiCharacter::change_adaptor()
+void GuiCharacter::resetToDefault()
{
- changed();
+ Font font(inherit_font);
+ font.setLanguage(reset_language);
+ paramsToDialog(font);
+ change_adaptor();
+}
- 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();
+void GuiCharacter::resetToNoChange()
+{
+ Font font(ignore_font);
+ font.setLanguage(ignore_language);
+ paramsToDialog(font);
+ change_adaptor();
}
namespace{
-FontState getBar(FontInfo const & fi)
+FontDeco getBar(FontInfo const & fi)
{
if (fi.underbar() == FONT_ON)
return UNDERBAR;
if (fi.underbar() == FONT_IGNORE)
return IGNORE;
+ if (fi.underbar() == FONT_INHERIT)
+ return INHERIT;
+
return NONE;
}
-FontState getStrike(FontInfo const & fi)
+FontDeco getStrike(FontInfo const & fi)
{
if (fi.strikeout() == FONT_ON)
return STRIKEOUT;
if (fi.strikeout() == FONT_IGNORE)
return IGNORE;
+ if (fi.strikeout() == FONT_INHERIT)
+ return INHERIT;
+
return NONE;
}
Qt::CheckState getMarkupState(lyx::FontState fs)
{
switch (fs) {
+ case FONT_INHERIT:
case FONT_OFF:
return Qt::Unchecked;
case FONT_ON:
return Qt::Checked;
case FONT_TOGGLE:
- case FONT_INHERIT:
case FONT_IGNORE:
default:
return Qt::PartiallyChecked;
} // end namespace anon
+void GuiCharacter::change_adaptor()
+{
+ changed();
+
+ checkRestoreDefaults();
+
+ 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();
+}
+
+
+void GuiCharacter::checkRestoreDefaults()
+{
+ if (familyCO->currentIndex() == -1 || seriesCO->currentIndex() == -1
+ || shapeCO->currentIndex() == -1 || sizeCO->currentIndex() == -1
+ || ulineCO->currentIndex() == -1 || strikeCO->currentIndex() == -1
+ || colorCO->currentIndex() == -1 || langCO->currentIndex() == -1)
+ // dialog not yet built
+ return;
+
+ // (De)Activate Restore Defaults menu items
+ resetdefault_->setEnabled(
+ family[familyCO->currentIndex()].second != INHERIT_FAMILY
+ || series[seriesCO->currentIndex()].second != INHERIT_SERIES
+ || shape[shapeCO->currentIndex()].second != INHERIT_SHAPE
+ || size[sizeCO->currentIndex()].second != INHERIT_SIZE
+ || setMarkupState(emphCB->checkState()) != FONT_OFF
+ || setMarkupState(nounCB->checkState()) != FONT_OFF
+ || setMarkupState(nospellcheckCB->checkState()) != FONT_OFF
+ || bar[ulineCO->currentIndex()].second != INHERIT
+ || strike[strikeCO->currentIndex()].second != INHERIT
+ || lcolor.getFromLyXName(fromqstr(colorCO->itemData(colorCO->currentIndex()).toString())) != Color_inherit
+ || languages.getLanguage(fromqstr(language[langCO->currentIndex()].second)) != reset_language);
+
+ resetnochange_->setEnabled(
+ family[familyCO->currentIndex()].second != IGNORE_FAMILY
+ || series[seriesCO->currentIndex()].second != IGNORE_SERIES
+ || shape[shapeCO->currentIndex()].second != IGNORE_SHAPE
+ || size[sizeCO->currentIndex()].second != IGNORE_SIZE
+ || setMarkupState(emphCB->checkState()) != FONT_IGNORE
+ || setMarkupState(nounCB->checkState()) != FONT_IGNORE
+ || setMarkupState(nospellcheckCB->checkState()) != FONT_IGNORE
+ || bar[ulineCO->currentIndex()].second != IGNORE
+ || strike[strikeCO->currentIndex()].second != IGNORE
+ || lcolor.getFromLyXName(fromqstr(colorCO->itemData(colorCO->currentIndex()).toString())) != Color_ignore
+ || languages.getLanguage(fromqstr(language[langCO->currentIndex()].second)) != ignore_language);
+}
+
+
void GuiCharacter::updateContents()
{
if (bufferview()->cursor().selection()) {
}
Paragraph const & par = dit.paragraph();
pos_type const pos = dit.pos();
- Font tmp = par.getFont(bp, pos, font);
+ Font tmp = par.getFontSettings(bp, pos);
if (font.language() != tmp.language())
font.setLanguage(ignore_language);
if (fi.family() != tmp.fontInfo().family())
if (fi.shape() != tmp.fontInfo().shape())
font.fontInfo().setShape(IGNORE_SHAPE);
if (fi.size() != tmp.fontInfo().size())
- font.fontInfo().setSize(FONT_SIZE_IGNORE);
+ font.fontInfo().setSize(IGNORE_SIZE);
if (fi.emph() != tmp.fontInfo().emph())
font.fontInfo().setEmph(FONT_IGNORE);
if (fi.noun() != tmp.fontInfo().noun())
} else
font_ = bufferview()->cursor().current_font;
+ // If we use the buffer language, display "Default"
+ if (font_.language() == buffer().params().language)
+ font_.setLanguage(reset_language);
+
paramsToDialog(font_);
+
+ checkRestoreDefaults();
}
-void GuiCharacter::setBar(FontInfo & fi, FontState val)
+void GuiCharacter::setBar(FontInfo & fi, FontDeco val)
{
switch (val) {
case IGNORE:
}
-void GuiCharacter::setStrike(FontInfo & fi, FontState val)
+void GuiCharacter::setStrike(FontInfo & fi, FontDeco val)
{
switch (val) {
case IGNORE:
if (fi.family() != IGNORE_FAMILY
|| fi.series() != IGNORE_SERIES
|| fi.shape() != IGNORE_SHAPE
- || fi.size() != FONT_SIZE_IGNORE
+ || fi.size() != IGNORE_SIZE
|| getBar(fi) != IGNORE
|| fi.color() != Color_ignore
|| font_.language() != ignore_language)