[Uml-devel] KDE/kdesdk/umbrello/umbrello/dialogs
Ralf Habacker
ralf.habacker at gmail.com
Fri Jan 13 12:17:56 UTC 2012
SVN commit 1273410 by habacker:
Moved widget style and font page from ActivityDialog into clas DialogBase so that they can be used by other dialogs.
This reduces duplicated implementations.
M +5 -34 activitydialog.cpp
M +2 -17 activitydialog.h
M +53 -5 dialogbase.cpp
M +14 -1 dialogbase.h
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/activitydialog.cpp #1273409:1273410
@@ -31,7 +31,7 @@
#include <QtGui/QRadioButton>
ActivityDialog::ActivityDialog(QWidget * parent, ActivityWidget * pWidget)
- : KPageDialog(parent)
+ : DialogBase(parent)
{
setCaption( i18n("Properties") );
setButtons( Ok | Apply | Cancel | Help );
@@ -93,8 +93,8 @@
void ActivityDialog::setupPages()
{
setupGeneralPage();
- setupStylePage();
- setupFontPage();
+ pageItemStyle = setupStylePage( m_pActivityWidget );
+ pageItemFont = setupFontPage( m_pActivityWidget );
}
/**
@@ -120,11 +120,11 @@
}
else if ( item == pageItemFont )
{
- m_pActivityWidget->setFont( m_pChooser->font() );
+ saveFontPageData( m_pActivityWidget );
}
else if ( item == pageItemStyle )
{
- m_pStylePage->updateUMLWidget();
+ saveStylePageData( m_pActivityWidget );
}
}
@@ -214,20 +214,6 @@
}
/**
- * Sets up the font selection page.
- */
-void ActivityDialog::setupFontPage()
-{
- KVBox *page = new KVBox();
- pageItemFont = new KPageWidgetItem( page, i18n("Font") );
- pageItemFont->setHeader( i18n("Font Settings") );
- pageItemFont->setIcon( Icon_Utils::DesktopIcon(Icon_Utils::it_Properties_Font) );
- addPage( pageItemFont );
- m_pChooser = new KFontChooser( (QWidget*)page, KFontChooser::NoDisplayFlags, QStringList(), 0);
- m_pChooser->setFont( m_pActivityWidget->font() );
-}
-
-/**
* Show the Activity Parameter entry text.
*/
void ActivityDialog::showParameterActivity()
@@ -244,19 +230,4 @@
}
}
-/**
- * Sets up the style page.
- */
-void ActivityDialog::setupStylePage()
-{
- QFrame *stylePage = new QFrame();
- pageItemStyle = new KPageWidgetItem( stylePage, i18nc("widget style page", "Style") );
- pageItemStyle->setHeader( i18n("Widget Style") );
- pageItemStyle->setIcon( Icon_Utils::DesktopIcon(Icon_Utils::it_Properties_Color) );
- addPage( pageItemStyle );
- QHBoxLayout * m_pStyleLayout = new QHBoxLayout(stylePage);
- m_pStylePage = new UMLWidgetStylePage( stylePage, m_pActivityWidget );
- m_pStyleLayout->addWidget(m_pStylePage);
-}
-
#include "activitydialog.moc"
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/activitydialog.h #1273409:1273410
@@ -16,8 +16,7 @@
//kde class includes
#include <klineedit.h>
-#include <kpagedialog.h>
-#include <kfontdialog.h>
+#include <dialogbase.h>
#include <ktextedit.h>
//forward declarations
@@ -33,7 +32,7 @@
* @author Paul Hensgen
* Bugs and comments to uml-devel at lists.sf.net or http://bugs.kde.org
*/
-class ActivityDialog : public KPageDialog
+class ActivityDialog : public DialogBase
{
Q_OBJECT
@@ -63,25 +62,11 @@
void setupGeneralPage();
- void setupStylePage();
-
- void setupFontPage();
-
void showParameterActivity();
void applyPage( KPageWidgetItem * );
/**
- * Font chooser widget for font page.
- */
- KFontChooser * m_pChooser;
-
- /**
- * style page
- */
- UMLWidgetStylePage * m_pStylePage;
-
- /**
* The widget to represent.
*/
ActivityWidget * m_pActivityWidget;
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/dialogbase.cpp #1273409:1273410
@@ -14,6 +14,9 @@
// local includes
#include "icon_utils.h"
#include "umlwidgetstylepage.h"
+#include "klocale.h"
+#include <KFontChooser>
+#include "umlwidget.h"
// qt includes
#include <QFrame>
@@ -37,10 +40,55 @@
QFrame* DialogBase::createPage(const QString& name, const QString& header, Icon_Utils::IconType icon)
{
QFrame* page = new QFrame();
- KPageWidgetItem *pageItem = new KPageWidgetItem( page, name );
- pageItem->setHeader( header );
- pageItem->setIcon( Icon_Utils::DesktopIcon(icon) );
- addPage( pageItem );
- page->setMinimumSize( 310, 330 );
+ m_pageItem = new KPageWidgetItem( page, name );
+ m_pageItem->setHeader( header );
+ m_pageItem->setIcon( Icon_Utils::DesktopIcon(icon) );
+ addPage( m_pageItem );
+ //page->setMinimumSize( 310, 330 );
return page;
}
+
+/**
+ * Sets up the font selection page.
+ * @param widget The widget to load the initial data from
+ */
+KPageWidgetItem *DialogBase::setupFontPage(UMLWidget *widget)
+{
+ QFrame* page = createPage(i18n("Font"), i18n("Font Settings"), Icon_Utils::it_Properties_Font);
+ QHBoxLayout * m_pStyleLayout = new QHBoxLayout(page);
+ m_fontChooser = new KFontChooser( (QWidget*)page, KFontChooser::NoDisplayFlags, QStringList(), 0);
+ m_fontChooser->setFont(widget->font());
+ m_pStyleLayout->addWidget(m_fontChooser);
+ return m_pageItem;
+}
+
+/**
+ * updates the font page data
+ * @param widget Widget to save the font data into
+ */
+void DialogBase::saveFontPageData(UMLWidget *widget)
+{
+ widget->setFont( m_fontChooser->font() );
+}
+
+/**
+ * Sets up the style page.
+ * @param widget The widget to load the initial data from
+ */
+KPageWidgetItem *DialogBase::setupStylePage(UMLWidget *widget)
+{
+ QFrame * page = createPage(i18nc("widget style page", "Style"), i18n("Widget Style"), Icon_Utils::it_Properties_Color);
+ QHBoxLayout * m_pStyleLayout = new QHBoxLayout(page);
+ m_pStylePage = new UMLWidgetStylePage(page, widget);
+ m_pStyleLayout->addWidget(m_pStylePage);
+ return m_pageItem;
+}
+
+/**
+ * updates the font page data
+ * @param widget Widget to save the font data into
+ */
+void DialogBase::saveStylePageData(UMLWidget *widget)
+{
+ m_pStylePage->updateUMLWidget();
+}
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/dialogbase.h #1273409:1273410
@@ -18,7 +18,10 @@
//forward declarations
class QFrame;
-class WidgetBase;
+class UMLWidget;
+class KFontChooser;
+class KPageWidgetItem;
+class UMLWidgetStylePage;
/**
* Base class for property dialogs
@@ -38,7 +41,17 @@
public:
DialogBase(QWidget *parent);
QFrame* createPage(const QString& name, const QString& header, Icon_Utils::IconType icon);
+ KPageWidgetItem *setupFontPage(UMLWidget *widget);
+ void saveFontPageData(UMLWidget *widget);
+ KPageWidgetItem *setupStylePage(UMLWidget *widget);
+ void saveStylePageData(UMLWidget *widget);
+
+protected:
+ KFontChooser *m_fontChooser;
+ UMLWidgetStylePage *m_pStylePage;
+ KPageWidgetItem *m_pageItem;
+
};
#endif
More information about the umbrello-devel
mailing list