#include <QCheckBox>
#include <QLineEdit>
#include <QPushButton>
+#include <QSettings>
+#include <QVariant>
#include <sstream>
// foreground and are hidden when the main window is not focused.
setWindowFlags(Qt::Tool);
synchronizedViewCB->setChecked(true);
+ closePB->setText(qt_("&Cancel"));
#else
synchronizedViewCB->setChecked(false);
#endif
}
-LyXAlignment GuiParagraph::getAlignmentFromDialog()
+LyXAlignment GuiParagraph::getAlignmentFromDialog() const
{
LyXAlignment alignment = LYX_ALIGN_NONE;
RadioMap::const_iterator it = radioMap_.begin();
bool in_sync = synchronizedViewCB->isChecked();
restorePB->setEnabled(!in_sync);
applyPB->setEnabled(!in_sync);
+ okPB->setEnabled(!in_sync);
+ if (!in_sync)
+ closePB->setText(qt_("&Cancel"));
+ else
+ closePB->setText(qt_("&Close"));
}
void GuiParagraph::on_applyPB_clicked()
{
- ParagraphParameters & pp = params();
+ applyView();
+}
+
+
+void GuiParagraph::on_okPB_clicked()
+{
+ applyView();
+ hide();
+}
+
+
+void GuiParagraph::on_closePB_clicked()
+{
+ hide();
+}
+
+
+void GuiParagraph::on_restorePB_clicked()
+{
+ updateView();
+}
+
+
+void GuiParagraph::applyView()
+{
+ params_ = params();
- pp.align(getAlignmentFromDialog());
+ params_.align(getAlignmentFromDialog());
// get spacing
Spacing::Space ls = Spacing::Default;
break;
case 4:
ls = Spacing::Other;
- other = fromqstr(linespacingValue->text());
+ other = widgetToDoubleStr(linespacingValue);
break;
}
Spacing const spacing(ls, other);
- pp.spacing(spacing);
+ params_.spacing(spacing);
// label width
- pp.labelWidthString(qstring_to_ucs4(labelWidth->text()));
- // indendation
- pp.noindent(!indentCB->isChecked());
+ params_.labelWidthString(qstring_to_ucs4(labelWidth->text()));
+ // indentation
+ params_.noindent(!indentCB->isChecked());
dispatchParams();
}
-void GuiParagraph::on_restorePB_clicked()
-{
- updateView();
-}
-
-
void GuiParagraph::updateView()
{
on_synchronizedViewCB_toggled();
// label width
docstring const & labelwidth = pp.labelWidthString();
- // FIXME We should not compare translated strings
- if (labelwidth != _("Senseless with this layout!")) {
+ if (hasLabelwidth()) {
labelwidthGB->setEnabled(true);
labelWidth->setText(toqstr(labelwidth));
} else {
}
linespacing->setCurrentIndex(ls);
if (space.getSpace() == Spacing::Other) {
- linespacingValue->setText(toqstr(space.getValueAsString()));
+ doubleToWidget(linespacingValue, space.getValue());
linespacingValue->setEnabled(true);
} else {
linespacingValue->setText(QString());
}
-ParagraphParameters & GuiParagraph::params()
+ParagraphParameters const & GuiParagraph::params() const
{
if (haveMultiParSelection()) {
- multiparsel_ = ParagraphParameters();
- // FIXME: It would be nice to initialise the parameters that
- // are common to all paragraphs.
- return multiparsel_;
+ // FIXME: in case of multi-paragraph selection, it would be nice to
+ // initialise the parameters that are common to all paragraphs.
+ static ParagraphParameters const empty;
+ return empty;
}
-
- return bufferview()->cursor().innerParagraph().params();
-}
-
-
-ParagraphParameters const & GuiParagraph::params() const
-{
return bufferview()->cursor().innerParagraph().params();
}
void GuiParagraph::dispatchParams()
{
- if (haveMultiParSelection()) {
- ostringstream data;
- multiparsel_.write(data);
- FuncRequest const fr(getLfun(), data.str());
- dispatch(fr);
- return;
- }
-
- bufferview()->updateMetrics();
- bufferview()->buffer().changed();
+ ostringstream data;
+ params_.write(data);
+ FuncRequest const fr(getLfun(), data.str());
+ dispatch(fr);
}
-bool GuiParagraph::haveMultiParSelection()
+bool GuiParagraph::haveMultiParSelection() const
{
- Cursor cur = bufferview()->cursor();
+ Cursor const & cur = bufferview()->cursor();
return cur.selection() && cur.selBegin().pit() != cur.selEnd().pit();
}
bool GuiParagraph::canIndent() const
{
- return buffer().params().paragraph_separation
- == BufferParams::ParagraphIndentSeparation;
+ Layout const lay = bufferview()->cursor().innerParagraph().layout();
+ if (buffer().params().paragraph_separation
+ == BufferParams::ParagraphIndentSeparation)
+ return (lay.toggle_indent != ITOGGLE_NEVER);
+ return (lay.toggle_indent == ITOGGLE_ALWAYS);
}
}
+bool GuiParagraph::hasLabelwidth() const
+{
+ Layout layout = bufferview()->cursor().innerParagraph().layout();
+ return (layout.margintype == MARGIN_MANUAL
+ || layout.latextype == LATEX_BIB_ENVIRONMENT);
+}
+
+
+void GuiParagraph::saveSession() const
+{
+ Dialog::saveSession();
+ QSettings settings;
+ settings.setValue(sessionKey() + "/autoapply", synchronizedViewCB->isChecked());
+}
+
+
+void GuiParagraph::restoreSession()
+{
+ Dialog::restoreSession();
+ QSettings settings;
+ synchronizedViewCB->setChecked(
+ settings.value(sessionKey() + "/autoapply").toBool());
+}
+
+
Dialog * createGuiParagraph(GuiView & lv)
{
return new GuiParagraph(lv);
} // namespace frontend
} // namespace lyx
-#include "GuiParagraph_moc.cpp"
+#include "moc_GuiParagraph.cpp"