Redesign and cleanup the Paragraph Settings dialog:

- GuiParagraphDialog: Renamed to GuiParagraph
- Now use the DockView infrastructure (and is thus docked by default)
- Additional mode for immediate application of changed parameters.

Some bits are missing due to some remaining bugs in the GUI dialog updating following the big GUII cleanup.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20513 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-09-26 13:13:01 +00:00
parent 960af372a8
commit 2e2d67a7de
4 changed files with 367 additions and 386 deletions

View File

@ -172,7 +172,13 @@ Dialog * Dialogs::build(string const & name)
} else if (name == "note") {
dialog = new GuiNoteDialog(lyxview_);
} else if (name == "paragraph") {
dialog = new GuiParagraphDialog(lyxview_);
#ifdef Q_WS_MACX
// On Mac show as a drawer at the right
dialog = new DockView<ControlParagraph, GuiParagraph>(guiview, name,
Qt::RightDockWidgetArea, Qt::Drawer);
#else
dialog = new DockView<ControlParagraph, GuiParagraph>(guiview, name);
#endif
} else if (name == "prefs") {
dialog = new GuiPrefsDialog(lyxview_);
} else if (name == "print") {

View File

@ -5,6 +5,7 @@
*
* \author Edwin Leuven
* \author Richard Heck
* \author Abdelrazak Younes
*
* Full author contact details are available in file CREDITS.
*/
@ -12,13 +13,14 @@
#include <config.h>
#include "GuiParagraph.h"
#include "qt_helpers.h"
#include "ControlParagraph.h"
#include "debug.h"
#include "frontend_helpers.h"
#include "gettext.h"
#include "ParagraphParameters.h"
#include "qt_helpers.h"
#include "Spacing.h"
#include <QCheckBox>
@ -34,31 +36,27 @@ using std::endl;
namespace lyx {
namespace frontend {
GuiParagraphDialog::GuiParagraphDialog(LyXView & lv)
: GuiDialog(lv, "paragraph")
GuiParagraph::GuiParagraph(ControlParagraph & controller)
: controller_(controller)
{
setupUi(this);
setViewTitle(_("Paragraph Settings"));
setController(new ControlParagraph(*this));
setWindowTitle(qt_("Paragraph Settings"));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
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()));
connect(alignCenterRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(linespacing, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
connect(linespacing, SIGNAL(activated(int)),
this, SLOT(enableLinespacingValue(int)));
connect(alignDefaultRB, SIGNAL(clicked()), this, SLOT(changed()));
connect(alignJustRB, SIGNAL(clicked()), this, SLOT(changed()));
connect(alignLeftRB, SIGNAL(clicked()), this, SLOT(changed()));
connect(alignRightRB, SIGNAL(clicked()), this, SLOT(changed()));
connect(alignCenterRB, SIGNAL(clicked()), this, SLOT(changed()));
connect(linespacing, SIGNAL(activated(int)), this, SLOT(changed()));
connect(linespacingValue, SIGNAL(textChanged(const QString &)),
this, SLOT(change_adaptor()));
connect(indentCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
this, SLOT(changed()));
connect(indentCB, SIGNAL(clicked()), this, SLOT(changed()));
connect(labelWidth, SIGNAL(textChanged(const QString &)),
this, SLOT(change_adaptor()));
this, SLOT(changed()));
synchronizedViewCB->setChecked(true);
on_synchronizedViewCB_toggled();
linespacingValue->setValidator(new QDoubleValidator(linespacingValue));
labelWidth->setWhatsThis( qt_(
@ -77,80 +75,47 @@ GuiParagraphDialog::GuiParagraphDialog(LyXView & lv)
radioMap[LYX_ALIGN_LEFT] = alignLeftRB;
radioMap[LYX_ALIGN_RIGHT] = alignRightRB;
radioMap[LYX_ALIGN_CENTER] = alignCenterRB;
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");
bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
bc().setOK(okPB);
bc().setApply(applyPB);
bc().setCancel(closePB);
bc().setRestore(restorePB);
const_cast<QString &>(alignDefaultLabel) = alignDefaultRB->text();
}
ControlParagraph & GuiParagraphDialog::controller()
void GuiParagraph::on_linespacing_activated(int index)
{
return static_cast<ControlParagraph &>(GuiDialog::controller());
linespacingValue->setEnabled(index == 4);
}
void GuiParagraphDialog::closeEvent(QCloseEvent * e)
{
slotClose();
e->accept();
}
void GuiParagraphDialog::change_adaptor()
{
changed();
}
void GuiParagraphDialog::enableLinespacingValue(int)
{
bool const enable = linespacing->currentIndex() == 4;
linespacingValue->setEnabled(enable);
}
void GuiParagraphDialog::checkAlignmentRadioButtons() {
LyXAlignment const alignPossible = controller().alignPossible();
void GuiParagraph::checkAlignmentRadioButtons() {
LyXAlignment const alignPossible = controller_.alignPossible();
RadioMap::iterator it = radioMap.begin();
for (; it != radioMap.end(); ++it) {
LyXAlignment const align = it->first;
it->second->setEnabled(align & alignPossible);
}
docstring label = labelMap[LYX_ALIGN_LAYOUT];
if (!controller().haveMulitParSelection())
label += (" (" + labelMap[controller().alignDefault()] + ")");
alignDefaultRB->setText(toqstr(label));
if (controller_.haveMulitParSelection())
alignDefaultRB->setText(alignDefaultLabel);
else
alignDefaultRB->setText(alignDefaultLabel + " ("
+ radioMap[controller_.alignDefault()]->text() + ")");
}
void GuiParagraphDialog::alignmentToRadioButtons(LyXAlignment align)
void GuiParagraph::alignmentToRadioButtons(LyXAlignment align)
{
RadioMap::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;
}
if (!it->second->isEnabled())
continue;
it->second->blockSignals(true);
it->second->setChecked(align == it->first);
it->second->blockSignals(false);
}
lyxerr << BOOST_CURRENT_FUNCTION << "Unknown alignment "
<< align << std::endl;
}
LyXAlignment GuiParagraphDialog::getAlignmentFromDialog()
LyXAlignment GuiParagraph::getAlignmentFromDialog()
{
LyXAlignment alignment = LYX_ALIGN_NONE;
RadioMap::const_iterator it = radioMap.begin();
@ -164,9 +129,24 @@ LyXAlignment GuiParagraphDialog::getAlignmentFromDialog()
}
void GuiParagraphDialog::applyView()
void GuiParagraph::on_synchronizedViewCB_toggled()
{
ParagraphParameters & params = controller().params();
bool in_sync = synchronizedViewCB->isChecked();
restorePB->setEnabled(!in_sync);
applyPB->setEnabled(!in_sync);
}
void GuiParagraph::changed()
{
if (synchronizedViewCB->isChecked())
on_applyPB_clicked();
}
void GuiParagraph::on_applyPB_clicked()
{
ParagraphParameters & params = controller_.params();
params.align(getAlignmentFromDialog());
@ -199,12 +179,22 @@ void GuiParagraphDialog::applyView()
params.labelWidthString(qstring_to_ucs4(labelWidth->text()));
// indendation
params.noindent(!indentCB->isChecked());
controller_.dispatchParams();
}
void GuiParagraphDialog::updateContents()
void GuiParagraph::on_restorePB_clicked()
{
ParagraphParameters const & params = controller().params();
updateView();
}
void GuiParagraph::updateView()
{
on_synchronizedViewCB_toggled();
ParagraphParameters const & params = controller_.params();
// label width
docstring const & labelwidth = params.labelWidthString();
@ -222,7 +212,7 @@ void GuiParagraphDialog::updateContents()
alignmentToRadioButtons(params.align());
//indentation
bool const canindent = controller().canIndent();
bool const canindent = controller_.canIndent();
indentCB->setEnabled(canindent);
indentCB->setChecked(canindent && !params.noindent());

View File

@ -13,48 +13,51 @@
#ifndef GUIPARAGRAPH_H
#define GUIPARAGRAPH_H
#include "GuiDialog.h"
#include "ControlParagraph.h"
#include "Layout.h"
#include "ui_ParagraphUi.h"
#include <QWidget>
#include <map>
namespace lyx {
namespace frontend {
class GuiParagraphDialog : public GuiDialog, public Ui::ParagraphUi
class GuiParagraph : public QWidget, public Ui::ParagraphUi
{
Q_OBJECT
public:
GuiParagraphDialog(LyXView & lv);
GuiParagraph(ControlParagraph & controller);
/// update
void updateView();
private:
///
void checkAlignmentRadioButtons();
///
void alignmentToRadioButtons(LyXAlignment align = LYX_ALIGN_LAYOUT);
///
LyXAlignment getAlignmentFromDialog();
private:
///
void closeEvent(QCloseEvent * e);
///
typedef std::map<LyXAlignment, QRadioButton *> RadioMap;
RadioMap radioMap;
///
typedef std::map<LyXAlignment, docstring> AlignmentLabels;
AlignmentLabels labelMap;
ControlParagraph & controller_;
QString const alignDefaultLabel;
private Q_SLOTS:
///
void change_adaptor();
void changed();
///
void enableLinespacingValue(int);
/// parent controller
ControlParagraph & controller();
void on_synchronizedViewCB_toggled();
///
void on_restorePB_clicked();
///
void on_linespacing_activated(int);
/// Apply changes
void applyView();
/// update
void updateContents();
void on_applyPB_clicked();
};
} // namespace frontend

View File

@ -1,335 +1,317 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>ParagraphUi</class>
<widget class="QDialog" name="ParagraphUi" >
<property name="windowModality" >
<enum>Qt::NonModal</enum>
</property>
<widget class="QWidget" name="ParagraphUi" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>488</width>
<height>286</height>
<width>222</width>
<height>488</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>1</vsizetype>
<hsizetype>5</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>222</width>
<height>16</height>
</size>
</property>
<property name="focusPolicy" >
<enum>Qt::NoFocus</enum>
</property>
<property name="windowTitle" >
<string/>
</property>
<property name="sizeGripEnabled" >
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
<widget class="QWidget" name="" >
<property name="geometry" >
<rect>
<x>10</x>
<y>440</y>
<width>201</width>
<height>26</height>
</rect>
</property>
<property name="spacing" >
<number>6</number>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="restorePB" >
<property name="text" >
<string>Restore</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="applyPB" >
<property name="text" >
<string>Apply</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox" >
<property name="geometry" >
<rect>
<x>11</x>
<y>11</y>
<width>201</width>
<height>51</height>
</rect>
</property>
<item row="5" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
<property name="title" >
<string>Line spacing</string>
</property>
<widget class="QLineEdit" name="linespacingValue" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="geometry" >
<rect>
<x>80</x>
<y>20</y>
<width>111</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="linespacing" >
<property name="geometry" >
<rect>
<x>10</x>
<y>20</y>
<width>63</width>
<height>20</height>
</rect>
</property>
<item>
<property name="text" >
<string>Default</string>
</property>
<property name="spacing" >
<number>6</number>
</item>
<item>
<property name="text" >
<string>Single</string>
</property>
<item>
<widget class="QPushButton" name="restorePB" >
<property name="text" >
<string>&amp;Restore</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="okPB" >
<property name="text" >
<string>&amp;OK</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
<property name="default" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="applyPB" >
<property name="text" >
<string>&amp;Apply</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="closePB" >
<property name="text" >
<string>&amp;Close</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</item>
<item>
<property name="text" >
<string>1.5</string>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>16</height>
</size>
</item>
<item>
<property name="text" >
<string>Double</string>
</property>
</spacer>
</item>
<item row="3" column="0" >
<widget class="QGroupBox" name="labelwidthGB" >
<property name="enabled" >
<bool>false</bool>
</item>
<item>
<property name="text" >
<string>Custom</string>
</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>
</item>
</widget>
</widget>
<widget class="QCheckBox" name="indentCB" >
<property name="geometry" >
<rect>
<x>10</x>
<y>250</y>
<width>201</width>
<height>19</height>
</rect>
</property>
<property name="text" >
<string>Indent Paragraph</string>
</property>
</widget>
<widget class="QGroupBox" name="aligmentGB" >
<property name="geometry" >
<rect>
<x>10</x>
<y>70</y>
<width>201</width>
<height>155</height>
</rect>
</property>
<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="4" column="0" >
<widget class="QRadioButton" name="alignRightRB" >
<property name="text" >
<string>Right</string>
</property>
<property name="spacing" >
<number>6</number>
</widget>
</item>
<item row="3" column="0" >
<widget class="QRadioButton" name="alignCenterRB" >
<property name="text" >
<string>Center</string>
</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="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>
</widget>
</item>
<item row="2" column="0" >
<widget class="QRadioButton" name="alignLeftRB" >
<property name="text" >
<string>Left</string>
</property>
<property name="spacing" >
<number>6</number>
</widget>
</item>
<item row="1" column="0" >
<widget class="QRadioButton" name="alignJustRB" >
<property name="text" >
<string>Justified</string>
</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="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="2" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QCheckBox" name="indentCB" >
<property name="text" >
<string>Indent &amp;Paragraph</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="0" column="0" >
<widget class="QRadioButton" name="alignDefaultRB" >
<property name="font" >
<font>
<family>MS Shell Dlg 2</family>
<pointsize>8</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="toolTip" >
<string>Use the default alignment for this paragraph, whatever it is.</string>
</property>
<property name="text" >
<string>Paragraph's Default</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="labelwidthGB" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="geometry" >
<rect>
<x>10</x>
<y>280</y>
<width>201</width>
<height>107</height>
</rect>
</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>
<widget class="QCheckBox" name="synchronizedViewCB" >
<property name="geometry" >
<rect>
<x>10</x>
<y>410</y>
<width>201</width>
<height>19</height>
</rect>
</property>
<property name="text" >
<string>Synchronized view</string>
</property>
</widget>
</widget>
<pixmapfunction></pixmapfunction>
<tabstops>
<tabstop>linespacing</tabstop>
<tabstop>linespacingValue</tabstop>
<tabstop>indentCB</tabstop>
<tabstop>labelWidth</tabstop>
<tabstop>restorePB</tabstop>
<tabstop>okPB</tabstop>
<tabstop>applyPB</tabstop>
<tabstop>closePB</tabstop>
</tabstops>
<includes>
<include location="local" >qt_helpers.h</include>