[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: PATCH: kicker cleanups
From: Wilco Greven <greven () kde ! org>
Date: 2002-02-28 1:00:40
[Download RAW message or body]
Hi,
The attached patch moves most of the ContainerArea's configuration handling to
the appropriate BaseContainer+derivative classes.
There's one thing I'm not completely sure about. In
ContainerArea::saveContainerConfig(), there's the following code.
if(a->inherits("AppletContainer"))
if(orientation() == Horizontal)
group.writeEntry( "WidthForHeightHint", a->widthForHeight(height()) );
I moved this to the AppletContainer class. The problem is that, above,
height() is ContainerArea::height(), and in the AppletContainer I used
AppletContainer::height(). But AFAIK, this won't make a difference, since
they are always equal.
Greetings,
Wilco
["kickercore.diff" (text/x-diff)]
? .panelbuttonbase.cpp.swo
Index: container_applet.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/core/container_applet.cpp,v
retrieving revision 1.29
diff -u -p -b -r1.29 container_applet.cpp
--- container_applet.cpp 2002/02/26 19:17:43 1.29
+++ container_applet.cpp 2002/02/28 00:44:20
@@ -188,6 +188,24 @@ void AppletContainer::slotRemoved()
}
}
+void AppletContainer::doLoadConfiguration( KConfigGroup& config )
+{
+ setWidthForHeightHint( config.readNumEntry( "WidthForHeightHint", 0 ) );
+ setHeightForWidthHint( config.readNumEntry( "HeightForWidthHint", 0 ) );
+}
+
+void AppletContainer::doSaveConfiguration( KConfigGroup& config,
+ bool layoutOnly ) const
+{
+ if (orientation() == Horizontal)
+ config.writeEntry( "WidthForHeightHint", widthForHeight(height()) );
+ else
+ config.writeEntry( "HeightForWidthHint", heightForWidth(width()) );
+
+ config.writeEntry( "ConfigFile", _configFile );
+ config.writeEntry( "DesktopFile", _deskFile );
+}
+
InternalAppletContainer::InternalAppletContainer( const AppletInfo& info, QWidget *parent)
: AppletContainer(info, parent)
{
@@ -210,13 +228,6 @@ InternalAppletContainer::~InternalApplet
{
}
-void InternalAppletContainer::saveConfiguration( KConfigGroup& config )
-{
- config.writeEntry("ConfigFile", _configFile);
- config.writeEntry("DesktopFile", _deskFile);
- config.sync();
-}
-
void InternalAppletContainer::slotSetPopupDirection(Direction d)
{
if (!_firstuse && _dir == d) return;
@@ -237,7 +248,7 @@ void InternalAppletContainer::slotSetOri
_applet->slotSetOrientation(o);
}
-int InternalAppletContainer::widthForHeight(int h)
+int InternalAppletContainer::widthForHeight(int h) const
{
if (!_applet) {
if (_widthForHeightHint > 0)
@@ -248,7 +259,7 @@ int InternalAppletContainer::widthForHei
return _applet->widthForHeight(h) + _handle->widthForHeight(h);
}
-int InternalAppletContainer::heightForWidth(int w)
+int InternalAppletContainer::heightForWidth(int w) const
{
if (!_applet) {
if (_heightForWidthHint > 0)
@@ -312,13 +323,6 @@ ExternalAppletContainer::~ExternalApplet
kapp->dcopClient()->send( _app, "AppletProxy", "removedFromPanel()", data);
}
-void ExternalAppletContainer::saveConfiguration( KConfigGroup& config )
-{
- config.writeEntry("ConfigFile", _configFile);
- config.writeEntry("DesktopFile", _deskFile);
- config.sync();
-}
-
void ExternalAppletContainer::slotSetPopupDirection(Direction d)
{
if (!_firstuse && _dir == d) return;
@@ -381,7 +385,7 @@ void ExternalAppletContainer::reportBug(
kapp->dcopClient()->send( _app, "AppletProxy", "reportBug()", data );
}
-int ExternalAppletContainer::widthForHeight(int h)
+int ExternalAppletContainer::widthForHeight(int h) const
{
int w = h;
if (_widthForHeightHint > 0)
@@ -405,7 +409,7 @@ int ExternalAppletContainer::widthForHei
return w + _handle->widthForHeight(h);
}
-int ExternalAppletContainer::heightForWidth(int w)
+int ExternalAppletContainer::heightForWidth(int w) const
{
int h = w;
if (_heightForWidthHint > 0)
Index: container_applet.h
===================================================================
RCS file: /home/kde/kdebase/kicker/core/container_applet.h,v
retrieving revision 1.13
diff -u -p -b -r1.13 container_applet.h
--- container_applet.h 2002/02/26 15:13:31 1.13
+++ container_applet.h 2002/02/28 00:44:20
@@ -69,6 +69,9 @@ public slots:
void activateWindow() { setActiveWindow(); }
protected:
+ virtual void doLoadConfiguration( KConfigGroup& );
+ virtual void doSaveConfiguration( KConfigGroup&, bool layoutOnly ) const;
+
AppletHandle *_handle;
AppletInfo _info;
QHBox *_appletframe;
@@ -87,16 +90,14 @@ public:
InternalAppletContainer(const AppletInfo& info, QWidget *parent);
~InternalAppletContainer();
- int widthForHeight(int height);
- int heightForWidth(int width);
+ int widthForHeight(int height) const;
+ int heightForWidth(int width) const;
void about();
void help();
void preferences();
void reportBug();
- void saveConfiguration( KConfigGroup& config );
-
QString appletType() { return "Applet"; }
public slots:
@@ -117,15 +118,13 @@ public:
ExternalAppletContainer(const AppletInfo& info, QWidget *parent);
~ExternalAppletContainer();
- int widthForHeight(int height);
- int heightForWidth(int width);
+ int widthForHeight(int height) const;
+ int heightForWidth(int width) const;
void about();
void help();
void preferences();
void reportBug();
-
- void saveConfiguration( KConfigGroup& config );
QString appletType() { return "Applet"; }
Index: container_base.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/core/container_base.cpp,v
retrieving revision 1.9
diff -u -p -b -r1.9 container_base.cpp
--- container_base.cpp 2001/12/31 07:31:25 1.9
+++ container_base.cpp 2002/02/28 00:44:20
@@ -50,6 +50,21 @@ BaseContainer::~BaseContainer()
delete _opMnu;
}
+void BaseContainer::loadConfiguration( KConfigGroup& group )
+{
+ setFreeSpace( QMIN( group.readDoubleNumEntry( "FreeSpace", 0 ), 1 ) );
+ doLoadConfiguration( group );
+}
+
+void BaseContainer::saveConfiguration( KConfigGroup& group,
+ bool layoutOnly ) const
+{
+ // write positioning info
+ group.writeEntry( "FreeSpace", freeSpace() );
+ // write type specific info
+ doSaveConfiguration( group, layoutOnly );
+}
+
void BaseContainer::slotRemoved()
{
KConfig* config = KGlobal::config();
Index: container_base.h
===================================================================
RCS file: /home/kde/kdebase/kicker/core/container_base.h,v
retrieving revision 1.12
diff -u -p -b -r1.12 container_base.h
--- container_base.h 2001/12/31 07:31:25 1.12
+++ container_base.h 2002/02/28 00:44:20
@@ -39,8 +39,8 @@ public:
BaseContainer( QWidget *parent = 0, const char * name = 0 );
~BaseContainer();
- virtual int widthForHeight(int height) = 0;
- virtual int heightForWidth(int width) = 0;
+ virtual int widthForHeight(int height) const = 0;
+ virtual int heightForWidth(int width) const = 0;
virtual bool isStretch() const { return false; }
@@ -60,7 +60,9 @@ public:
Direction popupDirection() const { return _dir; }
Orientation orientation() const { return _orient; }
- virtual void saveConfiguration( KConfigGroup& config ) = 0;
+ void loadConfiguration( KConfigGroup& );
+ void saveConfiguration( KConfigGroup&, bool layoutOnly = false ) const;
+
virtual void configure() {}
QPoint getPopupPosition(QPopupMenu *menu, QPoint eventpos);
@@ -90,6 +92,10 @@ signals:
void requestSave();
protected:
+ virtual void doLoadConfiguration( KConfigGroup& ) {}
+ virtual void doSaveConfiguration( KConfigGroup&,
+ bool layoutOnly = false ) const {}
+
Direction _dir;
Orientation _orient;
float _fspace;
Index: container_button.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/core/container_button.cpp,v
retrieving revision 1.20
diff -u -p -b -r1.20 container_button.cpp
--- container_button.cpp 2001/12/31 07:31:25 1.20
+++ container_button.cpp 2002/02/28 00:44:20
@@ -64,7 +64,7 @@ void ButtonContainer::configure()
if(_button) _button->configure();
}
-void ButtonContainer::saveConfiguration( KConfigGroup& config )
+void ButtonContainer::doSaveConfiguration( KConfigGroup& config ) const
{
if(_button) _button->saveConfig( config );
}
@@ -171,7 +171,7 @@ KMenuButtonContainer::KMenuButtonContain
embedButton(b);
}
-int KMenuButtonContainer::widthForHeight( int height )
+int KMenuButtonContainer::widthForHeight( int height ) const
{
if ( height < 32 )
return height + 10;
@@ -179,7 +179,7 @@ int KMenuButtonContainer::widthForHeight
return height;
}
-int KMenuButtonContainer::heightForWidth( int width )
+int KMenuButtonContainer::heightForWidth( int width ) const
{
if ( width < 32 )
return width + 10;
Index: container_button.h
===================================================================
RCS file: /home/kde/kdebase/kicker/core/container_button.h,v
retrieving revision 1.15
diff -u -p -b -r1.15 container_button.h
--- container_button.h 2002/01/05 12:49:02 1.15
+++ container_button.h 2002/02/28 00:44:20
@@ -38,13 +38,11 @@ public:
ButtonContainer(QWidget* parent = 0);
// buttons have a quadratic shape
- virtual int widthForHeight(int height) { return height; }
- virtual int heightForWidth(int width) { return width; }
+ virtual int widthForHeight(int height) const { return height; }
+ virtual int heightForWidth(int width) const { return width; }
- virtual void saveConfiguration( KConfigGroup& config );
virtual void configure();
-
bool eventFilter (QObject *, QEvent *);
void completeMoveOperation();
@@ -55,6 +53,7 @@ public slots:
void slotSetOrientation(Orientation o);
protected:
+ virtual void doSaveConfiguration( KConfigGroup& config ) const;
void embedButton(PanelButton* p);
protected:
@@ -69,8 +68,8 @@ public:
KMenuButtonContainer(QWidget* parent);
QString appletType() { return "KMenuButton"; }
- virtual int widthForHeight( int height );
- virtual int heightForWidth( int width );
+ virtual int widthForHeight( int height ) const;
+ virtual int heightForWidth( int width ) const;
};
class DesktopButtonContainer : public ButtonContainer
Index: containerarea.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/core/containerarea.cpp,v
retrieving revision 1.105
diff -u -p -b -r1.105 containerarea.cpp
--- containerarea.cpp 2002/02/27 22:14:12 1.105
+++ containerarea.cpp 2002/02/28 00:44:20
@@ -217,21 +217,6 @@ void ContainerArea::saveContainerConfig(
alist.append( a->appletId() );
KConfigGroup group( _config, a->appletId().latin1() );
-
- // write positioning info
- group.writeEntry( "FreeSpace", a->freeSpace() );
-
- // write size hint
- if(a->inherits("AppletContainer")) {
- if(orientation() == Horizontal) {
- group.writeEntry( "WidthForHeightHint", a->widthForHeight(height()) );
- } else {
- group.writeEntry( "HeightForWidthHint", a->heightForWidth(width()) );
- }
- }
-
- // let the container write custom data fields
- if(!layoutOnly)
a->saveConfiguration( group );
}
@@ -288,26 +273,14 @@ void ContainerArea::loadContainerConfig(
a = new KonsoleButtonContainer(viewport());
else if (appletId.contains("ExtensionButton") > 0)
a = new ExtensionButtonContainer(group, viewport());
- else if (appletId.contains("Applet") > 0) {
-
+ else if (appletId.contains("Applet") > 0)
a = PluginManager::pluginManager()->createAppletContainer(
group.readEntry("DesktopFile"),
true, // isStartup
group.readEntry("ConfigFile"),
viewport() );
-
- if(a) {
- int whint = group.readNumEntry("WidthForHeightHint", 0);
- int hhint = group.readNumEntry("HeightForWidthHint", 0);
- ((AppletContainer*)a)->setWidthForHeightHint(whint);
- ((AppletContainer*)a)->setHeightForWidthHint(hhint);
- }
- }
-
if (a) {
- float freeSpace = group.readDoubleNumEntry("FreeSpace", 0);
- if(freeSpace > 1) freeSpace = 1;
- a->setFreeSpace( freeSpace );
+ a->loadConfiguration(group);
addContainer(a);
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic