From 1a3daacc5fab78a4e7af23433c491508fc288c32 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Fri, 22 Jun 2007 22:34:16 +0000 Subject: [PATCH] Fix some UI bugs related to the paragraph settings dialog. The default checkbox has been changed to a radio button, so that other alignments can be chosen without the user's having to uncheck "Default". There was some disagreement about the interface here. See, for example, this thread: http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg121328.html For now, this will do. The interface here is not fully functional. At present, if the Default happens to be Justified, then checking Justified is simply equivalent to checking Default. This is due to the behavior of Text::setParagraph(), and it should be changed if this interface is retained. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18860 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/QParagraph.cpp | 66 +++-- src/frontends/qt4/QParagraph.h | 5 +- src/frontends/qt4/ui/ParagraphUi.ui | 408 ++++++++++++++-------------- 3 files changed, 243 insertions(+), 236 deletions(-) diff --git a/src/frontends/qt4/QParagraph.cpp b/src/frontends/qt4/QParagraph.cpp index be42310a51..c48beafa05 100644 --- a/src/frontends/qt4/QParagraph.cpp +++ b/src/frontends/qt4/QParagraph.cpp @@ -50,7 +50,7 @@ QParagraphDialog::QParagraphDialog(QParagraph * form) connect(applyPB, SIGNAL(clicked()), form_, SLOT(slotApply())); connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose())); connect(restorePB, SIGNAL(clicked()), form_, SLOT(slotRestore())); - connect(alignDefaultCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(alignDefaultRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); connect(alignJustRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); connect(alignLeftRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); connect(alignRightRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); @@ -77,10 +77,17 @@ QParagraphDialog::QParagraphDialog(QParagraph * form) " items is used." )); - radioMap[LYX_ALIGN_BLOCK] = alignJustRB; - radioMap[LYX_ALIGN_LEFT] = alignLeftRB; - radioMap[LYX_ALIGN_RIGHT] = alignRightRB; + radioMap[LYX_ALIGN_LAYOUT] = alignDefaultRB; + radioMap[LYX_ALIGN_BLOCK] = alignJustRB; + radioMap[LYX_ALIGN_LEFT] = alignLeftRB; + radioMap[LYX_ALIGN_RIGHT] = alignRightRB; radioMap[LYX_ALIGN_CENTER] = alignCenterRB; + +/* labelMap[LYX_ALIGN_LAYOUT] = "Default"; + labelMap[LYX_ALIGN_BLOCK] = "Justified"; + labelMap[LYX_ALIGN_LEFT] = "Left"; + labelMap[LYX_ALIGN_RIGHT] = "Right"; + labelMap[LYX_ALIGN_CENTER] = "Center"; */ } @@ -105,35 +112,37 @@ void QParagraphDialog::enableLinespacingValue(int) void QParagraphDialog::checkAlignmentRadioButtons() { - if (alignDefaultCB->isChecked()) { - QPRadioMap::const_iterator it = radioMap.begin(); - for (; it != radioMap.end(); ++it) - it->second->setDisabled(true); - } else { - LyXAlignment alignPossible = form_->controller().alignPossible(); - QPRadioMap::const_iterator it = radioMap.begin(); - for (; it != radioMap.end(); ++it) - it->second->setEnabled(it->first & alignPossible); + LyXAlignment const alignPossible = form_->controller().alignPossible(); + //LyXAlignment const defaultAlignment = form_->controller().alignDefault(); + QPRadioMap::iterator it = radioMap.begin(); + for (; it != radioMap.end(); ++it) { + LyXAlignment const align = it->first; + it->second->setEnabled((align & alignPossible) || + (align == LYX_ALIGN_LAYOUT)); +/* string label = labelMap[align]; + if (align == LYX_ALIGN_LAYOUT) + label += "()" + labelMap[defaultAlignment] + ")"; + it->second->setText(qt_(label));*/ } } -void QParagraphDialog::on_alignDefaultCB_toggled(bool) -{ - checkAlignmentRadioButtons(); - alignmentToRadioButtons(); -} - - void QParagraphDialog::alignmentToRadioButtons(LyXAlignment align) { - if (align == LYX_ALIGN_LAYOUT) - align = form_->controller().alignDefault(); + LyXAlignment const defaultAlignment = form_->controller().alignDefault(); + if (align == LYX_ALIGN_LAYOUT || align == defaultAlignment) { + alignDefaultRB->blockSignals(true); + alignDefaultRB->setChecked(true); + alignDefaultRB->blockSignals(false); + return; + } QPRadioMap::const_iterator it = radioMap.begin(); for (;it != radioMap.end(); ++it) { if (align == it->first) { + it->second->blockSignals(true); it->second->setChecked(true); + it->second->blockSignals(false); return; } } @@ -145,8 +154,6 @@ void QParagraphDialog::alignmentToRadioButtons(LyXAlignment align) LyXAlignment QParagraphDialog::getAlignmentFromDialog() { - if (alignDefaultCB->isChecked()) - return LYX_ALIGN_LAYOUT; LyXAlignment alignment = LYX_ALIGN_NONE; QPRadioMap::const_iterator it = radioMap.begin(); for (; it != radioMap.end(); ++it) { @@ -155,8 +162,6 @@ LyXAlignment QParagraphDialog::getAlignmentFromDialog() break; } } - if (alignment == form_->controller().alignDefault()) - return LYX_ALIGN_LAYOUT; return alignment; } @@ -243,15 +248,8 @@ void QParagraph::update_contents() } // alignment - LyXAlignment newAlignment = params.align(); - LyXAlignment defaultAlignment = controller().alignDefault(); - bool alignmentIsDefault = - newAlignment == LYX_ALIGN_LAYOUT || newAlignment == defaultAlignment; - dialog_->alignDefaultCB->blockSignals(true); - dialog_->alignDefaultCB->setChecked(alignmentIsDefault); - dialog_->alignDefaultCB->blockSignals(false); dialog_->checkAlignmentRadioButtons(); - dialog_->alignmentToRadioButtons(newAlignment); + dialog_->alignmentToRadioButtons(params.align()); //indentation bool const canindent = controller().canIndent(); diff --git a/src/frontends/qt4/QParagraph.h b/src/frontends/qt4/QParagraph.h index b6f771cbf5..bb27145de5 100644 --- a/src/frontends/qt4/QParagraph.h +++ b/src/frontends/qt4/QParagraph.h @@ -44,13 +44,14 @@ private: QParagraph * form_; typedef std::map QPRadioMap; QPRadioMap radioMap; +// typedef std::map QPAlignmentLabels; +// QPAlignmentLabels labelMap; + protected Q_SLOTS: /// void change_adaptor(); /// void enableLinespacingValue(int); - /// - void on_alignDefaultCB_toggled(bool); }; diff --git a/src/frontends/qt4/ui/ParagraphUi.ui b/src/frontends/qt4/ui/ParagraphUi.ui index b0a4e36121..b7cb58d08b 100644 --- a/src/frontends/qt4/ui/ParagraphUi.ui +++ b/src/frontends/qt4/ui/ParagraphUi.ui @@ -8,8 +8,8 @@ 0 0 - 373 - 203 + 387 + 245 @@ -36,6 +36,212 @@ 6 + + + + + 3 + 5 + 0 + 0 + + + + Alignment + + + + 9 + + + 6 + + + + + &Center + + + + + + + &Right + + + + + + + &Left + + + + + + + &Justified + + + + + + + + false + + + + Use the default alignment for this paragraph, whatever it is. + + + Default + + + + + + + + + + 0 + + + 6 + + + + + L&ine spacing: + + + linespacing + + + + + + + + Default + + + + + Single + + + + + 1.5 + + + + + Double + + + + + Custom + + + + + + + + false + + + + + + + + + Qt::Vertical + + + + 249 + 31 + + + + + + + + 0 + + + 6 + + + + + Indent &Paragraph + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 20 + 20 + + + + + + + + + + false + + + Label Width + + + + 11 + + + 6 + + + + + This text defines the width of the paragraph label + + + + + + + This text defines the width of the paragraph label + + + &Longest label + + + labelWidth + + + + + + @@ -105,204 +311,6 @@ - - - - false - - - Label Width - - - - 11 - - - 6 - - - - - This text defines the width of the paragraph label - - - - - - - This text defines the width of the paragraph label - - - &Longest label - - - labelWidth - - - - - - - - - - 0 - - - 6 - - - - - Indent &Paragraph - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 20 - 20 - - - - - - - - - - Qt::Vertical - - - - 249 - 31 - - - - - - - - 0 - - - 6 - - - - - L&ine spacing: - - - linespacing - - - - - - - - Default - - - - - Single - - - - - 1.5 - - - - - Double - - - - - Custom - - - - - - - - false - - - - - - - - - Alignment - - - - 9 - - - 6 - - - - - - 50 - true - false - true - - - - &Default - - - - - - - &Justified - - - - - - - &Left - - - - - - - &Right - - - - - - - &Center - - - - - -