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

kdeui

  • kdeui
kmainwindow.cpp
1  /* This file is part of the KDE libraries
2  Copyright
3  (C) 2000 Reginald Stadlbauer (reggie@kde.org)
4  (C) 1997 Stephan Kulow (coolo@kde.org)
5  (C) 1997-2000 Sven Radej (radej@kde.org)
6  (C) 1997-2000 Matthias Ettrich (ettrich@kde.org)
7  (C) 1999 Chris Schlaeger (cs@kde.org)
8  (C) 2002 Joseph Wenninger (jowenn@kde.org)
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Library General Public
12  License version 2 as published by the Free Software Foundation.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Library General Public License for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with this library; see the file COPYING.LIB. If not, write to
21  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  Boston, MA 02110-1301, USA.
23  */
24 #include "config.h"
25 
26 #include "kmainwindow.h"
27 #include "kmainwindowiface.h"
28 #include "ktoolbarhandler.h"
29 #include "kwhatsthismanager_p.h"
30 #include <tqsessionmanager.h>
31 #include <tqobjectlist.h>
32 #include <tqstyle.h>
33 #include <tqlayout.h>
34 #include <tqwidgetlist.h>
35 #include <tqtimer.h>
36 
37 #include <kaccel.h>
38 #include <kaction.h>
39 #include <kapplication.h>
40 #include <kconfig.h>
41 #include <kdebug.h>
42 #include <khelpmenu.h>
43 #include <kmenubar.h>
44 #include <kstatusbar.h>
45 #include <kwin.h>
46 #include <kedittoolbar.h>
47 #include <kmainwindow.h>
48 
49 #include <klocale.h>
50 #include <kstandarddirs.h>
51 #include <kstaticdeleter.h>
52 #if defined Q_WS_X11
53 #include <netwm.h>
54 #endif
55 
56 #include <stdlib.h>
57 #include <ctype.h>
58 #include <assert.h>
59 
60 class KMainWindowPrivate {
61 public:
62  bool showHelpMenu:1;
63 
64  bool autoSaveSettings:1;
65  bool settingsDirty:1;
66  bool autoSaveWindowSize:1;
67  bool care_about_geometry:1;
68  bool shuttingDown:1;
69  TQString autoSaveGroup;
70  KAccel * kaccel;
71  KMainWindowInterface *m_interface;
72  KDEPrivate::ToolBarHandler *toolBarHandler;
73  TQTimer* settingsTimer;
74  KToggleAction *showStatusBarAction;
75  TQRect defaultWindowSize;
76  TQPtrList<TQDockWindow> hiddenDockWindows;
77 };
78 
79 TQPtrList<KMainWindow>* KMainWindow::memberList = 0L;
80 static bool no_query_exit = false;
81 static KMWSessionManaged* ksm = 0;
82 static KStaticDeleter<KMWSessionManaged> ksmd;
83 
84 class KMWSessionManaged : public KSessionManaged
85 {
86 public:
87  KMWSessionManaged()
88  {
89  }
90  ~KMWSessionManaged()
91  {
92  }
93  bool saveState( QSessionManager& )
94  {
95  KConfig* config = KApplication::kApplication()->sessionConfig();
96  if ( KMainWindow::memberList->first() ){
97  // According to Jochen Wilhelmy <digisnap@cs.tu-berlin.de>, this
98  // hook is useful for better document orientation
99  KMainWindow::memberList->first()->saveGlobalProperties(config);
100  }
101 
102  TQPtrListIterator<KMainWindow> it(*KMainWindow::memberList);
103  int n = 0;
104  for (it.toFirst(); it.current(); ++it){
105  n++;
106  it.current()->savePropertiesInternal(config, n);
107  }
108  config->setGroup(TQString::fromLatin1("Number"));
109  config->writeEntry(TQString::fromLatin1("NumberOfWindows"), n );
110  return true;
111  }
112 
113  bool commitData( QSessionManager& sm )
114  {
115  // not really a fast method but the only compatible one
116  if ( sm.allowsInteraction() ) {
117  bool canceled = false;
118  TQPtrListIterator<KMainWindow> it(*KMainWindow::memberList);
119  ::no_query_exit = true;
120  for (it.toFirst(); it.current() && !canceled;){
121  KMainWindow *window = *it;
122  ++it; // Update now, the current window might get deleted
123  if ( !window->testWState( TQt::WState_ForceHide ) ) {
124  TQCloseEvent e;
125  TQApplication::sendEvent( window, &e );
126  canceled = !e.isAccepted();
127  /* Don't even think_about deleting widgets with
128  Qt::WDestructiveClose flag set at this point. We
129  are faking a close event, but we are *not*_
130  closing the window. The purpose of the faked
131  close event is to prepare the application so it
132  can safely be quit without the user losing data
133  (possibly showing a message box "do you want to
134  save this or that?"). It is possible that the
135  session manager quits the application later
136  (emitting TQApplication::aboutToQuit() when this
137  happens), but it is also possible that the user
138  cancels the shutdown, so the application will
139  continue to run.
140  */
141  }
142  }
143  ::no_query_exit = false;
144  if (canceled)
145  return false;
146 
147  KMainWindow* last = 0;
148  for (it.toFirst(); it.current() && !canceled; ++it){
149  KMainWindow *window = *it;
150  if ( !window->testWState( TQt::WState_ForceHide ) ) {
151  last = window;
152  }
153  }
154  if ( last )
155  return last->queryExit();
156  // else
157  return true;
158  }
159 
160  // the user wants it, the user gets it
161  return true;
162  }
163 };
164 
165 static bool being_first = true;
166 
167 KMainWindow::KMainWindow( TQWidget* parent, const char *name, WFlags f )
168  : TQMainWindow( parent, name, f ), KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )
169 {
170  initKMainWindow(name, 0);
171 }
172 
173 KMainWindow::KMainWindow( int cflags, TQWidget* parent, const char *name, WFlags f )
174  : TQMainWindow( parent, name, f ), KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )
175 {
176  initKMainWindow(name, cflags);
177 }
178 
179 void KMainWindow::initKMainWindow(const char *name, int cflags)
180 {
181  KWhatsThisManager::init ();
182  setDockMenuEnabled( false );
183  mHelpMenu = 0;
184  kapp->setTopWidget( this );
185  actionCollection()->setWidget( this );
186  connect(kapp, TQT_SIGNAL(shutDown()), this, TQT_SLOT(shuttingDown()));
187  if( !memberList )
188  memberList = new TQPtrList<KMainWindow>;
189 
190  if ( !ksm )
191  ksm = ksmd.setObject(ksm, new KMWSessionManaged());
192  // set a unique object name. Required by session management.
193  TQCString objname;
194  TQCString s;
195  int unusedNumber;
196  if ( !name )
197  { // no name given
198  objname = kapp->instanceName() + "-mainwindow#";
199  s = objname + '1'; // start adding number immediately
200  unusedNumber = 1;
201  }
202  else if( name[0] != '\0' && name[ strlen( name ) - 1 ] == '#' )
203  { // trailing # - always add a number
204  objname = name;
205  s = objname + '1'; // start adding number immediately
206  unusedNumber = 1;
207  }
208  else
209  {
210  objname = name;
211  s = objname;
212  unusedNumber = 0; // add numbers only when needed
213  }
214  for(;;) {
215  TQWidgetList* list = kapp->topLevelWidgets();
216  TQWidgetListIt it( *list );
217  bool found = false;
218  for( TQWidget* w = it.current();
219  w != NULL;
220  ++it, w = it.current())
221  if( w != this && w->name() == s )
222  {
223  found = true;
224  break;
225  }
226  delete list;
227  if( !found )
228  break;
229  s.setNum( ++unusedNumber );
230  s = objname + s;
231  }
232  setName( s );
233 
234  memberList->append( this );
235 
236  d = new KMainWindowPrivate;
237  d->showHelpMenu = true;
238  d->settingsDirty = false;
239  d->autoSaveSettings = false;
240  d->autoSaveWindowSize = true; // for compatibility
241  d->kaccel = actionCollection()->kaccel();
242  d->toolBarHandler = 0;
243  d->settingsTimer = 0;
244  d->showStatusBarAction = NULL;
245  d->shuttingDown = false;
246  if ((d->care_about_geometry = being_first)) {
247  being_first = false;
248  if ( kapp->geometryArgument().isNull() ) // if there is no geometry, it doesn't mater
249  d->care_about_geometry = false;
250  else
251  parseGeometry(false);
252  }
253 
254  setCaption( kapp->caption() );
255  if ( cflags & NoDCOPObject)
256  d->m_interface = 0;
257  else
258  d->m_interface = new KMainWindowInterface(this);
259 
260  if (!kapp->authorize("movable_toolbars"))
261  setDockWindowsMovable(false);
262 }
263 
264 KAction *KMainWindow::toolBarMenuAction()
265 {
266  if ( !d->toolBarHandler )
267  return 0;
268 
269  return d->toolBarHandler->toolBarMenuAction();
270 }
271 
272 
273 void KMainWindow::setupToolbarMenuActions()
274 {
275  if ( d->toolBarHandler )
276  d->toolBarHandler->setupActions();
277 }
278 
279 void KMainWindow::parseGeometry(bool parsewidth)
280 {
281  assert ( !kapp->geometryArgument().isNull() );
282  assert ( d->care_about_geometry );
283 
284 #if defined Q_WS_X11
285  int x, y;
286  int w, h;
287  int m = XParseGeometry( kapp->geometryArgument().latin1(), &x, &y, (unsigned int*)&w, (unsigned int*)&h);
288  if (parsewidth) {
289  TQSize minSize = minimumSize();
290  TQSize maxSize = maximumSize();
291  if ( !(m & WidthValue) )
292  w = width();
293  if ( !(m & HeightValue) )
294  h = height();
295  w = QMIN(w,maxSize.width());
296  h = QMIN(h,maxSize.height());
297  w = QMAX(w,minSize.width());
298  h = QMAX(h,minSize.height());
299  resize(w, h);
300  } else {
301  if ( parsewidth && !(m & XValue) )
302  x = geometry().x();
303  if ( parsewidth && !(m & YValue) )
304  y = geometry().y();
305  if ( (m & XNegative) )
306  x = KApplication::desktop()->width() + x - w;
307  if ( (m & YNegative) )
308  y = KApplication::desktop()->height() + y - h;
309  move(x, y);
310  }
311 #endif
312 }
313 
314 KMainWindow::~KMainWindow()
315 {
316  delete d->settingsTimer;
317  TQMenuBar* mb = internalMenuBar();
318  delete mb;
319  delete d->m_interface;
320  delete d;
321  memberList->remove( this );
322 }
323 
324 KPopupMenu* KMainWindow::helpMenu( const TQString &aboutAppText, bool showWhatsThis )
325 {
326  if( !mHelpMenu ) {
327  if ( aboutAppText.isEmpty() )
328  mHelpMenu = new KHelpMenu( this, instance()->aboutData(), showWhatsThis);
329  else
330  mHelpMenu = new KHelpMenu( this, aboutAppText, showWhatsThis );
331 
332  if ( !mHelpMenu )
333  return 0;
334  connect( mHelpMenu, TQT_SIGNAL( showAboutApplication() ),
335  this, TQT_SLOT( showAboutApplication() ) );
336  }
337 
338  return mHelpMenu->menu();
339 }
340 
341 KPopupMenu* KMainWindow::customHelpMenu( bool showWhatsThis )
342 {
343  if( !mHelpMenu ) {
344  mHelpMenu = new KHelpMenu( this, TQString::null, showWhatsThis );
345  connect( mHelpMenu, TQT_SIGNAL( showAboutApplication() ),
346  this, TQT_SLOT( showAboutApplication() ) );
347  }
348 
349  return mHelpMenu->menu();
350 }
351 
352 bool KMainWindow::canBeRestored( int number )
353 {
354  if ( !kapp->isRestored() )
355  return false;
356  KConfig *config = kapp->sessionConfig();
357  if ( !config )
358  return false;
359  config->setGroup( TQString::fromLatin1("Number") );
360  int n = config->readNumEntry( TQString::fromLatin1("NumberOfWindows") , 1 );
361  return number >= 1 && number <= n;
362 }
363 
364 const TQString KMainWindow::classNameOfToplevel( int number )
365 {
366  if ( !kapp->isRestored() )
367  return TQString::null;
368  KConfig *config = kapp->sessionConfig();
369  if ( !config )
370  return TQString::null;
371  TQString s;
372  s.setNum( number );
373  s.prepend( TQString::fromLatin1("WindowProperties") );
374  config->setGroup( s );
375  if ( !config->hasKey( TQString::fromLatin1("ClassName") ) )
376  return TQString::null;
377  else
378  return config->readEntry( TQString::fromLatin1("ClassName") );
379 }
380 
381 void KMainWindow::show()
382 {
383  TQMainWindow::show();
384 
385  for ( TQPtrListIterator<TQDockWindow> it( d->hiddenDockWindows ); it.current(); ++it )
386  it.current()->show();
387 
388  d->hiddenDockWindows.clear();
389 }
390 
391 void KMainWindow::hide()
392 {
393  if ( isVisible() ) {
394 
395  d->hiddenDockWindows.clear();
396 
397  TQObjectList *list = queryList( TQDOCKWINDOW_OBJECT_NAME_STRING );
398  for( TQObjectListIt it( *list ); it.current(); ++it ) {
399  TQDockWindow *dw = (TQDockWindow*)it.current();
400  if ( dw->isTopLevel() && dw->isVisible() ) {
401  d->hiddenDockWindows.append( dw );
402  dw->hide();
403  }
404  }
405  delete list;
406  }
407 
408  TQWidget::hide();
409 }
410 
411 bool KMainWindow::restore( int number, bool show )
412 {
413  if ( !canBeRestored( number ) )
414  return false;
415  KConfig *config = kapp->sessionConfig();
416  if ( readPropertiesInternal( config, number ) ){
417  if ( show )
418  KMainWindow::show();
419  return false;
420  }
421  return false;
422 }
423 
424 KXMLGUIFactory *KMainWindow::guiFactory()
425 {
426  if ( !factory_ )
427  factory_ = new KXMLGUIFactory( this, TQT_TQOBJECT(this), "guifactory" );
428  return factory_;
429 }
430 
431 int KMainWindow::configureToolbars()
432 {
433  saveMainWindowSettings(KGlobal::config());
434  KEditToolbar dlg(actionCollection(), xmlFile(), true, this);
435  connect(&dlg, TQT_SIGNAL(newToolbarConfig()), TQT_SLOT(saveNewToolbarConfig()));
436  return dlg.exec();
437 }
438 
439 void KMainWindow::saveNewToolbarConfig()
440 {
441  createGUI(xmlFile());
442  applyMainWindowSettings( KGlobal::config() );
443 }
444 
445 void KMainWindow::setupGUI( int options, const TQString & xmlfile ) {
446  setupGUI(TQSize(), options, xmlfile);
447 }
448 
449 void KMainWindow::setupGUI( TQSize defaultSize, int options, const TQString & xmlfile ) {
450  if( options & Keys ){
451  KStdAction::keyBindings(guiFactory(),
452  TQT_SLOT(configureShortcuts()), actionCollection());
453  }
454 
455  if( (options & StatusBar) && internalStatusBar() ){
456  createStandardStatusBarAction();
457  }
458 
459  if( options & ToolBar ){
460  setStandardToolBarMenuEnabled( true );
461  KStdAction::configureToolbars(TQT_TQOBJECT(this),
462  TQT_SLOT(configureToolbars() ), actionCollection());
463  }
464 
465  if( options & Create ){
466  createGUI(xmlfile,false);
467  }
468 
469  if( options & Save ){
470  // setupGUI() is typically called in the constructor before show(),
471  // so the default window size will be incorrect unless the application
472  // hard coded the size which they should try not to do (i.e. use
473  // size hints).
474  if(initialGeometrySet())
475  {
476  // Do nothing...
477  }
478  else if(defaultSize.isValid())
479  {
480  resize(defaultSize);
481  }
482  else if(!isShown())
483  {
484  adjustSize();
485  }
486  setAutoSaveSettings();
487  }
488 
489 }
490 
491 void KMainWindow::createGUI( const TQString &xmlfile, bool _conserveMemory )
492 {
493  // disabling the updates prevents unnecessary redraws
494  setUpdatesEnabled( false );
495 
496  // just in case we are rebuilding, let's remove our old client
497  guiFactory()->removeClient( this );
498 
499  // make sure to have an empty GUI
500  TQMenuBar* mb = internalMenuBar();
501  if ( mb )
502  mb->clear();
503 
504  (void)toolBarIterator(); // make sure toolbarList is most-up-to-date
505  toolbarList.setAutoDelete( true );
506  toolbarList.clear();
507  toolbarList.setAutoDelete( false );
508 
509  // don't build a help menu unless the user ask for it
510  if (d->showHelpMenu) {
511  // we always want a help menu
512  if (!helpMenu2)
513  helpMenu2 = new KHelpMenu(this, instance()->aboutData(), true,
514  actionCollection());
515  }
516 
517  // we always want to load in our global standards file
518  setXMLFile( locate( "config", "ui/ui_standards.rc", instance() ) );
519 
520  // now, merge in our local xml file. if this is null, then that
521  // means that we will be only using the global file
522  if ( !xmlfile.isNull() ) {
523  setXMLFile( xmlfile, true );
524  } else {
525  TQString auto_file(instance()->instanceName() + "ui.rc");
526  setXMLFile( auto_file, true );
527  }
528 
529  // make sure we don't have any state saved already
530  setXMLGUIBuildDocument( TQDomDocument() );
531 
532  // do the actual GUI building
533  guiFactory()->addClient( this );
534 
535  // try and get back *some* of our memory
536  if ( _conserveMemory )
537  {
538  // before freeing the memory allocated by the DOM document we also
539  // free all memory allocated internally in the KXMLGUIFactory for
540  // the menubar and the toolbars . This however implies that we
541  // have to take care of deleting those widgets ourselves. For
542  // destruction this is no problem, but when rebuilding we have
543  // to take care of that (and we want to rebuild the GUI when
544  // using stuff like the toolbar editor ).
545  // In addition we have to take care of not removing containers
546  // like popupmenus, defined in the XML document.
547  // this code should probably go into a separate method in KMainWindow.
548  // there's just one problem: I'm bad in finding names ;-) , so
549  // I skipped this ;-)
550 
551  TQDomDocument doc = domDocument();
552 
553  for( TQDomNode n = doc.documentElement().firstChild();
554  !n.isNull(); n = n.nextSibling())
555  {
556  TQDomElement e = n.toElement();
557 
558  if ( e.tagName().lower() == "toolbar" )
559  factory_->resetContainer( e.attribute( "name" ) );
560  else if ( e.tagName().lower() == "menubar" )
561  factory_->resetContainer( e.tagName(), true );
562  }
563 
564  conserveMemory();
565  }
566 
567  setUpdatesEnabled( true );
568  updateGeometry();
569 }
570 
571 void KMainWindow::setHelpMenuEnabled(bool showHelpMenu)
572 {
573  d->showHelpMenu = showHelpMenu;
574 }
575 
576 bool KMainWindow::isHelpMenuEnabled()
577 {
578  return d->showHelpMenu;
579 }
580 
581 void KMainWindow::setCaption( const TQString &caption )
582 {
583  setPlainCaption( kapp->makeStdCaption(caption) );
584 }
585 
586 void KMainWindow::setCaption( const TQString &caption, bool modified )
587 {
588  setPlainCaption( kapp->makeStdCaption(caption, true, modified) );
589 }
590 
591 void KMainWindow::setPlainCaption( const TQString &caption )
592 {
593  TQMainWindow::setCaption( caption );
594 #if defined Q_WS_X11
595  NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 );
596  info.setName( caption.utf8().data() );
597 #endif
598 }
599 
600 void KMainWindow::appHelpActivated( void )
601 {
602  if( !mHelpMenu ) {
603  mHelpMenu = new KHelpMenu( this );
604  if ( !mHelpMenu )
605  return;
606  }
607  mHelpMenu->appHelpActivated();
608 }
609 
610 void KMainWindow::slotStateChanged(const TQString &newstate)
611 {
612  stateChanged(newstate, KXMLGUIClient::StateNoReverse);
613 }
614 
615 /*
616  * Get rid of this for KDE 4.0
617  */
618 void KMainWindow::slotStateChanged(const TQString &newstate,
619  KXMLGUIClient::ReverseStateChange reverse)
620 {
621  stateChanged(newstate, reverse);
622 }
623 
624 /*
625  * Enable this for KDE 4.0
626  */
627 // void KMainWindow::slotStateChanged(const TQString &newstate,
628 // bool reverse)
629 // {
630 // stateChanged(newstate,
631 // reverse ? KXMLGUIClient::StateReverse : KXMLGUIClient::StateNoReverse);
632 // }
633 
634 void KMainWindow::closeEvent ( TQCloseEvent *e )
635 {
636  // Save settings if auto-save is enabled, and settings have changed
637  if (d->settingsDirty && d->autoSaveSettings)
638  saveAutoSaveSettings();
639 
640  if (queryClose()) {
641  e->accept();
642 
643  int not_withdrawn = 0;
644  TQPtrListIterator<KMainWindow> it(*KMainWindow::memberList);
645  for (it.toFirst(); it.current(); ++it){
646  if ( !it.current()->isHidden() && it.current()->isTopLevel() && it.current() != this )
647  not_withdrawn++;
648  }
649 
650  if ( !no_query_exit && not_withdrawn <= 0 ) { // last window close accepted?
651  if ( queryExit() && !kapp->sessionSaving() && !d->shuttingDown ) { // Yes, Quit app?
652  // don't call queryExit() twice
653  disconnect(kapp, TQT_SIGNAL(shutDown()), this, TQT_SLOT(shuttingDown()));
654  d->shuttingDown = true;
655  kapp->deref(); // ...and quit application.
656  } else {
657  // cancel closing, it's stupid to end up with no windows at all....
658  e->ignore();
659  }
660  }
661  }
662 }
663 
664 bool KMainWindow::queryExit()
665 {
666  return true;
667 }
668 
669 bool KMainWindow::queryClose()
670 {
671  return true;
672 }
673 
674 void KMainWindow::saveGlobalProperties( KConfig* )
675 {
676 }
677 
678 void KMainWindow::readGlobalProperties( KConfig* )
679 {
680 }
681 
682 #if defined(KDE_COMPAT)
683 void KMainWindow::updateRects()
684 {
685 }
686 #endif
687 
688 void KMainWindow::showAboutApplication()
689 {
690 }
691 
692 void KMainWindow::savePropertiesInternal( KConfig *config, int number )
693 {
694  bool oldASWS = d->autoSaveWindowSize;
695  d->autoSaveWindowSize = true; // make saveMainWindowSettings save the window size
696 
697  TQString s;
698  s.setNum(number);
699  s.prepend(TQString::fromLatin1("WindowProperties"));
700  config->setGroup(s);
701 
702  // store objectName, className, Width and Height for later restoring
703  // (Only useful for session management)
704  config->writeEntry(TQString::fromLatin1("ObjectName"), name());
705  config->writeEntry(TQString::fromLatin1("ClassName"), className());
706 
707  saveMainWindowSettings(config); // Menubar, statusbar and Toolbar settings.
708 
709  s.setNum(number);
710  config->setGroup(s);
711  saveProperties(config);
712 
713  d->autoSaveWindowSize = oldASWS;
714 }
715 
716 void KMainWindow::saveMainWindowSettings(KConfig *config, const TQString &configGroup)
717 {
718  kdDebug(200) << "KMainWindow::saveMainWindowSettings " << configGroup << endl;
719  TQString oldGroup;
720 
721  if (!configGroup.isEmpty())
722  {
723  oldGroup = config->group();
724  config->setGroup(configGroup);
725  }
726 
727  // Called by session management - or if we want to save the window size anyway
728  if ( d->autoSaveWindowSize )
729  saveWindowSize( config );
730 
731  TQStatusBar* sb = internalStatusBar();
732  if (sb) {
733  if(!config->hasDefault("StatusBar") && !sb->isHidden() )
734  config->revertToDefault("StatusBar");
735  else
736  config->writeEntry("StatusBar", sb->isHidden() ? "Disabled" : "Enabled");
737  }
738 
739  TQMenuBar* mb = internalMenuBar();
740  if (mb) {
741  TQString MenuBar = TQString::fromLatin1("MenuBar");
742  if(!config->hasDefault("MenuBar") && !mb->isHidden() )
743  config->revertToDefault("MenuBar");
744  else
745  config->writeEntry("MenuBar", mb->isHidden() ? "Disabled" : "Enabled");
746  }
747 
748  int n = 1; // Toolbar counter. toolbars are counted from 1,
749  KToolBar *toolbar = 0;
750  TQPtrListIterator<KToolBar> it( toolBarIterator() );
751  while ( ( toolbar = it.current() ) ) {
752  ++it;
753  TQString group;
754  if (!configGroup.isEmpty())
755  {
756  // Give a number to the toolbar, but prefer a name if there is one,
757  // because there's no real guarantee on the ordering of toolbars
758  group = (!::qstrcmp(toolbar->name(), "unnamed") ? TQString::number(n) : TQString(" ")+toolbar->name());
759  group.prepend(" Toolbar");
760  group.prepend(configGroup);
761  }
762  toolbar->saveSettings(config, group);
763  n++;
764  }
765  if (!configGroup.isEmpty())
766  config->setGroup(oldGroup);
767 }
768 
769 void KMainWindow::setStandardToolBarMenuEnabled( bool enable )
770 {
771  if ( enable ) {
772  if ( d->toolBarHandler )
773  return;
774 
775  d->toolBarHandler = new KDEPrivate::ToolBarHandler( this );
776 
777  if ( factory() )
778  factory()->addClient( d->toolBarHandler );
779  } else {
780  if ( !d->toolBarHandler )
781  return;
782 
783  if ( factory() )
784  factory()->removeClient( d->toolBarHandler );
785 
786  delete d->toolBarHandler;
787  d->toolBarHandler = 0;
788  }
789 }
790 
791 bool KMainWindow::isStandardToolBarMenuEnabled() const
792 {
793  return ( d->toolBarHandler );
794 }
795 
796 void KMainWindow::createStandardStatusBarAction(){
797  if(!d->showStatusBarAction){
798  d->showStatusBarAction = KStdAction::showStatusbar(TQT_TQOBJECT(this), TQT_SLOT(setSettingsDirty()), actionCollection());
799  KStatusBar *sb = statusBar(); // Creates statusbar if it doesn't exist already.
800  connect(d->showStatusBarAction, TQT_SIGNAL(toggled(bool)), sb, TQT_SLOT(setShown(bool)));
801  d->showStatusBarAction->setChecked(sb->isHidden());
802  }
803 }
804 
805 bool KMainWindow::readPropertiesInternal( KConfig *config, int number )
806 {
807  if ( number == 1 )
808  readGlobalProperties( config );
809 
810  // in order they are in toolbar list
811  TQString s;
812  s.setNum(number);
813  s.prepend(TQString::fromLatin1("WindowProperties"));
814 
815  config->setGroup(s);
816 
817  // restore the object name (window role)
818  if ( config->hasKey(TQString::fromLatin1("ObjectName" )) )
819  setName( config->readEntry(TQString::fromLatin1("ObjectName")).latin1()); // latin1 is right here
820 
821  applyMainWindowSettings(config); // Menubar, statusbar and toolbar settings.
822 
823  s.setNum(number);
824  config->setGroup(s);
825  readProperties(config);
826  return true;
827 }
828 
829 void KMainWindow::applyMainWindowSettings(KConfig *config, const TQString &configGroup)
830 {
831  return applyMainWindowSettings(config,configGroup,false);
832 }
833 
834 void KMainWindow::applyMainWindowSettings(KConfig *config, const TQString &configGroup,bool force)
835 {
836  kdDebug(200) << "KMainWindow::applyMainWindowSettings" << endl;
837 
838  KConfigGroupSaver saver( config, configGroup.isEmpty() ? config->group() : configGroup );
839 
840  restoreWindowSize(config);
841 
842  TQStatusBar* sb = internalStatusBar();
843  if (sb) {
844  TQString entry = config->readEntry("StatusBar", "Enabled");
845  if ( entry == "Disabled" )
846  sb->hide();
847  else
848  sb->show();
849  if(d->showStatusBarAction)
850  d->showStatusBarAction->setChecked(!sb->isHidden());
851  }
852 
853  TQMenuBar* mb = internalMenuBar();
854  if (mb) {
855  TQString entry = config->readEntry ("MenuBar", "Enabled");
856  if ( entry == "Disabled" )
857  mb->hide();
858  else
859  mb->show();
860  }
861 
862  int n = 1; // Toolbar counter. toolbars are counted from 1,
863  KToolBar *toolbar;
864  TQPtrListIterator<KToolBar> it( toolBarIterator() ); // must use own iterator
865 
866  for ( ; it.current(); ++it) {
867  toolbar= it.current();
868  TQString group;
869  if (!configGroup.isEmpty())
870  {
871  // Give a number to the toolbar, but prefer a name if there is one,
872  // because there's no real guarantee on the ordering of toolbars
873  group = (!::qstrcmp(toolbar->name(), "unnamed") ? TQString::number(n) : TQString(" ")+toolbar->name());
874  group.prepend(" Toolbar");
875  group.prepend(configGroup);
876  }
877  toolbar->applySettings(config, group, force);
878  n++;
879  }
880 
881  finalizeGUI( true );
882 }
883 
884 void KMainWindow::finalizeGUI( bool force )
885 {
886  //kdDebug(200) << "KMainWindow::finalizeGUI force=" << force << endl;
887  // The whole reason for this is that moveToolBar relies on the indexes
888  // of the other toolbars, so in theory it should be called only once per
889  // toolbar, but in increasing order of indexes.
890  // Since we can't do that immediately, we move them, and _then_
891  // we call positionYourself again for each of them, but this time
892  // the toolbariterator should give them in the proper order.
893  // Both the XMLGUI and applySettings call this, hence "force" for the latter.
894  TQPtrListIterator<KToolBar> it( toolBarIterator() );
895  for ( ; it.current() ; ++it ) {
896  it.current()->positionYourself( force );
897  }
898 
899  d->settingsDirty = false;
900 }
901 
902 void KMainWindow::saveWindowSize( KConfig * config ) const
903 {
904  int scnum = TQApplication::desktop()->screenNumber(parentWidget());
905  TQRect desk = TQApplication::desktop()->screenGeometry(scnum);
906  int w, h;
907 #if defined Q_WS_X11
908  // save maximalization as desktop size + 1 in that direction
909  KWin::WindowInfo info = KWin::windowInfo( winId(), NET::WMState );
910  w = info.state() & NET::MaxHoriz ? desk.width() + 1 : width();
911  h = info.state() & NET::MaxVert ? desk.height() + 1 : height();
912 #else
913  if (isMaximized()) {
914  w = desk.width() + 1;
915  h = desk.height() + 1;
916  }
917  //TODO: add "Maximized" property instead "+1" hack
918 #endif
919  TQRect size( desk.width(), w, desk.height(), h );
920  bool defaultSize = (size == d->defaultWindowSize);
921  TQString widthString = TQString::fromLatin1("Width %1").arg(desk.width());
922  TQString heightString = TQString::fromLatin1("Height %1").arg(desk.height());
923  if (!config->hasDefault(widthString) && defaultSize)
924  config->revertToDefault(widthString);
925  else
926  config->writeEntry(widthString, w );
927 
928  if (!config->hasDefault(heightString) && defaultSize)
929  config->revertToDefault(heightString);
930  else
931  config->writeEntry(heightString, h );
932 }
933 
934 void KMainWindow::restoreWindowSize( KConfig * config )
935 {
936  if (d->care_about_geometry) {
937  parseGeometry(true);
938  } else {
939  // restore the size
940  int scnum = TQApplication::desktop()->screenNumber(parentWidget());
941  TQRect desk = TQApplication::desktop()->screenGeometry(scnum);
942  if ( d->defaultWindowSize.isNull() ) // only once
943  d->defaultWindowSize = TQRect(desk.width(), width(), desk.height(), height()); // store default values
944  TQSize size( config->readNumEntry( TQString::fromLatin1("Width %1").arg(desk.width()), 0 ),
945  config->readNumEntry( TQString::fromLatin1("Height %1").arg(desk.height()), 0 ) );
946  if (size.isEmpty()) {
947  // try the KDE 2.0 way
948  size = TQSize( config->readNumEntry( TQString::fromLatin1("Width"), 0 ),
949  config->readNumEntry( TQString::fromLatin1("Height"), 0 ) );
950  if (!size.isEmpty()) {
951  // make sure the other resolutions don't get old settings
952  config->writeEntry( TQString::fromLatin1("Width"), 0 );
953  config->writeEntry( TQString::fromLatin1("Height"), 0 );
954  }
955  }
956  if ( !size.isEmpty() ) {
957 #ifdef Q_WS_X11
958  int state = 0;
959  if (size.width() > desk.width()) {
960  state = state | NET::MaxHoriz;
961  }
962  if (size.height() > desk.height()) {
963  state = state | NET::MaxVert;
964  }
965 
966  if (( state & NET::Max ) == NET::Max ) {
967  resize( desk.width(), desk.height());
968  }
969  else if(( state & NET::MaxHoriz ) == NET::MaxHoriz ) {
970  resize( width(), size.height());
971  }
972  else if(( state & NET::MaxVert ) == NET::MaxVert ) {
973  resize( size.width(), height());
974  }
975  else {
976  resize( size );
977  }
978  // TQWidget::showMaximized() is both insufficient and broken
979  KWin::setState( winId(), state );
980 #else
981  if (size.width() > desk.width() || size.height() > desk.height())
982  setWindowState( WindowMaximized );
983  else
984  resize( size );
985 #endif
986  }
987  }
988 }
989 
990 bool KMainWindow::initialGeometrySet() const
991 {
992  return d->care_about_geometry;
993 }
994 
995 void KMainWindow::ignoreInitialGeometry()
996 {
997  d->care_about_geometry = false;
998 }
999 
1000 void KMainWindow::setSettingsDirty()
1001 {
1002  //kdDebug(200) << "KMainWindow::setSettingsDirty" << endl;
1003  d->settingsDirty = true;
1004  if ( d->autoSaveSettings )
1005  {
1006  // Use a timer to save "immediately" user-wise, but not too immediately
1007  // (to compress calls and save only once, in case of multiple changes)
1008  if ( !d->settingsTimer )
1009  {
1010  d->settingsTimer = new TQTimer( this );
1011  connect( d->settingsTimer, TQT_SIGNAL( timeout() ), TQT_SLOT( saveAutoSaveSettings() ) );
1012  }
1013  d->settingsTimer->start( 500, true );
1014  }
1015 }
1016 
1017 bool KMainWindow::settingsDirty() const
1018 {
1019  return d->settingsDirty;
1020 }
1021 
1022 TQString KMainWindow::settingsGroup() const
1023 {
1024  return d->autoSaveGroup;
1025 }
1026 
1027 void KMainWindow::setAutoSaveSettings( const TQString & groupName, bool saveWindowSize )
1028 {
1029  d->autoSaveSettings = true;
1030  d->autoSaveGroup = groupName;
1031  d->autoSaveWindowSize = saveWindowSize;
1032  // Get notified when the user moves a toolbar around
1033  disconnect( this, TQT_SIGNAL( dockWindowPositionChanged( TQDockWindow * ) ),
1034  this, TQT_SLOT( setSettingsDirty() ) );
1035  connect( this, TQT_SIGNAL( dockWindowPositionChanged( TQDockWindow * ) ),
1036  this, TQT_SLOT( setSettingsDirty() ) );
1037 
1038  // Now read the previously saved settings
1039  applyMainWindowSettings( KGlobal::config(), groupName );
1040 }
1041 
1042 void KMainWindow::resetAutoSaveSettings()
1043 {
1044  d->autoSaveSettings = false;
1045  if ( d->settingsTimer )
1046  d->settingsTimer->stop();
1047 }
1048 
1049 bool KMainWindow::autoSaveSettings() const
1050 {
1051  return d->autoSaveSettings;
1052 }
1053 
1054 TQString KMainWindow::autoSaveGroup() const
1055 {
1056  return d->autoSaveGroup;
1057 }
1058 
1059 void KMainWindow::saveAutoSaveSettings()
1060 {
1061  Q_ASSERT( d->autoSaveSettings );
1062  //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl;
1063  saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup );
1064  KGlobal::config()->sync();
1065  d->settingsDirty = false;
1066  if ( d->settingsTimer )
1067  d->settingsTimer->stop();
1068 }
1069 
1070 void KMainWindow::resizeEvent( TQResizeEvent * )
1071 {
1072  if ( d->autoSaveWindowSize )
1073  setSettingsDirty();
1074 }
1075 
1076 bool KMainWindow::hasMenuBar()
1077 {
1078  return (internalMenuBar());
1079 }
1080 
1081 KMenuBar *KMainWindow::menuBar()
1082 {
1083  KMenuBar * mb = internalMenuBar();
1084  if ( !mb ) {
1085  mb = new KMenuBar( this );
1086  // trigger a re-layout and trigger a call to the private
1087  // setMenuBar method.
1088  TQMainWindow::menuBar();
1089  }
1090  return mb;
1091 }
1092 
1093 KStatusBar *KMainWindow::statusBar()
1094 {
1095  KStatusBar * sb = internalStatusBar();
1096  if ( !sb ) {
1097  sb = new KStatusBar( this );
1098  // trigger a re-layout and trigger a call to the private
1099  // setStatusBar method.
1100  TQMainWindow::statusBar();
1101  }
1102  return sb;
1103 }
1104 
1105 void KMainWindow::shuttingDown()
1106 {
1107  // Needed for Qt <= 3.0.3 at least to prevent reentrancy
1108  // when queryExit() shows a dialog. Check before removing!
1109  static bool reentrancy_protection = false;
1110  if (!reentrancy_protection)
1111  {
1112  reentrancy_protection = true;
1113  // call the virtual queryExit
1114  queryExit();
1115  reentrancy_protection = false;
1116  }
1117 
1118 }
1119 
1120 KMenuBar *KMainWindow::internalMenuBar()
1121 {
1122  TQObjectList *l = queryList( "KMenuBar", 0, false, false );
1123  if ( !l || !l->first() ) {
1124  delete l;
1125  return 0;
1126  }
1127 
1128  KMenuBar *m = (KMenuBar*)l->first();
1129  delete l;
1130  return m;
1131 }
1132 
1133 KStatusBar *KMainWindow::internalStatusBar()
1134 {
1135  TQObjectList *l = queryList( "KStatusBar", 0, false, false );
1136  if ( !l || !l->first() ) {
1137  delete l;
1138  return 0;
1139  }
1140 
1141  KStatusBar *s = (KStatusBar*)l->first();
1142  delete l;
1143  return s;
1144 }
1145 
1146 void KMainWindow::childEvent( TQChildEvent* e)
1147 {
1148  TQMainWindow::childEvent( e );
1149 }
1150 
1151 KToolBar *KMainWindow::toolBar( const char * name )
1152 {
1153  if (!name)
1154  name = "mainToolBar";
1155  KToolBar *tb = (KToolBar*)child( name, "KToolBar" );
1156  if ( tb )
1157  return tb;
1158  bool honor_mode = (!strcmp(name, "mainToolBar"));
1159 
1160  if ( builderClient() )
1161  return new KToolBar(this, name, honor_mode); // XMLGUI constructor
1162  else
1163  return new KToolBar(this, DockTop, false, name, honor_mode ); // non-XMLGUI
1164 }
1165 
1166 TQPtrListIterator<KToolBar> KMainWindow::toolBarIterator()
1167 {
1168  toolbarList.clear();
1169  TQPtrList<TQToolBar> lst;
1170  for ( int i = (int)TQMainWindow::DockUnmanaged; i <= (int)DockMinimized; ++i ) {
1171  lst = toolBars( (ToolBarDock)i );
1172  for ( TQToolBar *tb = lst.first(); tb; tb = lst.next() ) {
1173  if ( !tb->inherits( "KToolBar" ) )
1174  continue;
1175  toolbarList.append( (KToolBar*)tb );
1176  }
1177  }
1178  return TQPtrListIterator<KToolBar>( toolbarList );
1179 }
1180 
1181 KAccel * KMainWindow::accel()
1182 {
1183  if ( !d->kaccel )
1184  d->kaccel = new KAccel( this, "kmw-kaccel" );
1185  return d->kaccel;
1186 }
1187 
1188 void KMainWindow::paintEvent( TQPaintEvent * pe )
1189 {
1190  TQMainWindow::paintEvent(pe); //Upcall to handle SH_MainWindow_SpaceBelowMenuBar rendering
1191 }
1192 
1193 TQSize KMainWindow::sizeForCentralWidgetSize(TQSize size)
1194 {
1195  KToolBar *tb = (KToolBar*)child( "mainToolBar", "KToolBar" );
1196  if (tb && !tb->isHidden()) {
1197  switch( tb->barPos() )
1198  {
1199  case KToolBar::Top:
1200  case KToolBar::Bottom:
1201  size += TQSize(0, tb->sizeHint().height());
1202  break;
1203 
1204  case KToolBar::Left:
1205  case KToolBar::Right:
1206  size += TQSize(toolBar()->sizeHint().width(), 0);
1207  break;
1208 
1209  case KToolBar::Flat:
1210  size += TQSize(0, 3+kapp->style().pixelMetric( TQStyle::PM_DockWindowHandleExtent ));
1211  break;
1212 
1213  default:
1214  break;
1215  }
1216  }
1217  KMenuBar *mb = internalMenuBar();
1218  if (mb && !mb->isHidden()) {
1219  size += TQSize(0,mb->heightForWidth(size.width()));
1220  if (style().styleHint(TQStyle::SH_MainWindow_SpaceBelowMenuBar, this))
1221  size += TQSize( 0, dockWindowsMovable() ? 1 : 2);
1222  }
1223  TQStatusBar *sb = internalStatusBar();
1224  if( sb && !sb->isHidden() )
1225  size += TQSize(0, sb->sizeHint().height());
1226 
1227  return size;
1228 }
1229 
1230 #if KDE_IS_VERSION( 3, 9, 0 )
1231 #ifdef __GNUC__
1232 #warning Remove, should be in Qt
1233 #endif
1234 #endif
1235 void KMainWindow::setIcon( const TQPixmap& p )
1236 {
1237  TQMainWindow::setIcon( p );
1238 #ifdef Q_WS_X11
1239  // Qt3 doesn't support _NET_WM_ICON, but KApplication::setTopWidget(), which
1240  // is used by KMainWindow, sets it
1241  KWin::setIcons( winId(), p, TQPixmap());
1242 #endif
1243 }
1244 
1245 TQPtrList<KMainWindow>* KMainWindow::getMemberList() { return memberList; }
1246 
1247 // why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI;
1248 // DF: because they compile KDE much faster :)
1249 void KMainWindow::finalizeGUI( KXMLGUIClient *client )
1250 { KXMLGUIBuilder::finalizeGUI( client ); }
1251 
1252 void KMainWindow::virtual_hook( int id, void* data )
1253 { KXMLGUIBuilder::virtual_hook( id, data );
1254  KXMLGUIClient::virtual_hook( id, data ); }
1255 
1256 
1257 
1258 #include "kmainwindow.moc"
1259 
KAccel
KActionCollection::kaccel
KAccel * kaccel()
Returns the KAccel object of the most recently set widget.
Definition: kactioncollection.cpp:282
KActionCollection::setWidget
virtual void setWidget(TQWidget *widget)
This sets the widget to which the keyboard shortcuts should be attached.
Definition: kactioncollection.cpp:152
KAction
Class to encapsulate user-driven action or event.
Definition: kaction.h:203
KApplication::kApplication
static KApplication * kApplication()
KApplication::sessionConfig
KConfig * sessionConfig()
KConfigBase::sync
virtual void sync()
KConfigBase::revertToDefault
void revertToDefault(const TQString &key)
KConfigBase::hasDefault
bool hasDefault(const TQString &key) const
KConfigBase::readEntry
TQString readEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
KConfigBase::writeEntry
void writeEntry(const TQString &pKey, const TQString &pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
KConfigBase::group
TQString group() const
KConfigBase::setGroup
void setGroup(const TQString &group)
KConfigBase::hasKey
bool hasKey(const TQString &key) const
KConfigBase::readNumEntry
int readNumEntry(const TQString &pKey, int nDefault=0) const
KConfigGroupSaver
KConfig
KDEPrivate::ToolBarHandler
Definition: ktoolbarhandler.h:35
KEditToolbar
A dialog used to customize or configure toolbars.
Definition: kedittoolbar.h:111
KGlobal::config
static KConfig * config()
KHelpMenu
Standard KDE help menu with dialog boxes.
Definition: khelpmenu.h:132
KHelpMenu::appHelpActivated
void appHelpActivated()
Opens the help page for the application.
Definition: khelpmenu.cpp:187
KHelpMenu::menu
KPopupMenu * menu()
Returns a popup menu you can use in the menu bar or where you need it.
Definition: khelpmenu.cpp:112
KMainWindowInterface
DCOP interface to KMainWindow.
Definition: kmainwindowiface.h:41
KMainWindow
KDE top level main window
Definition: kmainwindow.h:99
KMainWindow::toolBar
KToolBar * toolBar(const char *name=0)
Returns a pointer to the toolbar with the specified name.
Definition: kmainwindow.cpp:1151
KMainWindow::sizeForCentralWidgetSize
TQSize sizeForCentralWidgetSize(TQSize size) KDE_DEPRECATED
Definition: kmainwindow.cpp:1193
KMainWindow::show
virtual void show()
Reimplementation of TQMainWindow::show()
Definition: kmainwindow.cpp:381
KMainWindow::setupToolbarMenuActions
void setupToolbarMenuActions()
Definition: kmainwindow.cpp:273
KMainWindow::applyMainWindowSettings
void applyMainWindowSettings(KConfig *config, const TQString &groupName, bool force)
Read settings for statusbar, menubar and toolbar from their respective groups in the config file and ...
Definition: kmainwindow.cpp:834
KMainWindow::autoSaveGroup
TQString autoSaveGroup() const
Definition: kmainwindow.cpp:1054
KMainWindow::saveProperties
virtual void saveProperties(KConfig *)
Save your instance-specific properties.
Definition: kmainwindow.h:884
KMainWindow::hasMenuBar
bool hasMenuBar()
Returns true, if there is a menubar.
Definition: kmainwindow.cpp:1076
KMainWindow::saveNewToolbarConfig
void saveNewToolbarConfig()
Rebuilds the GUI after KEditToolbar changed the toolbar layout.
Definition: kmainwindow.cpp:439
KMainWindow::readGlobalProperties
virtual void readGlobalProperties(KConfig *sessionConfig)
The counterpart of saveGlobalProperties().
Definition: kmainwindow.cpp:678
KMainWindow::ignoreInitialGeometry
void ignoreInitialGeometry()
Definition: kmainwindow.cpp:995
KMainWindow::saveAutoSaveSettings
void saveAutoSaveSettings()
This slot should only be called in case you reimplement closeEvent() and if you are using the "auto-s...
Definition: kmainwindow.cpp:1059
KMainWindow::setPlainCaption
virtual void setPlainCaption(const TQString &caption)
Make a plain caption without any modifications.
Definition: kmainwindow.cpp:591
KMainWindow::restore
bool restore(int number, bool show=true)
Restore the session specified by number.
Definition: kmainwindow.cpp:411
KMainWindow::closeEvent
virtual void closeEvent(TQCloseEvent *)
Reimplemented to call the queryClose() and queryExit() handlers.
Definition: kmainwindow.cpp:634
KMainWindow::saveWindowSize
void saveWindowSize(KConfig *config) const
For inherited classes Note that the group must be set before calling.
Definition: kmainwindow.cpp:902
KMainWindow::statusBar
KStatusBar * statusBar()
Returns a pointer to the status bar.
Definition: kmainwindow.cpp:1093
KMainWindow::resetAutoSaveSettings
void resetAutoSaveSettings()
Disable the auto-save-settings feature.
Definition: kmainwindow.cpp:1042
KMainWindow::Save
@ Save
auto-saves (and loads) the toolbar/menubar/statusbar settings and window size using the default name.
Definition: kmainwindow.h:584
KMainWindow::Create
@ Create
calls createGUI() once ToolBar, Keys and Statusbar have been taken care of.
Definition: kmainwindow.h:590
KMainWindow::StatusBar
@ StatusBar
adds action to show/hide the statusbar if the statusbar exists.
Definition: kmainwindow.h:572
KMainWindow::ToolBar
@ ToolBar
adds action to show/hide the toolbar(s) and adds action to configure the toolbar(s).
Definition: kmainwindow.h:561
KMainWindow::Keys
@ Keys
adds action to show the key configure action.
Definition: kmainwindow.h:566
KMainWindow::isStandardToolBarMenuEnabled
bool isStandardToolBarMenuEnabled() const
Definition: kmainwindow.cpp:791
KMainWindow::restoreWindowSize
void restoreWindowSize(KConfig *config)
For inherited classes Note that the group must be set before calling, and that a -geometry on the com...
Definition: kmainwindow.cpp:934
KMainWindow::canBeRestored
static bool canBeRestored(int number)
Session Management
Definition: kmainwindow.cpp:352
KMainWindow::setSettingsDirty
void setSettingsDirty()
Apply a state change.
Definition: kmainwindow.cpp:1000
KMainWindow::finalizeGUI
virtual void finalizeGUI(KXMLGUIClient *client)
Definition: kmainwindow.cpp:1249
KMainWindow::getMemberList
static TQPtrList< KMainWindow > * getMemberList()
List of members of KMainWindow class.
Definition: kmainwindow.cpp:1245
KMainWindow::queryExit
virtual bool queryExit()
Definition: kmainwindow.cpp:664
KMainWindow::appHelpActivated
void appHelpActivated(void)
Open the help page for the application.
Definition: kmainwindow.cpp:600
KMainWindow::KMainWindow
KMainWindow(TQWidget *parent=0, const char *name=0, WFlags f=(WFlags)(WType_TopLevel|WDestructiveClose))
Construct a main window.
Definition: kmainwindow.cpp:167
KMainWindow::showAboutApplication
virtual void showAboutApplication()
This slot does nothing.
Definition: kmainwindow.cpp:688
KMainWindow::saveMainWindowSettings
void saveMainWindowSettings(KConfig *config, const TQString &groupName=TQString::null)
Save settings for statusbar, menubar and toolbar to their respective groups in the config file config...
Definition: kmainwindow.cpp:716
KMainWindow::hide
virtual void hide()
Reimplementation of TQMainWindow::hide()
Definition: kmainwindow.cpp:391
KMainWindow::setAutoSaveSettings
void setAutoSaveSettings(const TQString &groupName=TQString::fromLatin1("MainWindow"), bool saveWindowSize=true)
Call this to enable "auto-save" of toolbar/menubar/statusbar settings (and optionally window size).
Definition: kmainwindow.cpp:1027
KMainWindow::autoSaveSettings
bool autoSaveSettings() const
Definition: kmainwindow.cpp:1049
KMainWindow::initialGeometrySet
bool initialGeometrySet() const
Definition: kmainwindow.cpp:990
KMainWindow::menuBar
KMenuBar * menuBar()
Returns a pointer to the menu bar.
Definition: kmainwindow.cpp:1081
KMainWindow::setStandardToolBarMenuEnabled
void setStandardToolBarMenuEnabled(bool enable)
Sets whether KMainWindow should provide a menu that allows showing/hiding the available toolbars ( us...
Definition: kmainwindow.cpp:769
KMainWindow::readProperties
virtual void readProperties(KConfig *)
Read your instance-specific properties.
Definition: kmainwindow.h:889
KMainWindow::setIcon
virtual void setIcon(const TQPixmap &)
Definition: kmainwindow.cpp:1235
KMainWindow::setHelpMenuEnabled
void setHelpMenuEnabled(bool showHelpMenu=true)
Enables the build of a standard help menu when calling createGUI().
Definition: kmainwindow.cpp:571
KMainWindow::~KMainWindow
virtual ~KMainWindow()
Destructor.
Definition: kmainwindow.cpp:314
KMainWindow::classNameOfToplevel
static const TQString classNameOfToplevel(int number)
Returns the className() of the number of the toplevel window which should be restored.
Definition: kmainwindow.cpp:364
KMainWindow::accel
KAccel * accel()
Definition: kmainwindow.cpp:1181
KMainWindow::settingsGroup
TQString settingsGroup() const
For inherited classes.
Definition: kmainwindow.cpp:1022
KMainWindow::setupGUI
void setupGUI(int options=ToolBar|Keys|StatusBar|Save|Create, const TQString &xmlfile=TQString::null)
Configures the current windows and its actions in the typical KDE fashion.
Definition: kmainwindow.cpp:445
KMainWindow::memberList
static TQPtrList< KMainWindow > * memberList
List of members of KMainWindow class.
Definition: kmainwindow.h:393
KMainWindow::toolBarIterator
TQPtrListIterator< KToolBar > toolBarIterator()
Definition: kmainwindow.cpp:1166
KMainWindow::saveGlobalProperties
virtual void saveGlobalProperties(KConfig *sessionConfig)
Save your application-wide properties.
Definition: kmainwindow.cpp:674
KMainWindow::parseGeometry
void parseGeometry(bool parsewidth)
parse the geometry from the geometry command line argument
Definition: kmainwindow.cpp:279
KMainWindow::settingsDirty
bool settingsDirty() const
For inherited classes.
Definition: kmainwindow.cpp:1017
KMainWindow::createGUI
void createGUI(const TQString &xmlfile=TQString::null, bool _conserveMemory=true)
Create a GUI given a local XML file.
Definition: kmainwindow.cpp:491
KMainWindow::isHelpMenuEnabled
bool isHelpMenuEnabled()
Return true when the help menu is enabled.
Definition: kmainwindow.cpp:576
KMainWindow::helpMenu
KPopupMenu * helpMenu(const TQString &aboutAppText=TQString::null, bool showWhatsThis=true)
Retrieve the standard help menu.
Definition: kmainwindow.cpp:324
KMainWindow::createStandardStatusBarAction
void createStandardStatusBarAction()
Sets whether KMainWindow should provide a menu that allows showing/hiding of the statusbar ( using KT...
Definition: kmainwindow.cpp:796
KMainWindow::toolBarMenuAction
KAction * toolBarMenuAction()
Returns a pointer to the mainwindows action responsible for the toolbars menu.
Definition: kmainwindow.cpp:264
KMainWindow::configureToolbars
int configureToolbars()
Show a standard configure toolbar dialog.
Definition: kmainwindow.cpp:431
KMainWindow::slotStateChanged
virtual void slotStateChanged(const TQString &newstate)
Apply a state change.
Definition: kmainwindow.cpp:610
KMainWindow::queryClose
virtual bool queryClose()
Called before the window is closed, either by the user or indirectly by the session manager.
Definition: kmainwindow.cpp:669
KMainWindow::customHelpMenu
KPopupMenu * customHelpMenu(bool showWhatsThis=true)
Returns the help menu.
Definition: kmainwindow.cpp:341
KMainWindow::setCaption
virtual void setCaption(const TQString &caption)
Makes a KDE compliant caption.
Definition: kmainwindow.cpp:581
KMenuBar
KDE Style-able menubar.
Definition: kmenubar.h:43
KPopupMenu
A menu with title items.
Definition: kpopupmenu.h:123
KSessionManaged
KSessionManaged::saveState
virtual bool saveState(TQSessionManager &sm)
KSessionManaged::commitData
virtual bool commitData(TQSessionManager &sm)
KStaticDeleter
KStatusBar
KDE statusbar widget
Definition: kstatusbar.h:88
KToggleAction
Checkbox like action.
Definition: kactionclasses.h:69
KToolBar
Floatable toolbar with auto resize.
Definition: ktoolbar.h:105
KToolBar::applySettings
void applySettings(KConfig *config, const TQString &configGroup, bool force)
Read the toolbar settings from group configGroup in config and apply them.
Definition: ktoolbar.cpp:1645
KToolBar::saveSettings
void saveSettings(KConfig *config, const TQString &configGroup)
Save the toolbar settings to group configGroup in config.
Definition: ktoolbar.cpp:1043
KWin::WindowInfo
KWin::WindowInfo::state
unsigned long state() const
KWin::windowInfo
static WindowInfo windowInfo(WId win, unsigned long properties=0, unsigned long properties2=0)
KWin::setState
static void setState(WId win, unsigned long state)
KWin::setIcons
static void setIcons(WId win, const TQPixmap &icon, const TQPixmap &miniIcon)
KXMLGUIBuilder
Abstract interface for a "GUI builder", used by the GUIFactory This interface is implemented by KMain...
Definition: kxmlguibuilder.h:40
KXMLGUIClient
A KXMLGUIClient can be used with KXMLGUIFactory to create a GUI from actions and an XML document,...
Definition: kxmlguiclient.h:44
KXMLGUIClient::xmlFile
virtual TQString xmlFile() const
This will return the name of the XML file as set by setXMLFile().
Definition: kxmlguiclient.cpp:133
KXMLGUIClient::instance
virtual KInstance * instance() const
Definition: kxmlguiclient.cpp:123
KXMLGUIClient::setXMLGUIBuildDocument
void setXMLGUIBuildDocument(const TQDomDocument &doc)
Definition: kxmlguiclient.cpp:540
KXMLGUIClient::setXMLFile
virtual void setXMLFile(const TQString &file, bool merge=false, bool setXMLDoc=true)
Sets the name of the rc file containing the XML for the part.
Definition: kxmlguiclient.cpp:165
KXMLGUIClient::actionCollection
virtual KActionCollection * actionCollection() const
Retrieves the entire action collection for the GUI client.
Definition: kxmlguiclient.cpp:107
KXMLGUIClient::factory
KXMLGUIFactory * factory() const
Retrieves a pointer to the KXMLGUIFactory this client is associated with (will return 0L if the clien...
Definition: kxmlguiclient.cpp:555
KXMLGUIClient::conserveMemory
virtual void conserveMemory()
This function will attempt to give up some memory after the GUI is built.
Definition: kxmlguiclient.cpp:534
KXMLGUIClient::stateChanged
virtual void stateChanged(const TQString &newstate, ReverseStateChange reverse=StateNoReverse)
Actions can collectively be assigned a "State".
Definition: kxmlguiclient.cpp:899
KXMLGUIClient::domDocument
virtual TQDomDocument domDocument() const
Definition: kxmlguiclient.cpp:128
KXMLGUIFactory
KXMLGUIFactory, together with KXMLGUIClient objects, can be used to create a GUI of container widgets...
Definition: kxmlguifactory.h:63
KXMLGUIFactory::removeClient
void removeClient(KXMLGUIClient *client)
Removes the GUI described by the client, by unplugging all provided actions and removing all owned co...
Definition: kxmlguifactory.cpp:321
KXMLGUIFactory::addClient
void addClient(KXMLGUIClient *client)
Creates the GUI described by the TQDomDocument of the client, using the client's actions,...
Definition: kxmlguifactory.cpp:224
KXMLGUIFactory::resetContainer
void resetContainer(const TQString &containerName, bool useTagName=false)
Use this method to free all memory allocated by the KXMLGUIFactory for a specific container,...
Definition: kxmlguifactory.cpp:413
endl
kndbgstream & endl(kndbgstream &s)
kdDebug
kdbgstream kdDebug(int area=0)
locate
TQString locate(const char *type, const TQString &filename, const KInstance *instance=KGlobal::instance())
klocale.h
KStdAccel::name
TQString name(StdAccel id)
KStdAction::showStatusbar
KToggleAction * showStatusbar(const TQObject *recvr, const char *slot, KActionCollection *parent, const char *_name)
Show/Hide the statusbar.
Definition: kstdaction.cpp:270
KStdAction::keyBindings
KAction * keyBindings(const TQObject *recvr, const char *slot, KActionCollection *parent, const char *name)
Display the configure key bindings dialog.
Definition: kstdaction.cpp:298
KStdAction::configureToolbars
KAction * configureToolbars(const TQObject *recvr, const char *slot, KActionCollection *parent, const char *name)
The Customize Toolbar dialog.
Definition: kstdaction.cpp:302

kdeui

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

kdeui

Skip menu "kdeui"
  • 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 kdeui by doxygen 1.9.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |