From 9b072f6e64092f7ebd481c877c55f1f34889c253 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Mon, 5 Apr 2010 20:31:10 +0000 Subject: [PATCH] don't use any longer the page background color white as being the default (equal no color) because document classes might have other colors as default (The default color is still internally white because we have to set a color but the color is only used when the user explicitly specified it.) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34058 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 1 + src/BufferParams.cpp | 10 +- src/BufferParams.h | 2 + src/frontends/qt4/GuiDocument.cpp | 25 ++-- src/frontends/qt4/ui/ColorUi.ui | 186 +++++++++++++++--------------- 5 files changed, 119 insertions(+), 105 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index f5f11e6991..96801b9463 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -668,6 +668,7 @@ int Buffer::readHeader(Lexer & lex) params().pdfoptions().clear(); params().indiceslist().clear(); params().backgroundcolor = lyx::rgbFromHexName("#ffffff"); + params().isbackgroundcolor = false; params().fontcolor = lyx::rgbFromHexName("#000000"); params().isfontcolor = false; params().notefontcolor = lyx::rgbFromHexName("#cccccc"); diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 98d4fd0a7c..5d6e56046f 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -367,8 +367,9 @@ BufferParams::BufferParams() listings_params = string(); pagestyle = "default"; suppress_date = false; - // white is equal to no background color + // no color is the default (white) backgroundcolor = lyx::rgbFromHexName("#ffffff"); + isbackgroundcolor = false; // no color is the default (black) fontcolor = lyx::rgbFromHexName("#000000"); isfontcolor = false; @@ -726,6 +727,7 @@ string BufferParams::readToken(Lexer & lex, string const & token, } else if (token == "\\backgroundcolor") { lex.eatLine(); backgroundcolor = lyx::rgbFromHexName(lex.getString()); + isbackgroundcolor = true; } else if (token == "\\fontcolor") { lex.eatLine(); fontcolor = lyx::rgbFromHexName(lex.getString()); @@ -927,7 +929,7 @@ void BufferParams::writeFile(ostream & os) const << "\n\\paperorientation " << string_orientation[orientation] << "\n\\suppress_date " << convert(suppress_date) << '\n'; - if (backgroundcolor != lyx::rgbFromHexName("#ffffff")) + if (isbackgroundcolor == true) os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n'; if (isfontcolor == true) os << "\\fontcolor " << lyx::X11hexname(fontcolor) << '\n'; @@ -1455,8 +1457,8 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, texrow.newline(); } - // only output when the background color is not white - if (backgroundcolor != lyx::rgbFromHexName("#ffffff")) { + // only output when the background color is not default + if (isbackgroundcolor == true) { // only require color here, the background color will be defined // in LaTeXFeatures.cpp to avoid interferences with the LaTeX // package pdfpages diff --git a/src/BufferParams.h b/src/BufferParams.h index cd5e96afd6..8ad2e06419 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -286,6 +286,8 @@ public: /// RGBColor backgroundcolor; /// + bool isbackgroundcolor; + /// RGBColor fontcolor; /// bool isfontcolor; diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 47a055bcc4..9678dfc38d 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -178,6 +178,7 @@ vector > pagestyles; namespace lyx { RGBColor set_backgroundcolor; +bool is_backgroundcolor; RGBColor set_fontcolor; bool is_fontcolor; RGBColor set_notefontcolor; @@ -886,7 +887,7 @@ GuiDocument::GuiDocument(GuiView & lv) this, SLOT(deleteNoteFontColor())); connect(colorModule->backgroundPB, SIGNAL(clicked()), this, SLOT(changeBackgroundColor())); - connect(colorModule->delbackgroundTB, SIGNAL(clicked()), + connect(colorModule->delBackgroundTB, SIGNAL(clicked()), this, SLOT(deleteBackgroundColor())); @@ -1359,22 +1360,26 @@ void GuiDocument::changeBackgroundColor() rgb2qcolor(set_backgroundcolor), asQWidget()); if (!newColor.isValid()) return; - // set the button color + // set the button color and text colorModule->backgroundPB->setStyleSheet( colorButtonStyleSheet(newColor)); + colorModule->backgroundPB->setText(toqstr("Change...")); // save color set_backgroundcolor = rgbFromHexName(fromqstr(newColor.name())); + is_backgroundcolor = true; changed(); } void GuiDocument::deleteBackgroundColor() { - // set the button color back to white - colorModule->backgroundPB->setStyleSheet( - colorButtonStyleSheet(QColor(Qt::white))); - // save white as the set color + // set the button color back to default by setting an epmty StyleSheet + colorModule->backgroundPB->setStyleSheet(QLatin1String("")); + // change button text + colorModule->backgroundPB->setText(toqstr("Default...")); + // save default color (white) set_backgroundcolor = rgbFromHexName("#ffffff"); + is_backgroundcolor = false; changed(); } @@ -2042,6 +2047,7 @@ void GuiDocument::applyView() //color bp_.backgroundcolor = set_backgroundcolor; + bp_.isbackgroundcolor = is_backgroundcolor; bp_.fontcolor = set_fontcolor; bp_.isfontcolor = is_fontcolor; bp_.notefontcolor = set_notefontcolor; @@ -2440,9 +2446,12 @@ void GuiDocument::paramsToDialog() colorButtonStyleSheet(rgb2qcolor(bp_.notefontcolor))); set_notefontcolor = bp_.notefontcolor; - colorModule->backgroundPB->setStyleSheet( - colorButtonStyleSheet(rgb2qcolor(bp_.backgroundcolor))); + if (bp_.isbackgroundcolor) { + colorModule->backgroundPB->setStyleSheet( + colorButtonStyleSheet(rgb2qcolor(bp_.backgroundcolor))); + } set_backgroundcolor = bp_.backgroundcolor; + is_backgroundcolor = bp_.isbackgroundcolor; // numbering int const min_toclevel = documentClass().min_toclevel(); diff --git a/src/frontends/qt4/ui/ColorUi.ui b/src/frontends/qt4/ui/ColorUi.ui index c6d0259c2b..7769939988 100644 --- a/src/frontends/qt4/ui/ColorUi.ui +++ b/src/frontends/qt4/ui/ColorUi.ui @@ -1,7 +1,7 @@ ColorUi - - + + 0 0 @@ -9,99 +9,99 @@ 275 - + Qt::DefaultContextMenu - + ColorUi - + - - + + 11 - + 6 - - - + + + Font colors - + true - - + + 11 - + 6 - - - + + + Main text: - + fontColorPB - - - - 11 - - + + + 6 + + 11 + - - + + 16777215 16777215 - + Click to change the color - + Default... - - + + 23 23 - + Revert the color to the default - + R&eset - + Qt::ToolButtonTextOnly - + Qt::LeftArrow - + Qt::Horizontal - + 40 20 @@ -111,68 +111,68 @@ - - - + + + Greyed-out notes: - + fontColorPB - - - - 11 - - + + + 6 + + 11 + - - + + 16777215 16777215 - + Click to change the color - + &Change... - - + + 23 23 - + Revert the color to the default - + R&eset - + Qt::ToolButtonTextOnly - + Qt::LeftArrow - + Qt::Horizontal - + 40 20 @@ -185,83 +185,83 @@ - - - + + + Background colors - + true - - + + 11 - + 6 - - - + + + Background color: - + backgroundPB - - - - 11 - - + + + 6 + + 11 + - - + + 16777215 16777215 - + Click to change the color - + &Change... - - + + 23 23 - + Revert the color to the default - + R&eset - + Qt::ToolButtonTextOnly - + Qt::LeftArrow - + Qt::Horizontal - + 40 20 @@ -274,12 +274,12 @@ - + - + Qt::Vertical - + 20 126 @@ -289,9 +289,9 @@ - + - qt_i18n.h + qt_i18n.h -- 2.39.2