]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiParagraph.cpp
Use <cstdint> instead of <boost/cstdint.hpp>
[lyx.git] / src / frontends / qt4 / GuiParagraph.cpp
index 0c8e01aaa434d66d258b13a5a32dd459fa9e1cf4..ab6c9aef8b671cee8386a098c0244fb547c88b0b 100644 (file)
@@ -32,6 +32,7 @@
 #include "support/gettext.h"
 
 #include <QCheckBox>
+#include <QDialogButtonBox>
 #include <QLineEdit>
 #include <QPushButton>
 #include <QSettings>
@@ -49,6 +50,9 @@ GuiParagraph::GuiParagraph(GuiView & lv)
 {
        setupUi(this);
 
+       // fix height to minimum
+       setFixedHeight(sizeHint().height());
+
        connect(alignDefaultRB, SIGNAL(clicked()), this, SLOT(changed()));
        connect(alignJustRB, SIGNAL(clicked()), this, SLOT(changed()));
        connect(alignLeftRB, SIGNAL(clicked()), this, SLOT(changed()));
@@ -66,7 +70,6 @@ GuiParagraph::GuiParagraph(GuiView & lv)
        // foreground and are hidden when the main window is not focused.
        setWindowFlags(Qt::Tool);
        synchronizedViewCB->setChecked(true);
-       closePB->setText(qt_("&Cancel"));
 #else
        synchronizedViewCB->setChecked(false);
 #endif
@@ -154,13 +157,13 @@ LyXAlignment GuiParagraph::getAlignmentFromDialog() const
 void GuiParagraph::on_synchronizedViewCB_toggled()
 {
        bool in_sync = synchronizedViewCB->isChecked();
-       restorePB->setEnabled(!in_sync);
-       applyPB->setEnabled(!in_sync);
-       okPB->setEnabled(!in_sync);
+       buttonBox->button(QDialogButtonBox::Reset)->setEnabled(!in_sync);
+       buttonBox->button(QDialogButtonBox::Apply)->setEnabled(!in_sync);
+       buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!in_sync);
        if (!in_sync)
-               closePB->setText(qt_("&Cancel"));
+               buttonBox->button(QDialogButtonBox::Cancel)->setText(qt_("&Cancel"));
        else
-               closePB->setText(qt_("&Close"));
+               buttonBox->button(QDialogButtonBox::Cancel)->setText(qt_("&Close"));
 }
 
 
@@ -174,32 +177,29 @@ void GuiParagraph::changed()
            && (linespacing->currentIndex() != 4
                || (!linespacingValue->text().endsWith(loc.decimalPoint())
                    && linespacingValue->hasAcceptableInput())))
-               on_applyPB_clicked();
-}
-
-
-void GuiParagraph::on_applyPB_clicked()
-{
-       applyView();
-}
-
-
-void GuiParagraph::on_okPB_clicked()
-{
-       applyView();
-       hide();
-}
-
-
-void GuiParagraph::on_closePB_clicked()
-{
-       hide();
+               applyView();
 }
 
 
-void GuiParagraph::on_restorePB_clicked()
+void GuiParagraph::on_buttonBox_clicked(QAbstractButton * button)
 {
-       updateView();
+       switch (buttonBox->standardButton(button)) {
+       case QDialogButtonBox::Ok:
+               applyView();
+               hide();
+               break;
+       case QDialogButtonBox::Apply:
+               applyView();
+               break;
+       case QDialogButtonBox::Cancel:
+               hide();
+               break;
+       case QDialogButtonBox::Reset:
+               updateView();
+               break;
+       default:
+               break;
+       }
 }
 
 
@@ -307,6 +307,8 @@ void GuiParagraph::updateView()
                linespacingValue->setText(QString());
                linespacingValue->setEnabled(false);
        }
+       // Somewhere in the chain this can lose default status (#11417)
+       buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
 }
 
 
@@ -316,8 +318,8 @@ void GuiParagraph::enableView(bool enable)
        linespacing->setEnabled(enable);
        labelWidth->setEnabled(enable);
        synchronizedViewCB->setEnabled(enable);
-       applyPB->setEnabled(enable);
-       restorePB->setEnabled(enable);
+       buttonBox->button(QDialogButtonBox::Apply)->setEnabled(enable);
+       buttonBox->button(QDialogButtonBox::Reset)->setEnabled(enable);
        if (!enable)
                synchronizedViewCB->setChecked(true);
        RadioMap::const_iterator it = radioMap_.begin();
@@ -340,9 +342,9 @@ ParagraphParameters const & GuiParagraph::params() const
 
 void GuiParagraph::dispatchParams()
 {
-       ostringstream data;
-       params_.write(data);
-       FuncRequest const fr(getLfun(), data.str());
+       ostringstream os;
+       params_.write(os);
+       FuncRequest const fr(getLfun(), os.str());
        dispatch(fr);
 }
 
@@ -384,10 +386,9 @@ bool GuiParagraph::hasLabelwidth() const
 }
 
 
-void GuiParagraph::saveSession() const
+void GuiParagraph::saveSession(QSettings & settings) const
 {
-       Dialog::saveSession();
-       QSettings settings;
+       Dialog::saveSession(settings);
        settings.setValue(sessionKey() + "/autoapply", synchronizedViewCB->isChecked());
 }