#include "support/filetools.h"
#include "support/lassert.h"
#include "support/lstrings.h"
+#include "support/qstring_helpers.h"
#include "support/Messages.h"
+#include <QLocale>
+#include <QString>
+
using namespace std;
using namespace lyx::support;
}
+docstring Language::decimalSeparator() const
+{
+ if (lyxrc.default_decimal_sep == "locale") {
+ QLocale loc = QLocale(toqstr(code()));
+ return qstring_to_ucs4(QString(loc.decimalPoint()));
+ }
+ return from_utf8(lyxrc.default_decimal_sep);
+}
+
+
bool Language::readLanguage(Lexer & lex)
{
enum LanguageTags {
std::string fontenc(BufferParams const &) const;
/// Return the localized date formats (long, medium, short format)
std::string dateFormat(size_t i) const;
+ /// Return the localized decimal separator
+ docstring decimalSeparator() const;
/// This language corresponds to a translation of the GUI
bool hasGuiSupport() const { return has_gui_support_; }
///
{ "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
{ "\\cursor_width", LyXRC::RC_CURSOR_WIDTH },
{ "\\def_file", LyXRC::RC_DEFFILE },
- { "\\default_decimal_point", LyXRC::RC_DEFAULT_DECIMAL_POINT },
+ { "\\default_decimal_point", LyXRC::RC_DEFAULT_DECIMAL_SEP },
{ "\\default_length_unit", LyXRC::RC_DEFAULT_LENGTH_UNIT },
{ "\\default_otf_view_format", LyXRC::RC_DEFAULT_OTF_VIEW_FORMAT },
{ "\\default_platex_view_format", LyXRC::RC_DEFAULT_PLATEX_VIEW_FORMAT },
if (lexrc.next())
backupdir_path = os::internal_path(lexrc.getString());
break;
- case RC_DEFAULT_DECIMAL_POINT:
- lexrc >> default_decimal_point;
+ case RC_DEFAULT_DECIMAL_SEP:
+ lexrc >> default_decimal_sep;
break;
case RC_DEFAULT_LENGTH_UNIT:
if (lexrc.next())
<< "#\n\n";
// fall through
- case RC_DEFAULT_DECIMAL_POINT:
+ case RC_DEFAULT_DECIMAL_SEP:
if (ignore_system_lyxrc ||
- default_decimal_point != system_lyxrc.default_decimal_point) {
- os << "\\default_decimal_point " << default_decimal_point << '\n';
+ default_decimal_sep != system_lyxrc.default_decimal_sep) {
+ os << "\\default_decimal_point \"" << default_decimal_sep << "\"" << '\n';
}
if (tag != RC_LAST)
break;
case LyXRC::RC_FORWARD_SEARCH_DVI:
case LyXRC::RC_FORWARD_SEARCH_PDF:
case LyXRC::RC_EXPORT_OVERWRITE:
- case LyXRC::RC_DEFAULT_DECIMAL_POINT:
+ case LyXRC::RC_DEFAULT_DECIMAL_SEP:
case LyXRC::RC_DEFAULT_LENGTH_UNIT:
case LyXRC::RC_SCROLL_WHEEL_ZOOM:
case LyXRC::RC_CURSOR_WIDTH:
RC_COPIER,
RC_CURSOR_FOLLOWS_SCROLLBAR,
RC_CURSOR_WIDTH,
- RC_DEFAULT_DECIMAL_POINT,
+ RC_DEFAULT_DECIMAL_SEP,
RC_DEFAULT_LENGTH_UNIT,
RC_DEFAULT_OTF_VIEW_FORMAT,
RC_DEFAULT_PLATEX_VIEW_FORMAT,
///
int export_overwrite = NO_FILES;
/// Default decimal point when aligning table columns on decimal
- std::string default_decimal_point = ".";
+ std::string default_decimal_sep = "locale";
///
Length::UNIT default_length_unit = Length::CM;
///
this, SIGNAL(changed()));
connect(uiLanguageCO, SIGNAL(activated(int)),
this, SIGNAL(changed()));
- connect(defaultDecimalPointLE, SIGNAL(textChanged(QString)),
+ connect(defaultDecimalSepED, SIGNAL(textChanged(QString)),
+ this, SIGNAL(changed()));
+ connect(defaultDecimalSepCO, SIGNAL(activated(int)),
this, SIGNAL(changed()));
connect(defaultLengthUnitCO, SIGNAL(activated(int)),
this, SIGNAL(changed()));
startCommandED->setValidator(new NoNewLineValidator(startCommandED));
endCommandED->setValidator(new NoNewLineValidator(endCommandED));
- defaultDecimalPointLE->setInputMask("X; ");
- defaultDecimalPointLE->setMaxLength(1);
+ defaultDecimalSepED->setInputMask("X; ");
+ defaultDecimalSepED->setMaxLength(1);
defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::CM]), Length::CM);
defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::IN]), Length::IN);
}
+void PrefLanguage::on_defaultDecimalSepCO_currentIndexChanged(int i)
+{
+ defaultDecimalSepED->setEnabled(i == 1);
+}
+
+
void PrefLanguage::applyRC(LyXRC & rc) const
{
rc.visual_cursor = visualCursorRB->isChecked();
rc.language_command_end = fromqstr(endCommandED->text());
rc.gui_language = fromqstr(
uiLanguageCO->itemData(uiLanguageCO->currentIndex()).toString());
- rc.default_decimal_point = fromqstr(defaultDecimalPointLE->text());
+ if (defaultDecimalSepCO->currentIndex() == 0)
+ rc.default_decimal_sep = "locale";
+ else
+ rc.default_decimal_sep = fromqstr(defaultDecimalSepED->text());
rc.default_length_unit = (Length::UNIT) defaultLengthUnitCO->itemData(defaultLengthUnitCO->currentIndex()).toInt();
}
save_langpack_ = toqstr(rc.language_custom_package);
languagePackageED->setEnabled(false);
}
+ defaultDecimalSepED->setEnabled(defaultDecimalSepCO->currentIndex() == 1);
globalCB->setChecked(rc.language_global_options);
startCommandED->setText(toqstr(rc.language_command_begin));
endCommandED->setText(toqstr(rc.language_command_end));
- defaultDecimalPointLE->setText(toqstr(rc.default_decimal_point));
+ if (rc.default_decimal_sep == "locale") {
+ defaultDecimalSepCO->setCurrentIndex(0);
+ defaultDecimalSepED->clear();
+ } else {
+ defaultDecimalSepCO->setCurrentIndex(1);
+ defaultDecimalSepED->setText(toqstr(rc.default_decimal_sep));
+ }
int pos = defaultLengthUnitCO->findData(int(rc.default_length_unit));
defaultLengthUnitCO->setCurrentIndex(pos);
private Q_SLOTS:
void on_uiLanguageCO_currentIndexChanged(int);
void on_languagePackageCO_currentIndexChanged(int);
+ void on_defaultDecimalSepCO_currentIndexChanged(int);
private:
///
QString save_langpack_;
#include "qt_helpers.h"
#include "Validator.h"
+#include "Buffer.h"
#include "BufferView.h"
#include "Cursor.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
+#include "Language.h"
#include "LyX.h"
#include "LyXRC.h"
setHAlign(param_str);
// SET_DECIMAL_POINT must come after setHAlign() (ALIGN_DECIMAL)
- string decimal_point = fromqstr(decimalPointED->text());
- if (decimal_point.empty())
- decimal_point = lyxrc.default_decimal_point;
- setParam(param_str, Tabular::SET_DECIMAL_POINT, decimal_point);
+ string decimal_sep = fromqstr(decimalPointED->text());
+ if (decimal_sep.empty())
+ decimal_sep = to_utf8(decimal_sep_);
+ setParam(param_str, Tabular::SET_DECIMAL_POINT, decimal_sep);
setVAlign(param_str);
setTableAlignment(param_str);
hAlignCO->setCurrentIndex(hAlignCO->findData(toqstr(align)));
//
- QString decimal_point = toqstr(tabular.column_info[col].decimal_point);
- if (decimal_point.isEmpty())
- decimal_point = toqstr(from_utf8(lyxrc.default_decimal_point));
- decimalPointED->setText(decimal_point);
+ decimal_sep_ = tabular.column_info[col].decimal_point;
+ if (decimal_sep_.empty()) {
+ Language const * lang = itab->buffer().paragraphs().front().getParLanguage(itab->buffer().params());
+ decimal_sep_ = lang->decimalSeparator();
+ }
+ decimalPointED->setText(toqstr(decimal_sep_));
int valign = 0;
switch (tabular.getVAlignment(cell)) {
GuiSetBorder::BorderState orig_rightborder_;
///
int lastrow_;
+ ///
+ docstring decimal_sep_;
};
} // namespace frontend
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="decimalPointL">
+ <property name="toolTip">
+ <string>Here you can specify the decimal separator that is used in the tabular dialog by default. "Language default" selects the appropriate separator for the current language.</string>
+ </property>
<property name="text">
<string>Default decimal &separator:</string>
</property>
<property name="buddy">
- <cstring>defaultDecimalPointLE</cstring>
+ <cstring>defaultDecimalSepED</cstring>
</property>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QLabel" name="defaultLengthUnitLA">
- <property name="text">
- <string>Default length &unit:</string>
+ <item row="1" column="6">
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
</property>
- <property name="buddy">
- <cstring>defaultLengthUnitCO</cstring>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
</property>
- </widget>
+ </spacer>
</item>
- <item row="0" column="1">
- <widget class="QLineEdit" name="defaultDecimalPointLE">
+ <item row="0" column="3">
+ <widget class="QLineEdit" name="defaultDecimalSepED">
<property name="maximumSize">
<size>
- <width>20</width>
+ <width>40</width>
<height>16777215</height>
</size>
</property>
+ <property name="toolTip">
+ <string>Insert a custom decimal separator here</string>
+ </property>
<property name="inputMask">
<string/>
</property>
</property>
</widget>
</item>
- <item row="1" column="1">
- <widget class="QComboBox" name="defaultLengthUnitCO"/>
+ <item row="1" column="0">
+ <widget class="QLabel" name="defaultLengthUnitLA">
+ <property name="toolTip">
+ <string>Select the default length unit for LyX dialogs</string>
+ </property>
+ <property name="text">
+ <string>Default length &unit:</string>
+ </property>
+ <property name="buddy">
+ <cstring>defaultLengthUnitCO</cstring>
+ </property>
+ </widget>
</item>
- <item row="1" column="2">
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="defaultDecimalSepCO">
+ <property name="toolTip">
+ <string>Here you can specify the decimal separator that is used in the tabular dialog by default. "Language default" selects the appropriate separator for the current language.</string>
</property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
+ <item>
+ <property name="text">
+ <string>Language Default</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Custom</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="defaultLengthUnitCO">
+ <property name="toolTip">
+ <string>Select the default length unit for LyX dialogs</string>
</property>
- </spacer>
+ </widget>
</item>
</layout>
</widget>
<tabstop>languagePackageED</tabstop>
<tabstop>startCommandED</tabstop>
<tabstop>endCommandED</tabstop>
- <tabstop>defaultDecimalPointLE</tabstop>
- <tabstop>defaultLengthUnitCO</tabstop>
+ <tabstop>defaultDecimalSepED</tabstop>
<tabstop>globalCB</tabstop>
<tabstop>explicitDocLangBeginCB</tabstop>
<tabstop>markForeignCB</tabstop>
}
column_info[col].alignment = align;
docstring & dpoint = column_info[col].decimal_point;
- if (align == LYX_ALIGN_DECIMAL && dpoint.empty())
- dpoint = from_utf8(lyxrc.default_decimal_point);
+ if (align == LYX_ALIGN_DECIMAL && dpoint.empty()) {
+ Language const * tlang = buffer().paragraphs().front().getParLanguage(buffer().params());
+ dpoint = tlang->decimalSeparator();
+ }
} else {
cellInfo(cell).alignment = align;
cellInset(cell)->setContentAlignment(align);