]> git.lyx.org Git - features.git/commitdiff
fileformat change:
authorUwe Stöhr <uwestoehr@web.de>
Wed, 31 Mar 2010 00:46:50 +0000 (00:46 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Wed, 31 Mar 2010 00:46:50 +0000 (00:46 +0000)
- 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

13 files changed:
development/FORMAT
lib/layouts/stdinsets.inc
lib/lyx2lyx/lyx_2_0.py
src/Buffer.cpp
src/BufferParams.cpp
src/BufferParams.h
src/Color.cpp
src/ColorCode.h
src/LaTeXFeatures.cpp
src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/GuiDocument.h
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/ui/FontUi.ui

index c20bd894f4571c6ffb47d01aa706a3a3381b802a..169617a166196e956ab0217e2a33e607fe8821a0 100644 (file)
@@ -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.
index 5b005ae79782e250ce8e1b10ae82d69422ec2f5d..852eccbe219533519af329b09726137570c3606c 100644 (file)
@@ -160,6 +160,9 @@ InsetLayout Note:Greyedout
        LatexType             environment
        LatexName             lyxgreyedout
        BgColor               greyedoutbg
+       Font
+         Color               greyedouttext
+       EndFont
        LabelFont
          Color               greyedout
          Size                Small
index 3392fec98fd474820e4047d4fbecb572fcf00b59..d1f46205385a812678bd6d640dce2fd207bc2ae0 100644 (file)
@@ -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, []],
index 1a47fdf5bded72eaab8c0524a35b35b7518cd508..6e8c480a4816b9e5f1003fc432b1a337412ff2a9 100644 (file)
@@ -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];
index 04d035481f9c4272b58447e17ac26777e970225d..bd43f2819fb71efb176e7d5389732d730a26b6ec 100644 (file)
@@ -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();
index c1992aac591d8551292cb340f9ddf17130d4808e..561a4f51a1e74f7acaf546417c0873fcd1ab7e91 100644 (file)
@@ -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;
index f2b5965e18d8cbdfb90235e475004b96d629b4c4..e11311ad8edf3244bf0bc48a43856a16f5ae5676 100644 (file)
@@ -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" },
index 4b1b78cab2430529f3c267fb4a1c7739c14a2f87..4286ae54ec0cc81294845eb0df70ac092548974c 100644 (file)
@@ -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
index 35fbe1933a02031e5dc85264e859fccc23e5f647..8f78e02d1ab0ce1c9ff00195dbc25d5d9d8a9b0c 100644 (file)
@@ -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;
 
index dac72fe2aed4b021e82093168dc6c3c67ab5bbfe..37198db827ce8928f08386e4c135e5824db4b737 100644 (file)
@@ -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)
index 537dce2749c84bdb77b7d8b05667f29d169b971f..64ce15aaa9defe917abd4c536cdb94e8caa67cd7 100644 (file)
@@ -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:
index f2a40b2641812bfc4542a69e6916a8069b41349e..56b0beba3cdecd478d5495eccd03d1b9b7f84405 100644 (file)
@@ -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());
index e5066f952e0af1387fe703ec2347129386ddfd39..7ac625dbbfe9b95815797a05b36f2f22d0ed0bcf 100644 (file)
      </property>
     </widget>
    </item>
-   <item row="8" column="1">
+   <item row="8" column="0">
+    <widget class="QLabel" name="noteFontColorLA">
+     <property name="text">
+      <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;Font color for&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;greyed-out notes:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>&amp;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&amp;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>