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

kparts

  • kparts
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 <kparts/mainwindow.h>
22 #include <kparts/event.h>
23 #include <kparts/part.h>
24 #include <kparts/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 <kaccel.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  : KMainWindow( parent, name, f )
62 {
63  d = new MainWindowPrivate();
64  PartBase::setPartObject( TQT_TQOBJECT(this) );
65 }
66 
67 MainWindow::MainWindow( const char *name, WFlags f )
68  : KMainWindow( 0L, name, f )
69 {
70  d = new MainWindowPrivate();
71  PartBase::setPartObject( TQT_TQOBJECT(this) );
72 }
73 
74 MainWindow::MainWindow( int cflags, TQWidget* parent, const char *name, WFlags f )
75  : KMainWindow( cflags, parent, name, f )
76 {
77  d = new MainWindowPrivate();
78  PartBase::setPartObject( TQT_TQOBJECT(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, TQT_SIGNAL( setWindowCaption( const TQString & ) ),
111  this, TQT_SLOT( setCaption( const TQString & ) ) );
112  disconnect( d->m_activePart, TQT_SIGNAL( setStatusBarText( const TQString & ) ),
113  this, TQT_SLOT( slotSetStatusBarText( const TQString & ) ) );
114  }
115 
116  if ( !d->m_bShellGUIActivated )
117  {
118  loadPlugins( TQT_TQOBJECT(this), this, KGlobal::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, TQT_SIGNAL( setWindowCaption( const TQString & ) ),
127  this, TQT_SLOT( setCaption( const TQString & ) ) );
128  connect( part, TQT_SIGNAL( setStatusBarText( const TQString & ) ),
129  this, TQT_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( KGlobal::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( KGlobal::config() );
189 }
190 
191 #include "mainwindow.moc"
locate
TQString locate(const char *type, const TQString &filename, const KInstance *instance=KGlobal::instance())
KXMLGUIClient::setXMLFile
virtual void setXMLFile(const TQString &file, bool merge=false, bool setXMLDoc=true)
KMainWindow::applyMainWindowSettings
void applyMainWindowSettings(KConfig *config, const TQString &groupName, bool force)
KMainWindow::autoSaveGroup
TQString autoSaveGroup() const
KParts::MainWindow::createGUI
void createGUI(KParts::Part *part)
Create the GUI (by merging the host&#39;s and the active part&#39;s) You must call this in order to see any G...
Definition: mainwindow.cpp:86
kdDebug
kdbgstream kdDebug(int area=0)
KParts::Part
Base class for parts.
Definition: part.h:181
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::~MainWindow
virtual ~MainWindow()
Destructor.
Definition: mainwindow.cpp:81
KAccel::setAutoUpdate
bool setAutoUpdate(bool bAuto)
KHelpMenu
KMainWindow
KMainWindow::setCaption
virtual void setCaption(const TQString &caption)
KParts::GUIActivateEvent
This event is sent to a Part when its GUI has been activated or deactivated.
Definition: event.h:54
KGlobal::instance
static KInstance * instance()
KParts::MainWindow::MainWindow
MainWindow(TQWidget *parent, const char *name=0L, WFlags f=(WFlags)(WType_TopLevel|WDestructiveClose))
Constructor, same signature as KMainWindow.
Definition: mainwindow.cpp:60
KMainWindow::accel
KAccel * accel()
KXMLGUIClient::factory
KXMLGUIFactory * factory() const
KXMLGUIFactory
KXMLGUIClient::xmlFile
virtual TQString xmlFile() const
KParts::PartBase::loadPlugins
void loadPlugins(TQObject *parent, KXMLGUIClient *parentGUIClient, KInstance *instance)
Load the Plugins honoring the PluginLoadingMode.
Definition: part.cpp:122
KMainWindow::isHelpMenuEnabled
bool isHelpMenuEnabled()
KMainWindow::statusBar
KStatusBar * statusBar()
KXMLGUIClient::actionCollection
virtual KActionCollection * actionCollection() const
endl
kndbgstream & endl(kndbgstream &s)
KXMLGUIClient::instance
virtual KInstance * instance() const
KParts::MainWindow::saveNewToolbarConfig
void saveNewToolbarConfig()
Rebuilds the GUI after KEditToolbar changed the toolbar layout.
Definition: mainwindow.cpp:185
KMainWindow::autoSaveSettings
bool autoSaveSettings() const
KParts
Definition: browserextension.cpp:64
KGlobal::config
static KConfig * config()
KParts::PartBase::setPartObject
void setPartObject(TQObject *object)
Internal method.
Definition: part.cpp:95

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.13
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |