summaryrefslogtreecommitdiffstats
path: root/tdeui/kpanelapplet.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-06 15:56:40 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-06 15:56:40 -0600
commite16866e072f94410321d70daedbcb855ea878cac (patch)
treeee3f52eabde7da1a0e6ca845fb9c2813cf1558cf /tdeui/kpanelapplet.cpp
parenta58c20c1a7593631a1b50213c805507ebc16adaf (diff)
downloadtdelibs-e16866e072f94410321d70daedbcb855ea878cac.tar.gz
tdelibs-e16866e072f94410321d70daedbcb855ea878cac.zip
Actually move the kde files that were renamed in the last commit
Diffstat (limited to 'tdeui/kpanelapplet.cpp')
-rw-r--r--tdeui/kpanelapplet.cpp198
1 files changed, 198 insertions, 0 deletions
diff --git a/tdeui/kpanelapplet.cpp b/tdeui/kpanelapplet.cpp
new file mode 100644
index 000000000..ece71ad54
--- /dev/null
+++ b/tdeui/kpanelapplet.cpp
@@ -0,0 +1,198 @@
+/*****************************************************************
+
+Copyright (c) 2000 Matthias Elter
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+******************************************************************/
+
+#include <tqptrlist.h>
+
+#include "kpanelapplet.h"
+#include "kpanelapplet.moc"
+#include <kapplication.h>
+#include <kconfig.h>
+
+class KPanelApplet::KPanelAppletPrivate
+{
+public:
+ KPanelAppletPrivate()
+ : customMenu(0),
+ hasFocus(false)
+ {}
+
+ const TQPopupMenu* customMenu;
+ KSharedConfig::Ptr sharedConfig;
+ TQPtrList<TQObject> watchedForFocus;
+ bool hasFocus;
+};
+
+KPanelApplet::KPanelApplet(const TQString& configFile, Type type,
+ int actions, TQWidget *parent, const char *name, WFlags f)
+ : TQFrame(parent, name, f)
+ , _type(type)
+ , _position( pBottom )
+ , _tqalignment( LeftTop )
+ , _config(0)
+ , _actions(actions)
+ , d(new KPanelApplet::KPanelAppletPrivate())
+{
+ setFrameStyle(NoFrame);
+ TQPalette pal(palette());
+ if(pal.active().mid() != pal.inactive().mid()){
+ pal.setInactive(pal.active());
+ setPalette(pal);
+ }
+ setBackgroundOrigin( AncestorOrigin );
+
+ d->sharedConfig = KSharedConfig::openConfig(configFile, kapp && kapp->config()->isImmutable());
+ _config = d->sharedConfig;
+}
+
+KPanelApplet::~KPanelApplet()
+{
+ d->watchedForFocus.clear();
+ needsFocus(false);
+ delete d;
+}
+
+void KPanelApplet::setPosition( Position p )
+{
+ if( _position == p ) return;
+ _position = p;
+ positionChange( p );
+}
+
+void KPanelApplet::tqsetAlignment( Alignment a )
+{
+ if( _tqalignment == a ) return;
+ _tqalignment = a;
+ alignmentChange( a );
+}
+
+// FIXME: Remove implementation for KDE 4
+void KPanelApplet::positionChange( Position )
+{
+ orientationChange( orientation() );
+ TQResizeEvent e( size(), size() );
+ resizeEvent( &e );
+ popupDirectionChange( popupDirection() );
+}
+
+Qt::Orientation KPanelApplet::orientation() const
+{
+ if( _position == pTop || _position == pBottom ) {
+ return Qt::Horizontal;
+ } else {
+ return Qt::Vertical;
+ }
+}
+
+// FIXME: Remove for KDE 4
+KPanelApplet::Direction KPanelApplet::popupDirection()
+{
+ switch( _position ) {
+ case pTop: return Down;
+ case pRight: return Left;
+ case pLeft: return Right;
+ default:
+ case pBottom: return Up;
+ }
+}
+
+void KPanelApplet::action( Action a )
+{
+ if ( (a & About) )
+ about();
+ if ( (a & Help) )
+ help();
+ if ( (a & Preferences) )
+ preferences();
+ if ( (a & ReportBug) )
+ reportBug();
+}
+
+const TQPopupMenu* KPanelApplet::customMenu() const
+{
+ return d->customMenu;
+}
+
+void KPanelApplet::setCustomMenu(const TQPopupMenu* menu)
+{
+ d->customMenu = menu;
+}
+
+void KPanelApplet::watchForFocus(TQWidget* widget, bool watch)
+{
+ if (!widget)
+ {
+ return;
+ }
+
+ if (watch)
+ {
+ if (d->watchedForFocus.find(TQT_TQOBJECT(widget)) == -1)
+ {
+ d->watchedForFocus.append(TQT_TQOBJECT(widget));
+ widget->installEventFilter(this);
+ }
+ }
+ else if (d->watchedForFocus.find(TQT_TQOBJECT(widget)) != -1)
+ {
+ d->watchedForFocus.remove(TQT_TQOBJECT(widget));
+ widget->removeEventFilter(this);
+ }
+}
+
+void KPanelApplet::needsFocus(bool focus)
+{
+ if (focus == d->hasFocus)
+ {
+ return;
+ }
+
+ d->hasFocus = focus;
+ emit requestFocus(focus);
+}
+
+bool KPanelApplet::eventFilter(TQObject *o, TQEvent * e)
+{
+ if (d->watchedForFocus.find(o) != -1)
+ {
+ if (e->type() == TQEvent::MouseButtonRelease ||
+ e->type() == TQEvent::FocusIn)
+ {
+ needsFocus(true);
+ }
+ else if (e->type() == TQEvent::FocusOut)
+ {
+ needsFocus(false);
+ }
+ }
+
+ return TQFrame::eventFilter(o, e);
+}
+
+KSharedConfig::Ptr KPanelApplet::sharedConfig() const
+{
+ return d->sharedConfig;
+}
+
+void KPanelApplet::virtual_hook( int, void* )
+{ /*BASE::virtual_hook( id, data );*/ }
+