[Uml-devel] branches/work/soc-umbrello/umbrello

Gopala Krishna A krishna.ggk at gmail.com
Sat Aug 29 15:29:50 UTC 2009


SVN commit 1017019 by gopala:

* Reintroduced "usesDiagramColor" like variables to reduce differences with
  the trunk version.
* Renamed fontColor to textColor, to avoid name collision in umbrello.kcfg.
* Introduced textColor property into optionstate.uistate. The idea is to make
  the text color of widgets to be configurable.



 M  +1 -0      optionstate.h  
 M  +5 -5      textitemgroup.cpp  
 M  +4 -4      textitemgroup.h  
 M  +5 -0      umbrello.kcfg  
 M  +2 -0      uml.cpp  
 M  +11 -0     umlscene.cpp  
 M  +8 -5      umlscene.h  
 M  +1 -1      widgets/categorywidget.cpp  
 M  +3 -3      widgets/combinedfragmentwidget.cpp  
 M  +2 -2      widgets/umlwidget.cpp  
 M  +139 -18   widgets/widgetbase.cpp  
 M  +28 -6     widgets/widgetbase.h  


--- branches/work/soc-umbrello/umbrello/optionstate.h #1017018:1017019
@@ -51,6 +51,7 @@
     QColor fillColor;
     QColor lineColor;
     uint   lineWidth;
+    QColor textColor;
     QFont font;
 };
 
--- branches/work/soc-umbrello/umbrello/textitemgroup.cpp #1017018:1017019
@@ -30,7 +30,7 @@
     m_lineBreakageWidth(TextItemGroup::NoLineBreak),
     m_margin(0),
     m_alignment(Qt::AlignCenter),
-    m_fontColor(Qt::black),
+    m_textColor(Qt::black),
     m_hoverBrush(Qt::NoBrush),
     m_backgroundBrush(Qt::NoBrush)
 {
@@ -80,7 +80,7 @@
     }
 
     textItem->setAlignment(m_alignment);
-    textItem->setDefaultTextColor(m_fontColor);
+    textItem->setDefaultTextColor(m_textColor);
     textItem->setHoverBrush(m_hoverBrush);
     textItem->setBackgroundBrush(m_backgroundBrush);
     textItem->setFont(m_font);
@@ -98,7 +98,7 @@
     }
 
     textItem->setAlignment(m_alignment);
-    textItem->setDefaultTextColor(m_fontColor);
+    textItem->setDefaultTextColor(m_textColor);
     textItem->setHoverBrush(m_hoverBrush);
     textItem->setBackgroundBrush(m_backgroundBrush);
     textItem->setFont(m_font);
@@ -201,9 +201,9 @@
     }
 }
 
-void TextItemGroup::setFontColor(const QColor& color)
+void TextItemGroup::setTextColor(const QColor& color)
 {
-    m_fontColor = color;
+    m_textColor = color;
     foreach(TextItem *item, m_textItems) {
         item->setDefaultTextColor(color);
     }
--- branches/work/soc-umbrello/umbrello/textitemgroup.h #1017018:1017019
@@ -87,10 +87,10 @@
     }
     void setAlignment(Qt::Alignment align);
 
