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

tdeui

  • tdeui
kpanelmenu.cpp
1/*****************************************************************
2
3Copyright (c) 1996-2000 the kicker authors. See file AUTHORS.
4 (c) Michael Goffioul <tdeprint@swing.be>
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION 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
34class KPanelMenuPrivate
35{
36public:
37 bool init;
38 int clearDelay;
39 TQString startPath;
40 TQTimer t;
41};
42
43KPanelMenu::KPanelMenu(const TQString &startDir, TQWidget *parent, const char *name)
44 : TDEPopupMenu(parent, name)
45{
46 init(startDir);
47}
48
49KPanelMenu::KPanelMenu(TQWidget *parent, const char *name)
50 : TDEPopupMenu(parent, name)
51{
52 init();
53}
54
55void KPanelMenu::init(const TQString& path)
56{
57 d = new KPanelMenuPrivate;
58
59 setInitialized( false );
60 d->startPath = path;
61
62 connect(this, TQ_SIGNAL(activated(int)), TQ_SLOT(slotExec(int)));
63 connect(this, TQ_SIGNAL(aboutToShow()), TQ_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
74KPanelMenu::~KPanelMenu()
75{
76 delete d;
77}
78
79void 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
92void KPanelMenu::slotClear()
93{
94 setInitialized( false );
95 clear();
96}
97
98void KPanelMenu::hideEvent(TQHideEvent *ev)
99{
100 // start the cache timer
101 if(d->clearDelay) {
102 disconnect(&(d->t), TQ_SIGNAL(timeout()), this, TQ_SLOT(slotClear()));
103 connect(&(d->t), TQ_SIGNAL(timeout()), this, TQ_SLOT(slotClear()));
104 d->t.start(d->clearDelay, true);
105 }
106 TQPopupMenu::hideEvent(ev);
107}
108
109void KPanelMenu::disableAutoClear()
110{
111 d->clearDelay = 0;
112}
113
114const TQString& KPanelMenu::path() const
115{
116 return d->startPath;
117}
118
119void KPanelMenu::setPath(const TQString& p)
120{
121 d->startPath = p;
122}
123
124bool KPanelMenu::initialized() const
125{
126 return d->init;
127}
128
129void KPanelMenu::setInitialized(bool on)
130{
131 d->init = on;
132}
133
134void 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
143void KPanelMenu::deinitialize()
144{
145 slotClear();
146}
147
148void KPanelMenu::internalInitialize()
149{
150 if( initialized() )
151 return;
152 initialize();
153 setInitialized( true );
154}
155
156void KPanelMenu::virtual_hook( int id, void* data )
157{ TDEPopupMenu::virtual_hook( id, data ); }
158
KPanelMenu::reinitialize
void reinitialize()
Reinitialize the menu: the menu is first cleared, the initial state is set to false,...
Definition: kpanelmenu.cpp:134
KPanelMenu::slotAboutToShow
virtual void slotAboutToShow()
This slot is called just before the menu is shown.
Definition: kpanelmenu.cpp:79
KPanelMenu::setInitialized
void setInitialized(bool on)
Set the initial state.
Definition: kpanelmenu.cpp:129
KPanelMenu::initialized
bool initialized() const
Tell if the menu has been initialized, that is it already contains items.
Definition: kpanelmenu.cpp:124
KPanelMenu::KPanelMenu
KPanelMenu(TQWidget *parent=0, const char *name=0)
Construct a KPanelMenu object.
Definition: kpanelmenu.cpp:49
KPanelMenu::init
void init(const TQString &path=TQString::null)
For internal use only.
Definition: kpanelmenu.cpp:55
KPanelMenu::slotExec
virtual void slotExec(int id)=0
This is slot is called when an item from the menu has been selected.
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::initialize
virtual void initialize()=0
This slots is called to initialize the menu.
KPanelMenu::hideEvent
virtual void hideEvent(TQHideEvent *ev)
Re-implemented for internal reasons.
Definition: kpanelmenu.cpp:98
KPanelMenu::slotClear
void slotClear()
Clears the menu, and update the initial state accordingly.
Definition: kpanelmenu.cpp:92
KPanelMenu::~KPanelMenu
virtual ~KPanelMenu()
Destructor.
Definition: kpanelmenu.cpp:74
KPanelMenu::deinitialize
void deinitialize()
Deinitialize the menu: the menu is cleared and the initialized state is set to false.
Definition: kpanelmenu.cpp:143
KPanelMenu::setPath
void setPath(const TQString &p)
Set a directory path to be associated with this menu.
Definition: kpanelmenu.cpp:119
KPanelMenu::disableAutoClear
void disableAutoClear()
Disable the automatic clearing of the menu.
Definition: kpanelmenu.cpp:109
TDEConfigBase::readNumEntry
int readNumEntry(const TQString &pKey, int nDefault=0) const
TDEConfigBase::setGroup
void setGroup(const TQString &group)
TDEConfig
TDEGlobal::config
static TDEConfig * config()
TDEPopupMenu
A menu with title items.
Definition: tdepopupmenu.h:123
TDEPopupMenu::setKeyboardShortcutsEnabled
void setKeyboardShortcutsEnabled(bool enable)
Enables keyboard navigation by searching for the entered key sequence.
Definition: tdepopupmenu.cpp:475

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
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.9.4
This website is maintained by Timothy Pearson.