mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Don't allow newline characters in preference (#5840).
Set a validator on QLineEdit widgets. The validator removes any \n and \r characters, thus preventing users from copy-pasting newline characters into these fields, and subsequently saving them, inadvertantly, to the preference file. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39664 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
bab818a784
commit
82edf5907a
@ -349,6 +349,33 @@ static void setComboxFont(QComboBox * cb, string const & family,
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NoNewLineValidator
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
class NoNewLineValidator : public QValidator
|
||||
{
|
||||
public:
|
||||
NoNewLineValidator(QWidget *);
|
||||
QValidator::State validate(QString & input, int & pos) const;
|
||||
};
|
||||
|
||||
|
||||
NoNewLineValidator::NoNewLineValidator(QWidget * parent)
|
||||
: QValidator(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QValidator::State NoNewLineValidator::validate(QString & input, int & /*pos*/) const
|
||||
{
|
||||
input.remove(QRegExp("[\\n\\r]"));
|
||||
return QValidator::Acceptable;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// StrftimeValidator
|
||||
@ -388,7 +415,11 @@ PrefOutput::PrefOutput(GuiPreferences * form)
|
||||
: PrefModule(qt_(catOutput), qt_("General"), form)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
DateED->setValidator(new StrftimeValidator(DateED));
|
||||
dviCB->setValidator(new NoNewLineValidator(dviCB));
|
||||
pdfCB->setValidator(new NoNewLineValidator(pdfCB));
|
||||
|
||||
connect(DateED, SIGNAL(textChanged(QString)),
|
||||
this, SIGNAL(changed()));
|
||||
connect(plaintextLinelengthSB, SIGNAL(valueChanged(int)),
|
||||
@ -691,6 +722,16 @@ PrefLatex::PrefLatex(GuiPreferences * form)
|
||||
: PrefModule(qt_(catOutput), qt_("LaTeX"), form)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
latexEncodingED->setValidator(new NoNewLineValidator(latexEncodingED));
|
||||
latexDviPaperED->setValidator(new NoNewLineValidator(latexDviPaperED));
|
||||
latexBibtexED->setValidator(new NoNewLineValidator(latexBibtexED));
|
||||
latexJBibtexED->setValidator(new NoNewLineValidator(latexJBibtexED));
|
||||
latexIndexED->setValidator(new NoNewLineValidator(latexIndexED));
|
||||
latexJIndexED->setValidator(new NoNewLineValidator(latexJIndexED));
|
||||
latexNomenclED->setValidator(new NoNewLineValidator(latexNomenclED));
|
||||
latexChecktexED->setValidator(new NoNewLineValidator(latexChecktexED));
|
||||
|
||||
connect(latexEncodingCB, SIGNAL(clicked()),
|
||||
this, SIGNAL(changed()));
|
||||
connect(latexEncodingED, SIGNAL(textChanged(QString)),
|
||||
@ -1340,6 +1381,9 @@ PrefPaths::PrefPaths(GuiPreferences * form)
|
||||
|
||||
connect(texinputsPrefixED, SIGNAL(textChanged(QString)),
|
||||
this, SIGNAL(changed()));
|
||||
|
||||
pathPrefixED->setValidator(new NoNewLineValidator(pathPrefixED));
|
||||
texinputsPrefixED->setValidator(new NoNewLineValidator(texinputsPrefixED));
|
||||
}
|
||||
|
||||
|
||||
@ -1488,6 +1532,9 @@ PrefSpellchecker::PrefSpellchecker(GuiPreferences * form)
|
||||
this, SIGNAL(changed()));
|
||||
connect(spellcheckNotesCB, SIGNAL(clicked()),
|
||||
this, SIGNAL(changed()));
|
||||
|
||||
altLanguageED->setValidator(new NoNewLineValidator(altLanguageED));
|
||||
escapeCharactersED->setValidator(new NoNewLineValidator(escapeCharactersED));
|
||||
#else
|
||||
spellcheckerCB->setEnabled(false);
|
||||
altLanguageED->setEnabled(false);
|
||||
@ -1571,6 +1618,8 @@ PrefConverters::PrefConverters(GuiPreferences * form)
|
||||
connect(maxAgeLE, SIGNAL(textEdited(QString)),
|
||||
this, SIGNAL(changed()));
|
||||
|
||||
converterED->setValidator(new NoNewLineValidator(converterED));
|
||||
converterFlagED->setValidator(new NoNewLineValidator(converterFlagED));
|
||||
maxAgeLE->setValidator(new QDoubleValidator(maxAgeLE));
|
||||
//converterDefGB->setFocusProxy(convertersLW);
|
||||
}
|
||||
@ -1851,8 +1900,14 @@ PrefFileformats::PrefFileformats(GuiPreferences * form)
|
||||
: PrefModule(qt_(catFiles), qt_("File Formats"), form)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
formatED->setValidator(new FormatNameValidator(formatsCB, form_->formats()));
|
||||
formatsCB->setValidator(new FormatPrettynameValidator(formatsCB, form_->formats()));
|
||||
extensionED->setValidator(new NoNewLineValidator(extensionED));
|
||||
shortcutED->setValidator(new NoNewLineValidator(shortcutED));
|
||||
editorED->setValidator(new NoNewLineValidator(editorED));
|
||||
viewerED->setValidator(new NoNewLineValidator(viewerED));
|
||||
copierED->setValidator(new NoNewLineValidator(copierED));
|
||||
|
||||
connect(documentCB, SIGNAL(clicked()),
|
||||
this, SLOT(setFlags()));
|
||||
@ -2232,6 +2287,10 @@ PrefLanguage::PrefLanguage(GuiPreferences * form)
|
||||
connect(defaultDecimalPointLE, SIGNAL(textChanged(QString)),
|
||||
this, SIGNAL(changed()));
|
||||
|
||||
languagePackageED->setValidator(new NoNewLineValidator(languagePackageED));
|
||||
startCommandED->setValidator(new NoNewLineValidator(startCommandED));
|
||||
endCommandED->setValidator(new NoNewLineValidator(endCommandED));
|
||||
|
||||
uiLanguageCO->clear();
|
||||
|
||||
QAbstractItemModel * language_model = guiApp->languageModel();
|
||||
@ -2375,6 +2434,24 @@ PrefPrinter::PrefPrinter(GuiPreferences * form)
|
||||
this, SIGNAL(changed()));
|
||||
connect(printerPaperSizeED, SIGNAL(textChanged(QString)),
|
||||
this, SIGNAL(changed()));
|
||||
|
||||
printerNameED->setValidator(new NoNewLineValidator(printerNameED));
|
||||
printerCommandED->setValidator(new NoNewLineValidator(printerCommandED));
|
||||
printerEvenED->setValidator(new NoNewLineValidator(printerEvenED));
|
||||
printerPageRangeED->setValidator(new NoNewLineValidator(printerPageRangeED));
|
||||
printerCopiesED->setValidator(new NoNewLineValidator(printerCopiesED));
|
||||
printerReverseED->setValidator(new NoNewLineValidator(printerReverseED));
|
||||
printerToFileED->setValidator(new NoNewLineValidator(printerToFileED));
|
||||
printerPaperTypeED->setValidator(new NoNewLineValidator(printerPaperTypeED));
|
||||
printerExtraED->setValidator(new NoNewLineValidator(printerExtraED));
|
||||
printerOddED->setValidator(new NoNewLineValidator(printerOddED));
|
||||
printerCollatedED->setValidator(new NoNewLineValidator(printerCollatedED));
|
||||
printerLandscapeED->setValidator(new NoNewLineValidator(printerLandscapeED));
|
||||
printerToPrinterED->setValidator(new NoNewLineValidator(printerToPrinterED));
|
||||
printerExtensionED->setValidator(new NoNewLineValidator(printerExtensionED));
|
||||
printerPaperSizeED->setValidator(new NoNewLineValidator(printerPaperSizeED));
|
||||
printerSpoolCommandED->setValidator(new NoNewLineValidator(printerSpoolCommandED));
|
||||
printerSpoolPrefixED->setValidator(new NoNewLineValidator(printerSpoolPrefixED));
|
||||
}
|
||||
|
||||
|
||||
@ -3115,6 +3192,9 @@ PrefIdentity::PrefIdentity(GuiPreferences * form)
|
||||
this, SIGNAL(changed()));
|
||||
connect(emailED, SIGNAL(textChanged(QString)),
|
||||
this, SIGNAL(changed()));
|
||||
|
||||
nameED->setValidator(new NoNewLineValidator(nameED));
|
||||
emailED->setValidator(new NoNewLineValidator(emailED));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user