-    QColor fontColor() const {
-        return m_fontColor;
+    QColor textColor() const {
+        return m_textColor;
     }
-    void setFontColor(const QColor& color);
+    void setTextColor(const QColor& color);
 
     QBrush hoverBrush() const {
         return m_hoverBrush;
@@ -115,7 +115,7 @@
     qreal m_margin;
 
     Qt::Alignment m_alignment;
-    QColor m_fontColor;
+    QColor m_textColor;
     QBrush m_hoverBrush;
     QBrush m_backgroundBrush;
     QFont m_font;
--- branches/work/soc-umbrello/umbrello/umbrello.kcfg #1017018:1017019
@@ -112,6 +112,11 @@
          <whatsthis>The Width of the Line</whatsthis>
          <default>0</default>
        </entry>
+       <entry name="textColor" type="Color">
+         <label>Text Color</label>
+         <whatsthis>The Color of the Text</whatsthis>
+         <default>black</default>
+       </entry>
        <entry name="showDocWindow" type="Bool">
          <label>Show Doc Window</label>
          <whatsthis>Enables/Disables showing of the doc window</whatsthis>
--- branches/work/soc-umbrello/umbrello/uml.cpp #1017018:1017019
@@ -803,6 +803,7 @@
     UmbrelloSettings::setFillColor(  optionState.uiState.fillColor );
     UmbrelloSettings::setLineColor(  optionState.uiState.lineColor );
     UmbrelloSettings::setLineWidth(  optionState.uiState.lineWidth );
+    UmbrelloSettings::setTextColor( optionState.uiState.textColor );
     UmbrelloSettings::setShowDocWindow(  m_documentationDock->isVisible() );
     UmbrelloSettings::setUiFont(  optionState.uiState.font );
 
@@ -1759,6 +1760,7 @@
     optionState.uiState.fillColor =  UmbrelloSettings::fillColor();
     optionState.uiState.lineColor =  UmbrelloSettings::lineColor();
     optionState.uiState.lineWidth =  UmbrelloSettings::lineWidth();
+    optionState.uiState.textColor = UmbrelloSettings::textColor();
     optionState.uiState.font =  UmbrelloSettings::uiFont();
 
     optionState.classState.showVisibility =  UmbrelloSettings::showVisibility();
--- branches/work/soc-umbrello/umbrello/umlscene.cpp #1017018:1017019
@@ -993,6 +993,17 @@
     emit sigLineWidthChanged(getID());
 }
 
+QColor UMLScene::getTextColor() const
+{
+    return m_Options.uiState.textColor;
+}
+
+void UMLScene::setTextColor(const QColor& color)
+{
+    m_Options.uiState.textColor = color;
+    // PORT: Apply for widgets.
+}
+
 /**
  * Override standard method.
  * Calls the same method in the current tool bar state.
--- branches/work/soc-umbrello/umbrello/umlscene.h #1017018:1017019
@@ -126,31 +126,34 @@
      * @param color  The color to use.
      */
      void setFillColor(const QColor &color);
- 
+
     /**
      * Returns the line color to use.
      */
      QColor getLineColor() const;
- 
+
     /**
      * Sets the line color.
      *
      * @param color  The color to use.
      */
      void setLineColor(const QColor &color);
- 
+
     /**
      * Returns the line width to use.
      */
      uint getLineWidth() const;
- 
+
     /**
      * Sets the line width.
      *
      * @param width  The width to use.
      */
      void setLineWidth(uint width);
- 
+
+     QColor getTextColor() const;
+     void setTextColor(const QColor& color);
+
     /**
      * Returns the ID of the diagram.
      */
--- branches/work/soc-umbrello/umbrello/widgets/categorywidget.cpp #1017018:1017019
@@ -60,7 +60,7 @@
     painter->drawEllipse(circle);
 
     // Now draw the letter inside circle.
-    painter->setPen(fontColor());
+    painter->setPen(textColor());
 
     QString letterType('D');
     switch( static_cast<UMLCategory*>( umlObject() )->getType() ) {
--- branches/work/soc-umbrello/umbrello/widgets/combinedfragmentwidget.cpp #1017018:1017019
@@ -421,8 +421,8 @@
  * - FontHasChanged -> Sets the CombinedFragmentWidget's changed font
  *                     to all the FloatingDashLineWidgets.
  *
- * - FontColorHasChanged -> Sets the CombinedFragmentWidget's changed
- *                          fontcolor to all the
+ * - TextColorHasChanged -> Sets the CombinedFragmentWidget's changed
+ *                          textcolor to all the
  *                          FloatingDashLineWidgets.
  *
  * - LineColorHasChanged -> Sets the CombinedFragmentWidget's changed
@@ -477,7 +477,7 @@
 {
     flt->setLineColor(lineColor());
     flt->setLineWidth(lineWidth());
-    flt->setFontColor(fontColor());
+    flt->setTextColor(textColor());
     flt->setFont(font());
 }
 
--- branches/work/soc-umbrello/umbrello/widgets/umlwidget.cpp #1017018:1017019
@@ -296,9 +296,9 @@
             group->setFont(font());
         }
     }
