static QList<ColorCode> colors()
{
QList<ColorCode> colors;
- colors << Color_none;
colors << Color_black;
colors << Color_white;
colors << Color_blue;
}
+namespace {
+
+bool ColorSorter(ColorCode lhs, ColorCode rhs)
+{
+ return support::compare_no_case(lcolor.getGUIName(lhs), lcolor.getGUIName(rhs)) < 0;
+}
+
+} // namespace anon
+
+
GuiBox::GuiBox(QWidget * parent) : InsetParamsWidget(parent)
{
setupUi(this);
connect(shadowsizeED, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
connect(shadowsizeUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
this, SIGNAL(changed()));
- connect(frameColorCO, SIGNAL(highlighted(QString)), this, SIGNAL(changed()));
- connect(backgroundColorCO, SIGNAL(highlighted(QString)), this, SIGNAL(changed()));
+ connect(backgroundColorCO, SIGNAL(currentIndexChanged(int)),
+ this, SIGNAL(changed()));
heightED->setValidator(unsignedLengthValidator(heightED));
widthED->setValidator(unsignedLengthValidator(widthED));
// the background can be uncolored while the frame cannot
color_codes_ = colors();
- fillComboColor(frameColorCO, false);
+ qSort(color_codes_.begin(), color_codes_.end(), ColorSorter);
fillComboColor(backgroundColorCO, true);
+ fillComboColor(frameColorCO, false);
initDialog();
}
void GuiBox::fillComboColor(QComboBox * combo, bool const is_none)
{
+ combo->clear();
QPixmap coloritem(32, 32);
QColor color;
// frameColorCO cannot be uncolored
if (is_none)
combo->addItem(toqstr(translateIfPossible(lcolor.getGUIName(Color_none))),
toqstr(lcolor.getLaTeXName(Color_none)));
- QList<ColorCode>::const_iterator cit = color_codes_.begin() + 1;
+ QList<ColorCode>::const_iterator cit = color_codes_.begin();
for (; cit != color_codes_.end(); ++cit) {
QString const latexname = toqstr(lcolor.getLaTeXName(*cit));
QString const guiname = toqstr(translateIfPossible(lcolor.getGUIName(*cit)));
{
// if there is a non-black frame color the background cannot be uncolored
// therefore remove the entry "none" in this case
+ int const n = backgroundColorCO->findData("none");
if (index != frameColorCO->findData("black")) {
- int const n = backgroundColorCO->findData("none");
if (n != -1) {
if (backgroundColorCO->currentIndex() == n)
backgroundColorCO->setCurrentIndex(
backgroundColorCO->removeItem(n);
}
} else {
- if (backgroundColorCO->count() == color_codes_.count() - 1)
+ if (n == -1)
backgroundColorCO->insertItem(0, toqstr(translateIfPossible((lcolor.getGUIName(Color_none)))),
toqstr(lcolor.getLaTeXName(Color_none)));
}