• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.10.2 API Reference
  • KDE Home
  • Contact Us
 

KDE3Support

  • kde3support
  • kdeui
k3panelmenu.cpp
Go to the documentation of this file.
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 <kconfiggroup.h>
27 #include <QTimer>
28 
29 #include "k3panelmenu.h"
30 #include "k3panelmenu.moc"
31 //#include "kaccelmanager.h"
32 
33 
34 class K3PanelMenu::Private
35 {
36 public:
37  bool init;
38  int clearDelay;
39  QString startPath;
40  QTimer t;
41 };
42 
43 K3PanelMenu::K3PanelMenu(const QString &startDir, QWidget *parent)
44  : KMenu(parent)
45 {
46  init(startDir);
47 }
48 
49 K3PanelMenu::K3PanelMenu(QWidget *parent)
50  : KMenu(parent)
51 {
52  init();
53 }
54 
55 void K3PanelMenu::init(const QString& path)
56 {
57  d = new Private;
58 
59  setInitialized( false );
60  d->startPath = path;
61 
62  connect(this, SIGNAL(activated(int)), SLOT(slotExec(int)));
63  connect(this, SIGNAL(aboutToShow()), SLOT(slotAboutToShow()));
64 
65  // setup cache timer
66  KConfigGroup config(KGlobal::config(), "menus");
67  d->clearDelay = config.readEntry("MenuCacheTime", 60000); // 1 minute
68 
69  //KAcceleratorManager::manage(this);
70  setKeyboardShortcutsEnabled(true);
71 }
72 
73 K3PanelMenu::~K3PanelMenu()
74 {
75  delete d;
76 }
77 
78 void K3PanelMenu::slotAboutToShow()
79 {
80  // stop the cache timer
81  if(d->clearDelay)
82  d->t.stop();
83 
84  // teared off ?
85  if ( isTopLevel() )
86  d->clearDelay = 0;
87 
88  internalInitialize();
89 }
90 
91 void K3PanelMenu::slotClear()
92 {
93  setInitialized( false );
94  clear();
95 }
96 
97 void K3PanelMenu::hideEvent(QHideEvent *ev)
98 {
99  // start the cache timer
100  if(d->clearDelay) {
101  disconnect(&(d->t), SIGNAL(timeout()), this, SLOT(slotClear()));
102  connect(&(d->t), SIGNAL(timeout()), this, SLOT(slotClear()));
103  d->t.setSingleShot(true);
104  d->t.start(d->clearDelay);
105  }
106  KMenu::hideEvent(ev);
107 }
108 
109 void K3PanelMenu::disableAutoClear()
110 {
111  d->clearDelay = 0;
112 }
113 
114 const QString& K3PanelMenu::path() const
115 {
116  return d->startPath;
117 }
118 
119 void K3PanelMenu::setPath(const QString& p)
120 {
121  d->startPath = p;
122 }
123 
124 bool K3PanelMenu::initialized() const
125 {
126  return d->init;
127 }
128 
129 void K3PanelMenu::setInitialized(bool on)
130 {
131  d->init = on;
132 }
133 
134 void K3PanelMenu::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 K3PanelMenu::deinitialize()
144 {
145  slotClear();
146 }
147 
148 void K3PanelMenu::internalInitialize()
149 {
150  if( initialized() )
151  return;
152  initialize();
153  setInitialized( true );
154 }
155 
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Apr 16 2013 21:12:45 by doxygen 1.8.3.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDE3Support

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

kdelibs-4.10.2 API Reference

Skip menu "kdelibs-4.10.2 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal