]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt/GuiParagraph.cpp
Move Lexer to support/ directory (and lyx::support namespace)
[lyx.git] / src / frontends / qt / GuiParagraph.cpp
index 0b54d7aaa4bb0c093c488fbfa8086a149c2d0d50..d2fbd484f5cfcadc011b289c0dce34b0d22c2da4 100644 (file)
@@ -4,7 +4,7 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Edwin Leuven
- * \author Richard Heck
+ * \author Richard Kimberly Heck
  * \author Abdelrazak Younes
  * \author Angus Leeming
  *
 #include "Cursor.h"
 #include "FuncRequest.h"
 #include "GuiView.h"
-#include "Lexer.h"
+#include "Layout.h"
 #include "Paragraph.h"
 #include "ParagraphParameters.h"
 #include "Spacing.h"
 
 #include "support/debug.h"
-#include "support/gettext.h"
+#include "support/Lexer.h"
 
 #include <QCheckBox>
 #include <QDialogButtonBox>
@@ -61,7 +61,7 @@ GuiParagraph::GuiParagraph(GuiView & lv)
        connect(linespacing, SIGNAL(activated(int)), this, SLOT(changed()));
        connect(linespacingValue, SIGNAL(textChanged(QString)),
                this, SLOT(changed()));
-       connect(indentCB, SIGNAL(clicked()), this, SLOT(changed()));
+       connect(noindentCB, SIGNAL(clicked()), this, SLOT(changed()));
        connect(labelWidth, SIGNAL(textChanged(QString)),
                this, SLOT(changed()));
 
@@ -74,7 +74,7 @@ GuiParagraph::GuiParagraph(GuiView & lv)
        synchronizedViewCB->setChecked(false);
 #endif
 
-       on_synchronizedViewCB_toggled();
+       setButtons(synchronizedViewCB->isChecked());
        QDoubleValidator * val = new QDoubleValidator(linespacingValue);
        val->setNotation(QDoubleValidator::StandardNotation);
        linespacingValue->setValidator(val);
@@ -154,16 +154,26 @@ LyXAlignment GuiParagraph::getAlignmentFromDialog() const
 }
 
 
-void GuiParagraph::on_synchronizedViewCB_toggled()
+void GuiParagraph::on_synchronizedViewCB_stateChanged(int state)
+{
+       bool in_sync = state == Qt::Checked;
+       setButtons(in_sync);
+
+       // Apply pending changes
+       if (in_sync) 
+               changed();
+}
+
+
+void GuiParagraph::setButtons(bool const in_sync)
 {
-       bool in_sync = synchronizedViewCB->isChecked();
        buttonBox->button(QDialogButtonBox::Reset)->setEnabled(!in_sync);
        buttonBox->button(QDialogButtonBox::Apply)->setEnabled(!in_sync);
        buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!in_sync);
-       if (!in_sync)
-               buttonBox->button(QDialogButtonBox::Cancel)->setText(qt_("&Cancel"));
-       else
+       if (in_sync) 
                buttonBox->button(QDialogButtonBox::Cancel)->setText(qt_("&Close"));
+       else
+               buttonBox->button(QDialogButtonBox::Cancel)->setText(qt_("&Cancel"));
 }
 
 
@@ -237,7 +247,7 @@ void GuiParagraph::applyView()
        // label width
        params_.labelWidthString(qstring_to_ucs4(labelWidth->text()));
        // indentation
-       params_.noindent(!indentCB->isChecked());
+       params_.noindent(noindentCB->isChecked());
 
        dispatchParams();
 }
@@ -245,7 +255,7 @@ void GuiParagraph::applyView()
 
 void GuiParagraph::updateView()
 {
-       on_synchronizedViewCB_toggled();
+       setButtons(synchronizedViewCB->isChecked());
 
        ParagraphParameters const & pp = params();
 
@@ -265,8 +275,8 @@ void GuiParagraph::updateView()
 
        //indentation
        bool const canindent = canIndent();
-       indentCB->setEnabled(canindent);
-       indentCB->setChecked(canindent && !pp.noindent());
+       noindentCB->setEnabled(canindent);
+       noindentCB->setChecked(canindent && pp.noindent());
 
        // linespacing
        int ls;
@@ -314,7 +324,7 @@ void GuiParagraph::updateView()
 
 void GuiParagraph::enableView(bool enable)
 {
-       indentCB->setEnabled(enable);
+       noindentCB->setEnabled(canIndent() && enable);
        linespacing->setEnabled(enable);
        labelWidth->setEnabled(enable);
        synchronizedViewCB->setEnabled(enable);
@@ -396,12 +406,6 @@ void GuiParagraph::restoreSession()
 }
 
 
-Dialog * createGuiParagraph(GuiView & lv)
-{
-       return new GuiParagraph(lv);
-}
-
-
 } // namespace frontend
 } // namespace lyx