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

tdeparts

  • tdeparts
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 <tdeparts/dockmainwindow.h>
23 #include <tdeparts/event.h>
24 #include <tdeparts/part.h>
25 #include <tdeaccel.h>
26 #include <tdeparts/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( 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, TQ_SIGNAL( setWindowCaption( const TQString & ) ),
93  this, TQ_SLOT( setCaption( const TQString & ) ) );
94  disconnect( d->m_activePart, TQ_SIGNAL( setStatusBarText( const TQString & ) ),
95  this, TQ_SLOT( slotSetStatusBarText( const TQString & ) ) );
96  }
97 
98  if ( !d->m_bShellGUIActivated )
99  {
100  loadPlugins( this, this, TDEGlobal::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, TQ_SIGNAL( setWindowCaption( const TQString & ) ),
109  this, TQ_SLOT( setCaption( const TQString & ) ) );
110  connect( part, TQ_SIGNAL( setStatusBarText( const TQString & ) ),
111  this, TQ_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"
KDockMainWindow
KHelpMenu
KParts::DockMainWindow::slotSetStatusBarText
virtual void slotSetStatusBarText(const TQString &)
Called when the active part wants to change the statusbar message.
Definition: dockmainwindow.cpp:125
KParts::DockMainWindow::~DockMainWindow
virtual ~DockMainWindow()
Destructor.
Definition: dockmainwindow.cpp:68
KParts::DockMainWindow::createGUI
void createGUI(KParts::Part *part)
Create the GUI (by merging the host's and the active part's)
Definition: dockmainwindow.cpp:73
KParts::DockMainWindow::DockMainWindow
DockMainWindow(TQWidget *parent=0L, const char *name=0L, WFlags f=(WFlags) WDestructiveClose)
Constructor, same signature as KDockMainWindow.
Definition: dockmainwindow.cpp:61
KParts::GUIActivateEvent
This event is sent to a Part when its GUI has been activated or deactivated.
Definition: event.h:55
KParts::PartBase::loadPlugins
void loadPlugins(TQObject *parent, KXMLGUIClient *parentGUIClient, TDEInstance *instance)
Load the Plugins honoring the PluginLoadingMode.
Definition: part.cpp:122
KParts::PartBase::setPartObject
void setPartObject(TQObject *object)
Internal method.
Definition: part.cpp:95
KParts::Part
Base class for parts.
Definition: part.h:182
KXMLGUIClient::xmlFile
virtual TQString xmlFile() const
KXMLGUIClient::instance
virtual TDEInstance * instance() const
KXMLGUIClient::setXMLFile
virtual void setXMLFile(const TQString &file, bool merge=false, bool setXMLDoc=true)
KXMLGUIClient::factory
KXMLGUIFactory * factory() const
KXMLGUIClient::actionCollection
virtual TDEActionCollection * actionCollection() const
KXMLGUIFactory
KXMLGUIFactory::removeClient
void removeClient(KXMLGUIClient *client)
KXMLGUIFactory::addClient
void addClient(KXMLGUIClient *client)
TDEAccel::setAutoUpdate
bool setAutoUpdate(bool bAuto)
TDEGlobal::instance
static TDEInstance * instance()
TDEMainWindow::statusBar
KStatusBar * statusBar()
TDEMainWindow::accel
TDEAccel * accel()
TDEMainWindow::setCaption
virtual void setCaption(const TQString &caption)
TDEMainWindow::isHelpMenuEnabled
bool isHelpMenuEnabled()
endl
kndbgstream & endl(kndbgstream &s)
kdDebug
kdbgstream kdDebug(int area=0)
locate
TQString locate(const char *type, const TQString &filename, const TDEInstance *instance=TDEGlobal::instance())

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.9.1
This website is maintained by Timothy Pearson.