[Uml-devel] KDE/kdesdk/umbrello/umbrello

Ralf Habacker ralf.habacker at gmail.com
Fri Jan 13 07:31:08 UTC 2012


SVN commit 1273379 by habacker:

Added widget style page to AssociationWidget property dialog, which makes it possible to change the text color of association role names.

BUG: 291401

 M  +1 -0      CMakeLists.txt  
 M  +25 -38    dialogs/assocpropdlg.cpp  
 M  +5 -4      dialogs/assocpropdlg.h  
 A             dialogs/dialogbase.cpp   [License: GPL (v2+)]
 A             dialogs/dialogbase.h   [License: GPL (v2+)]
 M  +3 -2      dialogs/umlwidgetstylepage.cpp  
 M  +3 -3      dialogs/umlwidgetstylepage.h  
 M  +27 -0     widgets/associationwidget.cpp  
 M  +6 -1      widgets/associationwidget.h  
 M  +1 -2      widgets/floatingtextwidget.cpp  
 M  +4 -4      widgets/umlwidget.h  
 M  +4 -4      widgets/widgetbase.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/CMakeLists.txt #1273378:1273379
@@ -220,6 +220,7 @@
     dialogs/defaultcodegenpolicypage.cpp
     dialogs/diagramprintpage.cpp
     dialogs/dialog_utils.cpp
+    dialogs/dialogbase.cpp
     dialogs/exportallviewsdialog.cpp
     dialogs/notedialog.cpp
     dialogs/objectnodedialog.cpp
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/assocpropdlg.cpp #1273378:1273379
@@ -37,7 +37,7 @@
 #include <QtGui/QHBoxLayout>
 
 AssocPropDlg::AssocPropDlg (QWidget *parent, AssociationWidget * assocWidget, int pageNum)
-  : KPageDialog(parent)
+  : DialogBase(parent)
 {
     Q_UNUSED(pageNum);
     setCaption( i18n("Association Properties") );
@@ -51,7 +51,7 @@
     m_pRolePage = 0;
     m_pAssoc = assocWidget;
 
-    setupPages(assocWidget);
+    setupPages();
 
     connect(this,SIGNAL(okClicked()),this,SLOT(slotOk()));
     connect(this,SIGNAL(applyClicked()),this,SLOT(slotApply()));
@@ -77,56 +77,43 @@
         m_pRolePage->updateObject();
     }
 
+    if (m_pStylePage) {
+        m_pStylePage->updateUMLWidget();
+    }
+
     if (m_pAssoc) {
         m_pAssoc->lwSetFont( m_pChooser->font() );
     }
 }
 
-// void AssocPropDlg::setupPages (UMLObject * c)
-void AssocPropDlg::setupPages (AssociationWidget *assocWidget)
+void AssocPropDlg::setupPages()
 {
     UMLDoc* umlDoc = UMLApp::app()->document();
 
     // general page
-    QFrame *page = new QFrame();
-    KPageWidgetItem *pageItem = new KPageWidgetItem( page, i18nc("general settings", "General"));
-    pageItem->setHeader( i18n("General Settings") );
-    pageItem->setIcon( Icon_Utils::DesktopIcon(Icon_Utils::it_Properties_General) );
-    addPage( pageItem );
-    QHBoxLayout *genLayout = new QHBoxLayout(page);
-    page->setMinimumSize(310, 330);
-    m_pGenPage = new AssocGenPage (umlDoc, page, assocWidget);
-    genLayout->addWidget(m_pGenPage);
+    QFrame *page = createPage( i18nc("general settings", "General"), i18n("General Settings"), Icon_Utils::it_Properties_General );
+    QHBoxLayout *layout = new QHBoxLayout( page );
+    m_pGenPage = new AssocGenPage ( umlDoc, page, m_pAssoc );
+    layout->addWidget( m_pGenPage );
 
     // role page
-    QFrame *newPage = new QFrame();
-    pageItem = new KPageWidgetItem( newPage, i18n("Roles"));
-    pageItem->setHeader( i18n("Role Settings"));
-    pageItem->setIcon( Icon_Utils::DesktopIcon(Icon_Utils::it_Properties_Roles) );
-    addPage( pageItem );
-    QHBoxLayout * roleLayout = new QHBoxLayout(newPage);
-    // newPage->setMinimumSize(310, 330);
-    m_pRolePage = new AssocRolePage(umlDoc, newPage, assocWidget);
-    roleLayout->addWidget(m_pRolePage);
+    page = createPage( i18nc("role style page name", "Roles"), i18n("Role Settings"), Icon_Utils::it_Properties_Roles );
+    layout = new QHBoxLayout( page );
+    m_pRolePage = new AssocRolePage(umlDoc, page, m_pAssoc ),
+    layout->addWidget( m_pRolePage );
 
-    setupFontPage();
-}
+    // style page
+    page = createPage( i18nc("role style page name", "Style"), i18n("Role Style"), Icon_Utils::it_Properties_Color );
+    layout = new QHBoxLayout( page );
+    m_pStylePage = new UMLWidgetStylePage( page, m_pAssoc );
+    layout->addWidget( m_pStylePage );
 
