kdeui Library API Documentation

kpanelapplet.cpp

00001 /*****************************************************************
00002 
00003 Copyright (c) 2000 Matthias Elter
00004 
00005 Permission is hereby granted, free of charge, to any person obtaining a copy
00006 of this software and associated documentation files (the "Software"), to deal
00007 in the Software without restriction, including without limitation the rights
00008 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00009 copies of the Software, and to permit persons to whom the Software is
00010 furnished to do so, subject to the following conditions:
00011 
00012 The above copyright notice and this permission notice shall be included in
00013 all copies or substantial portions of the Software.
00014 
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00018 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00019 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00020 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00021 
00022 ******************************************************************/
00023 
00024 #include "kpanelapplet.h"
00025 #include "kpanelapplet.moc"
00026 #include <kapplication.h>
00027 #include <kconfig.h>
00028 
00029 class KPanelApplet::KPanelAppletPrivate
00030 {
00031 public:
00032   KPanelAppletPrivate() : customMenu(0) {}
00033 
00034   const QPopupMenu* customMenu;
00035   KSharedConfig::Ptr sharedConfig;
00036 };
00037 
00038 KPanelApplet::KPanelApplet(const QString& configFile, Type type,
00039                            int actions, QWidget *parent, const char *name, WFlags f)
00040   : QFrame(parent, name, f)
00041   , _type(type)
00042   , _position( pBottom )
00043   , _alignment( LeftTop )
00044   , _config(0)
00045   , _actions(actions)
00046   , d(new KPanelApplet::KPanelAppletPrivate())
00047 {
00048   setFrameStyle(NoFrame);
00049   QPalette pal(palette());
00050   if(pal.active().mid() != pal.inactive().mid()){
00051     pal.setInactive(pal.active());
00052     setPalette(pal);
00053   }
00054   setBackgroundOrigin( AncestorOrigin );
00055 
00056   d->sharedConfig = KSharedConfig::openConfig(configFile, kapp && kapp->config()->isImmutable());
00057   _config = d->sharedConfig;
00058 }
00059 
00060 KPanelApplet::~KPanelApplet()
00061 {
00062   delete d;
00063 }
00064 
00065 void KPanelApplet::setPosition( Position p )
00066 {
00067   if( _position == p ) return;
00068   _position = p;
00069   positionChange( p );
00070 }
00071 
00072 void KPanelApplet::setAlignment( Alignment a )
00073 {
00074   if( _alignment == a ) return;
00075   _alignment = a;
00076   alignmentChange( a );
00077 }
00078 
00079 // FIXME: Remove implementation for KDE 4
00080 void KPanelApplet::positionChange( Position )
00081 {
00082   orientationChange( orientation() );
00083   QResizeEvent e( size(), size() );
00084   resizeEvent( &e );
00085   popupDirectionChange( popupDirection() );
00086 }
00087 
00088 Qt::Orientation KPanelApplet::orientation() const
00089 {
00090   if( _position == pTop || _position == pBottom ) {
00091     return Horizontal;
00092   } else {
00093     return Vertical;
00094   }
00095 }
00096 
00097 // FIXME: Remove for KDE 4
00098 KPanelApplet::Direction KPanelApplet::popupDirection()
00099 {
00100     switch( _position ) {
00101     case pTop:     return Down;
00102     case pRight:   return Left;
00103     case pLeft:    return Right;
00104     default:
00105     case pBottom:  return Up;
00106     }
00107 }
00108 
00109 void KPanelApplet::action( Action a )
00110 {
00111     if ( (a & About) != 0 )
00112     about();
00113     if ( (a & Help) != 0 )
00114     help();
00115     if ( (a & Preferences) != 0 )
00116     preferences();
00117     if ( (a & ReportBug) != 0 )
00118     reportBug();
00119 }
00120 
00121 const QPopupMenu* KPanelApplet::customMenu() const
00122 {
00123     return d->customMenu;
00124 }
00125 
00126 void KPanelApplet::setCustomMenu(const QPopupMenu* menu)
00127 {
00128     d->customMenu = menu;
00129 }
00130 
00131 KSharedConfig::Ptr KPanelApplet::sharedConfig() const
00132 {
00133     return d->sharedConfig;
00134 }
00135 
00136 void KPanelApplet::virtual_hook( int, void* )
00137 { /*BASE::virtual_hook( id, data );*/ }
00138 
KDE Logo
This file is part of the documentation for kdeui Library Version 3.3.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jan 22 16:45:15 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003