• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeui
 

tdeui

  • tdeui
kpanelapplet.cpp
1/*****************************************************************
2
3Copyright (c) 2000 Matthias Elter
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22******************************************************************/
23
24#include <tqptrlist.h>
25
26#include "kpanelapplet.h"
27#include "kpanelapplet.moc"
28#include <tdeapplication.h>
29#include <tdeconfig.h>
30
31class KPanelApplet::KPanelAppletPrivate
32{
33public:
34 KPanelAppletPrivate()
35 : customMenu(0),
36 hasFocus(false)
37 {}
38
39 const TQPopupMenu* customMenu;
40 TDESharedConfig::Ptr sharedConfig;
41 TQPtrList<TQObject> watchedForFocus;
42 bool hasFocus;
43};
44
45KPanelApplet::KPanelApplet(const TQString& configFile, Type type,
46 int actions, TQWidget *parent, const char *name, WFlags f)
47 : TQFrame(parent, name, f)
48 , _type(type)
49 , _position( pBottom )
50 , _alignment( LeftTop )
51 , _config(0)
52 , _actions(actions)
53 , d(new KPanelApplet::KPanelAppletPrivate())
54{
55 setFrameStyle(NoFrame);
56 TQPalette pal(palette());
57 if(pal.active().mid() != pal.inactive().mid()){
58 pal.setInactive(pal.active());
59 setPalette(pal);
60 }
61 setBackgroundOrigin( AncestorOrigin );
62
63 d->sharedConfig = TDESharedConfig::openConfig(configFile, tdeApp && tdeApp->config()->isImmutable());
64 _config = d->sharedConfig;
65}
66
67KPanelApplet::~KPanelApplet()
68{
69 d->watchedForFocus.clear();
70 needsFocus(false);
71 delete d;
72}
73
74void KPanelApplet::setPosition( Position p )
75{
76 if( _position == p ) return;
77 _position = p;
78 positionChange( p );
79}
80
81void KPanelApplet::setAlignment( Alignment a )
82{
83 if( _alignment == a ) return;
84 _alignment = a;
85 alignmentChange( a );
86}
87
88// FIXME: Remove implementation for KDE 4
89void KPanelApplet::positionChange( Position )
90{
91 orientationChange( orientation() );
92 TQResizeEvent e( size(), size() );
93 resizeEvent( &e );
94 popupDirectionChange( popupDirection() );
95}
96
97TQt::Orientation KPanelApplet::orientation() const
98{
99 if( _position == pTop || _position == pBottom ) {
100 return TQt::Horizontal;
101 } else {
102 return TQt::Vertical;
103 }
104}
105
106// FIXME: Remove for KDE 4
107KPanelApplet::Direction KPanelApplet::popupDirection()
108{
109 switch( _position ) {
110 case pTop: return Down;
111 case pRight: return Left;
112 case pLeft: return Right;
113 default:
114 case pBottom: return Up;
115 }
116}
117
118void KPanelApplet::action( Action a )
119{
120 if ( (a & About) )
121 about();
122 if ( (a & Help) )
123 help();
124 if ( (a & Preferences) )
125 preferences();
126 if ( (a & ReportBug) )
127 reportBug();
128}
129
130const TQPopupMenu* KPanelApplet::customMenu() const
131{
132 return d->customMenu;
133}
134
135void KPanelApplet::setCustomMenu(const TQPopupMenu* menu)
136{
137 d->customMenu = menu;
138}
139
140void KPanelApplet::watchForFocus(TQWidget* widget, bool watch)
141{
142 if (!widget)
143 {
144 return;
145 }
146
147 if (watch)
148 {
149 if (d->watchedForFocus.find(widget) == -1)
150 {
151 d->watchedForFocus.append(widget);
152 widget->installEventFilter(this);
153 }
154 }
155 else if (d->watchedForFocus.find(widget) != -1)
156 {
157 d->watchedForFocus.remove(widget);
158 widget->removeEventFilter(this);
159 }
160}
161
162void KPanelApplet::needsFocus(bool focus)
163{
164 if (focus == d->hasFocus)
165 {
166 return;
167 }
168
169 d->hasFocus = focus;
170 emit requestFocus(focus);
171}
172
173bool KPanelApplet::eventFilter(TQObject *o, TQEvent * e)
174{
175 if (d->watchedForFocus.find(o) != -1)
176 {
177 if (e->type() == TQEvent::MouseButtonRelease ||
178 e->type() == TQEvent::FocusIn)
179 {
180 needsFocus(true);
181 }
182 else if (e->type() == TQEvent::FocusOut)
183 {
184 needsFocus(false);
185 }
186 }
187
188 return TQFrame::eventFilter(o, e);
189}
190
191TDESharedConfig::Ptr KPanelApplet::sharedConfig() const
192{
193 return d->sharedConfig;
194}
195
196void KPanelApplet::virtual_hook( int, void* )
197{ /*BASE::virtual_hook( id, data );*/ }
198
KPanelApplet
TDE Panel Applet class
Definition: kpanelapplet.h:98
KPanelApplet::orientation
Orientation orientation() const
Definition: kpanelapplet.cpp:97
KPanelApplet::setCustomMenu
void setCustomMenu(const TQPopupMenu *)
Use this method to set the custom menu for this applet so that it can be shown in the applet handle m...
Definition: kpanelapplet.cpp:135
KPanelApplet::reportBug
virtual void reportBug()
Is called when the user selects "Report bug" from the applet's RMB menu.
Definition: kpanelapplet.h:300
KPanelApplet::Type
Type
This enum describes the type of the applet.
Definition: kpanelapplet.h:106
KPanelApplet::preferences
virtual void preferences()
Is called when the user selects "Preferences" from the applet's RMB menu.
Definition: kpanelapplet.h:290
KPanelApplet::alignmentChange
virtual void alignmentChange(Alignment)
The panel on which this applet resides has changed its alignment.
Definition: kpanelapplet.h:327
KPanelApplet::KPanelApplet
KPanelApplet(const TQString &configFile, Type t=Normal, int actions=0, TQWidget *parent=0, const char *name=0, WFlags f=0)
Constructs a KPanelApplet just like any other widget.
Definition: kpanelapplet.cpp:45
KPanelApplet::positionChange
virtual void positionChange(Position p)
The panel on which this applet resides has changed its position.
Definition: kpanelapplet.cpp:89
KPanelApplet::popupDirection
Direction popupDirection()
A convenience method that translates the position of the applet into which direction to show a popup.
Definition: kpanelapplet.cpp:107
KPanelApplet::setAlignment
void setAlignment(Alignment a)
Definition: kpanelapplet.cpp:81
KPanelApplet::Action
Action
This enum holds flags which can be ORed together to describe which items the context menu over the ap...
Definition: kpanelapplet.h:112
KPanelApplet::needsFocus
void needsFocus(bool focus)
Call this whenever focus is needed or not needed.
Definition: kpanelapplet.cpp:162
KPanelApplet::watchForFocus
void watchForFocus(TQWidget *widget, bool watch=true)
Register widgets that can receive keyboard focus with this this method This call results in an eventF...
Definition: kpanelapplet.cpp:140
KPanelApplet::customMenu
const TQPopupMenu * customMenu() const
Definition: kpanelapplet.cpp:130
KPanelApplet::action
virtual void action(Action a)
Generic action dispatcher.
Definition: kpanelapplet.cpp:118
KPanelApplet::setPosition
void setPosition(Position p)
Definition: kpanelapplet.cpp:74
KPanelApplet::orientationChange
virtual TDE_DEPRECATED void orientationChange(Orientation)
The orientation changed to orientation.
Definition: kpanelapplet.h:364
KPanelApplet::help
virtual void help()
Is called when the user selects "Help" from the applet's RMB menu.
Definition: kpanelapplet.h:281
KPanelApplet::requestFocus
void requestFocus()
Request keyboard focus from the panel.
KPanelApplet::popupDirectionChange
virtual TDE_DEPRECATED void popupDirectionChange(Direction)
The popup direction changed to direction.
Definition: kpanelapplet.h:379
KPanelApplet::~KPanelApplet
~KPanelApplet()
Destructor.
Definition: kpanelapplet.cpp:67
KPanelApplet::about
virtual void about()
Is called when the user selects "About" from the applet's RMB menu.
Definition: kpanelapplet.h:272
TDESharedConfig::openConfig
static TDESharedConfig::Ptr openConfig(const TQString &fileName, bool readOnly=false, bool bUseKDEGlobals=true)

tdeui

Skip menu "tdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeui

Skip menu "tdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.9.4
This website is maintained by Timothy Pearson.