20 #include "tdemdiguiclient.h"
21 #include "tdemdiguiclient.moc"
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>
33 #include <kdockwidget.h>
34 #include <tdeversion.h>
35 #include "tdemdimainfrm.h"
36 #include "tdemditoolviewaccessor.h"
37 #include "tdemditoolviewaccessor_p.h"
40 const char *actionListName =
"show_tdemdi_document_tool_view_actions";
42 const char *guiDescription =
""
43 "<!DOCTYPE kpartgui><kpartgui name=\"KMDIViewActions\">"
45 " <Menu name=\"view\">"
46 " <ActionList name=\"%1\" />"
51 const char *resourceFileName =
"tdemdiviewactions.rc";
56 using namespace KMDIPrivate;
60 ToggleToolViewAction::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 )
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() );
74 ToggleToolViewAction::~ToggleToolViewAction()
79 void ToggleToolViewAction::anDWChanged()
81 if ( isChecked() && m_dw->mayBeShow() )
83 else if ( ( !isChecked() ) && m_dw->mayBeHide() )
85 else if ( isChecked() && ( m_dw->parentDockTabGroup() &&
86 ( ( ::tqt_cast<KDockWidget*>( m_dw->parentDockTabGroup() ->
87 parent() ) ) ->mayBeShow() ) ) )
92 void ToggleToolViewAction::slotToggled(
bool t )
96 if ( ( !t ) && m_dw->mayBeHide() )
99 if ( t && m_dw->mayBeShow() )
100 m_mdiMainFrm->makeDockVisible( m_dw );
105 void ToggleToolViewAction::slotWidgetDestroyed()
107 disconnect( m_dw->dockManager(), TQ_SIGNAL( change() ),
this, TQ_SLOT( anDWChanged() ) );
108 disconnect(
this, TQ_SIGNAL( toggled(
bool ) ), 0, 0 );
114 KMDIGUIClient::KMDIGUIClient(
KMdiMainFrm* mdiMainFrm,
bool showMDIModeAction,
const char* name ) : TQObject( mdiMainFrm, name ),
115 KXMLGUIClient( mdiMainFrm )
117 m_mdiMode = KMdi::ChildframeMode;
118 m_mdiMainFrm = mdiMainFrm;
119 connect( mdiMainFrm->guiFactory(), TQ_SIGNAL( clientAdded( KXMLGUIClient * ) ),
120 this, TQ_SLOT( clientAdded( KXMLGUIClient * ) ) );
128 if ( domDocument().documentElement().isNull() )
131 TQString completeDescription = TQString::fromLatin1( guiDescription )
132 .arg( actionListName );
134 setXML( completeDescription,
false );
137 if ( actionCollection() ->tdeaccel() == 0 )
138 actionCollection() ->setWidget( mdiMainFrm );
139 m_toolMenu =
new TDEActionMenu( i18n(
"Tool &Views" ), actionCollection(),
"tdemdi_toolview_menu" );
140 if ( showMDIModeAction )
142 m_mdiModeAction =
new TDESelectAction( i18n(
"MDI Mode" ), 0, actionCollection() );
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 ) ) );
151 connect( m_mdiMainFrm, TQ_SIGNAL( mdiModeHasBeenChangedTo( KMdi::MdiMode ) ),
152 this, TQ_SLOT( mdiModeHasBeenChangedTo( KMdi::MdiMode ) ) );
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" ) );
169 actionCollection() ->readShortcutSettings(
"Shortcuts", kapp->config() );
172 KMDIGUIClient::~KMDIGUIClient()
176 for ( uint i = 0;i < m_toolViewActions.count();i++ )
177 disconnect( m_toolViewActions.at( i ), 0,
this, 0 );
179 m_toolViewActions.setAutoDelete(
false );
180 m_toolViewActions.clear();
181 m_documentViewActions.setAutoDelete(
false );
182 m_documentViewActions.clear();
185 void KMDIGUIClient::changeViewMode(
int id )
190 m_mdiMainFrm->switchToToplevelMode();
193 m_mdiMainFrm->switchToChildframeMode();
196 m_mdiMainFrm->switchToTabPageMode();
199 m_mdiMainFrm->switchToIDEAlMode();
206 void KMDIGUIClient::setupActions()
208 if ( !factory() || !m_mdiMainFrm )
217 unplugActionList( actionListName );
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 ) );
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 );
248 kdDebug( 760 ) <<
"*****void KMDIGUIClient::addToolView(KMdiToolViewAccessor* mtva)*****" << endl;
250 TQString aname = TQString(
"tdemdi_toolview_" ) + mtva->wrappedWidget() ->name();
254 TDEConfig *cfg = kapp->config();
255 TQString _grp = cfg->group();
256 cfg->setGroup(
"Shortcuts" );
258 sc = TDEShortcut( cfg->readEntry( aname,
"" ) );
259 cfg->setGroup( _grp );
260 TDEAction *a =
new ToggleToolViewAction( i18n(
"Show %1" ).arg( mtva->wrappedWidget() ->caption() ),
261 sc,
dynamic_cast<KDockWidget*
>( mtva->wrapperWidget() ),
262 m_mdiMainFrm, actionCollection(), aname.latin1() );
263 #if KDE_IS_VERSION(3,2,90)
265 ( (
ToggleToolViewAction* ) a ) ->setCheckedState( TQString(i18n(
"Hide %1" ).arg( mtva->wrappedWidget() ->caption() )) );
268 connect( a, TQ_SIGNAL( destroyed( TQObject* ) ),
this, TQ_SLOT( actionDeleted( TQObject* ) ) );
269 m_toolViewActions.append( a );
270 m_toolMenu->insert( a );
276 void KMDIGUIClient::actionDeleted( TQObject* a )
278 m_toolViewActions.remove(
static_cast<TDEAction*
>( a ) );
284 void KMDIGUIClient::clientAdded( KXMLGUIClient *client )
286 if ( client ==
this )
291 void KMDIGUIClient::mdiModeHasBeenChangedTo( KMdi::MdiMode mode )
293 kdDebug( 760 ) <<
"KMDIGUIClient::mdiModeHasBennChangeTo" << endl;
295 if ( m_mdiModeAction )
299 case KMdi::ToplevelMode:
300 m_mdiModeAction->setCurrentItem( 0 );
302 case KMdi::ChildframeMode:
303 m_mdiModeAction->setCurrentItem( 1 );
305 case KMdi::TabPageMode:
306 m_mdiModeAction->setCurrentItem( 2 );
308 case KMdi::IDEAlMode:
309 m_mdiModeAction->setCurrentItem( 3 );
void addToolView(KMdiToolViewAccessor *)
Add a new tool view to this KMDIGUIClient.
Base class for all your special main frames.