]> git.lyx.org Git - features.git/commitdiff
don't use any longer the page background color white as being the default (equal...
authorUwe Stöhr <uwestoehr@web.de>
Mon, 5 Apr 2010 20:31:10 +0000 (20:31 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Mon, 5 Apr 2010 20:31:10 +0000 (20:31 +0000)
(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
src/BufferParams.cpp
src/BufferParams.h
src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/ui/ColorUi.ui

index f5f11e69919a7398fe9ac511fe9bf93f0eeed71b..96801b94631f877606d49f7eb1291dad1f637a62 100644 (file)
@@ -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");
index 98d4fd0a7cfeea47f5a295bedf8ed86767491387..5d6e56046ff45220afd5ab4d19a80145646c783c 100644 (file)
@@ -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<string>(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 
index cd5e96afd67922ff6bbb8cf33b5b30b6d078a899..8ad2e064196e52f333e70e098085a7b7d1e09942 100644 (file)
@@ -286,6 +286,8 @@ public:
        ///
        RGBColor backgroundcolor;
        ///
+       bool isbackgroundcolor;
+       ///
        RGBColor fontcolor;
        ///
        bool isfontcolor;
index 47a055bcc4fb6e101ca5eda5c38b862eb754537f..9678dfc38d7efafceb46c0466597da9410406029 100644 (file)
@@ -178,6 +178,7 @@ vector<pair<string, QString> > 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();
index c6d0259c2bd2a93a8e24acb7a492fa555a96ddf7..7769939988df35e55033a6da0f1d03401a5650d7 100644 (file)
@@ -1,7 +1,7 @@
 <ui version="4.0" >
  <class>ColorUi</class>
- <widget class="QWidget" name="ColorUi" >
-  <property name="geometry" >
+ <widget class="QWidget" name="ColorUi">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
@@ -9,99 +9,99 @@
     <height>275</height>
    </rect>
   </property>
-  <property name="contextMenuPolicy" >
+  <property name="contextMenuPolicy">
    <enum>Qt::DefaultContextMenu</enum>
   </property>
-  <property name="windowTitle" >
+  <property name="windowTitle">
    <string>ColorUi</string>
   </property>
-  <property name="toolTip" >
+  <property name="toolTip">
    <string/>
   </property>
-  <layout class="QGridLayout" >
-   <property name="margin" >
+  <layout class="QGridLayout">
+   <property name="margin">
     <number>11</number>
    </property>
-   <property name="spacing" >
+   <property name="spacing">
     <number>6</number>
    </property>
-   <item row="0" column="0" >
-    <widget class="QGroupBox" name="fontcolorGB" >
-     <property name="title" >
+   <item row="0" column="0">
+    <widget class="QGroupBox" name="fontcolorGB">
+     <property name="title">
       <string>Font colors</string>
      </property>
-     <property name="flat" >
+     <property name="flat">
       <bool>true</bool>
      </property>
-     <layout class="QGridLayout" >
-      <property name="margin" >
+     <layout class="QGridLayout">
+      <property name="margin">
        <number>11</number>
       </property>
-      <property name="spacing" >
+      <property name="spacing">
        <number>6</number>
       </property>
-      <item row="0" column="0" >
-       <widget class="QLabel" name="fontColorLA" >
-        <property name="text" >
+      <item row="0" column="0">
+       <widget class="QLabel" name="fontColorLA">
+        <property name="text">
          <string>Main text:</string>
         </property>
-        <property name="buddy" >
+        <property name="buddy">
          <cstring>fontColorPB</cstring>
         </property>
        </widget>
       </item>
-      <item row="0" column="1" >
-       <layout class="QHBoxLayout" >
-        <property name="margin" >
-         <number>11</number>
-        </property>
-        <property name="spacing" >
+      <item row="0" column="1">
+       <layout class="QHBoxLayout">
+        <property name="spacing">
          <number>6</number>
         </property>
+        <property name="margin">
+         <number>11</number>
+        </property>
         <item>
-         <widget class="QPushButton" name="fontColorPB" >
-          <property name="maximumSize" >
+         <widget class="QPushButton" name="fontColorPB">
+          <property name="maximumSize">
            <size>
             <width>16777215</width>
             <height>16777215</height>
            </size>
           </property>
-          <property name="toolTip" >
+          <property name="toolTip">
            <string>Click to change the color</string>
           </property>
-          <property name="text" >
+          <property name="text">
            <string>Default...</string>
           </property>
          </widget>
         </item>
         <item>
-         <widget class="QToolButton" name="delFontColorTB" >
-          <property name="minimumSize" >
+         <widget class="QToolButton" name="delFontColorTB">
+          <property name="minimumSize">
            <size>
             <width>23</width>
             <height>23</height>
            </size>
           </property>
-          <property name="toolTip" >
+          <property name="toolTip">
            <string>Revert the color to the default</string>
           </property>
-          <property name="text" >
+          <property name="text">
            <string>R&amp;eset</string>
           </property>
-          <property name="toolButtonStyle" >
+          <property name="toolButtonStyle">
            <enum>Qt::ToolButtonTextOnly</enum>
           </property>
-          <property name="arrowType" >
+          <property name="arrowType">
            <enum>Qt::LeftArrow</enum>
           </property>
          </widget>
         </item>
         <item>
          <spacer>
-          <property name="orientation" >
+          <property name="orientation">
            <enum>Qt::Horizontal</enum>
           </property>
-          <property name="sizeHint" >
+          <property name="sizeHint" stdset="0">
            <size>
             <width>40</width>
             <height>20</height>
         </item>
        </layout>
       </item>
-      <item row="1" column="0" >
-       <widget class="QLabel" name="noteFontColorLA" >
-        <property name="text" >
+      <item row="1" column="0">
+       <widget class="QLabel" name="noteFontColorLA">
+        <property name="text">
          <string>Greyed-out notes:</string>
         </property>
-        <property name="buddy" >
+        <property name="buddy">
          <cstring>fontColorPB</cstring>
         </property>
        </widget>
       </item>
-      <item row="1" column="1" >
-       <layout class="QHBoxLayout" >
-        <property name="margin" >
-         <number>11</number>
-        </property>
-        <property name="spacing" >
+      <item row="1" column="1">
+       <layout class="QHBoxLayout">
+        <property name="spacing">
          <number>6</number>
         </property>
+        <property name="margin">
+         <number>11</number>
+        </property>
         <item>
-         <widget class="QPushButton" name="noteFontColorPB" >
-          <property name="maximumSize" >
+         <widget class="QPushButton" name="noteFontColorPB">
+          <property name="maximumSize">
            <size>
             <width>16777215</width>
             <height>16777215</height>
            </size>
           </property>
-          <property name="toolTip" >
+          <property name="toolTip">
            <string>Click to change the color</string>
           </property>
-          <property name="text" >
+          <property name="text">
            <string>&amp;Change...</string>
           </property>
          </widget>
         </item>
         <item>
-         <widget class="QToolButton" name="delNoteFontColorTB" >
-          <property name="minimumSize" >
+         <widget class="QToolButton" name="delNoteFontColorTB">
+          <property name="minimumSize">
            <size>
             <width>23</width>
             <height>23</height>
            </size>
           </property>
-          <property name="toolTip" >
+          <property name="toolTip">
            <string>Revert the color to the default</string>
           </property>
-          <property name="text" >
+          <property name="text">
            <string>R&amp;eset</string>
           </property>
-          <property name="toolButtonStyle" >
+          <property name="toolButtonStyle">
            <enum>Qt::ToolButtonTextOnly</enum>
           </property>
-          <property name="arrowType" >
+          <property name="arrowType">
            <enum>Qt::LeftArrow</enum>
           </property>
          </widget>
         </item>
         <item>
          <spacer>
-          <property name="orientation" >
+          <property name="orientation">
            <enum>Qt::Horizontal</enum>
           </property>
-          <property name="sizeHint" >
+          <property name="sizeHint" stdset="0">
            <size>
             <width>40</width>
             <height>20</height>
      </layout>
     </widget>
    </item>
-   <item row="1" column="0" >
-    <widget class="QGroupBox" name="backgroundGB" >
-     <property name="title" >
+   <item row="1" column="0">
+    <widget class="QGroupBox" name="backgroundGB">
+     <property name="title">
       <string>Background colors</string>
      </property>
-     <property name="flat" >
+     <property name="flat">
       <bool>true</bool>
      </property>
-     <layout class="QGridLayout" >
-      <property name="margin" >
+     <layout class="QGridLayout">
+      <property name="margin">
        <number>11</number>
       </property>
-      <property name="spacing" >
+      <property name="spacing">
        <number>6</number>
       </property>
-      <item row="0" column="0" >
-       <widget class="QLabel" name="backgroundColorLA" >
-        <property name="text" >
+      <item row="0" column="0">
+       <widget class="QLabel" name="backgroundColorLA">
+        <property name="text">
          <string>Background color:</string>
         </property>
-        <property name="buddy" >
+        <property name="buddy">
          <cstring>backgroundPB</cstring>
         </property>
        </widget>
       </item>
-      <item row="0" column="1" >
-       <layout class="QHBoxLayout" >
-        <property name="margin" >
-         <number>11</number>
-        </property>
-        <property name="spacing" >
+      <item row="0" column="1">
+       <layout class="QHBoxLayout">
+        <property name="spacing">
          <number>6</number>
         </property>
+        <property name="margin">
+         <number>11</number>
+        </property>
         <item>
-         <widget class="QPushButton" name="backgroundPB" >
-          <property name="maximumSize" >
+         <widget class="QPushButton" name="backgroundPB">
+          <property name="maximumSize">
            <size>
             <width>16777215</width>
             <height>16777215</height>
            </size>
           </property>
-          <property name="toolTip" >
+          <property name="toolTip">
            <string>Click to change the color</string>
           </property>
-          <property name="text" >
+          <property name="text">
            <string>&amp;Change...</string>
           </property>
          </widget>
         </item>
         <item>
-         <widget class="QToolButton" name="delbackgroundTB" >
-          <property name="minimumSize" >
+         <widget class="QToolButton" name="delBackgroundTB">
+          <property name="minimumSize">
            <size>
             <width>23</width>
             <height>23</height>
            </size>
           </property>
-          <property name="toolTip" >
+          <property name="toolTip">
            <string>Revert the color to the default</string>
           </property>
-          <property name="text" >
+          <property name="text">
            <string>R&amp;eset</string>
           </property>
-          <property name="toolButtonStyle" >
+          <property name="toolButtonStyle">
            <enum>Qt::ToolButtonTextOnly</enum>
           </property>
-          <property name="arrowType" >
+          <property name="arrowType">
            <enum>Qt::LeftArrow</enum>
           </property>
          </widget>
         </item>
         <item>
          <spacer>
-          <property name="orientation" >
+          <property name="orientation">
            <enum>Qt::Horizontal</enum>
           </property>
-          <property name="sizeHint" >
+          <property name="sizeHint" stdset="0">
            <size>
             <width>40</width>
             <height>20</height>
      </layout>
     </widget>
    </item>
-   <item row="2" column="0" >
+   <item row="2" column="0">
     <spacer>
-     <property name="orientation" >
+     <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
-     <property name="sizeHint" >
+     <property name="sizeHint" stdset="0">
       <size>
        <width>20</width>
        <height>126</height>
    </item>
   </layout>
  </widget>
- <layoutdefault spacing="6" margin="11" />
+ <layoutdefault spacing="6" margin="11"/>
  <includes>
-  <include location="local" >qt_i18n.h</include>
+  <include location="local">qt_i18n.h</include>
  </includes>
  <resources/>
  <connections/>