]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiBox.cpp
Use QFontMetrics information for underlines (and friends) width and position
[lyx.git] / src / frontends / qt4 / GuiBox.cpp
index 123c2868456352d4345e93c08bf6a4611bbcb76e..c76aeaf2b5ecdccbf5121b1b9c6be08c75b146fd 100644 (file)
@@ -80,7 +80,6 @@ static QStringList boxGuiSpecialLengthNames()
 static QList<ColorCode> colors()
 {
        QList<ColorCode> colors;
-       colors << Color_none;
        colors << Color_black;
        colors << Color_white;
        colors << Color_blue;
@@ -104,6 +103,16 @@ static QList<ColorCode> colors()
 }
 
 
+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);
@@ -139,8 +148,8 @@ GuiBox::GuiBox(QWidget * parent) : InsetParamsWidget(parent)
        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));
@@ -157,6 +166,7 @@ GuiBox::GuiBox(QWidget * parent) : InsetParamsWidget(parent)
 
        // the background can be uncolored while the frame cannot
        color_codes_ = colors();
+       qSort(color_codes_.begin(), color_codes_.end(), ColorSorter);
        fillComboColor(backgroundColorCO, true);
        fillComboColor(frameColorCO, false);
 
@@ -173,7 +183,7 @@ void GuiBox::fillComboColor(QComboBox * combo, bool const is_none)
        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)));
@@ -233,8 +243,8 @@ void GuiBox::on_frameColorCO_currentIndexChanged(int index)
 {
        // 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(
@@ -242,7 +252,7 @@ void GuiBox::on_frameColorCO_currentIndexChanged(int index)
                        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)));
        }