-void AssocPropDlg::setupFontPage()
-{
-    if ( !m_pAssoc) {
-        return;
-    }
-
-    KVBox *page = new KVBox();
-    KPageWidgetItem* pageItem = new KPageWidgetItem( page, i18n("Font"));
-    pageItem->setHeader( i18n("Font Settings"));
-    pageItem->setIcon( Icon_Utils::DesktopIcon(Icon_Utils::it_Properties_Font) );
-    addPage( pageItem );
-
-    m_pChooser = new KFontChooser( (QWidget*)page, KFontChooser::NoDisplayFlags, QStringList(), false);
+    // font page
+    page = createPage( i18nc("font page name", "Font"), i18n("Font Settings"), Icon_Utils::it_Properties_Font );
+    m_pChooser = new KFontChooser( page, KFontChooser::NoDisplayFlags, QStringList(), false );
     m_pChooser->setFont( m_pAssoc->font());
-    m_pChooser->setSampleText(i18n("Association font"));
+    m_pChooser->setSampleText( "Association font" );
 }
 
+
 #include "assocpropdlg.moc"
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/assocpropdlg.h #1273378:1273379
@@ -11,21 +11,22 @@
 #ifndef ASSOCPROPDLG_H
 #define ASSOCPROPDLG_H
 
+#include "dialogbase.h"
 #include "associationwidget.h"
 
 // kde includes
-#include <kpagedialog.h>
 #include <kfontdialog.h>
 
 class AssocRolePage;
 class AssocGenPage;
+class UMLWidgetStylePage;
 
 /**
  * Based off of AssocPropDlg class
  * @author Brian Thomas <Brian.A.Thomas at gsfc.nasa.gov>
  * Bugs and comments to uml-devel at lists.sf.net or http://bugs.kde.org
  */
