1 /* This file is part of the KDE project
2 Copyright (C) 2000 Falk Brettschneider <gigafalk@yahoo.com>
3 (C) 1999 Simon Hausmann <hausmann@kde.org>
4 (C) 1999 David Faure <faure@kde.org>
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 as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
22 #include "dockmainwindow3.h"
23 #include <kparts/event.h>
24 #include <kparts/part.h>
25 #include <kparts/plugin.h>
26 #include <kstatusbar.h>
27 #include <kcomponentdata.h>
28 #include <khelpmenu.h>
29 #include <kstandarddirs.h>
30 #include <QtGui/QApplication>
33 #include <kxmlguifactory.h>
37 using namespace KParts
;
41 class DockMainWindow3Private
44 DockMainWindow3Private()
47 m_bShellGUIActivated
= false;
50 ~DockMainWindow3Private()
54 QPointer
<Part
> m_activePart
;
55 bool m_bShellGUIActivated
;
56 KHelpMenu
*m_helpMenu
;
60 DockMainWindow3::DockMainWindow3( QWidget
* parent
, const char *name
, Qt::WFlags f
)
61 : K3DockMainWindow( parent
, name
, f
)
63 d
= new DockMainWindow3Private();
64 PartBase::setPartObject( this );
65 setAttribute( Qt::WA_DeleteOnClose
);
68 DockMainWindow3::~DockMainWindow3()
73 void DockMainWindow3::createGUI( Part
* part
)
75 kDebug(1000) << QString("DockMainWindow3::createGUI for %1").arg(part
?part
->name():"0L");
77 KXMLGUIFactory
*factory
= guiFactory();
79 setUpdatesEnabled( false );
81 Q3PtrList
<Plugin
> plugins
;
83 if ( d
->m_activePart
)
85 kDebug(1000) << QString("deactivating GUI for %1").arg(d
->m_activePart
->name());
87 GUIActivateEvent
ev( false );
88 QApplication::sendEvent( d
->m_activePart
, &ev
);
90 factory
->removeClient( d
->m_activePart
);
92 disconnect( d
->m_activePart
, SIGNAL( setWindowCaption( const QString
& ) ),
93 this, SLOT( setCaption( const QString
& ) ) );
94 disconnect( d
->m_activePart
, SIGNAL( setStatusBarText( const QString
& ) ),
95 this, SLOT( slotSetStatusBarText( const QString
& ) ) );
98 if ( !d
->m_bShellGUIActivated
)
100 loadPlugins( this, this, KGlobal::mainComponent() );
102 d
->m_bShellGUIActivated
= true;
107 // do this before sending the activate event
108 connect( part
, SIGNAL( setWindowCaption( const QString
& ) ),
109 this, SLOT( setCaption( const QString
& ) ) );
110 connect( part
, SIGNAL( setStatusBarText( const QString
& ) ),
111 this, SLOT( slotSetStatusBarText( const QString
& ) ) );
113 factory
->addClient( part
);
115 GUIActivateEvent
ev( true );
116 QApplication::sendEvent( part
, &ev
);
120 setUpdatesEnabled( true );
122 d
->m_activePart
= part
;
125 void DockMainWindow3::slotSetStatusBarText( const QString
& text
)
127 statusBar()->message( text
);
130 void DockMainWindow3::createShellGUI( bool create
)
132 assert( d
->m_bShellGUIActivated
!= create
);
133 d
->m_bShellGUIActivated
= create
;
136 if ( isHelpMenuEnabled() )
137 d
->m_helpMenu
= new KHelpMenu( this, componentData().aboutData(), true, actionCollection() );
139 QString f
= xmlFile();
140 setXMLFile( KStandardDirs::locate( "config", "ui/ui_standards.rc", componentData() ) );
142 setXMLFile( f
, true );
145 QString
auto_file( componentData().componentName() + "ui.rc" );
146 setXMLFile( auto_file
, true );
149 GUIActivateEvent
ev( true );
150 QApplication::sendEvent( this, &ev
);
152 guiFactory()->addClient( this );
157 GUIActivateEvent
ev( false );
158 QApplication::sendEvent( this, &ev
);
160 guiFactory()->removeClient( this );
164 #include "dockmainwindow3.moc"