]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiParagraph.cpp
do what the FIXME suggested
[lyx.git] / src / frontends / qt4 / GuiParagraph.cpp
index 7e785a54d2815eb951433074edbf986037420d85..49465a7ef06ec5cd53bf8536cc5fa179425a6fcd 100644 (file)
 
 #include "GuiParagraph.h"
 
+#include "qt_helpers.h"
+
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "BufferView.h"
 #include "Cursor.h"
-//#include "DialogView.h"
-//#include "DockView.h"
 #include "FuncRequest.h"
 #include "GuiView.h"
 #include "Lexer.h"
 #include "Paragraph.h"
 #include "ParagraphParameters.h"
-#include "qt_helpers.h"
 #include "Spacing.h"
 
 #include "support/debug.h"
 #include "support/gettext.h"
 
 #include <QCheckBox>
-#include <QCloseEvent>
 #include <QLineEdit>
 #include <QPushButton>
 
 #include <sstream>
 
-using std::istringstream;
-using std::ostringstream;
-using std::string;
-using std::endl;
+using namespace std;
 
 namespace lyx {
 namespace frontend {
 
 GuiParagraph::GuiParagraph(GuiView & lv)
-       : DialogView(lv, "paragraph")
+       : DialogView(lv, "paragraph", qt_("Paragraph Settings"))
 {
        setupUi(this);
-       setWindowTitle(qt_("Paragraph Settings"));
 
        connect(alignDefaultRB, SIGNAL(clicked()), this, SLOT(changed()));
        connect(alignJustRB, SIGNAL(clicked()), this, SLOT(changed()));
@@ -65,8 +59,15 @@ GuiParagraph::GuiParagraph(GuiView & lv)
        connect(labelWidth, SIGNAL(textChanged(QString)),
                this, SLOT(changed()));
 
-
+#ifdef Q_WS_MACX
+       // On Mac it's common to have tool windows which are always in the
+       // foreground and are hidden when the main window is not focused.
+       setWindowFlags(Qt::Tool);
+       synchronizedViewCB->setChecked(true);
+#else
        synchronizedViewCB->setChecked(false);
+#endif
+
        on_synchronizedViewCB_toggled();
        linespacingValue->setValidator(new QDoubleValidator(linespacingValue));
 
@@ -109,7 +110,7 @@ void GuiParagraph::checkAlignmentRadioButtons()
                LyXAlignment const align = it->first;
                it->second->setEnabled(align & alignPossible());
        }
-       if (haveMulitParSelection())
+       if (haveMultiParSelection())
                alignDefaultRB->setText(alignDefaultLabel);
        else
                alignDefaultRB->setText(alignDefaultLabel + " ("
@@ -121,8 +122,6 @@ void GuiParagraph::alignmentToRadioButtons(LyXAlignment align)
 {
        RadioMap::const_iterator it = radioMap.begin();
        for (;it != radioMap.end(); ++it) {
-               if (!it->second->isEnabled())
-                       continue;
                it->second->blockSignals(true);
                it->second->setChecked(align == it->first);
                it->second->blockSignals(false);
@@ -205,11 +204,6 @@ void GuiParagraph::on_restorePB_clicked()
 }
 
 
-void GuiParagraph::enableView(bool enable)
-{
-}
-
-
 void GuiParagraph::updateView()
 {
        on_synchronizedViewCB_toggled();
@@ -267,9 +261,25 @@ void GuiParagraph::updateView()
 }
 
 
+void GuiParagraph::enableView(bool enable)
+{
+       indentCB->setEnabled(enable);
+       linespacing->setEnabled(enable);
+       labelWidth->setEnabled(enable);
+       synchronizedViewCB->setEnabled(enable);
+       applyPB->setEnabled(enable);
+       restorePB->setEnabled(enable);
+       if (!enable)
+               synchronizedViewCB->setChecked(true);
+       RadioMap::const_iterator it = radioMap.begin();
+       for (; it != radioMap.end(); ++it)
+               it->second->setEnabled(enable);
+}
+
+
 ParagraphParameters & GuiParagraph::params()
 {
-       if (haveMulitParSelection()) {
+       if (haveMultiParSelection()) {
                multiparsel_ = ParagraphParameters();
                // FIXME: It would be nice to initialise the parameters that
                // are common to all paragraphs.
@@ -288,10 +298,10 @@ ParagraphParameters const & GuiParagraph::params() const
 
 void GuiParagraph::dispatchParams()
 {
-       if (haveMulitParSelection()) {
+       if (haveMultiParSelection()) {
                ostringstream data;
                multiparsel_.write(data);
-               FuncRequest const fr(LFUN_PARAGRAPH_PARAMS_APPLY, data.str());
+               FuncRequest const fr(getLfun(), data.str());
                dispatch(fr);
                return;
        }
@@ -301,7 +311,7 @@ void GuiParagraph::dispatchParams()
 }
 
 
-bool GuiParagraph::haveMulitParSelection()
+bool GuiParagraph::haveMultiParSelection()
 {
        Cursor cur = bufferview()->cursor();
        return cur.selection() && cur.selBegin().pit() != cur.selEnd().pit();
@@ -329,16 +339,6 @@ LyXAlignment GuiParagraph::alignDefault() const
 
 Dialog * createGuiParagraph(GuiView & lv)
 {
-#if 0
-       GuiView & guiview = static_cast<GuiView &>(lv);
-#ifdef USE_DOCK_WIDGET
-       return new DockView<ControlParagraph, GuiParagraph>(guiview, "paragraph",
-               Qt::TopDockWidgetArea);
-#else
-       return new DialogView<ControlParagraph, GuiParagraph>(guiview, "paragraph");
-#endif
-#endif
-
        return new GuiParagraph(lv);
 }