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

kdeui

  • kdeui
kmainwindowiface.cpp
1 /* This file is part of the KDE project
2  Copyright (C) 2001 Ian Reinhart Geiser <geiseri@yahoo.com>
3 
4  This program is free software; you can redistribute it and/or
5  modify it under the terms of the Lesser GNU General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  General Public License for more details.
13 
14  You should have received a copy of the Lesser GNU General Public License
15  along with this program; see the file COPYING. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include "kmainwindowiface.h"
21 
22 #include <dcopclient.h>
23 #include <kapplication.h>
24 #include <kdcopactionproxy.h>
25 #include <kdcoppropertyproxy.h>
26 #include <kmainwindow.h>
27 #include <kaction.h>
28 #include <tqclipboard.h>
29 
30 #include <kwin.h>
31 
32 KMainWindowInterface::KMainWindowInterface(KMainWindow * mainWindow)
33  : DCOPObject( mainWindow->name())
34 {
35  m_MainWindow = mainWindow;
36  m_dcopActionProxy = new KDCOPActionProxy( m_MainWindow->actionCollection(), this );
37  m_dcopPropertyProxy = new KDCOPPropertyProxy(TQT_TQOBJECT(m_MainWindow));
38 }
39 
40 KMainWindowInterface::~KMainWindowInterface()
41 {
42  delete m_dcopActionProxy;
43  delete m_dcopPropertyProxy;
44 }
45 
46 QCStringList KMainWindowInterface::actions()
47 {
48  delete m_dcopActionProxy;
49  m_dcopActionProxy = new KDCOPActionProxy( m_MainWindow->actionCollection(), this );
50  QCStringList tmp_actions;
51  TQValueList<KAction *> lst = m_dcopActionProxy->actions();
52  TQValueList<KAction *>::ConstIterator it = lst.begin();
53  TQValueList<KAction *>::ConstIterator end = lst.end();
54  for (; it != end; ++it )
55  if ((*it)->isPlugged())
56  tmp_actions.append( (TQCString)(*it)->name() );
57  return tmp_actions;
58 }
59 bool KMainWindowInterface::activateAction( TQCString action)
60 {
61  delete m_dcopActionProxy;
62  m_dcopActionProxy = new KDCOPActionProxy( m_MainWindow->actionCollection(), this );
63  KAction *tmp_Action = m_dcopActionProxy->action(action);
64  if (tmp_Action)
65  {
66  tmp_Action->activate();
67  return true;
68  }
69  else
70  return false;
71 }
72 bool KMainWindowInterface::disableAction( TQCString action)
73 {
74  delete m_dcopActionProxy;
75  m_dcopActionProxy = new KDCOPActionProxy( m_MainWindow->actionCollection(), this );
76  KAction *tmp_Action = m_dcopActionProxy->action(action);
77  if (tmp_Action)
78  {
79  tmp_Action->setEnabled(false);
80  return true;
81  }
82  else
83  return false;
84 }
85 bool KMainWindowInterface::enableAction( TQCString action)
86 {
87  delete m_dcopActionProxy;
88  m_dcopActionProxy = new KDCOPActionProxy( m_MainWindow->actionCollection(), this );
89  KAction *tmp_Action = m_dcopActionProxy->action(action);
90  if (tmp_Action)
91  {
92  tmp_Action->setEnabled(true);
93  return true;
94  }
95  else
96  return false;
97 }
98 bool KMainWindowInterface::actionIsEnabled( TQCString action)
99 {
100  delete m_dcopActionProxy;
101  m_dcopActionProxy = new KDCOPActionProxy( m_MainWindow->actionCollection(), this );
102  KAction *tmp_Action = m_dcopActionProxy->action(action);
103  if (tmp_Action)
104  {
105  return tmp_Action->isEnabled();
106  }
107  else
108  return false;
109 }
110 TQCString KMainWindowInterface::actionToolTip( TQCString action)
111 {
112  delete m_dcopActionProxy;
113  m_dcopActionProxy = new KDCOPActionProxy( m_MainWindow->actionCollection(), this );
114  KAction *tmp_Action = m_dcopActionProxy->action(action);
115  if (tmp_Action)
116  {
117  return tmp_Action->toolTip().utf8();
118  }
119  else
120  return "Error no such object!";
121 }
122 
123 DCOPRef KMainWindowInterface::action( const TQCString &name )
124 {
125  return DCOPRef( kapp->dcopClient()->appId(), m_dcopActionProxy->actionObjectId( name ) );
126 }
127 
128 TQMap<TQCString,DCOPRef> KMainWindowInterface::actionMap()
129 {
130  return m_dcopActionProxy->actionMap();
131 }
132 
133 int KMainWindowInterface::getWinID()
134 {
135  return (int) m_MainWindow->winId();
136 }
137 void KMainWindowInterface::grabWindowToClipBoard()
138 {
139  TQClipboard *clipboard = TQApplication::clipboard();
140  clipboard->setPixmap(TQPixmap::grabWidget(m_MainWindow));
141 }
142 void KMainWindowInterface::hide()
143 {
144  m_MainWindow->hide();
145 }
146 void KMainWindowInterface::maximize()
147 {
148  m_MainWindow->showMaximized();
149 }
150 void KMainWindowInterface::minimize()
151 {
152  m_MainWindow->showMinimized();
153 }
154 void KMainWindowInterface::resize(int newX, int newY)
155 {
156  m_MainWindow->resize(newX, newY);
157 }
158 void KMainWindowInterface::move(int newX, int newY)
159 {
160  m_MainWindow->move(newX, newY);
161 }
162 void KMainWindowInterface::setGeometry(int newX, int newY, int newWidth, int newHeight)
163 {
164  m_MainWindow->setGeometry(newX, newY, newWidth, newHeight);
165 }
166 void KMainWindowInterface::raise()
167 {
168  m_MainWindow->raise();
169 }
170 void KMainWindowInterface::lower()
171 {
172  m_MainWindow->lower();
173 }
174 void KMainWindowInterface::restore()
175 {
176  m_MainWindow->showNormal();
177 }
178 void KMainWindowInterface::close()
179 {
180  m_MainWindow->close();
181 }
182 void KMainWindowInterface::show()
183 {
184  m_MainWindow->show();
185 }
186 void KMainWindowInterface::setActiveWindow()
187 {
188  m_MainWindow->setActiveWindow();
189 }
190 void KMainWindowInterface::setActiveWindowFocused()
191 {
192  // just in case we don't have a WM running
193  m_MainWindow->raise();
194  m_MainWindow->setActiveWindow();
195 
196  // activate window (try to work around focus-stealing prevention)
197  KWin::forceActiveWindow(m_MainWindow->winId());
198 }
199 QCStringList KMainWindowInterface::functionsDynamic()
200 {
201  return m_dcopPropertyProxy->functions();
202 }
203 bool KMainWindowInterface::processDynamic(const TQCString &fun, const TQByteArray &data, TQCString& replyType, TQByteArray &replyData)
204 {
205  return m_dcopPropertyProxy->processPropertyRequest( fun, data, replyType, replyData);
206 
207 }
208 
DCOPObject
DCOPRef
KAction
Class to encapsulate user-driven action or event.
Definition: kaction.h:203
KAction::setEnabled
virtual void setEnabled(bool enable)
Enables or disables this action.
Definition: kaction.cpp:832
KAction::activate
virtual void activate()
Emulate user's interaction programmatically, by activating the action.
Definition: kaction.cpp:1104
KAction::isEnabled
virtual bool isEnabled() const
Returns true if this action is enabled.
Definition: kaction.cpp:596
KDCOPActionProxy
A proxy class publishing a DCOP interface for actions.
Definition: kdcopactionproxy.h:40
KDCOPActionProxy::actionObjectId
virtual TQCString actionObjectId(const TQCString &name) const
Use this method to retrieve a DCOP object id for an action with the given name.
Definition: kdcopactionproxy.cpp:86
KDCOPActionProxy::actionMap
virtual TQMap< TQCString, DCOPRef > actionMap(const TQCString &appId=TQCString()) const
Returns a map of all exported actions, with the action name as keys and a global DCOP reference as da...
Definition: kdcopactionproxy.cpp:91
KDCOPActionProxy::action
virtual KAction * action(const char *name) const
Returns an action object with the given name.
Definition: kdcopactionproxy.cpp:78
KDCOPActionProxy::actions
virtual TQValueList< KAction * > actions() const
Returns a list of exportable actions.
Definition: kdcopactionproxy.cpp:70
KDCOPPropertyProxy
KDCOPPropertyProxy::functions
TQValueList< TQCString > functions()
KDCOPPropertyProxy::processPropertyRequest
bool processPropertyRequest(const TQCString &fun, const TQByteArray &data, TQCString &replyType, TQByteArray &replyData)
KMainWindowInterface::actionIsEnabled
bool actionIsEnabled(TQCString action)
Returns the status of the requested action.
Definition: kmainwindowiface.cpp:98
KMainWindowInterface::actionMap
TQMap< TQCString, DCOPRef > actionMap()
Returns and action map.
Definition: kmainwindowiface.cpp:128
KMainWindowInterface::KMainWindowInterface
KMainWindowInterface(KMainWindow *mainWindow)
Construct a new interface object.
Definition: kmainwindowiface.cpp:32
KMainWindowInterface::disableAction
bool disableAction(TQCString action)
Disables the requested action.
Definition: kmainwindowiface.cpp:72
KMainWindowInterface::getWinID
int getWinID()
Returns the ID of the current main window.
Definition: kmainwindowiface.cpp:133
KMainWindowInterface::actions
QCStringList actions()
Return a list of actions available to the application's window.
Definition: kmainwindowiface.cpp:46
KMainWindowInterface::enableAction
bool enableAction(TQCString action)
Enables the requested action.
Definition: kmainwindowiface.cpp:85
KMainWindowInterface::~KMainWindowInterface
~KMainWindowInterface()
Destructor Cleans up the dcop action proxy object.
Definition: kmainwindowiface.cpp:40
KMainWindowInterface::actionToolTip
TQCString actionToolTip(TQCString action)
Returns the tool tip text of the requested action.
Definition: kmainwindowiface.cpp:110
KMainWindowInterface::grabWindowToClipBoard
void grabWindowToClipBoard()
Copies a pixmap representation of the current main window to the clipboard.
Definition: kmainwindowiface.cpp:137
KMainWindowInterface::activateAction
bool activateAction(TQCString action)
Activates the requested action.
Definition: kmainwindowiface.cpp:59
KMainWindowInterface::action
DCOPRef action(const TQCString &name)
Returns a dcop reference to the selected KAction.
Definition: kmainwindowiface.cpp:123
KMainWindow
KDE top level main window
Definition: kmainwindow.h:99
KMainWindow::show
virtual void show()
Reimplementation of TQMainWindow::show()
Definition: kmainwindow.cpp:381
KMainWindow::hide
virtual void hide()
Reimplementation of TQMainWindow::hide()
Definition: kmainwindow.cpp:391
KShortcut::append
bool append(const KKeySequence &keySeq)
KWin::forceActiveWindow
static void forceActiveWindow(WId win, long time=0)
KXMLGUIClient::actionCollection
virtual KActionCollection * actionCollection() const
Retrieves the entire action collection for the GUI client.
Definition: kxmlguiclient.cpp:107

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.9.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |