• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KParts

dockmainwindow.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2000 Falk Brettschneider <gigafalk@yahoo.com>
00003              (C) 1999 Simon Hausmann <hausmann@kde.org>
00004              (C) 1999 David Faure <faure@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 as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019    Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include <kparts/dockmainwindow.h>
00023 #include <kparts/event.h>
00024 #include <kparts/part.h>
00025 #include <kaccel.h>
00026 #include <kparts/plugin.h>
00027 #include <kstatusbar.h>
00028 #include <kinstance.h>
00029 #include <khelpmenu.h>
00030 #include <kstandarddirs.h>
00031 #include <qapplication.h>
00032 
00033 #include <kdebug.h>
00034 #include <kxmlguifactory.h>
00035 
00036 #include <assert.h>
00037 
00038 using namespace KParts;
00039 
00040 namespace KParts
00041 {
00042 class DockMainWindowPrivate
00043 {
00044 public:
00045   DockMainWindowPrivate()
00046   {
00047     m_activePart = 0;
00048     m_bShellGUIActivated = false;
00049     m_helpMenu = 0;
00050   }
00051   ~DockMainWindowPrivate()
00052   {
00053   }
00054 
00055   QGuardedPtr<Part> m_activePart;
00056   bool m_bShellGUIActivated;
00057   KHelpMenu *m_helpMenu;
00058 };
00059 }
00060 
00061 DockMainWindow::DockMainWindow( QWidget* parent, const char *name, WFlags f )
00062   : KDockMainWindow( parent, name, f )
00063 {
00064   d = new DockMainWindowPrivate();
00065   PartBase::setPartObject( this );
00066 }
00067 
00068 DockMainWindow::~DockMainWindow()
00069 {
00070   delete d;
00071 }
00072 
00073 void DockMainWindow::createGUI( Part * part )
00074 {
00075   kdDebug(1000) << QString("DockMainWindow::createGUI for %1").arg(part?part->name():"0L") << endl;
00076 
00077   KXMLGUIFactory *factory = guiFactory();
00078 
00079   setUpdatesEnabled( false );
00080 
00081   QPtrList<Plugin> plugins;
00082 
00083   if ( d->m_activePart )
00084   {
00085     kdDebug(1000) << QString("deactivating GUI for %1").arg(d->m_activePart->name()) << endl;
00086 
00087     GUIActivateEvent ev( false );
00088     QApplication::sendEvent( d->m_activePart, &ev );
00089 
00090     factory->removeClient( d->m_activePart );
00091 
00092     disconnect( d->m_activePart, SIGNAL( setWindowCaption( const QString & ) ),
00093              this, SLOT( setCaption( const QString & ) ) );
00094     disconnect( d->m_activePart, SIGNAL( setStatusBarText( const QString & ) ),
00095              this, SLOT( slotSetStatusBarText( const QString & ) ) );
00096   }
00097 
00098   if ( !d->m_bShellGUIActivated )
00099   {
00100     loadPlugins( this, this, KGlobal::instance() );
00101     createShellGUI();
00102     d->m_bShellGUIActivated = true;
00103   }
00104 
00105   if ( part )
00106   {
00107     // do this before sending the activate event
00108     connect( part, SIGNAL( setWindowCaption( const QString & ) ),
00109              this, SLOT( setCaption( const QString & ) ) );
00110     connect( part, SIGNAL( setStatusBarText( const QString & ) ),
00111              this, SLOT( slotSetStatusBarText( const QString & ) ) );
00112 
00113     factory->addClient( part );
00114 
00115     GUIActivateEvent ev( true );
00116     QApplication::sendEvent( part, &ev );
00117 
00118   }
00119 
00120   setUpdatesEnabled( true );
00121 
00122   d->m_activePart = part;
00123 }
00124 
00125 void DockMainWindow::slotSetStatusBarText( const QString & text )
00126 {
00127   statusBar()->message( text );
00128 }
00129 
00130 void DockMainWindow::createShellGUI( bool create )
00131 {
00132     bool bAccelAutoUpdate = accel()->setAutoUpdate( false );
00133     assert( d->m_bShellGUIActivated != create );
00134     d->m_bShellGUIActivated = create;
00135     if ( create )
00136     {
00137         if ( isHelpMenuEnabled() )
00138             d->m_helpMenu = new KHelpMenu( this, instance()->aboutData(), true, actionCollection() );
00139 
00140         QString f = xmlFile();
00141         setXMLFile( locate( "config", "ui/ui_standards.rc", instance() ) );
00142         if ( !f.isEmpty() )
00143             setXMLFile( f, true );
00144         else
00145         {
00146             QString auto_file( instance()->instanceName() + "ui.rc" );
00147             setXMLFile( auto_file, true );
00148         }
00149 
00150         GUIActivateEvent ev( true );
00151         QApplication::sendEvent( this, &ev );
00152 
00153         guiFactory()->addClient( this );
00154 
00155     }
00156     else
00157     {
00158         GUIActivateEvent ev( false );
00159         QApplication::sendEvent( this, &ev );
00160 
00161         guiFactory()->removeClient( this );
00162     }
00163     accel()->setAutoUpdate( bAccelAutoUpdate );
00164 }
00165 
00166 #include "dockmainwindow.moc"

KParts

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

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal