• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdemdi/tdemdi
 

tdemdi/tdemdi

guiclient.cpp

00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2003 Joseph Wenninger <jowenn@kde.org>
00003    Copyright (C) 2004 Christoph Cullmann <cullmann@kde.org>
00004    based on tdetoolbarhandler.cpp: Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License version 2 as published by the Free Software Foundation.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "guiclient.h"
00022 #include "guiclient.moc"
00023 
00024 #include <tqpopupmenu.h>
00025 #include <tdeapplication.h>
00026 #include <tdeconfig.h>
00027 #include <tdetoolbar.h>
00028 #include <tdelocale.h>
00029 #include <tdeaction.h>
00030 #include <tqstring.h>
00031 #include <kdebug.h>
00032 #include <kdockwidget.h>
00033 
00034 #include "mainwindow.h"
00035 #include "toolviewaccessor.h"
00036 #include "toolviewaccessor_p.h"
00037 
00038 static const char *actionListName = "show_tdemdi_document_tool_view_actions";
00039 
00040 static const char *guiDescription = ""
00041         "<!DOCTYPE kpartgui><kpartgui name=\"KMDIViewActions\">"
00042         "<MenuBar>"
00043         "    <Menu name=\"window\">"
00044         "        <ActionList name=\"%1\" />"
00045         "    </Menu>"
00046         "</MenuBar>"
00047         "</kpartgui>";
00048 
00049 static const char *resourceFileName = "tdemdiviewactions.rc";
00050 
00051 namespace KMDIPrivate
00052 {
00053 
00054 GUIClient::GUIClient (KMDI::MainWindow* mdiMainFrm,const char* name)
00055  : TQObject ( mdiMainFrm,name )
00056  , KXMLGUIClient ( mdiMainFrm )
00057 {
00058   m_mdiMainFrm=mdiMainFrm;
00059 
00060   connect( mdiMainFrm->guiFactory(), TQT_SIGNAL( clientAdded( KXMLGUIClient * ) ),
00061            this, TQT_SLOT( clientAdded( KXMLGUIClient * ) ) );
00062 
00063   /* re-use an existing resource file if it exists. can happen if the user launches the
00064    * toolbar editor */
00065   /*
00066   setXMLFile( resourceFileName );
00067   */
00068 
00069   if ( domDocument().documentElement().isNull() )
00070   {
00071     TQString completeDescription = TQString::fromLatin1( guiDescription ).arg( actionListName );
00072 
00073     setXML( completeDescription, false /*merge*/ );
00074   }
00075 
00076   if (actionCollection()->tdeaccel()==0)
00077     actionCollection()->setWidget(mdiMainFrm);
00078 
00079   m_toolMenu=new TDEActionMenu(i18n("Tool &Views"),actionCollection(),"tdemdi_toolview_menu");
00080 
00081   m_gotoToolDockMenu=new TDEActionMenu(i18n("Tool &Docks"),actionCollection(),"tdemdi_tooldock_menu");
00082   m_gotoToolDockMenu->insert(new TDEAction(i18n("Switch Top Dock"),ALT+CTRL+SHIFT+Key_T,this,TQT_SIGNAL(toggleTop()),
00083   actionCollection(),"tdemdi_activate_top"));
00084   m_gotoToolDockMenu->insert(new TDEAction(i18n("Switch Left Dock"),ALT+CTRL+SHIFT+Key_L,this,TQT_SIGNAL(toggleLeft()),
00085   actionCollection(),"tdemdi_activate_left"));
00086   m_gotoToolDockMenu->insert(new TDEAction(i18n("Switch Right Dock"),ALT+CTRL+SHIFT+Key_R,this,TQT_SIGNAL(toggleRight()),
00087   actionCollection(),"tdemdi_activate_right"));
00088   m_gotoToolDockMenu->insert(new TDEAction(i18n("Switch Bottom Dock"),ALT+CTRL+SHIFT+Key_B,this,TQT_SIGNAL(toggleBottom()),
00089   actionCollection(),"tdemdi_activate_bottom"));
00090   m_gotoToolDockMenu->insert(new TDEActionSeparator(actionCollection(),"tdemdi_goto_menu_separator"));
00091   m_gotoToolDockMenu->insert(new TDEAction(i18n("Previous Tool View"),ALT+CTRL+Key_Left,TQT_TQOBJECT(m_mdiMainFrm),TQT_SLOT(prevToolViewInDock()),
00092   actionCollection(),"tdemdi_prev_toolview"));
00093   m_gotoToolDockMenu->insert(new TDEAction(i18n("Next Tool View"),ALT+CTRL+Key_Right,TQT_TQOBJECT(m_mdiMainFrm),TQT_SLOT(nextToolViewInDock()),
00094   actionCollection(),"tdemdi_next_toolview"));
00095 
00096   actionCollection()->readShortcutSettings( "Shortcuts", kapp->config() );
00097 }
00098 
00099 GUIClient::~GUIClient()
00100 {
00101 //     actionCollection()->writeShortcutSettings( "KMDI Shortcuts", kapp->config() );
00102   for (uint i=0;i<m_toolViewActions.count();i++)
00103     disconnect(m_toolViewActions.at(i),0,this,0);
00104 
00105   m_toolViewActions.setAutoDelete( false );
00106   m_toolViewActions.clear();
00107   m_documentViewActions.setAutoDelete( false );
00108   m_documentViewActions.clear();
00109 }
00110 
00111 void GUIClient::setupActions()
00112 {
00113   if ( !factory() || !m_mdiMainFrm )
00114     return;
00115 
00116   unplugActionList( actionListName );
00117 
00118   TQPtrList<TDEAction> addList;
00119   if (m_toolViewActions.count()<3)
00120   {
00121     for (uint i=0;i<m_toolViewActions.count();i++)
00122       addList.append(m_toolViewActions.at(i));
00123   }
00124   else
00125     addList.append(m_toolMenu);
00126 
00127   addList.append(m_gotoToolDockMenu);
00128 
00129   kdDebug(760)<<"GUIClient::setupActions: plugActionList"<<endl;
00130 
00131   plugActionList( actionListName, addList );
00132 }
00133 
00134 void GUIClient::addToolView(KMDI::ToolViewAccessor* mtva)
00135 {
00136   kdDebug(760)<<"*****void GUIClient::addToolView(KMDI::ToolViewAccessor* mtva)*****"<<endl;
00137 
00138   TQString aname = TQString("tdemdi_toolview_") + mtva->wrappedWidget()->name();
00139 
00140   // try to read the action shortcut
00141   TDEShortcut sc;
00142   TDEConfig *cfg = kapp->config();
00143   TQString _grp = cfg->group();
00144   cfg->setGroup("Shortcuts");
00145   sc = TDEShortcut( cfg->readEntry( aname, "" ) );
00146   cfg->setGroup( _grp );
00147 
00148   TDEAction *a=new ToggleToolViewAction(i18n("Show %1").arg(mtva->wrappedWidget()->caption()),
00149     /*TQString::null*/sc,tqt_dynamic_cast<KDockWidget*>(mtva->wrapperWidget()),
00150     m_mdiMainFrm,actionCollection(), aname.latin1() );
00151 
00152   ((ToggleToolViewAction*)a)->setCheckedState(TQString(i18n("Hide %1").arg(mtva->wrappedWidget()->caption())));
00153 
00154   connect(a,TQT_SIGNAL(destroyed(TQObject*)),this,TQT_SLOT(actionDeleted(TQObject*)));
00155 
00156   m_toolViewActions.append(a);
00157   m_toolMenu->insert(a);
00158   mtva->d->action=a;
00159 
00160   setupActions();
00161 }
00162 
00163 void GUIClient::actionDeleted(TQObject* a)
00164 {
00165   m_toolViewActions.remove(static_cast<TDEAction*>(a));
00166   setupActions();
00167 }
00168 
00169 
00170 void GUIClient::clientAdded( KXMLGUIClient *client )
00171 {
00172   if ( client == this )
00173     setupActions();
00174 }
00175 
00176 ToggleToolViewAction::ToggleToolViewAction ( const TQString& text, const TDEShortcut& cut,KDockWidget *dw, KMDI::MainWindow *mdiMainFrm,
00177                                              TQObject* parent, const char* name )
00178  : TDEToggleAction(text,cut,parent,name)
00179  , m_dw(dw)
00180  , m_mdiMainFrm(mdiMainFrm)
00181 {
00182   if (m_dw)
00183   {
00184     connect(this,TQT_SIGNAL(toggled(bool)),this,TQT_SLOT(slotToggled(bool)));
00185     connect(m_dw->dockManager(),TQT_SIGNAL(change()),this,TQT_SLOT(anDWChanged()));
00186     connect(m_dw,TQT_SIGNAL(destroyed()),this,TQT_SLOT(slotWidgetDestroyed()));
00187 
00188     setChecked(m_dw->mayBeHide());
00189   }
00190 }
00191 
00192 ToggleToolViewAction::~ToggleToolViewAction()
00193 {
00194   unplugAll();
00195 }
00196 
00197 void ToggleToolViewAction::anDWChanged()
00198 {
00199   if (isChecked() && m_dw->mayBeShow())
00200     setChecked(false);
00201   else if ((!isChecked()) && m_dw->mayBeHide())
00202     setChecked(true);
00203   else if (isChecked() && (m_dw->parentDockTabGroup() &&
00204           ((::tqqt_cast<KDockWidget*>(m_dw->parentDockTabGroup()->
00205                   parent()))->mayBeShow())))
00206     setChecked(false);
00207 }
00208 
00209 
00210 void ToggleToolViewAction::slotToggled(bool t)
00211 {
00212   if ((!t) && m_dw->mayBeHide() )
00213     m_dw->undock();
00214   else
00215     if ( t && m_dw->mayBeShow() )
00216       m_mdiMainFrm->makeDockVisible(m_dw);
00217 }
00218 
00219 void ToggleToolViewAction::slotWidgetDestroyed()
00220 {
00221   disconnect(m_dw->dockManager(),TQT_SIGNAL(change()),this,TQT_SLOT(anDWChanged()));
00222   disconnect(this,TQT_SIGNAL(toggled(bool)),0,0);
00223 
00224   unplugAll();
00225   deleteLater();
00226 }
00227 
00228 }
00229 
00230 // kate: space-indent on; indent-width 2; replace-tabs on;

tdemdi/tdemdi

Skip menu "tdemdi/tdemdi"
  • Main Page
  • Namespace List
  • File List
  • Namespace Members

tdemdi/tdemdi

Skip menu "tdemdi/tdemdi"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdemdi/tdemdi by doxygen 1.7.1
This website is maintained by Timothy Pearson.