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

tdemdi/tdemdi

  • tdemdi
  • tdemdi
guiclient.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 2003 Joseph Wenninger <jowenn@kde.org>
3  Copyright (C) 2004 Christoph Cullmann <cullmann@kde.org>
4  based on tdetoolbarhandler.cpp: Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include "guiclient.h"
22 #include "guiclient.moc"
23 
24 #include <tqpopupmenu.h>
25 #include <tdeapplication.h>
26 #include <tdeconfig.h>
27 #include <tdetoolbar.h>
28 #include <tdelocale.h>
29 #include <tdeaction.h>
30 #include <tqstring.h>
31 #include <kdebug.h>
32 #include <kdockwidget.h>
33 
34 #include "mainwindow.h"
35 #include "toolviewaccessor.h"
36 #include "toolviewaccessor_p.h"
37 
38 static const char *actionListName = "show_tdemdi_document_tool_view_actions";
39 
40 static const char *guiDescription = ""
41  "<!DOCTYPE kpartgui><kpartgui name=\"KMDIViewActions\">"
42  "<MenuBar>"
43  " <Menu name=\"window\">"
44  " <ActionList name=\"%1\" />"
45  " </Menu>"
46  "</MenuBar>"
47  "</kpartgui>";
48 
49 static const char *resourceFileName = "tdemdiviewactions.rc";
50 
51 namespace KMDIPrivate
52 {
53 
54 GUIClient::GUIClient (KMDI::MainWindow* mdiMainFrm,const char* name)
55  : TQObject ( mdiMainFrm,name )
56  , KXMLGUIClient ( mdiMainFrm )
57 {
58  m_mdiMainFrm=mdiMainFrm;
59 
60  connect( mdiMainFrm->guiFactory(), TQ_SIGNAL( clientAdded( KXMLGUIClient * ) ),
61  this, TQ_SLOT( clientAdded( KXMLGUIClient * ) ) );
62 
63  /* re-use an existing resource file if it exists. can happen if the user launches the
64  * toolbar editor */
65  /*
66  setXMLFile( resourceFileName );
67  */
68 
69  if ( domDocument().documentElement().isNull() )
70  {
71  TQString completeDescription = TQString::fromLatin1( guiDescription ).arg( actionListName );
72 
73  setXML( completeDescription, false /*merge*/ );
74  }
75 
76  if (actionCollection()->tdeaccel()==0)
77  actionCollection()->setWidget(mdiMainFrm);
78 
79  m_toolMenu=new TDEActionMenu(i18n("Tool &Views"),actionCollection(),"tdemdi_toolview_menu");
80 
81  m_gotoToolDockMenu=new TDEActionMenu(i18n("Tool &Docks"),actionCollection(),"tdemdi_tooldock_menu");
82  m_gotoToolDockMenu->insert(new TDEAction(i18n("Switch Top Dock"),ALT+CTRL+SHIFT+Key_T,this,TQ_SIGNAL(toggleTop()),
83  actionCollection(),"tdemdi_activate_top"));
84  m_gotoToolDockMenu->insert(new TDEAction(i18n("Switch Left Dock"),ALT+CTRL+SHIFT+Key_L,this,TQ_SIGNAL(toggleLeft()),
85  actionCollection(),"tdemdi_activate_left"));
86  m_gotoToolDockMenu->insert(new TDEAction(i18n("Switch Right Dock"),ALT+CTRL+SHIFT+Key_R,this,TQ_SIGNAL(toggleRight()),
87  actionCollection(),"tdemdi_activate_right"));
88  m_gotoToolDockMenu->insert(new TDEAction(i18n("Switch Bottom Dock"),ALT+CTRL+SHIFT+Key_B,this,TQ_SIGNAL(toggleBottom()),
89  actionCollection(),"tdemdi_activate_bottom"));
90  m_gotoToolDockMenu->insert(new TDEActionSeparator(actionCollection(),"tdemdi_goto_menu_separator"));
91  m_gotoToolDockMenu->insert(new TDEAction(i18n("Previous Tool View"),ALT+CTRL+Key_Left,m_mdiMainFrm,TQ_SLOT(prevToolViewInDock()),
92  actionCollection(),"tdemdi_prev_toolview"));
93  m_gotoToolDockMenu->insert(new TDEAction(i18n("Next Tool View"),ALT+CTRL+Key_Right,m_mdiMainFrm,TQ_SLOT(nextToolViewInDock()),
94  actionCollection(),"tdemdi_next_toolview"));
95 
96  actionCollection()->readShortcutSettings( "Shortcuts", kapp->config() );
97 }
98 
99 GUIClient::~GUIClient()
100 {
101 // actionCollection()->writeShortcutSettings( "KMDI Shortcuts", kapp->config() );
102  for (uint i=0;i<m_toolViewActions.count();i++)
103  disconnect(m_toolViewActions.at(i),0,this,0);
104 
105  m_toolViewActions.setAutoDelete( false );
106  m_toolViewActions.clear();
107  m_documentViewActions.setAutoDelete( false );
108  m_documentViewActions.clear();
109 }
110 
111 void GUIClient::setupActions()
112 {
113  if ( !factory() || !m_mdiMainFrm )
114  return;
115 
116  unplugActionList( actionListName );
117 
118  TQPtrList<TDEAction> addList;
119  if (m_toolViewActions.count()<3)
120  {
121  for (uint i=0;i<m_toolViewActions.count();i++)
122  addList.append(m_toolViewActions.at(i));
123  }
124  else
125  addList.append(m_toolMenu);
126 
127  addList.append(m_gotoToolDockMenu);
128 
129  kdDebug(760)<<"GUIClient::setupActions: plugActionList"<<endl;
130 
131  plugActionList( actionListName, addList );
132 }
133 
134 void GUIClient::addToolView(KMDI::ToolViewAccessor* mtva)
135 {
136  kdDebug(760)<<"*****void GUIClient::addToolView(KMDI::ToolViewAccessor* mtva)*****"<<endl;
137 
138  TQString aname = TQString("tdemdi_toolview_") + mtva->wrappedWidget()->name();
139 
140  // try to read the action shortcut
141  TDEShortcut sc;
142  TDEConfig *cfg = kapp->config();
143  TQString _grp = cfg->group();
144  cfg->setGroup("Shortcuts");
145  sc = TDEShortcut( cfg->readEntry( aname, "" ) );
146  cfg->setGroup( _grp );
147 
148  TDEAction *a=new ToggleToolViewAction(i18n("Show %1").arg(mtva->wrappedWidget()->caption()),
149  /*TQString::null*/sc,dynamic_cast<KDockWidget*>(mtva->wrapperWidget()),
150  m_mdiMainFrm,actionCollection(), aname.latin1() );
151 
152  ((ToggleToolViewAction*)a)->setCheckedState(TQString(i18n("Hide %1").arg(mtva->wrappedWidget()->caption())));
153 
154  connect(a,TQ_SIGNAL(destroyed(TQObject*)),this,TQ_SLOT(actionDeleted(TQObject*)));
155 
156  m_toolViewActions.append(a);
157  m_toolMenu->insert(a);
158  mtva->d->action=a;
159 
160  setupActions();
161 }
162 
163 void GUIClient::actionDeleted(TQObject* a)
164 {
165  m_toolViewActions.remove(static_cast<TDEAction*>(a));
166  setupActions();
167 }
168 
169 
170 void GUIClient::clientAdded( KXMLGUIClient *client )
171 {
172  if ( client == this )
173  setupActions();
174 }
175 
176 ToggleToolViewAction::ToggleToolViewAction ( const TQString& text, const TDEShortcut& cut,KDockWidget *dw, KMDI::MainWindow *mdiMainFrm,
177  TQObject* parent, const char* name )
178  : TDEToggleAction(text,cut,parent,name)
179  , m_dw(dw)
180  , m_mdiMainFrm(mdiMainFrm)
181 {
182  if (m_dw)
183  {
184  connect(this,TQ_SIGNAL(toggled(bool)),this,TQ_SLOT(slotToggled(bool)));
185  connect(m_dw->dockManager(),TQ_SIGNAL(change()),this,TQ_SLOT(anDWChanged()));
186  connect(m_dw,TQ_SIGNAL(destroyed()),this,TQ_SLOT(slotWidgetDestroyed()));
187 
188  setChecked(m_dw->mayBeHide());
189  }
190 }
191 
192 ToggleToolViewAction::~ToggleToolViewAction()
193 {
194  unplugAll();
195 }
196 
197 void ToggleToolViewAction::anDWChanged()
198 {
199  if (isChecked() && m_dw->mayBeShow())
200  setChecked(false);
201  else if ((!isChecked()) && m_dw->mayBeHide())
202  setChecked(true);
203  else if (isChecked() && (m_dw->parentDockTabGroup() &&
204  ((::tqt_cast<KDockWidget*>(m_dw->parentDockTabGroup()->
205  parent()))->mayBeShow())))
206  setChecked(false);
207 }
208 
209 
210 void ToggleToolViewAction::slotToggled(bool t)
211 {
212  if ((!t) && m_dw->mayBeHide() )
213  m_dw->undock();
214  else
215  if ( t && m_dw->mayBeShow() )
216  m_mdiMainFrm->makeDockVisible(m_dw);
217 }
218 
219 void ToggleToolViewAction::slotWidgetDestroyed()
220 {
221  disconnect(m_dw->dockManager(),TQ_SIGNAL(change()),this,TQ_SLOT(anDWChanged()));
222  disconnect(this,TQ_SIGNAL(toggled(bool)),0,0);
223 
224  unplugAll();
225  deleteLater();
226 }
227 
228 }

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.9.1
This website is maintained by Timothy Pearson.