]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiBox.cpp
do what the FIXME suggested
[lyx.git] / src / frontends / qt4 / GuiBox.cpp
index 1c50d3b7b2ec56885d3b16ae6c5f794a96c980e6..b52d1ea3529c490f393760fe0135caf7ee875787 100644 (file)
 
 #include <QPushButton>
 #include <QLineEdit>
-#include <QCloseEvent>
-
-using std::string;
-using std::vector;
 
+using namespace std;
 
 namespace lyx {
 namespace frontend {
@@ -43,16 +40,17 @@ void box_gui_tokens(vector<string> & ids, vector<docstring> & gui_names)
 {
        char const * const ids_[] = {
                "Frameless", "Boxed", "ovalbox",
-               "Ovalbox", "Shadowbox", "Doublebox"};
+               "Ovalbox", "Shadowbox", "Shaded", "Doublebox"};
        size_t const ids_size = sizeof(ids_) / sizeof(char *);
        ids = vector<string>(ids_, ids_ + ids_size);
        gui_names.clear();
-       gui_names.push_back(_("No frame drawn"));
-       gui_names.push_back(_("Rectangular box"));
-       gui_names.push_back(_("Oval box, thin"));
-       gui_names.push_back(_("Oval box, thick"));
-       gui_names.push_back(_("Shadow box"));
-       gui_names.push_back(_("Double box"));
+       gui_names.push_back(_("No frame"));
+       gui_names.push_back(_("Simple rectangular frame"));
+       gui_names.push_back(_("Oval frame, thin"));
+       gui_names.push_back(_("Oval frame, thick"));
+       gui_names.push_back(_("Drop shadow"));
+       gui_names.push_back(_("Shaded background"));
+       gui_names.push_back(_("Double rectangular frame"));
 }
 
 
@@ -74,10 +72,9 @@ void box_gui_tokens_special_length(vector<string> & ids,
 
 
 GuiBox::GuiBox(GuiView & lv)
-       : GuiDialog(lv, "box"), params_("")
+       : GuiDialog(lv, "box", qt_("Box Settings")), params_("")
 {
        setupUi(this);
-       setViewTitle(_("Box Settings"));
 
        // fill the box type choice
        box_gui_tokens(ids_, gui_names_);
@@ -115,6 +112,8 @@ GuiBox::GuiBox(GuiView & lv)
        connect(innerBoxCO, SIGNAL(activated(const QString&)),
                this, SLOT(innerBoxChanged(const QString &)));
        connect(innerBoxCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
+       connect(pagebreakCB, SIGNAL(stateChanged(int)),
+               this, SLOT(pagebreakClicked()));
 
        heightED->setValidator(unsignedLengthValidator(heightED));
        widthED->setValidator(unsignedLengthValidator(widthED));
@@ -131,6 +130,7 @@ GuiBox::GuiBox(GuiView & lv)
        bc().addReadOnly(heightCB);
        bc().addReadOnly(heightED);
        bc().addReadOnly(heightUnitsLC);
+       bc().addReadOnly(pagebreakCB);
 
        bc().setRestore(restorePB);
        bc().setOK(okPB);
@@ -143,13 +143,6 @@ GuiBox::GuiBox(GuiView & lv)
 }
 
 
-void GuiBox::closeEvent(QCloseEvent * e)
-{
-       slotClose();
-       e->accept();
-}
-
-
 void GuiBox::change_adaptor()
 {
        changed();
@@ -183,6 +176,9 @@ void GuiBox::typeChanged(int index)
                heightUnitsLC->setEnabled(true);
                setSpecial(true);
        }
+       if (index != 1)
+               pagebreakCB->setChecked(false);
+       pagebreakCB->setEnabled(index == 1);
        int itype = innerBoxCO->currentIndex();
        setInnerType(frameless, itype);
 }
@@ -202,9 +198,34 @@ void GuiBox::restoreClicked()
 }
 
 
+void GuiBox::pagebreakClicked()
+{
+       bool pbreak = (pagebreakCB->checkState() == Qt::Checked);
+       innerBoxCO->setEnabled(!pbreak);
+       if (pbreak) {
+               valignCO->setEnabled(false);
+               ialignCO->setEnabled(false);
+               halignCO->setEnabled(false);
+               heightCB->setEnabled(false);
+               heightED->setEnabled(false);
+               heightUnitsLC->setEnabled(false);
+               setSpecial(false);
+       } else
+               typeChanged(typeCO->currentIndex());
+       change_adaptor();
+}
+
 void GuiBox::updateContents()
 {
        string type = params_.type;
+       if (type == "Framed") {
+               pagebreakCB->setChecked(true);
+               type = "Boxed";
+       } else
+               pagebreakCB->setChecked(false);
+
+       pagebreakCB->setEnabled(type == "Boxed");
+
        for (unsigned int i = 0; i < gui_names_.size(); ++i) {
                if (type == ids_[i])
                        typeCO->setCurrentIndex(i);
@@ -282,10 +303,14 @@ void GuiBox::updateContents()
 
 void GuiBox::applyView()
 {
-       params_.type = ids_[typeCO->currentIndex()];
+       bool pagebreak = pagebreakCB->isChecked();
+       if (pagebreak)
+               params_.type = "Framed";
+       else
+               params_.type = ids_[typeCO->currentIndex()];
 
-       params_.inner_box = innerBoxCO->currentText() != qt_("None");
-       params_.use_parbox = innerBoxCO->currentText() ==  qt_("Parbox");
+       params_.inner_box = (!pagebreak && innerBoxCO->currentText() != qt_("None"));
+       params_.use_parbox = (!pagebreak && innerBoxCO->currentText() == qt_("Parbox"));
 
        params_.pos = "tcb"[valignCO->currentIndex()];
        params_.inner_pos = "tcbs"[ialignCO->currentIndex()];