mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 13:48:59 +00:00
Add a preference option to specify the default length unit (cm or in).
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40030 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a5a5757b3e
commit
5014b38cb7
@ -28,6 +28,11 @@
|
|||||||
# Incremented to format 4, r40028 by vfr
|
# Incremented to format 4, r40028 by vfr
|
||||||
# Remove support for default paper size.
|
# Remove support for default paper size.
|
||||||
|
|
||||||
|
# Incremented to format 5, r40030 by vfr
|
||||||
|
# Add a default length unit.
|
||||||
|
# No conversion necessary.
|
||||||
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
@ -141,4 +146,5 @@ conversions = [
|
|||||||
[ 2, []],
|
[ 2, []],
|
||||||
[ 3, [ zipped_native ]],
|
[ 3, [ zipped_native ]],
|
||||||
[ 4, [ remove_default_papersize ]],
|
[ 4, [ remove_default_papersize ]],
|
||||||
|
[ 5, []],
|
||||||
]
|
]
|
||||||
|
@ -320,8 +320,7 @@ int Length::inBP() const
|
|||||||
|
|
||||||
Length::UNIT Length::defaultUnit()
|
Length::UNIT Length::defaultUnit()
|
||||||
{
|
{
|
||||||
// FIXME: use a preference
|
return lyxrc.default_length_unit;
|
||||||
return Length::CM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ namespace os = support::os;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
static unsigned int const LYXRC_FILEFORMAT = 4; // vfr: remove default paper size
|
static unsigned int const LYXRC_FILEFORMAT = 5; // vfr: add default length unit
|
||||||
|
|
||||||
// when adding something to this array keep it sorted!
|
// when adding something to this array keep it sorted!
|
||||||
LexerKeyword lyxrcTags[] = {
|
LexerKeyword lyxrcTags[] = {
|
||||||
@ -91,6 +91,7 @@ LexerKeyword lyxrcTags[] = {
|
|||||||
{ "\\def_file", LyXRC::RC_DEFFILE },
|
{ "\\def_file", LyXRC::RC_DEFFILE },
|
||||||
{ "\\default_decimal_point", LyXRC::RC_DEFAULT_DECIMAL_POINT },
|
{ "\\default_decimal_point", LyXRC::RC_DEFAULT_DECIMAL_POINT },
|
||||||
{ "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
|
{ "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
|
||||||
|
{ "\\default_length_unit", LyXRC::RC_DEFAULT_LENGTH_UNIT },
|
||||||
{ "\\default_view_format", LyXRC::RC_DEFAULT_VIEW_FORMAT },
|
{ "\\default_view_format", LyXRC::RC_DEFAULT_VIEW_FORMAT },
|
||||||
{ "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
|
{ "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
|
||||||
{ "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
|
{ "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
|
||||||
@ -365,6 +366,7 @@ void LyXRC::setDefaults()
|
|||||||
completion_inline_dots = -1;
|
completion_inline_dots = -1;
|
||||||
completion_inline_delay = 0.2;
|
completion_inline_delay = 0.2;
|
||||||
default_decimal_point = ".";
|
default_decimal_point = ".";
|
||||||
|
default_length_unit = Length::CM;
|
||||||
cursor_width = 1;
|
cursor_width = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -979,6 +981,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
|
|||||||
case RC_DEFAULT_DECIMAL_POINT:
|
case RC_DEFAULT_DECIMAL_POINT:
|
||||||
lexrc >> default_decimal_point;
|
lexrc >> default_decimal_point;
|
||||||
break;
|
break;
|
||||||
|
case RC_DEFAULT_LENGTH_UNIT:
|
||||||
|
if (lexrc.next())
|
||||||
|
default_length_unit = (Length::UNIT) lexrc.getInteger();
|
||||||
|
break;
|
||||||
case RC_DATE_INSERT_FORMAT:
|
case RC_DATE_INSERT_FORMAT:
|
||||||
lexrc >> date_insert_format;
|
lexrc >> date_insert_format;
|
||||||
break;
|
break;
|
||||||
@ -2448,6 +2454,14 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
|
|||||||
if (tag != RC_LAST)
|
if (tag != RC_LAST)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RC_DEFAULT_LENGTH_UNIT:
|
||||||
|
if (ignore_system_lyxrc ||
|
||||||
|
default_length_unit != system_lyxrc.default_length_unit) {
|
||||||
|
os << "\\default_length_unit " << int(default_length_unit) << '\n';
|
||||||
|
}
|
||||||
|
if (tag != RC_LAST)
|
||||||
|
break;
|
||||||
|
|
||||||
case RC_SPELLCHECKER:
|
case RC_SPELLCHECKER:
|
||||||
if (ignore_system_lyxrc ||
|
if (ignore_system_lyxrc ||
|
||||||
spellchecker != system_lyxrc.spellchecker) {
|
spellchecker != system_lyxrc.spellchecker) {
|
||||||
@ -2996,6 +3010,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
|
|||||||
case LyXRC::RC_FORWARD_SEARCH_PDF:
|
case LyXRC::RC_FORWARD_SEARCH_PDF:
|
||||||
case LyXRC::RC_EXPORT_OVERWRITE:
|
case LyXRC::RC_EXPORT_OVERWRITE:
|
||||||
case LyXRC::RC_DEFAULT_DECIMAL_POINT:
|
case LyXRC::RC_DEFAULT_DECIMAL_POINT:
|
||||||
|
case LyXRC::RC_DEFAULT_LENGTH_UNIT:
|
||||||
case LyXRC::RC_SCROLL_WHEEL_ZOOM:
|
case LyXRC::RC_SCROLL_WHEEL_ZOOM:
|
||||||
case LyXRC::RC_CURSOR_WIDTH:
|
case LyXRC::RC_CURSOR_WIDTH:
|
||||||
break;
|
break;
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#define LYXRC_H
|
#define LYXRC_H
|
||||||
|
|
||||||
#include "paper.h"
|
#include "paper.h"
|
||||||
|
#include "Length.h"
|
||||||
|
|
||||||
#include "support/strfwd.h"
|
#include "support/strfwd.h"
|
||||||
|
|
||||||
@ -68,6 +69,7 @@ public:
|
|||||||
RC_CURSOR_WIDTH,
|
RC_CURSOR_WIDTH,
|
||||||
RC_DATE_INSERT_FORMAT,
|
RC_DATE_INSERT_FORMAT,
|
||||||
RC_DEFAULT_DECIMAL_POINT,
|
RC_DEFAULT_DECIMAL_POINT,
|
||||||
|
RC_DEFAULT_LENGTH_UNIT,
|
||||||
RC_DEFAULT_LANGUAGE,
|
RC_DEFAULT_LANGUAGE,
|
||||||
RC_DEFAULT_VIEW_FORMAT,
|
RC_DEFAULT_VIEW_FORMAT,
|
||||||
RC_DEFFILE,
|
RC_DEFFILE,
|
||||||
@ -528,6 +530,8 @@ public:
|
|||||||
/// Default decimal point when aligning table columns on decimal
|
/// Default decimal point when aligning table columns on decimal
|
||||||
std::string default_decimal_point;
|
std::string default_decimal_point;
|
||||||
///
|
///
|
||||||
|
Length::UNIT default_length_unit;
|
||||||
|
///
|
||||||
enum ScrollWheelZoom {
|
enum ScrollWheelZoom {
|
||||||
SCROLL_WHEEL_ZOOM_OFF,
|
SCROLL_WHEEL_ZOOM_OFF,
|
||||||
SCROLL_WHEEL_ZOOM_CTRL,
|
SCROLL_WHEEL_ZOOM_CTRL,
|
||||||
|
@ -2255,6 +2255,8 @@ PrefLanguage::PrefLanguage(GuiPreferences * form)
|
|||||||
this, SIGNAL(changed()));
|
this, SIGNAL(changed()));
|
||||||
connect(defaultDecimalPointLE, SIGNAL(textChanged(QString)),
|
connect(defaultDecimalPointLE, SIGNAL(textChanged(QString)),
|
||||||
this, SIGNAL(changed()));
|
this, SIGNAL(changed()));
|
||||||
|
connect(defaultLengthUnitCO, SIGNAL(activated(int)),
|
||||||
|
this, SIGNAL(changed()));
|
||||||
|
|
||||||
languagePackageED->setValidator(new NoNewLineValidator(languagePackageED));
|
languagePackageED->setValidator(new NoNewLineValidator(languagePackageED));
|
||||||
startCommandED->setValidator(new NoNewLineValidator(startCommandED));
|
startCommandED->setValidator(new NoNewLineValidator(startCommandED));
|
||||||
@ -2268,6 +2270,9 @@ PrefLanguage::PrefLanguage(GuiPreferences * form)
|
|||||||
defaultDecimalPointLE->setInputMask("X; ");
|
defaultDecimalPointLE->setInputMask("X; ");
|
||||||
defaultDecimalPointLE->setMaxLength(1);
|
defaultDecimalPointLE->setMaxLength(1);
|
||||||
|
|
||||||
|
defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::CM]), Length::CM);
|
||||||
|
defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::IN]), Length::IN);
|
||||||
|
|
||||||
set<string> added;
|
set<string> added;
|
||||||
uiLanguageCO->blockSignals(true);
|
uiLanguageCO->blockSignals(true);
|
||||||
uiLanguageCO->addItem(qt_("Default"), toqstr("auto"));
|
uiLanguageCO->addItem(qt_("Default"), toqstr("auto"));
|
||||||
@ -2327,6 +2332,7 @@ void PrefLanguage::apply(LyXRC & rc) const
|
|||||||
rc.gui_language = fromqstr(
|
rc.gui_language = fromqstr(
|
||||||
uiLanguageCO->itemData(uiLanguageCO->currentIndex()).toString());
|
uiLanguageCO->itemData(uiLanguageCO->currentIndex()).toString());
|
||||||
rc.default_decimal_point = fromqstr(defaultDecimalPointLE->text());
|
rc.default_decimal_point = fromqstr(defaultDecimalPointLE->text());
|
||||||
|
rc.default_length_unit = (Length::UNIT) defaultLengthUnitCO->itemData(defaultLengthUnitCO->currentIndex()).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2348,8 +2354,10 @@ void PrefLanguage::update(LyXRC const & rc)
|
|||||||
startCommandED->setText(toqstr(rc.language_command_begin));
|
startCommandED->setText(toqstr(rc.language_command_begin));
|
||||||
endCommandED->setText(toqstr(rc.language_command_end));
|
endCommandED->setText(toqstr(rc.language_command_end));
|
||||||
defaultDecimalPointLE->setText(toqstr(rc.default_decimal_point));
|
defaultDecimalPointLE->setText(toqstr(rc.default_decimal_point));
|
||||||
|
int pos = defaultLengthUnitCO->findData(int(rc.default_length_unit));
|
||||||
|
defaultLengthUnitCO->setCurrentIndex(pos);
|
||||||
|
|
||||||
int pos = uiLanguageCO->findData(toqstr(rc.gui_language));
|
pos = uiLanguageCO->findData(toqstr(rc.gui_language));
|
||||||
uiLanguageCO->blockSignals(true);
|
uiLanguageCO->blockSignals(true);
|
||||||
uiLanguageCO->setCurrentIndex(pos);
|
uiLanguageCO->setCurrentIndex(pos);
|
||||||
uiLanguageCO->blockSignals(false);
|
uiLanguageCO->blockSignals(false);
|
||||||
|
@ -154,7 +154,20 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0" colspan="2">
|
<item row="5" column="0">
|
||||||
|
<widget class="QLabel" name="defaultLengthUnitLA">
|
||||||
|
<property name="text">
|
||||||
|
<string>Default length &unit:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>defaultLengthUnitCO</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QComboBox" name="defaultLengthUnitCO" />
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="globalCB">
|
<widget class="QCheckBox" name="globalCB">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Check to pass the language globally (to the document class), not locally (to the language package)</string>
|
<string>Check to pass the language globally (to the document class), not locally (to the language package)</string>
|
||||||
@ -164,7 +177,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="7" column="0">
|
||||||
<widget class="QCheckBox" name="autoBeginCB">
|
<widget class="QCheckBox" name="autoBeginCB">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>If checked, the document language is not explicitly set by a language switch command</string>
|
<string>If checked, the document language is not explicitly set by a language switch command</string>
|
||||||
@ -174,7 +187,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0">
|
<item row="8" column="0">
|
||||||
<widget class="QCheckBox" name="autoEndCB">
|
<widget class="QCheckBox" name="autoEndCB">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>If checked, the document language is not explicitly closed by a language switch command</string>
|
<string>If checked, the document language is not explicitly closed by a language switch command</string>
|
||||||
@ -184,7 +197,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0" colspan="2">
|
<item row="9" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="markForeignCB">
|
<widget class="QCheckBox" name="markForeignCB">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Check to highlight foreign languages visually in the work area</string>
|
<string>Check to highlight foreign languages visually in the work area</string>
|
||||||
@ -194,7 +207,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="0" colspan="3">
|
<item row="10" column="0" colspan="3">
|
||||||
<widget class="QGroupBox" name="rtlGB2">
|
<widget class="QGroupBox" name="rtlGB2">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string/>
|
<string/>
|
||||||
@ -272,7 +285,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="10" column="0">
|
<item row="11" column="0">
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
|
Loading…
Reference in New Issue
Block a user