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

tdeui

  • tdeui
kpanelappmenu.cpp
1 /*
2 
3 (C) Daniel M. Duley <mosfet@kde.org>
4 (C) Matthias Ettrich <ettrich@kde.org>
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 "kpanelappmenu.h"
26 #include <tqstringlist.h>
27 #include <dcopclient.h>
28 #include <tdeapplication.h>
29 #include <kdebug.h>
30 
31 static int panelmenu_get_seq_id()
32 {
33  static int panelmenu_seq_no = -2;
34  return panelmenu_seq_no--;
35 }
36 
37 
38 KPanelAppMenu::KPanelAppMenu(const TQString &title, TQObject *parent,
39  const char *name)
40  : TQObject(parent, name), DCOPObject()
41 {
42  init(TQString(), title);
43 }
44 
45 KPanelAppMenu::KPanelAppMenu(const TQPixmap &icon, const TQString &title,
46  TQObject *parent, const char *name)
47 : TQObject(parent, name), DCOPObject()
48 {
49 
50  init(icon, title);
51 }
52 
53 
54 KPanelAppMenu::KPanelAppMenu(TQObject *parent, const char *name)
55  : TQObject(parent, name), DCOPObject(name)
56 {
57  realObjId = name;
58 }
59 
60 
61 void KPanelAppMenu::init(const TQPixmap &icon, const TQString &title)
62 {
63  DCOPClient *client = kapp->dcopClient();
64  if(!client->isAttached())
65  client->attach();
66  TQByteArray sendData, replyData;
67  TQCString replyType;
68  {
69  TQDataStream stream(sendData, IO_WriteOnly);
70  stream << icon << title;
71  if ( client->call("kicker", "kickerMenuManager", "createMenu(TQPixmap,TQString)", sendData, replyType, replyData ) ) {
72  if (replyType != "TQCString")
73  kdDebug() << "error! replyType for createMenu should be QCstring in KPanelAppMenu::init" << endl;
74  else {
75  TQDataStream reply( replyData, IO_ReadOnly );
76  reply >> realObjId;
77  }
78  }
79  }
80  {
81  TQDataStream stream(sendData, IO_WriteOnly);
82  stream << TQCString("activated(int)") << client->appId() << objId();
83  client->send("kicker", realObjId, "connectDCOPSignal(TQCString,TQCString,TQCString)", sendData);
84  }
85 }
86 
87 KPanelAppMenu::~KPanelAppMenu()
88 {
89  DCOPClient *client = kapp->dcopClient();
90  TQByteArray sendData;
91  TQDataStream stream(sendData, IO_WriteOnly);
92  stream << realObjId;
93  client->send("kicker", "kickerMenuManager", "removeMenu", sendData );
94 }
95 
96 int KPanelAppMenu::insertItem(const TQPixmap &icon, const TQString &text, int id )
97 {
98  if ( id < 0 )
99  id = panelmenu_get_seq_id();
100  DCOPClient *client = kapp->dcopClient();
101  TQByteArray sendData;
102  TQDataStream stream(sendData, IO_WriteOnly);
103  stream << icon << text << id;
104  client->send("kicker", realObjId, "insertItem(TQPixmap,TQString,int)", sendData );
105  return id;
106 }
107 
108 
109 KPanelAppMenu *KPanelAppMenu::insertMenu(const TQPixmap &icon, const TQString &text, int id )
110 {
111  if ( id < 0 )
112  id = panelmenu_get_seq_id();
113  DCOPClient *client = kapp->dcopClient();
114  TQByteArray sendData, replyData;
115  TQCString replyType;
116  TQDataStream stream(sendData, IO_WriteOnly);
117  stream << icon << text << id;
118  client->call("kicker", realObjId, "insertMenu(TQPixmap,TQString,int)", sendData, replyType, replyData );
119  if ( replyType != "TQCString")
120  return 0;
121  TQDataStream ret(replyData, IO_ReadOnly);
122  TQCString subid;
123  ret >> subid;
124 
125  TQByteArray sendData2;
126  TQDataStream stream2(sendData2, IO_WriteOnly);
127  stream2 << TQCString("activated(int)") << client->appId() << subid;
128  client->send("kicker", subid, "connectDCOPSignal(TQCString,TQCString,TQCString)", sendData2);
129 
130  return new KPanelAppMenu(this, subid);
131 }
132 
133 
134 int KPanelAppMenu::insertItem(const TQString &text, int id )
135 {
136  if ( id < 0 )
137  id = panelmenu_get_seq_id();
138  DCOPClient *client = kapp->dcopClient();
139  TQByteArray sendData;
140  TQDataStream stream(sendData, IO_WriteOnly);
141  stream << text << id;
142  client->send("kicker", realObjId, "insertItem(TQString,int)", sendData );
143  return id;
144 }
145 
146 
147 void KPanelAppMenu::clear()
148 {
149  DCOPClient *client = kapp->dcopClient();
150  TQByteArray sendData;
151  client->send("kicker", realObjId, "clear()", sendData);
152 }
153 
154 
155 bool KPanelAppMenu::process(const TQCString &fun, const TQByteArray &data,
156  TQCString &replyType, TQByteArray &)
157 {
158  if ( fun == "activated(int)" ) {
159  TQDataStream dataStream( data, IO_ReadOnly );
160  int id;
161  dataStream >> id;
162  emit activated( id );
163  replyType = "void";
164  return true;
165  }
166  return false;
167 }
168 
169 
170 #include "kpanelappmenu.moc"
171 
172 
173 
174 
175 
176 
177 
178 
179 
180 
181 
182 
KPanelAppMenu::insertItem
int insertItem(const TQString &text, int id=-1)
Inserts an item into the menu.
Definition: kpanelappmenu.cpp:134
KPanelAppMenu::~KPanelAppMenu
~KPanelAppMenu()
Make sure you actually destroy this thing or the menu will never go away until this application quits...
Definition: kpanelappmenu.cpp:87
KPanelAppMenu::insertMenu
KPanelAppMenu * insertMenu(const TQPixmap &icon, const TQString &text, int id=-1)
Inserts a sub menu with a icon.
Definition: kpanelappmenu.cpp:109
DCOPClient::attach
bool attach()
DCOPClient::send
bool send(const TQCString &remApp, const TQCString &remObj, const TQCString &remFun, const TQByteArray &data)
kdDebug
kdbgstream kdDebug(int area=0)
DCOPClient
DCOPObject::objId
TQCString objId() const
DCOPClient::appId
TQCString appId() const
KPanelAppMenu::process
bool process(const TQCString &fun, const TQByteArray &data, TQCString &replyType, TQByteArray &replyData)
Definition: kpanelappmenu.cpp:155
KPanelAppMenu::KPanelAppMenu
KPanelAppMenu(const TQString &title, TQObject *parent=0, const char *name=0)
Constructs a new menu with the given title.
Definition: kpanelappmenu.cpp:38
DCOPClient::isAttached
bool isAttached() const
KPanelAppMenu
DCop client menu class for the Kicker panel that will insert a submenu into the TDE menu...
Definition: kpanelappmenu.h:37
KPanelAppMenu::activated
void activated(int id)
Emitted when the user selects an item from the Kicker menu.
endl
kndbgstream & endl(kndbgstream &s)
DCOPObject
DCOPClient::call
bool call(const TQCString &remApp, const TQCString &remObj, const TQCString &remFun, const TQByteArray &data, TQCString &replyType, TQByteArray &replyData, bool useEventLoop, int timeout, bool forceRemote)
KPanelAppMenu::clear
void clear()
Clears the menu.
Definition: kpanelappmenu.cpp:147

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.