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

tdeparts

mainwindow.cpp

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

tdeparts

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

tdeparts

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