Contrary to what I said in a previous message, completing the reworking of the Paragraph Settings dialog isn't terribly difficult. Here's the issue: In this dialog---both before the most recent patch and since it, though there was some disagreement about this---we distinguish between the Default alignment and, say, Justified, even if Justified happens to be the Default for that paragraph. The reason to make this distinction is that it is one thing to say, "Give this paragraph the default alignment, whatever that is" and another to say, "Make this paragraph fully justified, no matter what". The difference will only show up in certain kinds of cases, such as when one is changing layouts, but it seems to many of us, at least, that the difference should be respected, and that the option of requiring a certain alignment, even if that is currently the default, should be available.

The existing LyX code does not, however, respect the mentioned difference, and the result is that the mentioned option isn't available, in fact: If the default for a given paragraph is, as it happens, Justified , then attempting to set the alignment to LYX_ALIGN_BLOCK will fail: You'll actually get LYX_ALIGN_LAYOUT. The attached patch fixes this. It's fairly simple: (i) In Text::setParagraph(), the code that does what was just mentioned is removed; (ii) in Paragraph::StartTeXParParams(), we ignore the alignment stuff if the chosen alignment is the default for the paragraph; and (iii) in QParagraph::alignmentToRadioButtons(), we remove similarly offending code. (I've also removed some commented-out code I accidentally left in a previous patch.)

This is safe, I think, and in the spirit of completing the previous UI fix. Seeking two OKs.

Richard

Index: frontends/qt4/QParagraph.cpp
===================================================================
--- frontends/qt4/QParagraph.cpp	(revision 18865)
+++ frontends/qt4/QParagraph.cpp	(working copy)
@@ -113,30 +113,17 @@
 
 void QParagraphDialog::checkAlignmentRadioButtons() {
 	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::alignmentToRadioButtons(LyXAlignment align)
 {
-	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) {
Index: Paragraph.cpp
===================================================================
--- Paragraph.cpp	(revision 18865)
+++ Paragraph.cpp	(working copy)
@@ -1781,8 +1781,13 @@
 		os << "\\noindent ";
 		column += 10;
 	}
+	
+	LyXAlignment const curAlign = params().align();
 
-	switch (params().align()) {
+	if (curAlign == layout()->align)
+		return column;
+
+	switch (curAlign) {
 	case LYX_ALIGN_NONE:
 	case LYX_ALIGN_BLOCK:
 	case LYX_ALIGN_LAYOUT:
@@ -1798,7 +1803,7 @@
 		break;
 	}
 
-	switch (params().align()) {
+	switch (curAlign) {
 	case LYX_ALIGN_NONE:
 	case LYX_ALIGN_BLOCK:
 	case LYX_ALIGN_LAYOUT:
Index: Text2.cpp
===================================================================
--- Text2.cpp	(revision 18865)
+++ Text2.cpp	(working copy)
@@ -649,16 +649,9 @@
 		params.spacing(spacing);
 
 		// does the layout allow the new alignment?
-		Layout_ptr const & layout = par.layout();
-
-		if (align == LYX_ALIGN_LAYOUT)
-			align = layout->align;
-		if (align & layout->alignpossible) {
-			if (align == layout->align)
-				params.align(LYX_ALIGN_LAYOUT);
-			else
-				params.align(align);
-		}
+		if ((align == LYX_ALIGN_LAYOUT) ||
+		    (align & par.layout()->alignpossible))
+		    	params.align(align);
 		par.setLabelWidthString(labelwidthstring);
 		params.noindent(noindent);
 	}

Reply via email to