kdeui
kmainwindowiface.cpp
Go to the documentation of this file.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::grabWidget(m_MainWindow));
00140 }
00141 void KMainWindowInterface::hide()
00142 {
00143 m_MainWindow->hide();
00144 }
00145 void KMainWindowInterface::maximize()
00146 {
00147 m_MainWindow->showMaximized();
00148 }
00149 void KMainWindowInterface::minimize()
00150 {
00151 m_MainWindow->showMinimized();
00152 }
00153 void KMainWindowInterface::resize(int newX, int newY)
00154 {
00155 m_MainWindow->resize(newX, newY);
00156 }
00157 void KMainWindowInterface::move(int newX, int newY)
00158 {
00159 m_MainWindow->move(newX, newY);
00160 }
00161 void KMainWindowInterface::setGeometry(int newX, int newY, int newWidth, int newHeight)
00162 {
00163 m_MainWindow->setGeometry(newX, newY, newWidth, newHeight);
00164 }
00165 void KMainWindowInterface::raise()
00166 {
00167 m_MainWindow->raise();
00168 }
00169 void KMainWindowInterface::lower()
00170 {
00171 m_MainWindow->lower();
00172 }
00173 void KMainWindowInterface::restore()
00174 {
00175 m_MainWindow->showNormal();
00176 }
00177 void KMainWindowInterface::close()
00178 {
00179 m_MainWindow->close();
00180 }
00181 void KMainWindowInterface::show()
00182 {
00183 m_MainWindow->show();
00184 }
00185 QCStringList KMainWindowInterface::functionsDynamic()
00186 {
00187 return m_dcopPropertyProxy->functions();
00188 }
00189 bool KMainWindowInterface::processDynamic(const QCString &fun, const QByteArray &data, QCString& replyType, QByteArray &replyData)
00190 {
00191 return m_dcopPropertyProxy->processPropertyRequest( fun, data, replyType, replyData);
00192
00193 }
00194