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

kparts

  • kparts
dockmainwindow.cpp
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>
5 
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.
10 
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.
15 
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.
20 */
21 
22 #include <kparts/dockmainwindow.h>
23 #include <kparts/event.h>
24 #include <kparts/part.h>
25 #include <kaccel.h>
26 #include <kparts/plugin.h>
27 #include <kstatusbar.h>
28 #include <kinstance.h>
29 #include <khelpmenu.h>
30 #include <kstandarddirs.h>
31 #include <tqapplication.h>
32 
33 #include <kdebug.h>
34 #include <kxmlguifactory.h>
35 
36 #include <assert.h>
37 
38 using namespace KParts;
39 
40 namespace KParts
41 {
42 class DockMainWindowPrivate
43 {
44 public:
45  DockMainWindowPrivate()
46  {
47  m_activePart = 0;
48  m_bShellGUIActivated = false;
49  m_helpMenu = 0;
50  }
51  ~DockMainWindowPrivate()
52  {
53  }
54 
55  TQGuardedPtr<Part> m_activePart;
56  bool m_bShellGUIActivated;
57  KHelpMenu *m_helpMenu;
58 };
59 }
60 
61 DockMainWindow::DockMainWindow( TQWidget* parent, const char *name, WFlags f )
62  : KDockMainWindow( parent, name, f )
63 {
64  d = new DockMainWindowPrivate();
65  PartBase::setPartObject( TQT_TQOBJECT(this) );
66 }
67 
68 DockMainWindow::~DockMainWindow()
69 {
70  delete d;
71 }
72 
73 void DockMainWindow::createGUI( Part * part )
74 {
75  kdDebug(1000) << TQString(TQString("DockMainWindow::createGUI for %1").arg(part?part->name():"0L")) << endl;
76 
77  KXMLGUIFactory *factory = guiFactory();
78 
79  setUpdatesEnabled( false );
80 
81  TQPtrList<Plugin> plugins;
82 
83  if ( d->m_activePart )
84  {
85  kdDebug(1000) << TQString(TQString("deactivating GUI for %1").arg(d->m_activePart->name())) << endl;
86 
87  GUIActivateEvent ev( false );
88  TQApplication::sendEvent( d->m_activePart, &ev );
89 
90  factory->removeClient( d->m_activePart );
91 
92  disconnect( d->m_activePart, TQT_SIGNAL( setWindowCaption( const TQString & ) ),
93  this, TQT_SLOT( setCaption( const TQString & ) ) );
94  disconnect( d->m_activePart, TQT_SIGNAL( setStatusBarText( const TQString & ) ),
95  this, TQT_SLOT( slotSetStatusBarText( const TQString & ) ) );
96  }
97 
98  if ( !d->m_bShellGUIActivated )
99  {
100  loadPlugins( TQT_TQOBJECT(this), this, KGlobal::instance() );
101  createShellGUI();
102  d->m_bShellGUIActivated = true;
103  }
104 
105  if ( part )
106  {
107  // do this before sending the activate event
108  connect( part, TQT_SIGNAL( setWindowCaption( const TQString & ) ),
109  this, TQT_SLOT( setCaption( const TQString & ) ) );
110  connect( part, TQT_SIGNAL( setStatusBarText( const TQString & ) ),
111  this, TQT_SLOT( slotSetStatusBarText( const TQString & ) ) );
112 
113  factory->addClient( part );
114 
115  GUIActivateEvent ev( true );
116  TQApplication::sendEvent( part, &ev );
117 
118  }
119 
120  setUpdatesEnabled( true );
121 
122  d->m_activePart = part;
123 }
124 
125 void DockMainWindow::slotSetStatusBarText( const TQString & text )
126 {
127  statusBar()->message( text );
128 }
129 
130 void DockMainWindow::createShellGUI( bool create )
131 {
132  bool bAccelAutoUpdate = accel()->setAutoUpdate( false );
133  assert( d->m_bShellGUIActivated != create );
134  d->m_bShellGUIActivated = create;
135  if ( create )
136  {
137  if ( isHelpMenuEnabled() )
138  d->m_helpMenu = new KHelpMenu( this, instance()->aboutData(), true, actionCollection() );
139 
140  TQString f = xmlFile();
141  setXMLFile( locate( "config", "ui/ui_standards.rc", instance() ) );
142  if ( !f.isEmpty() )
143  setXMLFile( f, true );
144  else
145  {
146  TQString auto_file( instance()->instanceName() + "ui.rc" );
147  setXMLFile( auto_file, true );
148  }
149 
150  GUIActivateEvent ev( true );
151  TQApplication::sendEvent( this, &ev );
152 
153  guiFactory()->addClient( this );
154 
155  }
156  else
157  {
158  GUIActivateEvent ev( false );
159  TQApplication::sendEvent( this, &ev );
160 
161  guiFactory()->removeClient( this );
162  }
163  accel()->setAutoUpdate( bAccelAutoUpdate );
164 }
165 
166 #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

kparts

Skip menu "kparts"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kparts by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |