• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Plasma

extenderapplet.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 2008 by Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin St, Fifth Floor,
00017  * Boston, MA  02110-1301  USA
00018  */
00019 
00020 #include "extenderapplet_p.h"
00021 
00022 #include "../extender.h"
00023 #include "../extenderitem.h"
00024 
00025 #include <QGraphicsLinearLayout>
00026 
00027 namespace Plasma
00028 {
00029 
00030 ExtenderApplet::ExtenderApplet(QObject *parent, const QVariantList &args)
00031     : PopupApplet(parent, args)
00032 {
00033     setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
00034 }
00035 
00036 ExtenderApplet::~ExtenderApplet()
00037 {
00038     if (destroyed()) {
00039         disconnect(extender(), SIGNAL(itemDetached(Plasma::ExtenderItem*)),
00040                 this, SLOT(itemDetached(Plasma::ExtenderItem*)));
00041         foreach (ExtenderItem *item, extender()->attachedItems()) {
00042             item->returnToSource();
00043         }
00044     }
00045 }
00046 
00047 void ExtenderApplet::init()
00048 {
00049     setPopupIcon("utilities-desktop-extra");
00050 
00051     extender()->setAppearance(Extender::NoBorders);
00052 
00053     connect(extender(), SIGNAL(itemDetached(Plasma::ExtenderItem*)),
00054             this, SLOT(itemDetached(Plasma::ExtenderItem*)));
00055     connect(extender(), SIGNAL(geometryChanged()),
00056             this, SLOT(extenderGeometryChanged()));
00057 }
00058 
00059 void ExtenderApplet::itemDetached(Plasma::ExtenderItem *)
00060 {
00061     if (extender()->attachedItems().isEmpty()) {
00062         destroy();
00063     }
00064 }
00065 
00066 void ExtenderApplet::extenderGeometryChanged()
00067 {
00068     if (formFactor() != Plasma::Horizontal &&
00069         formFactor() != Plasma::Vertical) {
00070 
00071         qreal left, top, right, bottom;
00072         getContentsMargins(&left, &top, &right, &bottom);
00073         QSizeF margins(left + right, top + bottom);
00074 
00075         setMinimumSize(extender()->minimumSize() + margins);
00076         setMaximumSize(extender()->maximumSize() + margins);
00077         setPreferredSize(extender()->preferredSize() + margins);
00078 
00079         updateGeometry();
00080     }
00081 }
00082 
00083 } // namespace Plasma
00084 
00085 #include "extenderapplet_p.moc"
00086 

Plasma

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal