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

KDE3Support

dockmainwindow3.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 "dockmainwindow3.h"
00023 #include <kparts/event.h>
00024 #include <kparts/part.h>
00025 #include <kparts/plugin.h>
00026 #include <kstatusbar.h>
00027 #include <kcomponentdata.h>
00028 #include <khelpmenu.h>
00029 #include <kstandarddirs.h>
00030 #include <QtGui/QApplication>
00031 
00032 #include <kdebug.h>
00033 #include <kxmlguifactory.h>
00034 
00035 #include <assert.h>
00036 
00037 using namespace KParts;
00038 
00039 namespace KParts
00040 {
00041 class DockMainWindow3Private
00042 {
00043 public:
00044   DockMainWindow3Private()
00045   {
00046     m_activePart = 0;
00047     m_bShellGUIActivated = false;
00048     m_helpMenu = 0;
00049   }
00050   ~DockMainWindow3Private()
00051   {
00052   }
00053 
00054   QPointer<Part> m_activePart;
00055   bool m_bShellGUIActivated;
00056   KHelpMenu *m_helpMenu;
00057 };
00058 }
00059 
00060 DockMainWindow3::DockMainWindow3( QWidget* parent, const char *name, Qt::WFlags f )
00061     : K3DockMainWindow( parent, name, f )
00062 {
00063     d = new DockMainWindow3Private();
00064     PartBase::setPartObject( this );
00065     setAttribute( Qt::WA_DeleteOnClose );
00066 }
00067 
00068 DockMainWindow3::~DockMainWindow3()
00069 {
00070   delete d;
00071 }
00072 
00073 void DockMainWindow3::createGUI( Part * part )
00074 {
00075   kDebug(1000) << QString("DockMainWindow3::createGUI for %1").arg(part?part->name():"0L");
00076 
00077   KXMLGUIFactory *factory = guiFactory();
00078 
00079   setUpdatesEnabled( false );
00080 
00081   Q3PtrList<Plugin> plugins;
00082 
00083   if ( d->m_activePart )
00084   {
00085     kDebug(1000) << QString("deactivating GUI for %1").arg(d->m_activePart->name());
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::mainComponent() );
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 DockMainWindow3::slotSetStatusBarText( const QString & text )
00126 {
00127   statusBar()->message( text );
00128 }
00129 
00130 void DockMainWindow3::createShellGUI( bool create )
00131 {
00132     assert( d->m_bShellGUIActivated != create );
00133     d->m_bShellGUIActivated = create;
00134     if ( create )
00135     {
00136         if ( isHelpMenuEnabled() )
00137             d->m_helpMenu = new KHelpMenu( this, componentData().aboutData(), true, actionCollection() );
00138 
00139         QString f = xmlFile();
00140         setXMLFile( KStandardDirs::locate( "config", "ui/ui_standards.rc", componentData() ) );
00141         if ( !f.isEmpty() )
00142             setXMLFile( f, true );
00143         else
00144         {
00145             QString auto_file( componentData().componentName() + "ui.rc" );
00146             setXMLFile( auto_file, true );
00147         }
00148 
00149         GUIActivateEvent ev( true );
00150         QApplication::sendEvent( this, &ev );
00151 
00152         guiFactory()->addClient( this );
00153 
00154     }
00155     else
00156     {
00157         GUIActivateEvent ev( false );
00158         QApplication::sendEvent( this, &ev );
00159 
00160         guiFactory()->removeClient( this );
00161     }
00162 }
00163 
00164 #include "dockmainwindow3.moc"

KDE3Support

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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