• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDE3Support

  • sources
  • kde-4.14
  • kdelibs
  • kde3support
  • kparts
dockmainwindow3.cpp
Go to the documentation of this file.
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 "dockmainwindow3.h"
23 #include <kparts/event.h>
24 #include <kparts/part.h>
25 #include <kparts/plugin.h>
26 #include <kstatusbar.h>
27 #include <kcomponentdata.h>
28 #include <khelpmenu.h>
29 #include <kstandarddirs.h>
30 #include <QtGui/QApplication>
31 
32 #include <kdebug.h>
33 #include <kxmlguifactory.h>
34 
35 #include <assert.h>
36 
37 using namespace KParts;
38 
39 namespace KParts
40 {
41 class DockMainWindow3Private
42 {
43 public:
44  DockMainWindow3Private()
45  {
46  m_activePart = 0;
47  m_bShellGUIActivated = false;
48  m_helpMenu = 0;
49  }
50  ~DockMainWindow3Private()
51  {
52  }
53 
54  QPointer<Part> m_activePart;
55  bool m_bShellGUIActivated;
56  KHelpMenu *m_helpMenu;
57 };
58 }
59 
60 DockMainWindow3::DockMainWindow3( QWidget* parent, const char *name, Qt::WindowFlags f )
61  : K3DockMainWindow( parent, name, f )
62 {
63  d = new DockMainWindow3Private();
64  PartBase::setPartObject( this );
65  setAttribute( Qt::WA_DeleteOnClose );
66 }
67 
68 DockMainWindow3::~DockMainWindow3()
69 {
70  delete d;
71 }
72 
73 void DockMainWindow3::createGUI( Part * part )
74 {
75  kDebug(1000) << QString("DockMainWindow3::createGUI for %1").arg(part?part->name():"0L");
76 
77  KXMLGUIFactory *factory = guiFactory();
78 
79  setUpdatesEnabled( false );
80 
81  Q3PtrList<Plugin> plugins;
82 
83  if ( d->m_activePart )
84  {
85  kDebug(1000) << QString("deactivating GUI for %1").arg(d->m_activePart->name());
86 
87  GUIActivateEvent ev( false );
88  QApplication::sendEvent( d->m_activePart, &ev );
89 
90  factory->removeClient( d->m_activePart );
91 
92  disconnect( d->m_activePart, SIGNAL(setWindowCaption(QString)),
93  this, SLOT(setCaption(QString)) );
94  disconnect( d->m_activePart, SIGNAL(setStatusBarText(QString)),
95  this, SLOT(slotSetStatusBarText(QString)) );
96  }
97 
98  if ( !d->m_bShellGUIActivated )
99  {
100  loadPlugins( this, this, KGlobal::mainComponent() );
101  createShellGUI();
102  d->m_bShellGUIActivated = true;
103  }
104 
105  if ( part )
106  {
107  // do this before sending the activate event
108  connect( part, SIGNAL(setWindowCaption(QString)),
109  this, SLOT(setCaption(QString)) );
110  connect( part, SIGNAL(setStatusBarText(QString)),
111  this, SLOT(slotSetStatusBarText(QString)) );
112 
113  factory->addClient( part );
114 
115  GUIActivateEvent ev( true );
116  QApplication::sendEvent( part, &ev );
117 
118  }
119 
120  setUpdatesEnabled( true );
121 
122  d->m_activePart = part;
123 }
124 
125 void DockMainWindow3::slotSetStatusBarText( const QString & text )
126 {
127  statusBar()->message( text );
128 }
129 
130 void DockMainWindow3::createShellGUI( bool create )
131 {
132  assert( d->m_bShellGUIActivated != create );
133  d->m_bShellGUIActivated = create;
134  if ( create )
135  {
136  if ( isHelpMenuEnabled() )
137  d->m_helpMenu = new KHelpMenu( this, componentData().aboutData(), true, actionCollection() );
138 
139  QString f = xmlFile();
140  setXMLFile( KStandardDirs::locate( "config", "ui/ui_standards.rc", componentData() ) );
141  if ( !f.isEmpty() )
142  setXMLFile( f, true );
143  else
144  {
145  QString auto_file( componentData().componentName() + "ui.rc" );
146  setXMLFile( auto_file, true );
147  }
148 
149  GUIActivateEvent ev( true );
150  QApplication::sendEvent( this, &ev );
151 
152  guiFactory()->addClient( this );
153 
154  }
155  else
156  {
157  GUIActivateEvent ev( false );
158  QApplication::sendEvent( this, &ev );
159 
160  guiFactory()->removeClient( this );
161  }
162 }
163 
164 #include "dockmainwindow3.moc"
QWidget
QWidget::create
void create(WId window, bool initializeWindow, bool destroyOldWindow)
KXMLGUIClient::actionCollection
virtual KActionCollection * actionCollection() const
kdebug.h
KXMLGUIFactory::removeClient
void removeClient(KXMLGUIClient *client)
KStandardDirs::locate
static QString locate(const char *type, const QString &filename, const KComponentData &cData=KGlobal::mainComponent())
KXMLGUIFactory::addClient
void addClient(KXMLGUIClient *client)
QPointer
plugin.h
kxmlguifactory.h
QWidget::setAttribute
void setAttribute(Qt::WidgetAttribute attribute, bool on)
KXMLGUIClient::setXMLFile
virtual void setXMLFile(const QString &file, bool merge=false, bool setXMLDoc=true)
KXMLGUIClient::factory
KXMLGUIFactory * factory() const
Q3PtrList
KXMLGUIClient::xmlFile
virtual QString xmlFile() const
KParts::Part
kstatusbar.h
kDebug
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
QObject::disconnect
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
K3DockMainWindow
A special kind of KMainWindow that is able to have dockwidget child widgets (and member of the dockwi...
Definition: k3dockwidget.h:1278
QObject::name
const char * name() const
KHelpMenu
KParts::DockMainWindow3::DockMainWindow3
DockMainWindow3(QWidget *parent=0L, const char *name=0L, Qt::WindowFlags f=0)
Constructor, same signature as K3DockMainWindow3.
Definition: dockmainwindow3.cpp:60
QStatusBar::message
void message(const QString &message, int timeout)
KXMLGUIClient::componentData
virtual KComponentData componentData() const
QWidget::setUpdatesEnabled
void setUpdatesEnabled(bool enable)
KParts::DockMainWindow3::slotSetStatusBarText
virtual void slotSetStatusBarText(const QString &)
Called when the active part wants to change the statusbar message Reimplement if your dock-mainwindow...
Definition: dockmainwindow3.cpp:125
khelpmenu.h
QString::isEmpty
bool isEmpty() const
QCoreApplication::sendEvent
bool sendEvent(QObject *receiver, QEvent *event)
QString
KParts::GUIActivateEvent
KMainWindow::setCaption
virtual void setCaption(const QString &caption)
KXmlGuiWindow::guiFactory
virtual KXMLGUIFactory * guiFactory()
KXMLGUIFactory
KParts::DockMainWindow3::~DockMainWindow3
virtual ~DockMainWindow3()
Destructor.
Definition: dockmainwindow3.cpp:68
event.h
dockmainwindow3.h
KMainWindow::statusBar
KStatusBar * statusBar()
KParts::DockMainWindow3::createGUI
void createGUI(KParts::Part *part)
Create the GUI (by merging the host's and the active part's)
Definition: dockmainwindow3.cpp:73
kstandarddirs.h
KGlobal::mainComponent
const KComponentData & mainComponent()
Qt::WindowFlags
typedef WindowFlags
KParts::DockMainWindow3::createShellGUI
virtual void createShellGUI(bool create=true)
Definition: dockmainwindow3.cpp:130
kcomponentdata.h
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
KXmlGuiWindow::isHelpMenuEnabled
bool isHelpMenuEnabled() const
part.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:26:47 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDE3Support

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal