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

kdeui

  • kdeui
kpanelmenu.cpp
1 /*****************************************************************
2 
3 Copyright (c) 1996-2000 the kicker authors. See file AUTHORS.
4  (c) Michael Goffioul <kdeprint@swing.be>
5 
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:
12 
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15 
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.
22 
23 ******************************************************************/
24 
25 #include <kglobal.h>
26 #include <kconfig.h>
27 #include <tqtimer.h>
28 
29 #include "kpanelmenu.h"
30 #include "kpanelmenu.moc"
31 //#include "kaccelmanager.h"
32 
33 
34 class KPanelMenuPrivate
35 {
36 public:
37  bool init;
38  int clearDelay;
39  TQString startPath;
40  TQTimer t;
41 };
42 
43 KPanelMenu::KPanelMenu(const TQString &startDir, TQWidget *parent, const char *name)
44  : KPopupMenu(parent, name)
45 {
46  init(startDir);
47 }
48 
49 KPanelMenu::KPanelMenu(TQWidget *parent, const char *name)
50  : KPopupMenu(parent, name)
51 {
52  init();
53 }
54 
55 void KPanelMenu::init(const TQString& path)
56 {
57  d = new KPanelMenuPrivate;
58 
59  setInitialized( false );
60  d->startPath = path;
61 
62  connect(this, TQT_SIGNAL(activated(int)), TQT_SLOT(slotExec(int)));
63  connect(this, TQT_SIGNAL(aboutToShow()), TQT_SLOT(slotAboutToShow()));
64 
65  // setup cache timer
66  KConfig *config = KGlobal::config();
67  config->setGroup("menus");
68  d->clearDelay = config->readNumEntry("MenuCacheTime", 60000); // 1 minute
69 
70  //KAcceleratorManager::manage(this);
71  setKeyboardShortcutsEnabled(true);
72 }
73 
74 KPanelMenu::~KPanelMenu()
75 {
76  delete d;
77 }
78 
79 void KPanelMenu::slotAboutToShow()
80 {
81  // stop the cache timer
82  if(d->clearDelay)
83  d->t.stop();
84 
85  // teared off ?
86  if ( isTopLevel() )
87  d->clearDelay = 0;
88 
89  internalInitialize();
90 }
91 
92 void KPanelMenu::slotClear()
93 {
94  setInitialized( false );
95  clear();
96 }
97 
98 void KPanelMenu::hideEvent(TQHideEvent *ev)
99 {
100  // start the cache timer
101  if(d->clearDelay) {
102  disconnect(&(d->t), TQT_SIGNAL(timeout()), this, TQT_SLOT(slotClear()));
103  connect(&(d->t), TQT_SIGNAL(timeout()), this, TQT_SLOT(slotClear()));
104  d->t.start(d->clearDelay, true);
105  }
106  TQPopupMenu::hideEvent(ev);
107 }
108 
109 void KPanelMenu::disableAutoClear()
110 {
111  d->clearDelay = 0;
112 }
113 
114 const TQString& KPanelMenu::path() const
115 {
116  return d->startPath;
117 }
118 
119 void KPanelMenu::setPath(const TQString& p)
120 {
121  d->startPath = p;
122 }
123 
124 bool KPanelMenu::initialized() const
125 {
126  return d->init;
127 }
128 
129 void KPanelMenu::setInitialized(bool on)
130 {
131  d->init = on;
132 }
133 
134 void KPanelMenu::reinitialize()
135 {
136  deinitialize();
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();
141 }
142 
143 void KPanelMenu::deinitialize()
144 {
145  slotClear();
146 }
147 
148 void KPanelMenu::internalInitialize()
149 {
150  if( initialized() )
151  return;
152  initialize();
153  setInitialized( true );
154 }
155 
156 void KPanelMenu::virtual_hook( int id, void* data )
157 { KPopupMenu::virtual_hook( id, data ); }
158 

kdeui

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

kdeui

Skip menu "kdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdeui by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |