commit b774ebb610a375db7aecf4480bb0f0a508769919
Author: Juergen Spitzmueller <[email protected]>
Date: Sat Jul 5 17:58:17 2025 +0200
Make "Use justification in LyX work area" a preference (#13009)
---
lib/lyx2lyx/lyx_2_5.py | 16 +-
src/BufferParams.cpp | 12 +-
src/BufferParams.h | 4 +-
src/LyXRC.cpp | 18 +-
src/LyXRC.h | 3 +
src/TextMetrics.cpp | 2 +-
src/frontends/qt/GuiDocument.cpp | 10 +-
src/frontends/qt/GuiPrefs.cpp | 3 +
src/frontends/qt/ui/PrefDisplayUi.ui | 20 ++-
src/frontends/qt/ui/TextLayoutUi.ui | 317 +++++++++++++++++++----------------
src/version.h | 4 +-
11 files changed, 248 insertions(+), 161 deletions(-)
diff --git a/lib/lyx2lyx/lyx_2_5.py b/lib/lyx2lyx/lyx_2_5.py
index e06378f59e..f5cef6f325 100644
--- a/lib/lyx2lyx/lyx_2_5.py
+++ b/lib/lyx2lyx/lyx_2_5.py
@@ -3181,6 +3181,18 @@ def revert_prettyref_l7n(document):
if i != -1:
document.header[i] = "\\crossref_package prettyref"
+def revert_justification_pref(document):
+ """Revert justification pref setting"""
+ i = find_token(document.header, "\\justification default", 0)
+ if i != -1:
+ document.header[i] = "\\justification true"
+
+def convert_justification_pref(document):
+ """Convert justification pref setting"""
+ i = find_token(document.header, "\\justification true", 0)
+ if i != -1:
+ document.header[i] = "\\justification default"
+
##
# Conversion hub
#
@@ -3206,11 +3218,13 @@ convert = [
[637, [convert_reflists]],
[638, []],
[639, [convert_theorem_local_def]],
- [640, []]
+ [640, []],
+ [641, [convert_justification_pref]]
]
revert = [
+ [640, [revert_justification_pref]],
[639, [revert_prettyref_l7n]],
[638, [revert_theorem_local_def]],
[637, [revert_xr]],
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 66499dec19..91919ff40d 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -462,7 +462,7 @@ BufferParams::BufferParams()
float_alignment = "class";
float_placement = "class";
suppress_date = false;
- justification = true;
+ justification = "default";
// no color is the default (white)
backgroundcolor = "none";
// no color is the default (black)
@@ -1769,7 +1769,7 @@ void BufferParams::writeFile(ostream & os, Buffer const *
buf) const
<< "\n\\use_indices " << convert<string>(use_indices)
<< "\n\\paperorientation " << string_orientation[orientation]
<< "\n\\suppress_date " << convert<string>(suppress_date)
- << "\n\\justification " << convert<string>(justification)
+ << "\n\\justification " << justification
<< "\n\\crossref_package " << xref_package
<< "\n\\use_formatted_ref " << use_formatted_ref
<< "\n\\use_minted " << use_minted
@@ -4507,4 +4507,12 @@ BufferParams const & defaultBufferParams()
}
+bool BufferParams::workareaJustified() const
+{
+ if (justification == "default")
+ return lyxrc.workarea_justify;
+ return justification == "true";
+}
+
+
} // namespace lyx
diff --git a/src/BufferParams.h b/src/BufferParams.h
index 7723c6f416..7c66b465af 100644
--- a/src/BufferParams.h
+++ b/src/BufferParams.h
@@ -413,7 +413,9 @@ public:
///
unsigned int columns;
///
- bool justification;
+ std::string justification;
+ ///
+ bool workareaJustified() const;
/// parameters for the listings package
std::string listings_params;
///
diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
index a8fafae2ae..8e0d875442 100644
--- a/src/LyXRC.cpp
+++ b/src/LyXRC.cpp
@@ -199,7 +199,7 @@ LexerKeyword lyxrcTags[] = {
{ "\\thesaurusdir_path", LyXRC::RC_THESAURUSDIRPATH },
{ "\\ui_file", LyXRC::RC_UIFILE },
{ "\\ui_style", LyXRC::RC_UI_STYLE },
- { "\\ui_theme", LyXRC::RC_UI_THEME },
+ { "\\ui_theme", LyXRC::RC_UI_THEME },
{ "\\use_converter_cache", LyXRC::RC_USE_CONVERTER_CACHE },
{ "\\use_converter_needauth", LyXRC::RC_USE_CONVERTER_NEEDAUTH },
{ "\\use_converter_needauth_forbidden",
LyXRC::RC_USE_CONVERTER_NEEDAUTH_FORBIDDEN },
@@ -217,6 +217,7 @@ LexerKeyword lyxrcTags[] = {
{ "\\viewer", LyXRC::RC_VIEWER},
{ "\\viewer_alternatives", LyXRC::RC_VIEWER_ALTERNATIVES },
{ "\\visual_cursor", LyXRC::RC_VISUAL_CURSOR },
+ { "\\workarea_justify", LyXRC::RC_WORKAREA_JUSTIFY },
{ "format", LyXRC::RC_LYXRCFORMAT }
};
@@ -1152,6 +1153,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool
check_format)
}
break;
+ case RC_WORKAREA_JUSTIFY:
+ lexrc >> workarea_justify;
+ break;
+
case RC_DRAW_STRATEGY:
if (lexrc.next()) {
string const tmp = lexrc.getString();
@@ -1775,6 +1780,16 @@ void LyXRC::write(ostream & os, bool
ignore_system_lyxrc, string const & name) c
if (tag != RC_LAST)
break;
// fall through
+ case RC_WORKAREA_JUSTIFY:
+ if (ignore_system_lyxrc ||
+ workarea_justify != system_lyxrc.workarea_justify) {
+ os << "\\workarea_justify "
+ << convert<string>(workarea_justify)
+ << '\n';
+ }
+ if (tag != RC_LAST)
+ break;
+ // fall through
case RC_PARAGRAPH_MARKERS:
if (ignore_system_lyxrc ||
paragraph_markers
@@ -3133,6 +3148,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC
const & lyxrc_new)
case LyXRC::RC_DEFAULT_LENGTH_UNIT:
case LyXRC::RC_SCROLL_WHEEL_ZOOM:
case LyXRC::RC_CURSOR_WIDTH:
+ case LyXRC::RC_WORKAREA_JUSTIFY:
break;
}
}
diff --git a/src/LyXRC.h b/src/LyXRC.h
index cf492d2bdc..01b5e99b52 100644
--- a/src/LyXRC.h
+++ b/src/LyXRC.h
@@ -192,6 +192,7 @@ public:
RC_VIEWER,
RC_VIEWER_ALTERNATIVES,
RC_VISUAL_CURSOR,
+ RC_WORKAREA_JUSTIFY,
RC_CLOSE_BUFFER_WITH_LAST_VIEW,
RC_DRAW_STRATEGY,
RC_LAST
@@ -581,6 +582,8 @@ public:
BMK_MARGIN,
BMK_INLINE
};
+ ///
+ bool workarea_justify = true;
///
BookmarksVisibility bookmarks_visibility = BMK_MARGIN;
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 46e2b9c9df..045c2e9ae3 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -631,7 +631,7 @@ LyXAlignment TextMetrics::getAlign(Paragraph const & par,
Row const & row) const
// A forced block alignment can only be overridden the 'no
// justification on screen' setting.
if ((row.flushed() && !forced_block)
- || !bv_->buffer().params().justification)
+ || !bv_->buffer().params().workareaJustified())
align = row.isRTL() ? LYX_ALIGN_RIGHT : LYX_ALIGN_LEFT;
}
diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp
index a10a87cefc..56e2d4cebd 100644
--- a/src/frontends/qt/GuiDocument.cpp
+++ b/src/frontends/qt/GuiDocument.cpp
@@ -866,8 +866,11 @@ GuiDocument::GuiDocument(GuiView & lv)
this, SLOT(change_adaptor()));
connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()),
this, SLOT(setColSep()));
- connect(textLayoutModule->justCB, SIGNAL(clicked()),
+ connect(textLayoutModule->justCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
+ textLayoutModule->justCO->addItem(qt_("Default"), toqstr("default"));
+ textLayoutModule->justCO->addItem(qt_("Yes"), toqstr("true"));
+ textLayoutModule->justCO->addItem(qt_("No"), toqstr("false"));
connect(textLayoutModule->tableStyleCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
@@ -3892,7 +3895,8 @@ void GuiDocument::applyView()
else
bp_.columns = 1;
- bp_.justification = textLayoutModule->justCB->isChecked();
+ bp_.justification = fromqstr(textLayoutModule->justCO->itemData(
+
textLayoutModule->justCO->currentIndex()).toString());
if (textLayoutModule->indentRB->isChecked()) {
// if paragraphs are separated by an indentation
@@ -4485,7 +4489,7 @@ void GuiDocument::paramsToDialog()
textLayoutModule->twoColumnCB->setChecked(
bp_.columns == 2);
- textLayoutModule->justCB->setChecked(bp_.justification);
+
textLayoutModule->justCO->setCurrentIndex(textLayoutModule->justCO->findData(toqstr(bp_.justification)));
if (!bp_.options.empty()) {
latexModule->optionsLE->setText(
diff --git a/src/frontends/qt/GuiPrefs.cpp b/src/frontends/qt/GuiPrefs.cpp
index 2f1c68720a..36786d9ba3 100644
--- a/src/frontends/qt/GuiPrefs.cpp
+++ b/src/frontends/qt/GuiPrefs.cpp
@@ -1945,6 +1945,7 @@ PrefDisplay::PrefDisplay(GuiPreferences * form)
bookmarksCO->addItem(qt_("No[[bookmarks]]"), "none");
bookmarksCO->addItem(qt_("Inline"), "inline");
bookmarksCO->addItem(qt_("In Margin"), "margin");
+ connect(justCB, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
}
@@ -1972,6 +1973,7 @@ void PrefDisplay::applyRC(LyXRC & rc) const
rc.preview_scale_factor = previewSizeSB->value();
rc.paragraph_markers = paragraphMarkerCB->isChecked();
rc.ct_additions_underlined = ctAdditionsUnderlinedCB->isChecked();
+ rc.workarea_justify = justCB->isChecked();
QString const bm =
bookmarksCO->itemData(bookmarksCO->currentIndex()).toString();
if (bm == "inline")
rc.bookmarks_visibility = LyXRC::BMK_INLINE;
@@ -2007,6 +2009,7 @@ void PrefDisplay::updateRC(LyXRC const & rc)
displayGraphicsCB->setChecked(rc.display_graphics);
previewSizeSB->setValue(rc.preview_scale_factor);
paragraphMarkerCB->setChecked(rc.paragraph_markers);
+ justCB->setChecked(rc.workarea_justify);
ctAdditionsUnderlinedCB->setChecked(rc.ct_additions_underlined);
bookmarksCO->setCurrentIndex(rc.bookmarks_visibility);
switch (rc.bookmarks_visibility) {
diff --git a/src/frontends/qt/ui/PrefDisplayUi.ui
b/src/frontends/qt/ui/PrefDisplayUi.ui
index a288a58972..0147c79c1b 100644
--- a/src/frontends/qt/ui/PrefDisplayUi.ui
+++ b/src/frontends/qt/ui/PrefDisplayUi.ui
@@ -107,7 +107,17 @@
</property>
</widget>
</item>
- <item row="2" column="0" colspan="2">
+ <item row="2" column="0" colspan="5">
+ <widget class="QCheckBox" name="justCB">
+ <property name="toolTip">
+ <string>Justify text in the LyX editor (this does not affect whether the
text is justified in the output)</string>
+ </property>
+ <property name="text">
+ <string>Use &justification in LyX work area</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="paragraphMarkerCB">
<property name="toolTip">
<string>Mark end of paragraphs on screen with a pilcrow
character.</string>
@@ -117,7 +127,7 @@
</property>
</widget>
</item>
- <item row="3" column="0" colspan="3">
+ <item row="4" column="0" colspan="3">
<widget class="QCheckBox" name="ctAdditionsUnderlinedCB">
<property name="toolTip">
<string>If this is checked, additions in change tracking are underlined
in the workarea</string>
@@ -127,7 +137,7 @@
</property>
</widget>
</item>
- <item row="4" column="0" colspan="3">
+ <item row="5" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="bookmarksLA">
@@ -161,7 +171,7 @@
</item>
</layout>
</item>
- <item row="5" column="2">
+ <item row="6" column="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -169,7 +179,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
- <height>121</height>
+ <height>67</height>
</size>
</property>
</spacer>
diff --git a/src/frontends/qt/ui/TextLayoutUi.ui
b/src/frontends/qt/ui/TextLayoutUi.ui
index dae190f19f..3c2195a0b3 100644
--- a/src/frontends/qt/ui/TextLayoutUi.ui
+++ b/src/frontends/qt/ui/TextLayoutUi.ui
@@ -14,144 +14,6 @@
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_4">
- <item row="1" column="0">
- <widget class="QGroupBox" name="spacingGB">
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
- <property name="title">
- <string>Spacing</string>
- </property>
- <property name="flat">
- <bool>true</bool>
- </property>
- <property name="checkable">
- <bool>false</bool>
- </property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <widget class="QLabel" name="lspacingL">
- <property name="minimumSize">
- <size>
- <width>91</width>
- <height>18</height>
- </size>
- </property>
- <property name="text">
- <string>&Line spacing:</string>
- </property>
- <property name="buddy">
- <cstring>lspacingCO</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QComboBox" name="lspacingCO">
- <property name="toolTip">
- <string>Spacing type</string>
- </property>
- <property name="duplicatesEnabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="QLineEdit" name="lspacingLE">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="toolTip">
- <string>Number of lines</string>
- </property>
- <property name="inputMethodHints">
- <set>Qt::ImhFormattedNumbersOnly|Qt::ImhLatinOnly</set>
- </property>
- </widget>
- </item>
- <item row="0" column="3">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>69</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QGroupBox" name="tableStyleGB">
- <property name="title">
- <string>Table Style</string>
- </property>
- <property name="flat">
- <bool>true</bool>
- </property>
- <layout class="QGridLayout" name="gridLayout_3">
- <item row="0" column="0">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QLabel" name="tableStyleLA">
- <property name="text">
- <string>Default St&yle:</string>
- </property>
- <property name="buddy">
- <cstring>tableStyleCO</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="tableStyleCO">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item row="7" column="0">
- <spacer>
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>403</width>
- <height>21</height>
- </size>
- </property>
- </spacer>
- </item>
<item row="0" column="0">
<widget class="QGroupBox" name="separateGB">
<property name="title">
@@ -335,17 +197,129 @@
</layout>
</widget>
</item>
- <item row="6" column="0">
- <widget class="QCheckBox" name="justCB">
- <property name="toolTip">
- <string>Justify text in the LyX editor (this does not affect whether the
text is justified in the output)</string>
+ <item row="1" column="0">
+ <widget class="QGroupBox" name="spacingGB">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
</property>
- <property name="text">
- <string>Use &justification in LyX work area</string>
+ <property name="title">
+ <string>Spacing</string>
</property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <widget class="QLabel" name="lspacingL">
+ <property name="minimumSize">
+ <size>
+ <width>91</width>
+ <height>18</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>&Line spacing:</string>
+ </property>
+ <property name="buddy">
+ <cstring>lspacingCO</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="lspacingCO">
+ <property name="toolTip">
+ <string>Spacing type</string>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLineEdit" name="lspacingLE">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>Number of lines</string>
+ </property>
+ <property name="inputMethodHints">
+ <set>Qt::ImhFormattedNumbersOnly|Qt::ImhLatinOnly</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>69</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
</widget>
</item>
- <item row="5" column="0">
+ <item row="2" column="0">
+ <widget class="QGroupBox" name="tableStyleGB">
+ <property name="title">
+ <string>Table Style</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="tableStyleLA">
+ <property name="text">
+ <string>Default St&yle:</string>
+ </property>
+ <property name="buddy">
+ <cstring>tableStyleCO</cstring>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="tableStyleCO">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="3" column="0">
<widget class="QCheckBox" name="twoColumnCB">
<property name="toolTip">
<string>Format text into two columns</string>
@@ -355,6 +329,59 @@
</property>
</widget>
</item>
+ <item row="4" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="justLA">
+ <property name="toolTip">
+ <string>Justify text in the LyX editor (this does not affect whether
the text is justified in the output)</string>
+ </property>
+ <property name="text">
+ <string>Use &justification in LyX work area:</string>
+ </property>
+ <property name="buddy">
+ <cstring>justCO</cstring>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="justCO">
+ <property name="toolTip">
+ <string>Justify text in the LyX editor (this does not affect whether
the text is justified in the output)</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="5" column="0">
+ <spacer>
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>403</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</widget>
<customwidgets>
diff --git a/src/version.h b/src/version.h
index d3cc200529..dd69b60fcb 100644
--- a/src/version.h
+++ b/src/version.h
@@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 640 // spitz: prettyref-l7n
-#define LYX_FORMAT_TEX2LYX 640
+#define LYX_FORMAT_LYX 641 // spitz: justification2pref
+#define LYX_FORMAT_TEX2LYX 641
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs