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

tdeparts

  • tdeparts
mainwindow.cpp
1 /* This file is part of the KDE project
2  Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
3  (C) 1999 David Faure <faure@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include <tdeparts/mainwindow.h>
22 #include <tdeparts/event.h>
23 #include <tdeparts/part.h>
24 #include <tdeparts/plugin.h>
25 #include <kinstance.h>
26 #include <kstatusbar.h>
27 #include <khelpmenu.h>
28 #include <kstandarddirs.h>
29 #include <tqapplication.h>
30 #include <kxmlguifactory.h>
31 
32 #include <tdeaccel.h>
33 #include <kdebug.h>
34 
35 #include <assert.h>
36 
37 using namespace KParts;
38 
39 namespace KParts
40 {
41 class MainWindowPrivate
42 {
43 public:
44  MainWindowPrivate()
45  {
46  m_activePart = 0;
47  m_bShellGUIActivated = false;
48  m_helpMenu = 0;
49  }
50  ~MainWindowPrivate()
51  {
52  }
53 
54  TQGuardedPtr<Part> m_activePart;
55  bool m_bShellGUIActivated;
56  KHelpMenu *m_helpMenu;
57 };
58 }
59 
60 MainWindow::MainWindow( TQWidget* parent, const char *name, WFlags f )
61  : TDEMainWindow( parent, name, f )
62 {
63  d = new MainWindowPrivate();
64  PartBase::setPartObject( this );
65 }
66 
67 MainWindow::MainWindow( const char *name, WFlags f )
68  : TDEMainWindow( 0L, name, f )
69 {
70  d = new MainWindowPrivate();
71  PartBase::setPartObject( this );
72 }
73 
74 MainWindow::MainWindow( int cflags, TQWidget* parent, const char *name, WFlags f )
75  : TDEMainWindow( cflags, parent, name, f )
76 {
77  d = new MainWindowPrivate();
78  PartBase::setPartObject( this );
79 }
80 
81 MainWindow::~MainWindow()
82 {
83  delete d;
84 }
85 
86 void MainWindow::createGUI( Part * part )
87 {
88  kdDebug(1000) << "MainWindow::createGUI, part=" << part << " " << ( part ? part->className() : "" )
89  << " " << ( part ? part->name() : "" )
90  << endl;
91 
92  KXMLGUIFactory *factory = guiFactory();
93 
94  assert( factory );
95 
96  setUpdatesEnabled( false );
97 
98  TQPtrList<Plugin> plugins;
99 
100  if ( d->m_activePart )
101  {
102  kdDebug(1000) << "deactivating GUI for " << d->m_activePart << " " << d->m_activePart->className()
103  << " " << d->m_activePart->name() << endl;
104 
105  GUIActivateEvent ev( false );
106  TQApplication::sendEvent( d->m_activePart, &ev );
107 
108  factory->removeClient( d->m_activePart );
109 
110  disconnect( d->m_activePart, TQ_SIGNAL( setWindowCaption( const TQString & ) ),
111  this, TQ_SLOT( setCaption( const TQString & ) ) );
112  disconnect( d->m_activePart, TQ_SIGNAL( setStatusBarText( const TQString & ) ),
113  this, TQ_SLOT( slotSetStatusBarText( const TQString & ) ) );
114  }
115 
116  if ( !d->m_bShellGUIActivated )
117  {
118  loadPlugins( this, this, TDEGlobal::instance() );
119  createShellGUI();
120  d->m_bShellGUIActivated = true;
121  }
122 
123  if ( part )
124  {
125  // do this before sending the activate event
126  connect( part, TQ_SIGNAL( setWindowCaption( const TQString & ) ),
127  this, TQ_SLOT( setCaption( const TQString & ) ) );
128  connect( part, TQ_SIGNAL( setStatusBarText( const TQString & ) ),
129  this, TQ_SLOT( slotSetStatusBarText( const TQString & ) ) );
130 
131  factory->addClient( part );
132 
133  GUIActivateEvent ev( true );
134  TQApplication::sendEvent( part, &ev );
135 
136  if ( autoSaveSettings() )
137  applyMainWindowSettings( TDEGlobal::config(), autoSaveGroup() );
138  }
139 
140  setUpdatesEnabled( true );
141 
142  d->m_activePart = part;
143 }
144 
145 void MainWindow::slotSetStatusBarText( const TQString & text )
146 {
147  statusBar()->message( text );
148 }
149 
150 void MainWindow::createShellGUI( bool create )
151 {
152  bool bAccelAutoUpdate = accel()->setAutoUpdate( false );
153  assert( d->m_bShellGUIActivated != create );
154  d->m_bShellGUIActivated = create;
155  if ( create )
156  {
157  if ( isHelpMenuEnabled() && !d->m_helpMenu )
158  d->m_helpMenu = new KHelpMenu( this, instance()->aboutData(), true, actionCollection() );
159 
160  TQString f = xmlFile();
161  setXMLFile( locate( "config", "ui/ui_standards.rc", instance() ) );
162  if ( !f.isEmpty() )
163  setXMLFile( f, true );
164  else
165  {
166  TQString auto_file( instance()->instanceName() + "ui.rc" );
167  setXMLFile( auto_file, true );
168  }
169 
170  GUIActivateEvent ev( true );
171  TQApplication::sendEvent( this, &ev );
172 
173  guiFactory()->addClient( this );
174  }
175  else
176  {
177  GUIActivateEvent ev( false );
178  TQApplication::sendEvent( this, &ev );
179 
180  guiFactory()->removeClient( this );
181  }
182  accel()->setAutoUpdate( bAccelAutoUpdate );
183 }
184 
185 void KParts::MainWindow::saveNewToolbarConfig()
186 {
187  createGUI( d->m_activePart );
188  applyMainWindowSettings( TDEGlobal::config() );
189 }
190 
191 #include "mainwindow.moc"
KHelpMenu
KParts::GUIActivateEvent
This event is sent to a Part when its GUI has been activated or deactivated.
Definition: event.h:55
KParts::MainWindow::slotSetStatusBarText
virtual void slotSetStatusBarText(const TQString &)
Called when the active part wants to change the statusbar message Reimplement if your mainwindow has ...
Definition: mainwindow.cpp:145
KParts::MainWindow::saveNewToolbarConfig
void saveNewToolbarConfig()
Rebuilds the GUI after KEditToolbar changed the toolbar layout.
Definition: mainwindow.cpp:185
KParts::MainWindow::~MainWindow
virtual ~MainWindow()
Destructor.
Definition: mainwindow.cpp:81
KParts::MainWindow::MainWindow
MainWindow(TQWidget *parent, const char *name=0L, WFlags f=(WFlags)(WType_TopLevel|WDestructiveClose))
Constructor, same signature as TDEMainWindow.
Definition: mainwindow.cpp:60
KParts::MainWindow::createGUI
void createGUI(KParts::Part *part)
Create the GUI (by merging the host's and the active part's) You must call this in order to see any G...
Definition: mainwindow.cpp:86
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::config
static TDEConfig * config()
TDEGlobal::instance
static TDEInstance * instance()
TDEMainWindow
TDEMainWindow::statusBar
KStatusBar * statusBar()
TDEMainWindow::accel
TDEAccel * accel()
TDEMainWindow::setCaption
virtual void setCaption(const TQString &caption)
TDEMainWindow::autoSaveSettings
bool autoSaveSettings() const
TDEMainWindow::isHelpMenuEnabled
bool isHelpMenuEnabled()
TDEMainWindow::applyMainWindowSettings
void applyMainWindowSettings(TDEConfig *config, const TQString &groupName, bool force)
TDEMainWindow::autoSaveGroup
TQString autoSaveGroup() const
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.