kmainwindowiface.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "kmainwindowiface.h"
00021
00022 #include <dcopclient.h>
00023 #include <kapplication.h>
00024 #include <kdcopactionproxy.h>
00025 #include <kdcoppropertyproxy.h>
00026 #include <kmainwindow.h>
00027 #include <kaction.h>
00028 #include <qclipboard.h>
00029
00030
00031 KMainWindowInterface::KMainWindowInterface(KMainWindow * mainWindow)
00032 : DCOPObject( mainWindow->name())
00033 {
00034 m_MainWindow = mainWindow;
00035 m_dcopActionProxy = new KDCOPActionProxy( m_MainWindow->actionCollection(), this );
00036 m_dcopPropertyProxy = new KDCOPPropertyProxy(m_MainWindow);
00037 }
00038
00039 KMainWindowInterface::~KMainWindowInterface()
00040 {
00041 delete m_dcopActionProxy;
00042 delete m_dcopPropertyProxy;
00043 }
00044
00045 QCStringList KMainWindowInterface::actions()
00046 {
00047 delete m_dcopActionProxy;
00048 m_dcopActionProxy = new KDCOPActionProxy( m_MainWindow->actionCollection(), this );
00049 QCStringList tmp_actions;
00050 QValueList<KAction *> lst = m_dcopActionProxy->actions();
00051 QValueList<KAction *>::ConstIterator it = lst.begin();
00052 QValueList<KAction *>::ConstIterator end = lst.end();
00053 for (; it != end; ++it )
00054 if ((*it)->isPlugged())
00055 tmp_actions.append( (QCString)(*it)->name() );
00056 return tmp_actions;
00057 }
00058 bool KMainWindowInterface::activateAction( QCString action)
00059 {
00060 delete m_dcopActionProxy;
00061 m_dcopActionProxy = new KDCOPActionProxy( m_MainWindow->actionCollection(), this );
00062 KAction *tmp_Action = m_dcopActionProxy->action(action);
00063 if (tmp_Action)
00064 {
00065 tmp_Action->activate();
00066 return true;
00067 }
00068 else
00069 return false;
00070 }
00071 bool KMainWindowInterface::disableAction( QCString action)
00072 {
00073 delete m_dcopActionProxy;
00074 m_dcopActionProxy = new KDCOPActionProxy( m_MainWindow->actionCollection(), this );
00075 KAction *tmp_Action = m_dcopActionProxy->action(action);
00076 if (tmp_Action)
00077 {
00078 tmp_Action->setEnabled(false);
00079 return true;
00080 }
00081 else
00082 return false;
00083 }
00084 bool KMainWindowInterface::enableAction( QCString action)
00085 {
00086 delete m_dcopActionProxy;
00087 m_dcopActionProxy = new KDCOPActionProxy( m_MainWindow->actionCollection(), this );
00088 KAction *tmp_Action = m_dcopActionProxy->action(action);
00089 if (tmp_Action)
00090 {
00091 tmp_Action->setEnabled(true);
00092 return true;
00093 }
00094 else
00095 return false;
00096 }
00097 bool KMainWindowInterface::actionIsEnabled( QCString action)
00098 {
00099 delete m_dcopActionProxy;
00100 m_dcopActionProxy = new KDCOPActionProxy( m_MainWindow->actionCollection(), this );
00101 KAction *tmp_Action = m_dcopActionProxy->action(action);
00102 if (tmp_Action)
00103 {
00104 return tmp_Action->isEnabled();
00105 }
00106 else
00107 return false;
00108 }
00109 QCString KMainWindowInterface::actionToolTip( QCString action)
00110 {
00111 delete m_dcopActionProxy;
00112 m_dcopActionProxy = new KDCOPActionProxy( m_MainWindow->actionCollection(), this );
00113 KAction *tmp_Action = m_dcopActionProxy->action(action);
00114 if (tmp_Action)
00115 {
00116 return tmp_Action->toolTip().utf8();
00117 }
00118 else
00119 return "Error no such object!";
00120 }
00121
00122 DCOPRef KMainWindowInterface::action( const QCString &name )
00123 {
00124 return DCOPRef( kapp->dcopClient()->appId(), m_dcopActionProxy->actionObjectId( name ) );
00125 }
00126
00127 QMap<QCString,DCOPRef> KMainWindowInterface::actionMap()
00128 {
00129 return m_dcopActionProxy->actionMap();
00130 }
00131
00132 int KMainWindowInterface::getWinID()
00133 {
00134 return (int) m_MainWindow->winId();
00135 }
00136 void KMainWindowInterface::grabWindowToClipBoard()
00137 {
00138 QClipboard *clipboard = QApplication::clipboard();
00139 clipboard->setPixmap(QPixmap::grabWindow(m_MainWindow->winId()));
00140 }
00141
00142
00143
00144
00145
00146
00147 void KMainWindowInterface::hide()
00148 {
00149 m_MainWindow->hide();
00150 }
00151
00152
00153
00154
00155
00156 void KMainWindowInterface::maximize()
00157 {
00158 m_MainWindow->showMaximized();
00159 }
00160
00161
00162
00163
00164
00165
00166 void KMainWindowInterface::minimize()
00167 {
00168 m_MainWindow->showMinimized();
00169 }
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180 void KMainWindowInterface::resize(int newX, int newY)
00181 {
00182 m_MainWindow->resize(newX, newY);
00183 }
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194 void KMainWindowInterface::move(int newX, int newY)
00195 {
00196 m_MainWindow->move(newX, newY);
00197 }
00198 void KMainWindowInterface::setGeometry(int newX, int newY, int newWidth, int newHeight)
00199 {
00200 m_MainWindow->setGeometry(newX, newY, newWidth, newHeight);
00201 }
00202 void KMainWindowInterface::raise()
00203 {
00204 m_MainWindow->raise();
00205 }
00206 void KMainWindowInterface::lower()
00207 {
00208 m_MainWindow->lower();
00209 }
00210 void KMainWindowInterface::restore()
00211 {
00212 m_MainWindow->showNormal();
00213 }
00214 void KMainWindowInterface::show()
00215 {
00216 m_MainWindow->show();
00217 }
00218
00219
00220
00221
00222
00223
00224 QCStringList KMainWindowInterface::functionsDynamic()
00225 {
00226 return m_dcopPropertyProxy->functions();
00227 }
00228 bool KMainWindowInterface::processDynamic(const QCString &fun, const QByteArray &data, QCString& replyType, QByteArray &replyData)
00229 {
00230 return m_dcopPropertyProxy->processPropertyRequest( fun, data, replyType, replyData);
00231
00232 }
00233
This file is part of the documentation for kdelibs Version 3.1.5.