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

KDE3Support

k3panelmenu.cpp

Go to the documentation of this file.
00001 /*****************************************************************
00002 
00003 Copyright (c) 1996-2000 the kicker authors. See file AUTHORS.
00004           (c) Michael Goffioul <kdeprint@swing.be>
00005 
00006 Permission is hereby granted, free of charge, to any person obtaining a copy
00007 of this software and associated documentation files (the "Software"), to deal
00008 in the Software without restriction, including without limitation the rights
00009 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00010 copies of the Software, and to permit persons to whom the Software is
00011 furnished to do so, subject to the following conditions:
00012 
00013 The above copyright notice and this permission notice shall be included in
00014 all copies or substantial portions of the Software.
00015 
00016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00019 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00020 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00021 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00022 
00023 ******************************************************************/
00024 
00025 #include <kglobal.h>
00026 #include <kconfiggroup.h>
00027 #include <QTimer>
00028 
00029 #include "k3panelmenu.h"
00030 #include "k3panelmenu.moc"
00031 //#include "kaccelmanager.h"
00032 
00033 
00034 class K3PanelMenu::Private
00035 {
00036 public:
00037     bool init;
00038     int clearDelay;
00039     QString startPath;
00040     QTimer t;
00041 };
00042 
00043 K3PanelMenu::K3PanelMenu(const QString &startDir, QWidget *parent)
00044   : KMenu(parent)
00045 {
00046     init(startDir);
00047 }
00048 
00049 K3PanelMenu::K3PanelMenu(QWidget *parent)
00050   : KMenu(parent)
00051 {
00052     init();
00053 }
00054 
00055 void K3PanelMenu::init(const QString& path)
00056 {
00057     d = new Private;
00058 
00059     setInitialized( false );
00060     d->startPath = path;
00061 
00062     connect(this, SIGNAL(activated(int)), SLOT(slotExec(int)));
00063     connect(this, SIGNAL(aboutToShow()), SLOT(slotAboutToShow()));
00064 
00065     // setup cache timer
00066     KConfigGroup config(KGlobal::config(), "menus");
00067     d->clearDelay = config.readEntry("MenuCacheTime", 60000); // 1 minute
00068 
00069     //KAcceleratorManager::manage(this);
00070     setKeyboardShortcutsEnabled(true);
00071 }
00072 
00073 K3PanelMenu::~K3PanelMenu()
00074 {
00075     delete d;
00076 }
00077 
00078 void K3PanelMenu::slotAboutToShow()
00079 {
00080     // stop the cache timer
00081     if(d->clearDelay)
00082         d->t.stop();
00083 
00084     // teared off ?
00085     if ( isTopLevel() )
00086         d->clearDelay = 0;
00087 
00088     internalInitialize();
00089 }
00090 
00091 void K3PanelMenu::slotClear()
00092 {
00093     setInitialized( false );
00094     clear();
00095 }
00096 
00097 void K3PanelMenu::hideEvent(QHideEvent *ev)
00098 {
00099     // start the cache timer
00100     if(d->clearDelay) {
00101         disconnect(&(d->t), SIGNAL(timeout()), this, SLOT(slotClear()));
00102         connect(&(d->t), SIGNAL(timeout()), this, SLOT(slotClear()));
00103         d->t.setSingleShot(true);
00104         d->t.start(d->clearDelay);
00105     }
00106     KMenu::hideEvent(ev);
00107 }
00108 
00109 void K3PanelMenu::disableAutoClear()
00110 {
00111     d->clearDelay = 0;
00112 }
00113 
00114 const QString& K3PanelMenu::path() const
00115 {
00116     return d->startPath;
00117 }
00118 
00119 void K3PanelMenu::setPath(const QString& p)
00120 {
00121     d->startPath = p;
00122 }
00123 
00124 bool K3PanelMenu::initialized() const
00125 {
00126     return d->init;
00127 }
00128 
00129 void K3PanelMenu::setInitialized(bool on)
00130 {
00131     d->init = on;
00132 }
00133 
00134 void K3PanelMenu::reinitialize()
00135 {
00136     deinitialize();
00137     // Yes, reinitialize must call initialize(). Otherwise, menus
00138     // may not appear in the right place. Don't change this! If
00139     // you want delayed initialization, use deinitialize() instead.
00140     internalInitialize();
00141 }
00142 
00143 void K3PanelMenu::deinitialize()
00144 {
00145     slotClear();
00146 }
00147 
00148 void K3PanelMenu::internalInitialize()
00149 {
00150     if( initialized() )
00151         return;
00152     initialize();
00153     setInitialized( true );
00154 }
00155 

KDE3Support

Skip menu "KDE3Support"
  • 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
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
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