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

tdeui

  • tdeui
kpanelmenu.cpp
1 /*****************************************************************
2 
3 Copyright (c) 1996-2000 the kicker authors. See file AUTHORS.
4  (c) Michael Goffioul <tdeprint@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 <tdeglobal.h>
26 #include <tdeconfig.h>
27 #include <tqtimer.h>
28 
29 #include "kpanelmenu.h"
30 #include "kpanelmenu.moc"
31 //#include "tdeaccelmanager.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  : TDEPopupMenu(parent, name)
45 {
46  init(startDir);
47 }
48 
49 KPanelMenu::KPanelMenu(TQWidget *parent, const char *name)
50  : TDEPopupMenu(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  TDEConfig *config = TDEGlobal::config();
67  config->setGroup("menus");
68  d->clearDelay = config->readNumEntry("MenuCacheTime", 60000); // 1 minute
69 
70  //TDEAcceleratorManager::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 { TDEPopupMenu::virtual_hook( id, data ); }
158 
TDEConfig
KPanelMenu::KPanelMenu
KPanelMenu(TQWidget *parent=0, const char *name=0)
Construct a KPanelMenu object.
Definition: kpanelmenu.cpp:49
KPanelMenu::initialize
virtual void initialize()=0
This slots is called to initialize the menu.
KPanelMenu::deinitialize
void deinitialize()
Deinitialize the menu: the menu is cleared and the initialized state is set to false.
Definition: kpanelmenu.cpp:143
KPanelMenu::~KPanelMenu
virtual ~KPanelMenu()
Destructor.
Definition: kpanelmenu.cpp:74
KPanelMenu::hideEvent
virtual void hideEvent(TQHideEvent *ev)
Re-implemented for internal reasons.
Definition: kpanelmenu.cpp:98
KPanelMenu::slotExec
virtual void slotExec(int id)=0
This is slot is called when an item from the menu has been selected.
KPanelMenu::initialized
bool initialized() const
Tell if the menu has been initialized, that is it already contains items.
Definition: kpanelmenu.cpp:124
KPanelMenu::path
const TQString & path() const
Get the directory path associated with this menu, or TQString::null if there's no such associated pat...
Definition: kpanelmenu.cpp:114
KPanelMenu::reinitialize
void reinitialize()
Reinitialize the menu: the menu is first cleared, the initial state is set to false, and finally initialize() is called.
Definition: kpanelmenu.cpp:134
KPanelMenu::setInitialized
void setInitialized(bool on)
Set the initial state.
Definition: kpanelmenu.cpp:129
KPanelMenu::slotClear
void slotClear()
Clears the menu, and update the initial state accordingly.
Definition: kpanelmenu.cpp:92
KPanelMenu::setPath
void setPath(const TQString &p)
Set a directory path to be associated with this menu.
Definition: kpanelmenu.cpp:119
TDEPopupMenu
A menu with title items.
Definition: tdepopupmenu.h:123
KPanelMenu::init
void init(const TQString &path=TQString::null)
For internal use only.
Definition: kpanelmenu.cpp:55
TDEGlobal::config
static TDEConfig * config()
KPanelMenu::disableAutoClear
void disableAutoClear()
Disable the automatic clearing of the menu.
Definition: kpanelmenu.cpp:109
TDEPopupMenu::setKeyboardShortcutsEnabled
void setKeyboardShortcutsEnabled(bool enable)
Enables keyboard navigation by searching for the entered key sequence.
Definition: tdepopupmenu.cpp:479
KPanelMenu::slotAboutToShow
virtual void slotAboutToShow()
This slot is called just before the menu is shown.
Definition: kpanelmenu.cpp:79

tdeui

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

tdeui

Skip menu "tdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.8.8
This website is maintained by Timothy Pearson.