-class AssocPropDlg : public KPageDialog
+class AssocPropDlg : public DialogBase
 {
     Q_OBJECT
 public:
@@ -46,8 +47,7 @@
     enum Page { page_gen = 0, page_role, page_font };
 
 protected:
-    void setupPages(AssociationWidget * assocWidget);
-    void setupFontPage();
+    void setupPages();
 
 protected slots:
     void slotOk();
@@ -56,6 +56,7 @@
 private:
     AssocGenPage *m_pGenPage;
     AssocRolePage *m_pRolePage;
+    UMLWidgetStylePage *m_pStylePage;
     KFontChooser *m_pChooser;
     AssociationWidget *m_pAssoc;
 
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/umlwidgetstylepage.cpp #1273378:1273379
@@ -12,9 +12,10 @@
 
 #include "optionstate.h"
 #include "uml.h"
+#include "umlscene.h"
 #include "umlview.h"
 #include "umlviewcanvas.h"
-#include "umlwidget.h"
+#include "widgetbase.h"
 
 #include <klocale.h>
 #include <kcolorbutton.h>
@@ -31,7 +32,7 @@
 /**
  *   Constructor - Observe a UMLWidget.
  */
-UMLWidgetStylePage::UMLWidgetStylePage( QWidget *pParent, UMLWidget *pWidget ) : QWidget( pParent )
+UMLWidgetStylePage::UMLWidgetStylePage( QWidget *pParent, WidgetBase *pWidget ) : QWidget( pParent )
 {
     m_pUMLWidget = pWidget;
     m_options = 0;
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/umlwidgetstylepage.h #1273378:1273379
@@ -19,7 +19,7 @@
  * @author Paul Hensgen
  * Bugs and comments to uml-devel at lists.sf.net or http://bugs.kde.org
  */
-class UMLWidget;
+class WidgetBase;
 class KColorButton;
 class KIntSpinBox;
 class QLabel;
@@ -32,7 +32,7 @@
     Q_OBJECT
 public:
 
-    UMLWidgetStylePage( QWidget * pParent, UMLWidget * pWidget );
+    UMLWidgetStylePage( QWidget * pParent, WidgetBase * pWidget );
     UMLWidgetStylePage( QWidget * pParent, Settings::OptionState *options );
 
     virtual ~UMLWidgetStylePage();
@@ -50,7 +50,7 @@
 
 protected:
 
-    UMLWidget * m_pUMLWidget;  ///< the widget to set the color for
+    WidgetBase * m_pUMLWidget;  ///< the widget to set the style for
 
     Settings::OptionState * m_options;
 
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/associationwidget.cpp #1273378:1273379
@@ -2850,6 +2850,33 @@
 }
 
 /**
+ * Set all 'owned' child widgets to this text color.
+ */
+void AssociationWidget::setTextColor(const QColor &color)
+{
+    WidgetBase::setTextColor(color);
+    if( m_pName) {
+        m_pName->setTextColor( color );
+    }
+    if( m_role[A].m_pRole ) {
+        m_role[A].m_pRole->setTextColor( color );
+    }
+    if( m_role[B].m_pRole ) {
+        m_role[B].m_pRole->setTextColor( color );
+    }
+    if( m_role[A].m_pMulti ) {
+        m_role[A].m_pMulti->setTextColor( color );
+    }
+    if( m_role[B].m_pMulti ) {
+        m_role[B].m_pMulti->setTextColor( color );
+    }
+    if( m_role[A].m_pChangeWidget)
+        m_role[A].m_pChangeWidget->setTextColor( color );
+    if( m_role[B].m_pChangeWidget)
+        m_role[B].m_pChangeWidget->setTextColor( color );
+}
+
+/**
  * Overrides the method from WidgetBase.
  */
 void AssociationWidget::setLineColor(const QColor &color)
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/associationwidget.h #1273378:1273379
@@ -393,11 +393,16 @@
     /**
      * Overrides the method from WidgetBase.
      */
-    void setLineColor(const QColor &color);
+    virtual void setTextColor(const QColor &color);
 
     /**
      * Overrides the method from WidgetBase.
      */
+    virtual void setLineColor(const QColor &colour);
+
+    /**
+     * Overrides the method from WidgetBase.
+     */
     void setLineWidth(uint width);
 
     /**
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/floatingtextwidget.cpp #1273378:1273379
@@ -469,8 +469,7 @@
     int w = width();
     int h = height();
     p.setFont( UMLWidget::font() );
-    QColor textColor(50, 50, 50);
-    p.setPen(textColor);
+    p.setPen(textColor());
     p.drawText( offsetX, offsetY,w,h, Qt::AlignCenter, displayText() );
     if(m_selected)
         drawSelected(&p, offsetX, offsetY);
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/umlwidget.h #1273378:1273379
@@ -58,15 +58,15 @@
 
     void setUseFillColor(bool fc);
 
-    void setTextColor(const QColor &color);
+    virtual void setTextColor(const QColor &color);
     void setTextColorcmd(const QColor &color);
 
-    void setLineColor(const QColor &color);
+    virtual void setLineColor(const QColor &color);
     void setLineColorcmd(const QColor &color);
 
-    void setLineWidth(uint width);
+    virtual void setLineWidth(uint width);
 
-    void setFillColor(const QColor &color);
+    virtual void setFillColor(const QColor &color);
     void setFillColorcmd(const QColor &color);
 
     /**
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/widgetbase.h #1273378:1273379
@@ -89,16 +89,16 @@
     void setDocumentation(const QString &doc);
 
     QColor textColor() const;
-    void setTextColor(const QColor &color);
+    virtual void setTextColor(const QColor &color);
 
     QColor lineColor() const;
-    void setLineColor(const QColor &color);
+    virtual void setLineColor(const QColor &color);
 
     QColor fillColor() const;
-    void setFillColor(const QColor &color);
+    virtual void setFillColor(const QColor &color);
 
     uint lineWidth() const;
-    void setLineWidth(uint width);
+    virtual void setLineWidth(uint width);
 
     bool useFillColor();
     void setUseFillColor(bool state);




More information about the umbrello-devel mailing list