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

tdemdi

  • tdemdi
tdemdiguiclient.cpp
1/* This file is part of the KDE libraries
2 Copyright (C) 2003 Joseph Wenninger <jowenn@kde.org>
3 based on tdetoolbarhandler.cpp: Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
8
9 This library 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 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. 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 "tdemdiguiclient.h"
21#include "tdemdiguiclient.moc"
22
23#include <tqpopupmenu.h>
24#include <tdeapplication.h>
25#include <tdeconfig.h>
26#include <tdetoolbar.h>
27#include <tdemainwindow.h>
28#include <tdelocale.h>
29#include <tdeaction.h>
30#include <tqstring.h>
31#include <assert.h>
32#include <kdebug.h>
33#include <kdockwidget.h>
34#include <tdeversion.h>
35#include "tdemdimainfrm.h"
36#include "tdemditoolviewaccessor.h"
37#include "tdemditoolviewaccessor_p.h"
38namespace
39{
40const char *actionListName = "show_tdemdi_document_tool_view_actions";
41
42const char *guiDescription = ""
43 "<!DOCTYPE kpartgui><kpartgui name=\"KMDIViewActions\">"
44 "<MenuBar>"
45 " <Menu name=\"view\">"
46 " <ActionList name=\"%1\" />"
47 " </Menu>"
48 "</MenuBar>"
49 "</kpartgui>";
50
51const char *resourceFileName = "tdemdiviewactions.rc";
52
53}
54
55
56using namespace KMDIPrivate;
57
58
59
60ToggleToolViewAction::ToggleToolViewAction( const TQString& text, const TDEShortcut& cut, KDockWidget *dw, KMdiMainFrm *mdiMainFrm,
61 TQObject* parent, const char* name )
62 : TDEToggleAction( text, cut, parent, name ), m_dw( dw ), m_mdiMainFrm( mdiMainFrm )
63{
64 if ( m_dw )
65 {
66 connect( this, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotToggled( bool ) ) );
67 connect( m_dw->dockManager(), TQ_SIGNAL( change() ), this, TQ_SLOT( anDWChanged() ) );
68 connect( m_dw, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotWidgetDestroyed() ) );
69 setChecked( m_dw->mayBeHide() );
70 }
71}
72
73
74ToggleToolViewAction::~ToggleToolViewAction()
75{
76 unplugAll();
77}
78
79void ToggleToolViewAction::anDWChanged()
80{
81 if ( isChecked() && m_dw->mayBeShow() )
82 setChecked( false );
83 else if ( ( !isChecked() ) && m_dw->mayBeHide() )
84 setChecked( true );
85 else if ( isChecked() && ( m_dw->parentDockTabGroup() &&
86 ( ( ::tqt_cast<KDockWidget*>( m_dw->parentDockTabGroup() ->
87 parent() ) ) ->mayBeShow() ) ) )
88 setChecked( false );
89}
90
91
92void ToggleToolViewAction::slotToggled( bool t )
93{
94 // m_mw->mainDock->setDockSite( KDockWidget::DockCorner );
95
96 if ( ( !t ) && m_dw->mayBeHide() )
97 m_dw->undock();
98 else
99 if ( t && m_dw->mayBeShow() )
100 m_mdiMainFrm->makeDockVisible( m_dw );
101
102 // m_mw->mainDock->setDockSite( KDockWidget::DockNone );
103}
104
105void ToggleToolViewAction::slotWidgetDestroyed()
106{
107 disconnect( m_dw->dockManager(), TQ_SIGNAL( change() ), this, TQ_SLOT( anDWChanged() ) );
108 disconnect( this, TQ_SIGNAL( toggled( bool ) ), 0, 0 );
109 unplugAll();
110 deleteLater();
111}
112
113
114KMDIGUIClient::KMDIGUIClient( KMdiMainFrm* mdiMainFrm, bool showMDIModeAction, const char* name ) : TQObject( mdiMainFrm, name ),
115 KXMLGUIClient( mdiMainFrm )
116{
117 m_mdiMode = KMdi::ChildframeMode;
118 m_mdiMainFrm = mdiMainFrm;
119 connect( mdiMainFrm->guiFactory(), TQ_SIGNAL( clientAdded( KXMLGUIClient * ) ),
120 this, TQ_SLOT( clientAdded( KXMLGUIClient * ) ) );
121
122 /* re-use an existing resource file if it exists. can happen if the user launches the
123 * toolbar editor */
124 /*
125 setXMLFile( resourceFileName );
126 */
127
128 if ( domDocument().documentElement().isNull() )
129 {
130
131 TQString completeDescription = TQString::fromLatin1( guiDescription )
132 .arg( actionListName );
133
134 setXML( completeDescription, false /*merge*/ );
135 }
136
137 if ( actionCollection() ->tdeaccel() == 0 )
138 actionCollection() ->setWidget( mdiMainFrm );
139 m_toolMenu = new TDEActionMenu( i18n( "Tool &Views" ), actionCollection(), "tdemdi_toolview_menu" );
140 if ( showMDIModeAction )
141 {
142 m_mdiModeAction = new TDESelectAction( i18n( "MDI Mode" ), 0, actionCollection() );
143 TQStringList modes;
144 modes << i18n( "&Toplevel Mode" ) << i18n( "C&hildframe Mode" ) << i18n( "Ta&b Page Mode" ) << i18n( "I&DEAl Mode" );
145 m_mdiModeAction->setItems( modes );
146 connect( m_mdiModeAction, TQ_SIGNAL( activated( int ) ), this, TQ_SLOT( changeViewMode( int ) ) );
147 }
148 else
149 m_mdiModeAction = 0;
150
151 connect( m_mdiMainFrm, TQ_SIGNAL( mdiModeHasBeenChangedTo( KMdi::MdiMode ) ),
152 this, TQ_SLOT( mdiModeHasBeenChangedTo( KMdi::MdiMode ) ) );
153
154 m_gotoToolDockMenu = new TDEActionMenu( i18n( "Tool &Docks" ), actionCollection(), "tdemdi_tooldock_menu" );
155 m_gotoToolDockMenu->insert( new TDEAction( i18n( "Switch Top Dock" ), ALT + CTRL + SHIFT + Key_T, this, TQ_SIGNAL( toggleTop() ),
156 actionCollection(), "tdemdi_activate_top" ) );
157 m_gotoToolDockMenu->insert( new TDEAction( i18n( "Switch Left Dock" ), ALT + CTRL + SHIFT + Key_L, this, TQ_SIGNAL( toggleLeft() ),
158 actionCollection(), "tdemdi_activate_left" ) );
159 m_gotoToolDockMenu->insert( new TDEAction( i18n( "Switch Right Dock" ), ALT + CTRL + SHIFT + Key_R, this, TQ_SIGNAL( toggleRight() ),
160 actionCollection(), "tdemdi_activate_right" ) );
161 m_gotoToolDockMenu->insert( new TDEAction( i18n( "Switch Bottom Dock" ), ALT + CTRL + SHIFT + Key_B, this, TQ_SIGNAL( toggleBottom() ),
162 actionCollection(), "tdemdi_activate_bottom" ) );
163 m_gotoToolDockMenu->insert( new TDEActionSeparator( actionCollection(), "tdemdi_goto_menu_separator" ) );
164 m_gotoToolDockMenu->insert( new TDEAction( i18n( "Previous Tool View" ), ALT + CTRL + Key_Left, m_mdiMainFrm, TQ_SLOT( prevToolViewInDock() ),
165 actionCollection(), "tdemdi_prev_toolview" ) );
166 m_gotoToolDockMenu->insert( new TDEAction( i18n( "Next Tool View" ), ALT + CTRL + Key_Right, m_mdiMainFrm, TQ_SLOT( nextToolViewInDock() ),
167 actionCollection(), "tdemdi_next_toolview" ) );
168
169 actionCollection() ->readShortcutSettings( "Shortcuts", tdeApp->config() );
170}
171
172KMDIGUIClient::~KMDIGUIClient()
173{
174
175 // actionCollection()->writeShortcutSettings( "KMDI Shortcuts", tdeApp->config() );
176 for ( uint i = 0;i < m_toolViewActions.count();i++ )
177 disconnect( m_toolViewActions.at( i ), 0, this, 0 );
178
179 m_toolViewActions.setAutoDelete( false );
180 m_toolViewActions.clear();
181 m_documentViewActions.setAutoDelete( false );
182 m_documentViewActions.clear();
183}
184
185void KMDIGUIClient::changeViewMode( int id )
186{
187 switch ( id )
188 {
189 case 0:
190 m_mdiMainFrm->switchToToplevelMode();
191 break;
192 case 1:
193 m_mdiMainFrm->switchToChildframeMode();
194 break;
195 case 2:
196 m_mdiMainFrm->switchToTabPageMode();
197 break;
198 case 3:
199 m_mdiMainFrm->switchToIDEAlMode();
200 break;
201 default:
202 Q_ASSERT( 0 );
203 }
204}
205
206void KMDIGUIClient::setupActions()
207{
208 if ( !factory() || !m_mdiMainFrm )
209 return ;
210
211 // BarActionBuilder builder( actionCollection(), m_mainWindow, m_toolBars );
212
213 // if ( !builder.needsRebuild() )
214 // return;
215
216
217 unplugActionList( actionListName );
218
219 // m_actions.setAutoDelete( true );
220 // m_actions.clear();
221 // m_actions.setAutoDelete( false );
222
223 // m_actions = builder.create();
224
225 // m_toolBars = builder.toolBars();
226
227 // m_toolViewActions.append(new TDEAction( "TESTKMDIGUICLIENT", TQString::null, 0,
228 // this, TQ_SLOT(blah()),actionCollection(),"nothing"));
229
230 TQPtrList<TDEAction> addList;
231 if ( m_toolViewActions.count() < 3 )
232 for ( uint i = 0;i < m_toolViewActions.count();i++ )
233 addList.append( m_toolViewActions.at( i ) );
234 else
235 addList.append( m_toolMenu );
236 if ( m_mdiMode == KMdi::IDEAlMode )
237 addList.append( m_gotoToolDockMenu );
238 if ( m_mdiModeAction )
239 addList.append( m_mdiModeAction );
240 kdDebug( 760 ) << "KMDIGUIClient::setupActions: plugActionList" << endl;
241 plugActionList( actionListName, addList );
242
243 // connectToActionContainers();
244}
245
246void KMDIGUIClient::addToolView( KMdiToolViewAccessor* mtva )
247{
248 kdDebug( 760 ) << "*****void KMDIGUIClient::addToolView(KMdiToolViewAccessor* mtva)*****" << endl;
249 // kdDebug()<<"name: "<<mtva->wrappedWidget()->name()<<endl;
250 TQString aname = TQString( "tdemdi_toolview_" ) + mtva->wrappedWidget() ->name();
251
252 // try to read the action shortcut
253 TDEShortcut sc;
254 TDEConfig *cfg = tdeApp->config();
255 TQString _grp = cfg->group();
256 cfg->setGroup( "Shortcuts" );
257 // if ( cfg->hasKey( aname ) )
258 sc = TDEShortcut( cfg->readEntry( aname, "" ) );
259 cfg->setGroup( _grp );
260 TDEAction *a = new ToggleToolViewAction( i18n( "Show %1" ).arg( mtva->wrappedWidget() ->caption() ),
261 /*TQString::null*/sc, dynamic_cast<KDockWidget*>( mtva->wrapperWidget() ),
262 m_mdiMainFrm, actionCollection(), aname.latin1() );
263#if KDE_IS_VERSION(3,2,90)
264
265 ( ( ToggleToolViewAction* ) a ) ->setCheckedState( TQString(i18n( "Hide %1" ).arg( mtva->wrappedWidget() ->caption() )) );
266#endif
267
268 connect( a, TQ_SIGNAL( destroyed( TQObject* ) ), this, TQ_SLOT( actionDeleted( TQObject* ) ) );
269 m_toolViewActions.append( a );
270 m_toolMenu->insert( a );
271 mtva->d->action = a;
272
273 setupActions();
274}
275
276void KMDIGUIClient::actionDeleted( TQObject* a )
277{
278 m_toolViewActions.remove( static_cast<TDEAction*>( a ) );
279 /* if (!m_toolMenu.isNull()) m_toolMenu->remove(static_cast<TDEAction*>(a));*/
280 setupActions();
281}
282
283
284void KMDIGUIClient::clientAdded( KXMLGUIClient *client )
285{
286 if ( client == this )
287 setupActions();
288}
289
290
291void KMDIGUIClient::mdiModeHasBeenChangedTo( KMdi::MdiMode mode )
292{
293 kdDebug( 760 ) << "KMDIGUIClient::mdiModeHasBennChangeTo" << endl;
294 m_mdiMode = mode;
295 if ( m_mdiModeAction )
296 {
297 switch ( mode )
298 {
299 case KMdi::ToplevelMode:
300 m_mdiModeAction->setCurrentItem( 0 );
301 break;
302 case KMdi::ChildframeMode:
303 m_mdiModeAction->setCurrentItem( 1 );
304 break;
305 case KMdi::TabPageMode:
306 m_mdiModeAction->setCurrentItem( 2 );
307 break;
308 case KMdi::IDEAlMode:
309 m_mdiModeAction->setCurrentItem( 3 );
310 break;
311 default:
312 Q_ASSERT( 0 );
313 }
314 }
315 setupActions();
316
317}
KMDIPrivate::KMDIGUIClient::addToolView
void addToolView(KMdiToolViewAccessor *)
Add a new tool view to this KMDIGUIClient.
Definition: tdemdiguiclient.cpp:246
KMDIPrivate::ToggleToolViewAction
A TDEToggleAction specifically for toggling the showing or the hiding of a KMDI tool view.
Definition: tdemdiguiclient.h:122
KMdiMainFrm
Base class for all your special main frames.
Definition: tdemdimainfrm.h:240

tdemdi

Skip menu "tdemdi"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdemdi

Skip menu "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 by doxygen 1.9.4
This website is maintained by Timothy Pearson.