-    else if(change == FontColorHasChanged) {
+    else if(change == TextColorHasChanged) {
         foreach(TextItemGroup *group, m_textItemGroups) {
-            group->setFontColor(fontColor());
+            group->setTextColor(textColor());
         }
     }
     else if(change == NameHasChanged) {
--- branches/work/soc-umbrello/umbrello/widgets/widgetbase.cpp #1017018:1017019
@@ -375,28 +375,28 @@
 }
 
 /// @return Font color used to draw font.
-QColor WidgetBase::fontColor() const
+QColor WidgetBase::textColor() const
 {
-    return m_fontColor;
+    return m_textColor;
 }
 
 /**
  * Sets the color of the font to \a color.
  * If \a color is invalid, black is used instead.
  *
- * This method issues @ref FontColorHasChanged notification after
+ * This method issues @ref TextColorHasChanged notification after
  * setting the new font color.
  * @see WidgetBase::attributeChange
  */
-void WidgetBase::setFontColor(const QColor& color)
+void WidgetBase::setTextColor(const QColor& color)
 {
-    const QColor oldColor = fontColor();
-    m_fontColor = color;
-    if(!m_fontColor.isValid()) {
-        m_fontColor = Qt::black;
+    const QColor oldColor = textColor();
+    m_textColor = color;
+    if(!m_textColor.isValid()) {
+        m_textColor = Qt::black;
     }
 
-    attributeChange(FontColorHasChanged, oldColor);
+    attributeChange(TextColorHasChanged, oldColor);
 }
 
 /// @return The QBrush object used to fill this widget.
@@ -421,6 +421,102 @@
     attributeChange(BrushHasChanged, oldBrush);
 }
 
+
+bool WidgetBase::usesDiagramLineColor() const
+{
+    return m_usesDiagramLineColor;
+}
+
+void WidgetBase::setUsesDiagramLineColor(bool status)
+{
+    if (m_usesDiagramLineColor == status) {
+        return;
+    }
+    m_usesDiagramLineColor = status;
+    if (status && umlScene()) {
+        QColor color = umlScene()->getLineColor();
+        if (color != lineColor()) {
+            setLineColor(color);
+        }
+    }
+}
+
+bool WidgetBase::usesDiagramLineWidth() const
+{
+    return m_usesDiagramLineWidth;
+}
+
+void WidgetBase::setUsesDiagramLineWidth(bool status)
+{
+    if (m_usesDiagramLineWidth == status) {
+        return;
+    }
+    m_usesDiagramLineWidth = status;
+    if (status && umlScene()) {
+        uint lw = umlScene()->getLineWidth();
+        if (lw != lineWidth()) {
+            setLineWidth(lw);
+        }
+    }
+}
+
+bool WidgetBase::usesDiagramBrush() const
+{
+    return m_usesDiagramBrush;
+}
+
+void WidgetBase::setUsesDiagramBrush(bool status)
+{
+    if (status == m_usesDiagramBrush) {
+        return;
+    }
+    m_usesDiagramBrush = status;
+    if (status && umlScene()) {
+        QBrush b = umlScene()->brush();
+        if (b != brush()) {
+            setBrush(b);
+        }
+    }
+}
+
+bool WidgetBase::usesDiagramFont() const
+{
+    return m_usesDiagramFont;
+}
+
+void WidgetBase::setUsesDiagramFont(bool status)
+{
+    if (status == m_usesDiagramFont) {
+        return;
+    }
+    m_usesDiagramFont = status;
+    if (status && umlScene()) {
+        QFont f = umlScene()->getFont();
+        if (f != font()) {
+            setFont(f);
+        }
+    }
+}
+
+bool WidgetBase::usesDiagramTextColor() const
+{
+    return m_usesDiagramTextColor;
+}
+
+void WidgetBase::setUsesDiagramTextColor(bool status)
+{
+    if (m_usesDiagramTextColor == status) {
+        return;
+    }
+    m_usesDiagramTextColor = status;
+    if (status && umlScene()) {
+        QColor color = umlScene()->getTextColor();
+        if (color != textColor()) {
+            setTextColor(color);
+        }
+    }
+}
+
 /// @return The font used for displaying any text
 QFont WidgetBase::font() const
 {
@@ -532,8 +628,8 @@
     }
 
     // Load the font color, if invalid black is used.
-    QString fontColor = qElement.attribute("fontcolor");
-    setFontColor(QColor(fontColor));
+    QString textColor = qElement.attribute("textcolor");
+    setTextColor(QColor(textColor));
 
     // Load the brush.
     QBrush newBrush;
@@ -611,13 +707,38 @@
 void WidgetBase::saveToXMI(QDomDocument &qDoc, QDomElement &qElement)
 {
     Q_ASSERT(umlScene());
-    qElement.setAttribute("linecolor", m_lineColor.name());
-    qElement.setAttribute("linewidth", m_lineWidth);
-    qElement.setAttribute("fontcolor", m_fontColor.name());
-    qElement.setAttribute("font", m_font.toString());
+    if (m_usesDiagramLineColor) {
+        qElement.setAttribute("linecolor", "none");
+    } else {
+        qElement.setAttribute("linecolor", m_lineColor.name());
+    }
 
-    Widget_Utils::saveBrushToXMI(qDoc, qElement, m_brush);
+    if (m_usesDiagramLineWidth) {
+        qElement.setAttribute("linewidth", m_lineWidth);
+    } else {
+        qElement.setAttribute("linewidth", m_lineWidth);
+    }
 
+    if (m_usesDiagramTextColor) {
+        qElement.setAttribute("textcolor", "none");
+    } else {
+        qElement.setAttribute("textcolor", m_textColor.name());
+    }
+
+    if (m_usesDiagramFont) {
+        // do not save font attribute, which would result in default font
+        // being set while loading.
+    } else {
+        qElement.setAttribute("font", m_font.toString());
+    }
+
+    if (m_usesDiagramBrush) {
+        qElement.setAttribute("usesdiagrambrush", true);
+    } else {
+        qElement.setAttribute("usesdiagrambrush", false);
+        Widget_Utils::saveBrushToXMI(qDoc, qElement, m_brush);
+    }
+
     qElement.setAttribute("xmi.id", ID2STR(id()));
     const QPointF pos = scenePos();
     qElement.setAttribute("x", pos.x());
@@ -834,7 +955,7 @@
     attributeChange(LineColorHasChanged, v);
     attributeChange(LineWidthHasChanged, v);
     attributeChange(FontHasChanged, v);
-    attributeChange(FontColorHasChanged, v);
+    attributeChange(TextColorHasChanged, v);
     attributeChange(BrushHasChanged, v);
 
     // Now show the item (Ugly hack to prevent floatingtext widget from showing up
@@ -906,7 +1027,7 @@
         break;
 
     case LineColorHasChanged:
-    case FontColorHasChanged:
+    case TextColorHasChanged:
     case BrushHasChanged:
         update();
         break;
--- branches/work/soc-umbrello/umbrello/widgets/widgetbase.h #1017018:1017019
@@ -55,7 +55,7 @@
     Q_PROPERTY(QString documentation READ documentation WRITE setDocumentation)
     Q_PROPERTY(QColor lineColor READ lineColor WRITE setLineColor)
     Q_PROPERTY(uint lineWidth READ lineWidth WRITE setLineWidth)
-    Q_PROPERTY(QColor fontColor READ fontColor WRITE setFontColor)
+    Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
     Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
     Q_PROPERTY(QFont font READ font WRITE setFont)
     Q_PROPERTY(QPointF pos READ pos WRITE setPos)
@@ -76,7 +76,7 @@
         // Graphical attribute change notification
         LineColorHasChanged,
         LineWidthHasChanged,
-        FontColorHasChanged,
+        TextColorHasChanged,
         FontHasChanged,
         BrushHasChanged,
 
@@ -110,12 +110,27 @@
     uint lineWidth() const;
     void setLineWidth(uint lw);
 
-    QColor fontColor() const;
-    void setFontColor(const QColor& color);
+    QColor textColor() const;
+    void setTextColor(const QColor& color);
 
     QBrush brush() const;
     void setBrush(const QBrush& brush);
 
+    bool usesDiagramLineColor() const;
+    void setUsesDiagramLineColor(bool status);
+
+    bool usesDiagramLineWidth() const;
+    void setUsesDiagramLineWidth(bool status);
+
+    bool usesDiagramBrush() const;
+    void setUsesDiagramBrush(bool status);
+
+    bool usesDiagramFont() const;
+    void setUsesDiagramFont(bool status);
+
+    bool usesDiagramTextColor() const;
+    void setUsesDiagramTextColor(bool status);
+
     QFont font() const;
     void setFont(const QFont& font);
 
@@ -173,7 +188,7 @@
     QColor m_lineColor;
     uint m_lineWidth;
 
-    QColor m_fontColor;
+    QColor m_textColor;
 
     QBrush m_brush;
     QFont m_font;
@@ -191,7 +206,14 @@
      * This is used to ensure that there is only one initialization when a
      * new UMLScene is set for this widget for the first time.
      */
-    bool m_isSceneSetBefore;
+    bool m_isSceneSetBefore:1;
+
+    bool m_usesDiagramLineColor:1;
+    bool m_usesDiagramLineWidth:1;
+    bool m_usesDiagramBrush:1;
+    bool m_usesDiagramFont:1;
+    bool m_usesDiagramTextColor:1;
+
     /**
      * Disable the copy constructor and assignment operator.
      */




More information about the umbrello-devel mailing list