]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiBox.cpp
Use <cstdint> instead of <boost/cstdint.hpp>
[lyx.git] / src / frontends / qt4 / GuiBox.cpp
index afc646281fcd6ca8fc5cc4fe01ff3e7063304b3a..6a991b5df5063e4fc6a61827c70397038ed76466 100644 (file)
@@ -26,7 +26,6 @@
 #include "insets/InsetBox.h"
 
 #include "support/gettext.h"
-#include "support/foreach.h"
 #include "support/lstrings.h"
 
 #include <QComboBox>
@@ -103,19 +102,6 @@ static QList<ColorCode> colors()
 }
 
 
-namespace {
-
-struct ColorSorter
-{
-       bool operator()(ColorCode lhs, ColorCode rhs) const {
-               return
-                       support::compare_no_case(lcolor.getGUIName(lhs), lcolor.getGUIName(rhs)) < 0;
-       }
-};
-
-} // namespace anon
-
-
 GuiBox::GuiBox(QWidget * parent) : InsetParamsWidget(parent)
 {
        setupUi(this);
@@ -169,7 +155,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);
 
@@ -347,14 +333,16 @@ void GuiBox::paramsToDialog(Inset const * inset)
        ialignCO->setEnabled(ibox);
        setSpecial(ibox);
 
-       // halign is only allowed if a width is used
-       halignCO->setEnabled(widthCB->isChecked());
+       // halign is only allowed without inner box and if a width is used and if
+       // pagebreak is not used
+       halignCO->setEnabled(!pagebreakCB->isChecked() && widthCB->isChecked()
+                            && ((!ibox && type == "Boxed") || inner_type == "makebox"));
        // add the entry "Stretch" if the box is \makebox or \framebox and if not already there
        if ((inner_type == "makebox" || (type == "Boxed" && inner_type == "none"))
                && halignCO->count() < 4)
-               halignCO->addItem(toqstr("Stretch"));
+               halignCO->addItem(qt_("Stretch"));
        else if (inner_type != "makebox" && (type != "Boxed" && inner_type != "none"))
-               halignCO->removeItem(3); 
+               halignCO->removeItem(3);
        // pagebreak is only allowed for Boxed without inner box
        pagebreakCB->setEnabled(!ibox && type == "Boxed");
 
@@ -451,7 +439,7 @@ docstring GuiBox::dialogToParams() const
                if (ids_spec_.contains(unit) && !isValidLength(fromqstr(value))) {
                        params.special = fromqstr(unit);
                        // Note: the unit is simply ignored in this case
-                       params.width = Length(value.toDouble(), Length::IN);
+                       params.width = Length(widgetToDouble(widthED), Length::IN);
                } else {
                        params.special = "none";
                        // we must specify a valid length in this case
@@ -477,7 +465,7 @@ docstring GuiBox::dialogToParams() const
                if (ids_spec_.contains(unit) && !isValidLength(fromqstr(value))) {
                        params.height_special = fromqstr(unit);
                        // Note: the unit is simply ignored in this case
-                       params.height = Length(value.toDouble(), Length::IN);
+                       params.height = Length(widgetToDouble(heightED), Length::IN);
                } else {
                        params.height_special = "none";
                        params.height =
@@ -560,12 +548,14 @@ bool GuiBox::checkWidgets(bool readonly) const
                        widthED->setEnabled(false);
                        widthUnitsLC->setEnabled(false);
                }
-               // halign is only allowed if a width is used
-               halignCO->setEnabled(widthCB->isChecked());
+               // halign is only allowed without inner box and if a width is used and if
+               // pagebreak is not used
+               halignCO->setEnabled(!pagebreakCB->isChecked() && widthCB->isChecked()
+                                    && ((!ibox && outer == "Boxed") || itype == "makebox"));
                // add the entry "Stretch" if the box is \makebox or \framebox and if not already there
                if ((itype == "makebox" || (outer == "Boxed" && itype == "none"))
                        && halignCO->count() < 4)
-                       halignCO->addItem(toqstr("Stretch"));
+                       halignCO->addItem(qt_("Stretch"));
                else if (itype != "makebox" && (outer != "Boxed" && itype != "none"))
                        halignCO->removeItem(3);
                // pagebreak is only allowed for Boxed without inner box