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

Andi Fischer andi.fischer at hispeed.ch
Sat Jan 21 14:16:38 UTC 2012


SVN commit 1275023 by fischer:

Save and load of the background and the grid color fixed.

 M  +2 -2      dialogs/umlviewdialog.cpp  
 M  +14 -12    dialogs/umlwidgetstylepage.cpp  
 M  +20 -9     optionstate.cpp  
 M  +4 -3      umlscene.cpp  
 M  +1 -0      umlscene.h  


--- branches/work/soc-umbrello/umbrello/dialogs/umlviewdialog.cpp #1275022:1275023
@@ -185,9 +185,9 @@
         m_pScene->setUseFillColor( m_options.uiState.useFillColor );
         m_pScene->setLineColor( m_options.uiState.lineColor );
         m_pScene->setBrush( m_options.uiState.fillColor );
-        //:TODO:
+        m_pScene->setBackgroundBrush(m_options.uiState.backgroundColor);
         m_pScene->setGridDotColor(m_options.uiState.gridDotColor);
-        // gridCrossColor, gridTextColor, gridTextFont, gridTextIsVisible
+        //:TODO: gridCrossColor, gridTextColor, gridTextFont, gridTextIsVisible
     }
     else if ( item == m_pageFontItem )
     {
--- branches/work/soc-umbrello/umbrello/dialogs/umlwidgetstylepage.cpp #1275022:1275023
@@ -14,7 +14,6 @@
 #include "uml.h"
 #include "umlscene.h"
 #include "umlview.h"
-//:TODO:#include "umlviewcanvas.h"
 #include "widgetbase.h"
 
 #include <klocale.h>
@@ -32,7 +31,8 @@
 /**
  *   Constructor - Observe a UMLWidget.
  */
-UMLWidgetStylePage::UMLWidgetStylePage( QWidget *pParent, WidgetBase *pWidget ) : QWidget( pParent )
+UMLWidgetStylePage::UMLWidgetStylePage( QWidget *pParent, WidgetBase *pWidget )
+  : QWidget( pParent )
 {
     m_pUMLWidget = pWidget;
     m_options = 0;
@@ -46,19 +46,20 @@
     if (!m_pUMLWidget) {  //  when we are on the diagram
         UMLView * view = UMLApp::app()->currentView();
         if (view) {
-//:TODO:            UMLViewCanvas* canvas = dynamic_cast<UMLViewCanvas*>(view->canvas());
-//:TODO:            if (canvas) {
-//:TODO:                m_BackgroundColorB->setColor(canvas->backgroundColor());
-//:TODO:                m_GridDotColorB->setColor(canvas->gridDotColor());
-//:TODO:            }
+            UMLScene* scene = view->umlScene();
+            if (scene) {
+                m_BackgroundColorB->setColor(scene->backgroundBrush().color());
+                m_GridDotColorB->setColor(scene->gridDotColor());
         }
     }
 }
+}
 
 /**
  *   Constructor - Observe an OptionState structure.
  */
-UMLWidgetStylePage::UMLWidgetStylePage( QWidget * pParent, Settings::OptionState *options ) : QWidget( pParent )
+UMLWidgetStylePage::UMLWidgetStylePage( QWidget * pParent, Settings::OptionState *options )
+  : QWidget( pParent )
 {
     m_options = options;
     m_pUMLWidget = 0;
@@ -256,12 +257,13 @@
     if (!m_pUMLWidget) {  // when we are on the diagram
         UMLView * view = UMLApp::app()->currentView();
         if (view) {
-//:TODO:            UMLViewCanvas* canvas = dynamic_cast<UMLViewCanvas*>(view->canvas());
-//:TODO:            if (canvas) {
-//:TODO:                canvas->setColors(m_BackgroundColorB->color(), m_GridDotColorB->color());
-//:TODO:            }
+            UMLScene* scene = view->umlScene();
+            if (scene) {
+                scene->setBackgroundBrush(m_BackgroundColorB->color());
+                scene->setGridDotColor(m_GridDotColorB->color());
         }
     }
 }
+}
 
 #include "umlwidgetstylepage.moc"
--- branches/work/soc-umbrello/umbrello/optionstate.cpp #1275022:1275023
@@ -35,11 +35,14 @@
     void saveToXMI(QDomElement& element, const OptionState& optstate)
     {
         // uistate
+        element.setAttribute("usefillcolor",     optstate.uiState.useFillColor);
         element.setAttribute("fillcolor",    optstate.uiState.fillColor.name());
         element.setAttribute("linecolor",    optstate.uiState.lineColor.name());
         element.setAttribute("linewidth",    optstate.uiState.lineWidth);
-        element.setAttribute("usefillcolor", optstate.uiState.useFillColor);
+        element.setAttribute("textcolor",        optstate.uiState.textColor.name());
         element.setAttribute("font",         optstate.uiState.font.toString());
+        element.setAttribute("backgroundcolor",  optstate.uiState.backgroundColor.name());
+        element.setAttribute("griddotcolor",     optstate.uiState.gridDotColor.name());
         // classstate
         element.setAttribute("showattsig",       optstate.classState.showAttSig);
         element.setAttribute("showatts",         optstate.classState.showAtts);
@@ -55,11 +58,8 @@
     bool loadFromXMI(QDomElement& element, OptionState& optstate)
     {
         // uistate
-        QString font = element.attribute("font", "");
-        if (!font.isEmpty()) {
-            optstate.uiState.font.fromString(font);
-            optstate.uiState.font.setUnderline(false);
-        }
+        QString usefillcolor = element.attribute("usefillcolor", "0");
+        optstate.uiState.useFillColor = (bool)usefillcolor.toInt();
         QString fillcolor = element.attribute("fillcolor", "");
         if (!fillcolor.isEmpty())
             optstate.uiState.fillColor = QColor(fillcolor);
@@ -69,8 +69,20 @@
         QString linewidth = element.attribute("linewidth", "");
         if (!linewidth.isEmpty())
             optstate.uiState.lineWidth = linewidth.toInt();
-        QString usefillcolor = element.attribute("usefillcolor", "0");
-        optstate.uiState.useFillColor = (bool)usefillcolor.toInt();
+        QString textColor = element.attribute("textcolor", "");
+        if (!textColor.isEmpty())
+            optstate.uiState.textColor = QColor(textColor);
+        QString font = element.attribute("font", "");
+        if (!font.isEmpty()) {
+            optstate.uiState.font.fromString(font);
+            optstate.uiState.font.setUnderline(false);
+        }
+        QString backgroundColor = element.attribute("backgroundcolor", "");
+        if (!backgroundColor.isEmpty())
+            optstate.uiState.backgroundColor = QColor(backgroundColor);
+        QString gridDotColor = element.attribute("griddotcolor", "");
+        if (!gridDotColor.isEmpty())
+            optstate.uiState.gridDotColor = QColor(gridDotColor);
         // classstate
         QString temp = element.attribute("showattsig", "0");
         optstate.classState.showAttSig = (bool)temp.toInt();
@@ -93,4 +105,3 @@
     }
 
 }  // namespace Settings
-
--- branches/work/soc-umbrello/umbrello/umlscene.cpp #1275022:1275023
@@ -1089,7 +1089,7 @@
  */
 QBrush UMLScene::brush() const
 {
-    return QBrush();  //:TODO: m_Options.uiState.fillColor);
+    return QBrush(m_Options.uiState.fillColor);
 }
 
 /**
@@ -1156,8 +1156,7 @@
 void UMLScene::setTextColor(const QColor& color)
 {
     m_Options.uiState.textColor = color;
-    // PORT: Apply for widgets.
-    // emit sigTextColorChanged(getID());
+    emit sigTextColorChanged(getID());
 }
 
 /**
@@ -3842,6 +3841,8 @@
     QString localid = qElement.attribute("localid", "0");
     // option state
     Settings::loadFromXMI(qElement, m_Options);
+    setBackgroundBrush(m_Options.uiState.backgroundColor);
+    setGridDotColor(m_Options.uiState.gridDotColor);
     //misc
     QString showgrid = qElement.attribute("showgrid", "0");
     m_layoutGrid->setVisible((bool)showgrid.toInt());
--- branches/work/soc-umbrello/umbrello/umlscene.h #1275022:1275023
@@ -458,6 +458,7 @@
     void sigRemovePopupMenu();
     void sigClearAllSelected();
     void sigLineWidthChanged(Uml::IDType);
+    void sigTextColorChanged(Uml::IDType);
     void sigSnapToGridToggled(bool);
     void sigSnapComponentSizeToGridToggled(bool);
     void sigShowGridToggled(bool);




More information about the umbrello-devel mailing list