]> 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 adc107e2151d460b42414648b98f9df983b1c89b..c76aeaf2b5ecdccbf5121b1b9c6be08c75b146fd 100644 (file)
@@ -105,13 +105,10 @@ static QList<ColorCode> colors()
 
 namespace {
 
-struct ColorSorter
+bool ColorSorter(ColorCode lhs, ColorCode rhs)
 {
-       bool operator()(ColorCode lhs, ColorCode rhs) const {
-               return
-                       support::compare_no_case(lcolor.getGUIName(lhs), lcolor.getGUIName(rhs)) < 0;
-       }
-};
+       return support::compare_no_case(lcolor.getGUIName(lhs), lcolor.getGUIName(rhs)) < 0;
+}
 
 } // namespace anon
 
@@ -151,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));
@@ -169,7 +166,7 @@ GuiBox::GuiBox(QWidget * parent) : InsetParamsWidget(parent)
 
        // the background can be uncolored while the frame cannot
        color_codes_ = colors();
-       sort(color_codes_.begin(), color_codes_.end(), ColorSorter());
+       qSort(color_codes_.begin(), color_codes_.end(), ColorSorter);
        fillComboColor(backgroundColorCO, true);
        fillComboColor(frameColorCO, false);
 
@@ -246,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(
@@ -255,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)));
        }