Fix some issues with the paragraph settings dialog. The main change

is that we distinguish between the "Default" alignment and whatever
that default happens to be: I.e., so far as the code goes, the UI now
distinguishes LYX_ALIGN_LAYOUT from LYX_ALIGN_WHATEVER, when WHATEVER
happens to be the default. So you can explicitly force, say, left-align,
and that will stick between document classes.

* src/Paragraph.cpp:
Don't output params if alignment is the default.

* src/ParagraphParameters.cpp
Treat LYX_ALIGN_LAYOUT as its own alignment.

* src/Text2.cpp
Treat LYX_ALIGN_LAYOUT as its own alignment, and force it to be accepted
as a possible alignment.

* src/frontends/controllers/ControlParagraph.{h,cpp}
New method haveMultiParSelection().

*src/frontends/qt4/QParagraph.{h,cpp}
*src/frontends/qt4/ui/ParagraphUi.ui
UI adjustments as mentioned.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18922 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2007-06-28 00:48:06 +00:00
parent 4cef6923f4
commit 3fcc6711f0
8 changed files with 213 additions and 201 deletions

View File

@ -1782,7 +1782,12 @@ int Paragraph::startTeXParParams(BufferParams const & bparams,
column += 10;
}
switch (params().align()) {
LyXAlignment const curAlign = 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 @@ int Paragraph::startTeXParParams(BufferParams const & bparams,
break;
}
switch (params().align()) {
switch (curAlign) {
case LYX_ALIGN_NONE:
case LYX_ALIGN_BLOCK:
case LYX_ALIGN_LAYOUT:

View File

@ -279,14 +279,11 @@ void params2string(Paragraph const & par, string & data)
// This needs to be done separately
params.labelWidthString(par.getLabelWidthString());
// Alignment
Layout_ptr const & layout = par.layout();
if (params.align() == LYX_ALIGN_LAYOUT)
params.align(layout->align);
ostringstream os;
params.write(os);
Layout_ptr const & layout = par.layout();
// Is alignment possible
os << "\\alignpossible " << layout->alignpossible << '\n';

View File

@ -649,16 +649,12 @@ void Text::setParagraph(Cursor & cur,
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
//FIXME The reason we need the first check is because
//LYX_ALIGN_LAYOUT isn't required to be possible. It
//should be...and will be.
if ((align == LYX_ALIGN_LAYOUT) ||
(align & par.layout()->alignpossible))
params.align(align);
}
par.setLabelWidthString(labelwidthstring);
params.noindent(noindent);
}

View File

@ -14,7 +14,9 @@
#include "ControlParagraph.h"
#include "Buffer.h"
#include "BufferParams.h"
#include "BufferView.h"
#include "ButtonController.h"
#include "Cursor.h"
#include "FuncRequest.h"
#include "Lexer.h"
#include "Paragraph.h"
@ -150,6 +152,13 @@ ParagraphParameters const & ControlParagraph::params() const
}
bool const ControlParagraph::haveMulitParSelection() {
Cursor cur = kernel().bufferview()->cursor();
if (!cur.selection())
return false;
return (cur.selBegin().pit() != cur.selEnd().pit());
}
bool ControlParagraph::inInset() const
{
return ininset_;

View File

@ -38,6 +38,8 @@ public:
///
ParagraphParameters const & params() const;
///
bool const haveMulitParSelection();
///
bool inInset() const;
///
bool canIndent() const;

View File

@ -83,11 +83,11 @@ QParagraphDialog::QParagraphDialog(QParagraph * form)
radioMap[LYX_ALIGN_RIGHT] = alignRightRB;
radioMap[LYX_ALIGN_CENTER] = alignCenterRB;
/* labelMap[LYX_ALIGN_LAYOUT] = "Default";
labelMap[LYX_ALIGN_LAYOUT] = "Use Paragraph's Default Alignment";
labelMap[LYX_ALIGN_BLOCK] = "Justified";
labelMap[LYX_ALIGN_LEFT] = "Left";
labelMap[LYX_ALIGN_RIGHT] = "Right";
labelMap[LYX_ALIGN_CENTER] = "Center"; */
labelMap[LYX_ALIGN_CENTER] = "Center";
}
@ -113,30 +113,25 @@ void QParagraphDialog::enableLinespacingValue(int)
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;
//FIXME The reason we need the second check is because
//LYX_ALIGN_LAYOUT isn't required to be possible. It
//should be...and will be.
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));*/
}
std::string label = labelMap[LYX_ALIGN_LAYOUT];
if (!form_->controller().haveMulitParSelection())
label += (" (" + labelMap[form_->controller().alignDefault()] + ")");
alignDefaultRB->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) {

View File

@ -44,8 +44,8 @@ private:
QParagraph * form_;
typedef std::map<LyXAlignment, QRadioButton *> QPRadioMap;
QPRadioMap radioMap;
// typedef std::map<LyXAlignment, std::string> QPAlignmentLabels;
// QPAlignmentLabels labelMap;
typedef std::map<LyXAlignment, std::string> QPAlignmentLabels;
QPAlignmentLabels labelMap;
protected Q_SLOTS:
///

View File

@ -8,8 +8,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>387</width>
<height>245</height>
<width>488</width>
<height>334</height>
</rect>
</property>
<property name="sizePolicy" >
@ -36,142 +36,20 @@
<property name="spacing" >
<number>6</number>
</property>
<item rowspan="4" row="0" column="0" >
<widget class="QGroupBox" name="aligmentGB" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title" >
<string>Alignment</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="3" column="0" >
<widget class="QRadioButton" name="alignCenterRB" >
<property name="text" >
<string>&amp;Center</string>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QRadioButton" name="alignRightRB" >
<property name="text" >
<string>&amp;Right</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QRadioButton" name="alignLeftRB" >
<property name="text" >
<string>&amp;Left</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QRadioButton" name="alignJustRB" >
<property name="text" >
<string>&amp;Justified</string>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QRadioButton" name="alignDefaultRB" >
<property name="font" >
<font>
<italic>false</italic>
</font>
</property>
<property name="toolTip" >
<string>Use the default alignment for this paragraph, whatever it is.</string>
</property>
<property name="text" >
<string>Default</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="linespacingL" >
<property name="text" >
<string>L&amp;ine spacing:</string>
</property>
<property name="buddy" >
<cstring>linespacing</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="linespacing" >
<item>
<property name="text" >
<string>Default</string>
</property>
</item>
<item>
<property name="text" >
<string>Single</string>
</property>
</item>
<item>
<property name="text" >
<string>1.5</string>
</property>
</item>
<item>
<property name="text" >
<string>Double</string>
</property>
</item>
<item>
<property name="text" >
<string>Custom</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLineEdit" name="linespacingValue" >
<property name="enabled" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>249</width>
<width>20</width>
<height>31</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" >
<item row="2" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
@ -204,45 +82,7 @@
</item>
</layout>
</item>
<item row="3" column="1" >
<widget class="QGroupBox" name="labelwidthGB" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="title" >
<string>Label Width</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>11</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="1" >
<widget class="QLineEdit" name="labelWidth" >
<property name="toolTip" >
<string>This text defines the width of the paragraph label</string>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="TextLabel2" >
<property name="toolTip" >
<string>This text defines the width of the paragraph label</string>
</property>
<property name="text" >
<string>&amp;Longest label</string>
</property>
<property name="buddy" >
<cstring>labelWidth</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0" colspan="2" >
<item row="5" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
@ -311,6 +151,174 @@
</item>
</layout>
</item>
<item row="0" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="linespacingL" >
<property name="text" >
<string>L&amp;ine spacing:</string>
</property>
<property name="buddy" >
<cstring>linespacing</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="linespacing" >
<item>
<property name="text" >
<string>Default</string>
</property>
</item>
<item>
<property name="text" >
<string>Single</string>
</property>
</item>
<item>
<property name="text" >
<string>1.5</string>
</property>
</item>
<item>
<property name="text" >
<string>Double</string>
</property>
</item>
<item>
<property name="text" >
<string>Custom</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLineEdit" name="linespacingValue" >
<property name="enabled" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" >
<widget class="QGroupBox" name="aligmentGB" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title" >
<string>Alignment</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" colspan="4" >
<widget class="QRadioButton" name="alignDefaultRB" >
<property name="font" >
<font>
<italic>false</italic>
</font>
</property>
<property name="toolTip" >
<string>Use the default alignment for this paragraph, whatever it is.</string>
</property>
<property name="text" >
<string>Use Paragraph's Default Alignment</string>
</property>
</widget>
</item>
<item row="1" column="3" >
<widget class="QRadioButton" name="alignRightRB" >
<property name="text" >
<string>&amp;Right</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QRadioButton" name="alignLeftRB" >
<property name="text" >
<string>&amp;Left</string>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="QRadioButton" name="alignCenterRB" >
<property name="text" >
<string>&amp;Center</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QRadioButton" name="alignJustRB" >
<property name="text" >
<string>&amp;Justified</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0" >
<widget class="QGroupBox" name="labelwidthGB" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>1</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title" >
<string>Label Width</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="1" >
<widget class="QLineEdit" name="labelWidth" >
<property name="toolTip" >
<string>This text defines the width of the paragraph label</string>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="TextLabel2" >
<property name="toolTip" >
<string>This text defines the width of the paragraph label</string>
</property>
<property name="text" >
<string>&amp;Longest label</string>
</property>
<property name="buddy" >
<cstring>labelWidth</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<tabstops>