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