mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Move the half baked code that guesses whether to default on metric or
imperial units in only one place (instead of thousands of slightly different copies). Functionally equivalent. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28380 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0a1abacc42
commit
26751d83ee
@ -276,6 +276,26 @@ int Length::inBP() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Length::UNIT Length::defaultUnit()
|
||||||
|
{
|
||||||
|
// FIXME user a proper pref, since we should get rid of
|
||||||
|
// default_papersize in lyxrc.
|
||||||
|
UNIT u = Length::CM;
|
||||||
|
switch (lyxrc.default_papersize) {
|
||||||
|
case PAPER_USLETTER:
|
||||||
|
case PAPER_USLEGAL:
|
||||||
|
case PAPER_USEXECUTIVE:
|
||||||
|
u = Length::IN;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool operator==(Length const & l1, Length const & l2)
|
bool operator==(Length const & l1, Length const & l2)
|
||||||
{
|
{
|
||||||
return l1.value() == l2.value() && l1.unit() == l2.unit();
|
return l1.value() == l2.value() && l1.unit() == l2.unit();
|
||||||
|
@ -92,6 +92,9 @@ public:
|
|||||||
/// return the value in Big Postscript points.
|
/// return the value in Big Postscript points.
|
||||||
int inBP() const;
|
int inBP() const;
|
||||||
|
|
||||||
|
/// return the default unit (centimeter or inch)
|
||||||
|
static UNIT defaultUnit();
|
||||||
|
|
||||||
friend bool isValidLength(std::string const & data, Length * result);
|
friend bool isValidLength(std::string const & data, Length * result);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
#include "LengthCombo.h"
|
#include "LengthCombo.h"
|
||||||
#include "Length.h"
|
#include "Length.h"
|
||||||
#include "LyXRC.h" // to set the default length values
|
|
||||||
#include "qt_helpers.h"
|
#include "qt_helpers.h"
|
||||||
#include "Validator.h"
|
#include "Validator.h"
|
||||||
|
|
||||||
@ -265,8 +264,7 @@ void GuiBox::updateContents()
|
|||||||
halignCO->setEnabled(!ibox);
|
halignCO->setEnabled(!ibox);
|
||||||
setSpecial(ibox);
|
setSpecial(ibox);
|
||||||
|
|
||||||
Length::UNIT default_unit =
|
Length::UNIT const default_unit = Length::defaultUnit();
|
||||||
(lyxrc.default_papersize > 3) ? Length::CM : Length::IN;
|
|
||||||
|
|
||||||
lengthToWidgets(widthED, widthUnitsLC,
|
lengthToWidgets(widthED, widthUnitsLC,
|
||||||
(params_.width).asString(), default_unit);
|
(params_.width).asString(), default_unit);
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include "Language.h"
|
#include "Language.h"
|
||||||
#include "LaTeXFeatures.h"
|
#include "LaTeXFeatures.h"
|
||||||
#include "Layout.h"
|
#include "Layout.h"
|
||||||
#include "LyXRC.h" // defaultUnit
|
#include "LyXRC.h"
|
||||||
#include "ModuleList.h"
|
#include "ModuleList.h"
|
||||||
#include "OutputParams.h"
|
#include "OutputParams.h"
|
||||||
#include "PDFOptions.h"
|
#include "PDFOptions.h"
|
||||||
@ -1832,27 +1832,7 @@ void GuiDocument::applyView()
|
|||||||
void GuiDocument::paramsToDialog()
|
void GuiDocument::paramsToDialog()
|
||||||
{
|
{
|
||||||
// set the default unit
|
// set the default unit
|
||||||
Length::UNIT defaultUnit = Length::CM;
|
Length::UNIT const defaultUnit = Length::defaultUnit();
|
||||||
switch (lyxrc.default_papersize) {
|
|
||||||
case PAPER_DEFAULT: break;
|
|
||||||
|
|
||||||
case PAPER_USLETTER:
|
|
||||||
case PAPER_USLEGAL:
|
|
||||||
case PAPER_USEXECUTIVE:
|
|
||||||
defaultUnit = Length::IN;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PAPER_A3:
|
|
||||||
case PAPER_A4:
|
|
||||||
case PAPER_A5:
|
|
||||||
case PAPER_B3:
|
|
||||||
case PAPER_B4:
|
|
||||||
case PAPER_B5:
|
|
||||||
defaultUnit = Length::CM;
|
|
||||||
break;
|
|
||||||
case PAPER_CUSTOM:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// preamble
|
// preamble
|
||||||
preambleModule->update(bp_, id());
|
preambleModule->update(bp_, id());
|
||||||
|
@ -349,22 +349,6 @@ void GuiExternal::widthUnitChanged()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Length::UNIT defaultUnit()
|
|
||||||
{
|
|
||||||
Length::UNIT default_unit = Length::CM;
|
|
||||||
switch (lyxrc.default_papersize) {
|
|
||||||
case PAPER_USLETTER:
|
|
||||||
case PAPER_USLEGAL:
|
|
||||||
case PAPER_USEXECUTIVE:
|
|
||||||
default_unit = Length::IN;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return default_unit;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void setRotation(QLineEdit & angleED, QComboBox & originCO,
|
static void setRotation(QLineEdit & angleED, QComboBox & originCO,
|
||||||
external::RotationData const & data)
|
external::RotationData const & data)
|
||||||
{
|
{
|
||||||
@ -401,11 +385,11 @@ static void setSize(QLineEdit & widthED, LengthCombo & widthUnitCO,
|
|||||||
widthUnitCO.setCurrentItem("scale");
|
widthUnitCO.setCurrentItem("scale");
|
||||||
} else
|
} else
|
||||||
lengthToWidgets(&widthED, &widthUnitCO,
|
lengthToWidgets(&widthED, &widthUnitCO,
|
||||||
data.width.asString(), defaultUnit());
|
data.width.asString(), Length::defaultUnit());
|
||||||
|
|
||||||
string const h = data.height.zero() ? string() : data.height.asString();
|
string const h = data.height.zero() ? string() : data.height.asString();
|
||||||
Length::UNIT default_unit = data.width.zero() ?
|
Length::UNIT const default_unit = data.width.zero() ?
|
||||||
defaultUnit() : data.width.unit();
|
Length::defaultUnit() : data.width.unit();
|
||||||
lengthToWidgets(&heightED, &heightUnitCO, h, default_unit);
|
lengthToWidgets(&heightED, &heightUnitCO, h, default_unit);
|
||||||
|
|
||||||
heightED.setEnabled(!using_scale);
|
heightED.setEnabled(!using_scale);
|
||||||
|
@ -540,16 +540,7 @@ void GuiGraphics::paramsToDialog(InsetGraphicsParams const & igp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set the right default unit
|
// set the right default unit
|
||||||
Length::UNIT unitDefault = Length::CM;
|
Length::UNIT const defaultUnit = Length::defaultUnit();
|
||||||
switch (lyxrc.default_papersize) {
|
|
||||||
case PAPER_USLETTER:
|
|
||||||
case PAPER_USLEGAL:
|
|
||||||
case PAPER_USEXECUTIVE:
|
|
||||||
unitDefault = Length::IN;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//lyxerr << bufferFilepath();
|
//lyxerr << bufferFilepath();
|
||||||
string const name =
|
string const name =
|
||||||
@ -642,9 +633,9 @@ void GuiGraphics::paramsToDialog(InsetGraphicsParams const & igp)
|
|||||||
groupCO->blockSignals(false);
|
groupCO->blockSignals(false);
|
||||||
|
|
||||||
if (igp.width.value() == 0)
|
if (igp.width.value() == 0)
|
||||||
lengthToWidgets(Width, widthUnit, _(autostr), unitDefault);
|
lengthToWidgets(Width, widthUnit, _(autostr), defaultUnit);
|
||||||
else
|
else
|
||||||
lengthToWidgets(Width, widthUnit, igp.width, unitDefault);
|
lengthToWidgets(Width, widthUnit, igp.width, defaultUnit);
|
||||||
|
|
||||||
bool const widthChecked = !Width->text().isEmpty() &&
|
bool const widthChecked = !Width->text().isEmpty() &&
|
||||||
Width->text() != qt_(autostr);
|
Width->text() != qt_(autostr);
|
||||||
@ -655,9 +646,9 @@ void GuiGraphics::paramsToDialog(InsetGraphicsParams const & igp)
|
|||||||
widthUnit->setEnabled(widthChecked);
|
widthUnit->setEnabled(widthChecked);
|
||||||
|
|
||||||
if (igp.height.value() == 0)
|
if (igp.height.value() == 0)
|
||||||
lengthToWidgets(Height, heightUnit, _(autostr), unitDefault);
|
lengthToWidgets(Height, heightUnit, _(autostr), defaultUnit);
|
||||||
else
|
else
|
||||||
lengthToWidgets(Height, heightUnit, igp.height, unitDefault);
|
lengthToWidgets(Height, heightUnit, igp.height, defaultUnit);
|
||||||
|
|
||||||
bool const heightChecked = !Height->text().isEmpty()
|
bool const heightChecked = !Height->text().isEmpty()
|
||||||
&& Height->text() != qt_(autostr);
|
&& Height->text() != qt_(autostr);
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#include "qt_helpers.h"
|
#include "qt_helpers.h"
|
||||||
#include "Validator.h"
|
#include "Validator.h"
|
||||||
|
|
||||||
#include "LyXRC.h"
|
|
||||||
#include "Spacing.h"
|
#include "Spacing.h"
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
|
|
||||||
@ -248,8 +247,7 @@ static void setWidgetsFromHSpace(InsetSpaceParams const & params,
|
|||||||
fillPattern->setCurrentIndex(pattern);
|
fillPattern->setCurrentIndex(pattern);
|
||||||
keep->setChecked(protect);
|
keep->setChecked(protect);
|
||||||
|
|
||||||
Length::UNIT default_unit =
|
Length::UNIT const default_unit = Length::defaultUnit();
|
||||||
(lyxrc.default_papersize > 3) ? Length::CM : Length::IN;
|
|
||||||
if (item == (params.math ? 9 : 7))
|
if (item == (params.math ? 9 : 7))
|
||||||
lengthToWidgets(value, unit, params.length, default_unit);
|
lengthToWidgets(value, unit, params.length, default_unit);
|
||||||
else
|
else
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include "BufferView.h"
|
#include "BufferView.h"
|
||||||
#include "Cursor.h"
|
#include "Cursor.h"
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
#include "LyXRC.h"
|
|
||||||
|
|
||||||
#include "insets/InsetTabular.h"
|
#include "insets/InsetTabular.h"
|
||||||
|
|
||||||
@ -639,8 +638,7 @@ void GuiTabular::updateContents()
|
|||||||
bool const isReadonly = bc().policy().isReadOnly();
|
bool const isReadonly = bc().policy().isReadOnly();
|
||||||
specialAlignmentED->setEnabled(!isReadonly);
|
specialAlignmentED->setEnabled(!isReadonly);
|
||||||
|
|
||||||
Length::UNIT default_unit =
|
Length::UNIT const default_unit = Length::defaultUnit();
|
||||||
useMetricUnits() ? Length::CM : Length::IN;
|
|
||||||
|
|
||||||
borderDefaultRB->setChecked(!tabular_.use_booktabs);
|
borderDefaultRB->setChecked(!tabular_.use_booktabs);
|
||||||
booktabsRB->setChecked(tabular_.use_booktabs);
|
booktabsRB->setChecked(tabular_.use_booktabs);
|
||||||
@ -996,12 +994,6 @@ void GuiTabular::set(Tabular::Feature f, string const & arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool GuiTabular::useMetricUnits() const
|
|
||||||
{
|
|
||||||
return lyxrc.default_papersize > PAPER_USEXECUTIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GuiTabular::setSpecial(string const & special)
|
void GuiTabular::setSpecial(string const & special)
|
||||||
{
|
{
|
||||||
if (tabular_.isMultiColumn(getActiveCell()))
|
if (tabular_.isMultiColumn(getActiveCell()))
|
||||||
|
@ -91,8 +91,6 @@ private:
|
|||||||
|
|
||||||
///
|
///
|
||||||
Tabular::idx_type getActiveCell() const;
|
Tabular::idx_type getActiveCell() const;
|
||||||
/// return true if units should default to metric
|
|
||||||
bool useMetricUnits() const;
|
|
||||||
/// set a parameter
|
/// set a parameter
|
||||||
void set(Tabular::Feature, std::string const & arg = std::string());
|
void set(Tabular::Feature, std::string const & arg = std::string());
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#include "qt_helpers.h"
|
#include "qt_helpers.h"
|
||||||
#include "Validator.h"
|
#include "Validator.h"
|
||||||
|
|
||||||
#include "LyXRC.h" // to set the default length values
|
|
||||||
#include "Spacing.h"
|
#include "Spacing.h"
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
|
|
||||||
@ -114,8 +113,7 @@ static void setWidgetsFromVSpace(VSpace const & space,
|
|||||||
spacing->setCurrentIndex(item);
|
spacing->setCurrentIndex(item);
|
||||||
keep->setChecked(space.keep());
|
keep->setChecked(space.keep());
|
||||||
|
|
||||||
Length::UNIT default_unit =
|
Length::UNIT const default_unit = Length::defaultUnit();
|
||||||
(lyxrc.default_papersize > 3) ? Length::CM : Length::IN;
|
|
||||||
bool const custom_vspace = space.kind() == VSpace::LENGTH;
|
bool const custom_vspace = space.kind() == VSpace::LENGTH;
|
||||||
if (custom_vspace) {
|
if (custom_vspace) {
|
||||||
value->setEnabled(true);
|
value->setEnabled(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user