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 "kpanelextension.h"
00027
#include "kpanelextension.moc"
00028
00029
class KPanelExtensionPrivate
00030 {
00031
public:
00032 KPanelExtensionPrivate()
00033 : _size(
KPanelExtension::SizeNormal),
00034 _customSize(58)
00035 {}
00036
00037
KPanelExtension::Size _size;
00038
int _customSize;
00039 };
00040
00041 KPanelExtension::KPanelExtension(
const QString& configFile, Type type,
00042
int actions,
QWidget *parent,
const char *name)
00043 :
QFrame(parent, name)
00044 , _type(type)
00045 , _position( Top )
00046 , _alignment( LeftTop )
00047 , _config(0)
00048 , _actions(actions)
00049 {
00050 d =
new KPanelExtensionPrivate;
00051
setFrameStyle(NoFrame);
00052 _config =
new KConfig(configFile);
00053 }
00054
00055 KPanelExtension::~KPanelExtension()
00056 {
00057
delete _config;
00058
delete d;
00059 }
00060
00061
void KPanelExtension::setPosition( Position p )
00062 {
00063
if( _position == p )
return;
00064 _position = p;
00065
positionChange( p );
00066 }
00067
00068
void KPanelExtension::setAlignment( Alignment a )
00069 {
00070
if( _alignment == a )
return;
00071 _alignment = a;
00072
alignmentChange( a );
00073 }
00074
00075
void KPanelExtension::setSize( Size size,
int customSize )
00076 {
00077
if ( d->_size == size && d->_customSize == customSize )
return;
00078 d->_size = size;
00079 d->_customSize = customSize;
00080 emit
updateLayout();
00081 }
00082
00083 void KPanelExtension::action( Action a )
00084 {
00085
if ( (a & About) != 0 )
00086
about();
00087
if ( (a & Help) != 0 )
00088
help();
00089
if ( (a & Preferences) != 0 )
00090
preferences();
00091
if ( (a & ReportBug) != 0 )
00092
reportBug();
00093 }
00094
00095 Qt::Orientation
KPanelExtension::orientation()
00096 {
00097
if (_position == Left || _position == Right)
00098
return Vertical;
00099
else
00100
return Horizontal;
00101 }
00102
00103 KPanelExtension::Size KPanelExtension::sizeSetting()
const
00104
{
00105
return d->_size;
00106 }
00107
00108 int KPanelExtension::customSize()
const
00109
{
00110
return d->_customSize;
00111 }
00112
00113 int KPanelExtension::sizeInPixels()
const
00114
{
00115
if (d->_size == SizeTiny)
00116 {
00117
return 24;
00118 }
00119
else if (d->_size == SizeSmall)
00120 {
00121
return 30;
00122 }
00123
else if (d->_size == SizeNormal)
00124 {
00125
return 46;
00126 }
00127
else if (d->_size == SizeLarge)
00128 {
00129
return 58;
00130 }
00131
00132
return d->_customSize;
00133 }
00134
00135
void KPanelExtension::virtual_hook(
int,
void* )
00136 { }
00137