mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 13:48:59 +00:00
fileformat change:
- support to change the greyed-out note font color (fixes #3865) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33962 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
8cf5ff6fbf
commit
33978c0b1b
@ -1,6 +1,10 @@
|
||||
LyX file-format changes
|
||||
-----------------------
|
||||
|
||||
2010-03-31 Uwe Stöhr <uwestoehr@web.de>
|
||||
* Format incremented to 382: support to change the font color
|
||||
for greyed-out notes
|
||||
|
||||
2010-03-28: Vincent van Ravesteijn <vfr@lyx.org>
|
||||
* Format incremented to 381: support for new parameters
|
||||
for \xymatrix: \xymatrix@!0, \xymatrix!R and \xymatrix!C.
|
||||
|
@ -160,6 +160,9 @@ InsetLayout Note:Greyedout
|
||||
LatexType environment
|
||||
LatexName lyxgreyedout
|
||||
BgColor greyedoutbg
|
||||
Font
|
||||
Color greyedouttext
|
||||
EndFont
|
||||
LabelFont
|
||||
Color greyedout
|
||||
Size Small
|
||||
|
@ -1338,6 +1338,44 @@ def revert_equalspacing_xymatrix(document):
|
||||
if has_equal_spacing and not has_preamble:
|
||||
add_to_preamble(document, ['\\usepackage[all]{xy}'])
|
||||
|
||||
|
||||
def revert_notefontcolor(document):
|
||||
" Reverts greyed-out note font color to preamble code "
|
||||
i = 0
|
||||
colorcode = ""
|
||||
while True:
|
||||
i = find_token(document.header, "\\notefontcolor", i)
|
||||
if i == -1:
|
||||
return
|
||||
colorcode = get_value(document.header, '\\notefontcolor', 0)
|
||||
del document.header[i]
|
||||
# the color code is in the form #rrggbb where every character denotes a hex number
|
||||
# convert the string to an int
|
||||
red = string.atoi(colorcode[1:3],16)
|
||||
# we want the output "0.5" for the value "127" therefore increment here
|
||||
if red != 0:
|
||||
red = red + 1
|
||||
redout = float(red) / 256
|
||||
green = string.atoi(colorcode[3:5],16)
|
||||
if green != 0:
|
||||
green = green + 1
|
||||
greenout = float(green) / 256
|
||||
blue = string.atoi(colorcode[5:7],16)
|
||||
if blue != 0:
|
||||
blue = blue + 1
|
||||
blueout = float(blue) / 256
|
||||
# write the preamble
|
||||
insert_to_preamble(0, document,
|
||||
'% Commands inserted by lyx2lyx to set the font color\n'
|
||||
'% for greyed-out notes\n'
|
||||
+ '\\@ifundefined{definecolor}{\\usepackage{color}}{}\n'
|
||||
+ '\\definecolor{note_fontcolor}{rgb}{'
|
||||
+ str(redout) + ', ' + str(greenout)
|
||||
+ ', ' + str(blueout) + '}\n'
|
||||
+ '\\renewenvironment{lyxgreyedout}\n'
|
||||
+ ' {\\textcolor{note_fontcolor}\\bgroup}{\\egroup}\n')
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -1378,10 +1416,12 @@ convert = [[346, []],
|
||||
[378, []],
|
||||
[379, [convert_math_output]],
|
||||
[380, []],
|
||||
[381, []]
|
||||
[381, []],
|
||||
[382, []]
|
||||
]
|
||||
|
||||
revert = [[380, [revert_equalspacing_xymatrix]],
|
||||
revert = [[381, [revert_notefontcolor]],
|
||||
[380, [revert_equalspacing_xymatrix]],
|
||||
[379, [revert_inset_preview]],
|
||||
[378, [revert_math_output]],
|
||||
[377, []],
|
||||
|
@ -126,7 +126,7 @@ namespace {
|
||||
|
||||
// Do not remove the comment below, so we get merge conflict in
|
||||
// independent branches. Instead add your own.
|
||||
int const LYX_FORMAT = 381; // vfr: new parameters for xymatrix
|
||||
int const LYX_FORMAT = 382; // uwestoehr: support to change font color for greyed-out notes
|
||||
|
||||
typedef map<string, bool> DepClean;
|
||||
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
||||
@ -668,6 +668,7 @@ int Buffer::readHeader(Lexer & lex)
|
||||
params().pdfoptions().clear();
|
||||
params().indiceslist().clear();
|
||||
params().backgroundcolor = lyx::rgbFromHexName("#ffffff");
|
||||
params().notefontcolor = lyx::rgbFromHexName("#cccccc");
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
params().user_defined_bullet(i) = ITEMIZE_DEFAULTS[i];
|
||||
|
@ -369,6 +369,8 @@ BufferParams::BufferParams()
|
||||
suppress_date = false;
|
||||
// white is equal to no background color
|
||||
backgroundcolor = lyx::rgbFromHexName("#ffffff");
|
||||
// light gray is the default font color for greyed-out notes
|
||||
notefontcolor = lyx::rgbFromHexName("#cccccc");
|
||||
compressed = lyxrc.save_compressed;
|
||||
for (int iter = 0; iter < 4; ++iter) {
|
||||
user_defined_bullet(iter) = ITEMIZE_DEFAULTS[iter];
|
||||
@ -721,6 +723,12 @@ string BufferParams::readToken(Lexer & lex, string const & token,
|
||||
} else if (token == "\\backgroundcolor") {
|
||||
lex.eatLine();
|
||||
backgroundcolor = lyx::rgbFromHexName(lex.getString());
|
||||
} else if (token == "\\notefontcolor") {
|
||||
lex.eatLine();
|
||||
string color = lex.getString();
|
||||
notefontcolor = lyx::rgbFromHexName(color);
|
||||
// set the font color within LyX
|
||||
lcolor.setColor(Color_greyedouttext, color);
|
||||
} else if (token == "\\paperwidth") {
|
||||
lex >> paperwidth;
|
||||
} else if (token == "\\paperheight") {
|
||||
@ -913,6 +921,8 @@ void BufferParams::writeFile(ostream & os) const
|
||||
<< '\n';
|
||||
if (backgroundcolor != lyx::rgbFromHexName("#ffffff"))
|
||||
os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n';
|
||||
if (notefontcolor != lyx::rgbFromHexName("#cccccc"))
|
||||
os << "\\notefontcolor " << lyx::X11hexname(notefontcolor) << '\n';
|
||||
|
||||
BranchList::const_iterator it = branchlist().begin();
|
||||
BranchList::const_iterator end = branchlist().end();
|
||||
|
@ -288,6 +288,8 @@ public:
|
||||
std::string pagestyle;
|
||||
///
|
||||
RGBColor backgroundcolor;
|
||||
///
|
||||
RGBColor notefontcolor;
|
||||
/// \param index should lie in the range 0 <= \c index <= 3.
|
||||
Bullet & temp_bullet(size_type index);
|
||||
Bullet const & temp_bullet(size_type index) const;
|
||||
|
@ -181,6 +181,7 @@ ColorSet::ColorSet()
|
||||
{ Color_commentlabel, N_("comment label"), "comment", "magenta", "comment" },
|
||||
{ Color_commentbg, N_("comment background"), "commentbg", "linen", "commentbg" },
|
||||
{ Color_greyedoutlabel, N_("greyedout inset label"), "greyedout", "#ff0080", "greyedout" },
|
||||
{ Color_greyedouttext, N_("greyedout inset text"), "greyedouttext", grey80, "greyedouttext" },
|
||||
{ Color_greyedoutbg, N_("greyedout inset background"), "greyedoutbg", "linen", "greyedoutbg" },
|
||||
{ Color_phantomtext, N_("phantom inset text"), "phantomtext", "#7f7f7f", "phantomtext" },
|
||||
{ Color_shadedbg, N_("shaded box"), "shaded", "#ff0000", "shaded" },
|
||||
|
@ -65,6 +65,8 @@ enum ColorCode
|
||||
Color_commentbg,
|
||||
/// Label color for greyedout insets
|
||||
Color_greyedoutlabel,
|
||||
/// Color for greyedout inset text
|
||||
Color_greyedouttext,
|
||||
/// Background color of greyedout inset
|
||||
Color_greyedoutbg,
|
||||
/// Background color of shaded box
|
||||
|
@ -160,7 +160,7 @@ static docstring const tabularnewline_def = from_ascii(
|
||||
|
||||
static docstring const lyxgreyedout_def = from_ascii(
|
||||
"%% The greyedout annotation environment\n"
|
||||
"\\newenvironment{lyxgreyedout}{\\textcolor[gray]{0.8}\\bgroup}{\\egroup}\n");
|
||||
"\\newenvironment{lyxgreyedout}{\\textcolor{note_fontcolor}\\bgroup}{\\egroup}\n");
|
||||
|
||||
// We want to omit the file extension for includegraphics, but this does not
|
||||
// work when the filename contains other dots.
|
||||
@ -580,16 +580,23 @@ string const LaTeXFeatures::getColorOptions() const
|
||||
if (mustProvide("pdfcolmk"))
|
||||
colors << "\\usepackage{pdfcolmk}\n";
|
||||
|
||||
// the following 3 color commands must be set after color
|
||||
// is loaded and before pdfpages, therefore add the command
|
||||
// here define the set color
|
||||
if (mustProvide("pagecolor")) {
|
||||
// the \pagecolor command must be set after color is loaded and
|
||||
// before pdfpages, therefore add the command here
|
||||
// define the set color
|
||||
colors << "\\definecolor{page_backgroundcolor}{rgb}{";
|
||||
colors << outputLaTeXColor(params_.backgroundcolor) << "}\n";
|
||||
// set the page color
|
||||
colors << "\\pagecolor{page_backgroundcolor}\n";
|
||||
}
|
||||
|
||||
if (mustProvide("lyxgreyedout")) {
|
||||
colors << "\\definecolor{note_fontcolor}{rgb}{";
|
||||
colors << outputLaTeXColor(params_.notefontcolor) << "}\n";
|
||||
// the color will be set together with the definition of
|
||||
// the lyxgreyedout environment (lyxgreyedout_def)
|
||||
}
|
||||
|
||||
return colors.str();
|
||||
}
|
||||
|
||||
@ -885,7 +892,9 @@ docstring const LaTeXFeatures::getMacros() const
|
||||
if (mustProvide("NeedTabularnewline"))
|
||||
macros << tabularnewline_def;
|
||||
|
||||
// greyedout environment (note inset)
|
||||
// greyed-out environment (note inset)
|
||||
// the color is specified in the routine
|
||||
// getColorOptions() to avoid LaTeX-package clashes
|
||||
if (mustProvide("lyxgreyedout"))
|
||||
macros << lyxgreyedout_def;
|
||||
|
||||
|
@ -178,6 +178,7 @@ vector<pair<string, QString> > pagestyles;
|
||||
namespace lyx {
|
||||
|
||||
RGBColor set_backgroundcolor;
|
||||
RGBColor set_notefontcolor;
|
||||
|
||||
namespace {
|
||||
// used when sorting the textclass list.
|
||||
@ -682,6 +683,10 @@ GuiDocument::GuiDocument(GuiView & lv)
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(fontModule->fontOsfCB, SIGNAL(clicked()),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(fontModule->noteFontColorPB, SIGNAL(clicked()),
|
||||
this, SLOT(changeNoteFontColor()));
|
||||
connect(fontModule->delNoteFontColorTB, SIGNAL(clicked()),
|
||||
this, SLOT(deleteNoteFontColor()));
|
||||
|
||||
updateFontlist();
|
||||
|
||||
@ -1349,6 +1354,32 @@ void GuiDocument::deleteBackgroundColor()
|
||||
}
|
||||
|
||||
|
||||
void GuiDocument::changeNoteFontColor()
|
||||
{
|
||||
QColor const & newColor = QColorDialog::getColor(
|
||||
rgb2qcolor(set_notefontcolor), asQWidget());
|
||||
if (!newColor.isValid())
|
||||
return;
|
||||
// set the button color
|
||||
fontModule->noteFontColorPB->setStyleSheet(
|
||||
colorButtonStyleSheet(newColor));
|
||||
// save color
|
||||
set_notefontcolor = rgbFromHexName(fromqstr(newColor.name()));
|
||||
changed();
|
||||
}
|
||||
|
||||
|
||||
void GuiDocument::deleteNoteFontColor()
|
||||
{
|
||||
// set the button color back to light gray
|
||||
fontModule->noteFontColorPB->setStyleSheet(
|
||||
colorButtonStyleSheet(QColor(204, 204, 204, 255)));
|
||||
// save light gray as the set color
|
||||
set_notefontcolor = rgbFromHexName("#cccccc");
|
||||
changed();
|
||||
}
|
||||
|
||||
|
||||
void GuiDocument::xetexChanged(bool xetex)
|
||||
{
|
||||
updateFontlist();
|
||||
@ -2210,6 +2241,7 @@ void GuiDocument::applyView()
|
||||
bp_.orientation = ORIENTATION_PORTRAIT;
|
||||
|
||||
bp_.backgroundcolor = set_backgroundcolor;
|
||||
bp_.notefontcolor = set_notefontcolor;
|
||||
|
||||
// margins
|
||||
bp_.use_geometry = !marginsModule->marginCB->isChecked()
|
||||
@ -2591,6 +2623,9 @@ void GuiDocument::paramsToDialog()
|
||||
fontModule->fontOsfCB->setChecked(bp_.fontsOSF);
|
||||
fontModule->scaleSansSB->setValue(bp_.fontsSansScale);
|
||||
fontModule->scaleTypewriterSB->setValue(bp_.fontsTypewriterScale);
|
||||
fontModule->noteFontColorPB->setStyleSheet(
|
||||
colorButtonStyleSheet(rgb2qcolor(bp_.notefontcolor)));
|
||||
set_notefontcolor = bp_.notefontcolor;
|
||||
|
||||
int nn = findToken(GuiDocument::fontfamilies, bp_.fontsDefaultFamily);
|
||||
if (nn >= 0)
|
||||
|
@ -111,6 +111,8 @@ private Q_SLOTS:
|
||||
void modulesChanged();
|
||||
void changeBackgroundColor();
|
||||
void deleteBackgroundColor();
|
||||
void changeNoteFontColor();
|
||||
void deleteNoteFontColor();
|
||||
void xetexChanged(bool);
|
||||
void branchesRename(docstring const &, docstring const &);
|
||||
private:
|
||||
|
@ -1005,7 +1005,8 @@ PrefColors::PrefColors(GuiPreferences * form)
|
||||
|| lc == Color_magenta
|
||||
|| lc == Color_yellow
|
||||
|| lc == Color_inherit
|
||||
|| lc == Color_ignore) continue;
|
||||
|| lc == Color_ignore
|
||||
|| lc == Color_greyedouttext) continue;
|
||||
|
||||
lcolors_.push_back(lc);
|
||||
}
|
||||
@ -1013,7 +1014,7 @@ PrefColors::PrefColors(GuiPreferences * form)
|
||||
vector<ColorCode>::const_iterator cit = lcolors_.begin();
|
||||
vector<ColorCode>::const_iterator const end = lcolors_.end();
|
||||
for (; cit != end; ++cit) {
|
||||
(void) new QListWidgetItem(QIcon(icon),
|
||||
(void) new QListWidgetItem(QIcon(icon),
|
||||
toqstr(lcolor.getGUIName(*cit)), lyxObjectsLW);
|
||||
}
|
||||
curcolors_.resize(lcolors_.size());
|
||||
|
@ -201,7 +201,74 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="noteFontColorLA">
|
||||
<property name="text">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Font color for</span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">greyed-out notes:</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="noteFontColorPB">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Click to change the color</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Change...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="delNoteFontColorTB">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>23</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Revert the color to the default</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>R&eset</string>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextOnly</enum>
|
||||
</property>
|
||||
<property name="arrowType">
|
||||
<enum>Qt::LeftArrow</enum>
|
||||
</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>
|
||||
<item row="9" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
Loading…
Reference in New Issue
Block a user