1 /*****************************************************************
3 Copyright (c) 1996-2000 the kicker authors. See file AUTHORS.
4 (c) Michael Goffioul <kdeprint@swing.be>
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 ******************************************************************/
29 #include "kpanelmenu.h"
30 #include "kpanelmenu.moc"
31 //#include "kaccelmanager.h"
34 class KPanelMenuPrivate
43 KPanelMenu::KPanelMenu(const QString
&startDir
, QWidget
*parent
, const char *name
)
44 : KPopupMenu(parent
, name
)
49 KPanelMenu::KPanelMenu(QWidget
*parent
, const char *name
)
50 : KPopupMenu(parent
, name
)
55 void KPanelMenu::init(const QString
& path
)
57 d
= new KPanelMenuPrivate
;
59 setInitialized( false );
62 connect(this, SIGNAL(activated(int)), SLOT(slotExec(int)));
63 connect(this, SIGNAL(aboutToShow()), SLOT(slotAboutToShow()));
66 KConfig
*config
= KGlobal::config();
67 config
->setGroup("menus");
68 d
->clearDelay
= config
->readNumEntry("MenuCacheTime", 60000); // 1 minute
70 //KAcceleratorManager::manage(this);
71 setKeyboardShortcutsEnabled(true);
74 KPanelMenu::~KPanelMenu()
79 void KPanelMenu::slotAboutToShow()
81 // stop the cache timer
92 void KPanelMenu::slotClear()
94 setInitialized( false );
98 void KPanelMenu::hideEvent(QHideEvent
*ev
)
100 // start the cache timer
102 disconnect(&(d
->t
), SIGNAL(timeout()), this, SLOT(slotClear()));
103 connect(&(d
->t
), SIGNAL(timeout()), this, SLOT(slotClear()));
104 d
->t
.start(d
->clearDelay
, true);
106 QPopupMenu::hideEvent(ev
);
109 void KPanelMenu::disableAutoClear()
114 const QString
& KPanelMenu::path() const
119 void KPanelMenu::setPath(const QString
& p
)
124 bool KPanelMenu::initialized() const
129 void KPanelMenu::setInitialized(bool on
)
134 void KPanelMenu::reinitialize()
137 // Yes, reinitialize must call initialize(). Otherwise, menus
138 // may not appear in the right place. Don't change this! If
139 // you want delayed initialization, use deinitialize() instead.
140 internalInitialize();
143 void KPanelMenu::deinitialize()
148 void KPanelMenu::internalInitialize()
153 setInitialized( true );
156 void KPanelMenu::virtual_hook( int id
, void* data
)
157 { KPopupMenu::virtual_hook( id
, data
); }