kpanelapplet.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <kconfig.h>
00025
00026 #include "kpanelapplet.h"
00027 #include "kpanelapplet.moc"
00028
00029 KPanelApplet::KPanelApplet(const QString& configFile, Type type,
00030 int actions, QWidget *parent, const char *name, WFlags f)
00031 : QFrame(parent, name, f)
00032 , _type(type)
00033 , _position( pBottom )
00034 , _alignment( LeftTop )
00035 , _config(0)
00036 , _actions(actions)
00037 {
00038 setFrameStyle(NoFrame);
00039 QPalette pal(palette());
00040 if(pal.active().mid() != pal.inactive().mid()){
00041 pal.setInactive(pal.active());
00042 setPalette(pal);
00043 }
00044
00045 _config = new KConfig(configFile);
00046 }
00047
00048 KPanelApplet::~KPanelApplet()
00049 {
00050 delete _config;
00051 }
00052
00053 void KPanelApplet::setPosition( Position p )
00054 {
00055 if( _position == p ) return;
00056 _position = p;
00057 positionChange( p );
00058 }
00059
00060 void KPanelApplet::setAlignment( Alignment a )
00061 {
00062 if( _alignment == a ) return;
00063 _alignment = a;
00064 alignmentChange( a );
00065 }
00066
00067
00068 void KPanelApplet::positionChange( Position )
00069 {
00070 orientationChange( orientation() );
00071 QResizeEvent e( size(), size() );
00072 resizeEvent( &e );
00073 popupDirectionChange( popupDirection() );
00074 }
00075
00076 Qt::Orientation KPanelApplet::orientation() const
00077 {
00078 if( _position == pTop || _position == pBottom ) {
00079 return Horizontal;
00080 } else {
00081 return Vertical;
00082 }
00083 }
00084
00085
00086 KPanelApplet::Direction KPanelApplet::popupDirection()
00087 {
00088 switch( _position ) {
00089 case pTop: return Down;
00090 case pRight: return Left;
00091 case pLeft: return Right;
00092 default:
00093 case pBottom: return Up;
00094 }
00095 }
00096
00097 void KPanelApplet::action( Action a )
00098 {
00099 if ( (a & About) != 0 )
00100 about();
00101 if ( (a & Help) != 0 )
00102 help();
00103 if ( (a & Preferences) != 0 )
00104 preferences();
00105 if ( (a & ReportBug) != 0 )
00106 reportBug();
00107 }
00108
00109 void KPanelApplet::virtual_hook( int, void* )
00110 { }
00111
This file is part of the documentation for kdelibs Version 3.1.0.