author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kdeui/kmainwindow.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-p1.zip kdepimpi-p1.tar.gz kdepimpi-p1.tar.bz2 |
initial public commit of qt4 portp1
Diffstat (limited to 'microkde/kdeui/kmainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kdeui/kmainwindow.cpp | 97 |
1 files changed, 47 insertions, 50 deletions
diff --git a/microkde/kdeui/kmainwindow.cpp b/microkde/kdeui/kmainwindow.cpp index fa678f2..bac0db8 100644 --- a/microkde/kdeui/kmainwindow.cpp +++ b/microkde/kdeui/kmainwindow.cpp | |||
@@ -12,30 +12,36 @@ | |||
12 | License version 2 as published by the Free Software Foundation. | 12 | License version 2 as published by the Free Software Foundation. |
13 | 13 | ||
14 | This library is distributed in the hope that it will be useful, | 14 | This library is distributed in the hope that it will be useful, |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 | Library General Public License for more details. | 17 | Library General Public License for more details. |
18 | 18 | ||
19 | You should have received a copy of the GNU Library General Public License | 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 | 20 | along with this library; see the file COPYING.LIB. If not, write to |
21 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 21 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
22 | Boston, MA 02111-1307, USA. | 22 | Boston, MA 02111-1307, USA. |
23 | */ | 23 | */ |
24 | #include <qobjectlist.h> | 24 | #include <qobject.h> |
25 | #include <qstringlist.h> | 25 | #include <qstringlist.h> |
26 | #include <qtimer.h> | 26 | #include <qtimer.h> |
27 | #include <qmenubar.h> | 27 | #include <qmenubar.h> |
28 | #include <qstatusbar.h> | 28 | #include <qstatusbar.h> |
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | //Added by qt3to4: | ||
31 | #include <QCloseEvent> | ||
32 | #include <QPaintEvent> | ||
33 | #include <QResizeEvent> | ||
34 | #include <QChildEvent> | ||
35 | #include <Q3PtrList> | ||
30 | 36 | ||
31 | 37 | ||
32 | #include "kdebug.h" | 38 | #include "kdebug.h" |
33 | #include "kmainwindow.h" | 39 | #include "kmainwindow.h" |
34 | #include "kglobalsettings.h" | 40 | #include "kglobalsettings.h" |
35 | #include "kactioncollection.h" | 41 | #include "kactioncollection.h" |
36 | 42 | ||
37 | class KMainWindowPrivate { | 43 | class KMainWindowPrivate { |
38 | public: | 44 | public: |
39 | //US bool showHelpMenu:1; | 45 | //US bool showHelpMenu:1; |
40 | 46 | ||
41 | bool autoSaveSettings:1; | 47 | bool autoSaveSettings:1; |
@@ -45,25 +51,25 @@ public: | |||
45 | QString autoSaveGroup; | 51 | QString autoSaveGroup; |
46 | //US KAccel * kaccel; | 52 | //US KAccel * kaccel; |
47 | //US KMainWindowInterface *m_interface; | 53 | //US KMainWindowInterface *m_interface; |
48 | KDEPrivate::ToolBarHandler *toolBarHandler; | 54 | KDEPrivate::ToolBarHandler *toolBarHandler; |
49 | QTimer* settingsTimer; | 55 | QTimer* settingsTimer; |
50 | KToggleAction *showStatusBarAction; | 56 | KToggleAction *showStatusBarAction; |
51 | QRect defaultWindowSize; | 57 | QRect defaultWindowSize; |
52 | }; | 58 | }; |
53 | 59 | ||
54 | static bool no_query_exit = false; | 60 | static bool no_query_exit = false; |
55 | 61 | ||
56 | KMainWindow::KMainWindow( QWidget* parent, const char *name ) | 62 | KMainWindow::KMainWindow( QWidget* parent, const char *name ) |
57 | : QMainWindow( parent, name ) /*LR, f ) with the default widget flag we cannot have fastload */ /*US, KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )*/ | 63 | : Q3MainWindow( parent, name ) /*LR, f ) with the default widget flag we cannot have fastload */ /*US, KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )*/ |
58 | { | 64 | { |
59 | mQToolBar = 0; | 65 | mQToolBar = 0; |
60 | initKMainWindow(name); | 66 | initKMainWindow(name); |
61 | } | 67 | } |
62 | 68 | ||
63 | void KMainWindow::parseGeometry(bool parsewidth) | 69 | void KMainWindow::parseGeometry(bool parsewidth) |
64 | { | 70 | { |
65 | //US the following code is not getting used in the embedded version !! So disable it for now | 71 | //US the following code is not getting used in the embedded version !! So disable it for now |
66 | /*US | 72 | /*US |
67 | 73 | ||
68 | assert ( !kapp->geometryArgument().isNull() ); | 74 | assert ( !kapp->geometryArgument().isNull() ); |
69 | assert ( d->care_about_geometry ); | 75 | assert ( d->care_about_geometry ); |
@@ -267,25 +273,25 @@ void KMainWindow::setCaption( const QString &caption ) | |||
267 | //US setPlainCaption( kapp->makeStdCaption(caption) ); | 273 | //US setPlainCaption( kapp->makeStdCaption(caption) ); |
268 | setPlainCaption( caption ); | 274 | setPlainCaption( caption ); |
269 | } | 275 | } |
270 | 276 | ||
271 | void KMainWindow::setCaption( const QString &caption, bool modified ) | 277 | void KMainWindow::setCaption( const QString &caption, bool modified ) |
272 | { | 278 | { |
273 | //US setPlainCaption( kapp->makeStdCaption(caption, true, modified) ); | 279 | //US setPlainCaption( kapp->makeStdCaption(caption, true, modified) ); |
274 | setPlainCaption( caption + "modified:" ); | 280 | setPlainCaption( caption + "modified:" ); |
275 | } | 281 | } |
276 | 282 | ||
277 | void KMainWindow::setPlainCaption( const QString &caption ) | 283 | void KMainWindow::setPlainCaption( const QString &caption ) |
278 | { | 284 | { |
279 | QMainWindow::setCaption( caption ); | 285 | Q3MainWindow::setCaption( caption ); |
280 | #ifndef Q_WS_QWS | 286 | #ifndef Q_WS_QWS |
281 | //US the following is disabled for the embedded version | 287 | //US the following is disabled for the embedded version |
282 | //US NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 ); | 288 | //US NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 ); |
283 | //US info.setName( caption.utf8().data() ); | 289 | //US info.setName( caption.utf8().data() ); |
284 | #endif | 290 | #endif |
285 | } | 291 | } |
286 | 292 | ||
287 | void KMainWindow::slotStateChanged(const QString &newstate) | 293 | void KMainWindow::slotStateChanged(const QString &newstate) |
288 | { | 294 | { |
289 | stateChanged(newstate, KXMLGUIClient::StateNoReverse); | 295 | stateChanged(newstate, KXMLGUIClient::StateNoReverse); |
290 | } | 296 | } |
291 | 297 | ||
@@ -412,73 +418,74 @@ bool KMainWindow::isStandardToolBarMenuEnabled() const | |||
412 | return ( d->toolBarHandler != 0 ); | 418 | return ( d->toolBarHandler != 0 ); |
413 | } | 419 | } |
414 | 420 | ||
415 | void KMainWindow::createStandardStatusBarAction(){ | 421 | void KMainWindow::createStandardStatusBarAction(){ |
416 | if(!d->showStatusBarAction){ | 422 | if(!d->showStatusBarAction){ |
417 | d->showStatusBarAction = KStdAction::showStatusbar(this, SLOT(setSettingsDirty()), actionCollection()); | 423 | d->showStatusBarAction = KStdAction::showStatusbar(this, SLOT(setSettingsDirty()), actionCollection()); |
418 | connect(d->showStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setShown(bool))); | 424 | connect(d->showStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setShown(bool))); |
419 | if(internalStatusBar()) | 425 | if(internalStatusBar()) |
420 | d->showStatusBarAction->setChecked(!internalStatusBar()->isHidden()); | 426 | d->showStatusBarAction->setChecked(!internalStatusBar()->isHidden()); |
421 | } | 427 | } |
422 | } | 428 | } |
423 | 429 | ||
424 | QToolBar *KMainWindow::tBar( ) | 430 | Q3ToolBar *KMainWindow::tBar( ) |
425 | { | 431 | { |
426 | if ( ! mQToolBar ) | 432 | if ( ! mQToolBar ) |
427 | mQToolBar = new QToolBar( this ); | 433 | mQToolBar = new Q3ToolBar( this ); |
428 | return mQToolBar; | 434 | return mQToolBar; |
429 | } | 435 | } |
430 | 436 | ||
431 | KToolBar *KMainWindow::toolBar( const char * name ) | 437 | KToolBar *KMainWindow::toolBar( const char * name ) |
432 | { | 438 | { |
433 | 439 | ||
434 | if (!name) | 440 | if (!name) |
435 | name = "mainToolBar"; | 441 | name = "mainToolBar"; |
436 | KToolBar *tb = (KToolBar*)child( name, "KToolBar" ); | 442 | KToolBar *tb = (KToolBar*)child( name, "KToolBar" ); |
437 | if ( tb ) | 443 | if ( tb ) |
438 | return tb; | 444 | return tb; |
439 | bool honor_mode = (name == "mainToolBar"); | 445 | bool honor_mode = (name == "mainToolBar"); |
440 | 446 | ||
441 | /*US | 447 | /*US |
442 | if ( builderClient() ) | 448 | if ( builderClient() ) |
443 | return new KToolBar(this, name, honor_mode); // XMLGUI constructor | 449 | return new KToolBar(this, name, honor_mode); // XMLGUI constructor |
444 | else | 450 | else |
445 | */ | 451 | */ |
446 | return new KToolBar(this, Top, false, name, honor_mode ); // non-XMLGUI | 452 | return new KToolBar(this, Qt::Top, false, name, honor_mode ); // non-XMLGUI |
447 | } | 453 | } |
448 | 454 | ||
449 | QPtrListIterator<KToolBar> KMainWindow::toolBarIterator() | 455 | Q3PtrListIterator<KToolBar> KMainWindow::toolBarIterator() |
450 | { | 456 | { |
451 | toolbarList.clear(); | 457 | toolbarList.clear(); |
452 | QPtrList<QToolBar> lst; | 458 | QList<Q3ToolBar*> lst; |
453 | for ( int i = (int)QMainWindow::Unmanaged; i <= (int)Minimized; ++i ) { | 459 | for ( int i = (int)Qt::Unmanaged; i <= (int)Qt::Minimized; ++i ) { |
454 | lst = toolBars( (ToolBarDock)i ); | 460 | lst = toolBars( (Qt::ToolBarDock)i ); |
455 | for ( QToolBar *tb = lst.first(); tb; tb = lst.next() ) { | 461 | for(QList<Q3ToolBar*>::iterator i=lst.begin();i!=lst.end();++i) { |
462 | Q3ToolBar *tb = *i; | ||
456 | if ( !tb->inherits( "KToolBar" ) ) | 463 | if ( !tb->inherits( "KToolBar" ) ) |
457 | continue; | 464 | continue; |
458 | toolbarList.append( (KToolBar*)tb ); | 465 | toolbarList.append( (KToolBar*)tb ); |
459 | } | 466 | } |
460 | } | 467 | } |
461 | return QPtrListIterator<KToolBar>( toolbarList ); | 468 | return Q3PtrListIterator<KToolBar>( toolbarList ); |
462 | } | 469 | } |
463 | 470 | ||
464 | void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize ) | 471 | void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize ) |
465 | { | 472 | { |
466 | d->autoSaveSettings = true; | 473 | d->autoSaveSettings = true; |
467 | d->autoSaveGroup = groupName; | 474 | d->autoSaveGroup = groupName; |
468 | d->autoSaveWindowSize = saveWindowSize; | 475 | d->autoSaveWindowSize = saveWindowSize; |
469 | // Get notified when the user moves a toolbar around | 476 | // Get notified when the user moves a toolbar around |
470 | //US connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ), | 477 | //US connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ), |
471 | //US this, SLOT( setSettingsDirty() ) ); | 478 | //US this, SLOT( setSettingsDirty() ) ); |
472 | connect( this, SIGNAL( toolBarPositionChanged(QToolBar *) ), | 479 | connect( this, SIGNAL( toolBarPositionChanged(Q3ToolBar *) ), |
473 | this, SLOT( setSettingsDirty() ) ); | 480 | this, SLOT( setSettingsDirty() ) ); |
474 | 481 | ||
475 | 482 | ||
476 | // Get default values | 483 | // Get default values |
477 | //US int scnum = QApplication::desktop()->screenNumber(parentWidget()); | 484 | //US int scnum = QApplication::desktop()->screenNumber(parentWidget()); |
478 | //US QRect desk = QApplication::desktop()->screenGeometry(scnum); | 485 | //US QRect desk = QApplication::desktop()->screenGeometry(scnum); |
479 | QRect desk = KGlobalSettings::desktopGeometry(0); | 486 | QRect desk = KGlobalSettings::desktopGeometry(0); |
480 | 487 | ||
481 | d->defaultWindowSize = QRect(desk.width(), width(), desk.height(), height()); | 488 | d->defaultWindowSize = QRect(desk.width(), width(), desk.height(), height()); |
482 | // Now read the previously saved settings | 489 | // Now read the previously saved settings |
483 | applyMainWindowSettings( KGlobal::config(), groupName ); | 490 | applyMainWindowSettings( KGlobal::config(), groupName ); |
484 | } | 491 | } |
@@ -494,25 +501,25 @@ void KMainWindow::resetAutoSaveSettings() | |||
494 | bool KMainWindow::autoSaveSettings() const | 501 | bool KMainWindow::autoSaveSettings() const |
495 | { | 502 | { |
496 | return d->autoSaveSettings; | 503 | return d->autoSaveSettings; |
497 | } | 504 | } |
498 | 505 | ||
499 | QString KMainWindow::autoSaveGroup() const | 506 | QString KMainWindow::autoSaveGroup() const |
500 | { | 507 | { |
501 | return d->autoSaveGroup; | 508 | return d->autoSaveGroup; |
502 | } | 509 | } |
503 | 510 | ||
504 | void KMainWindow::saveAutoSaveSettings() | 511 | void KMainWindow::saveAutoSaveSettings() |
505 | { | 512 | { |
506 | ASSERT( d->autoSaveSettings ); | 513 | Q_ASSERT( d->autoSaveSettings ); |
507 | //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl; | 514 | //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl; |
508 | saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup ); | 515 | saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup ); |
509 | KGlobal::config()->sync(); | 516 | KGlobal::config()->sync(); |
510 | d->settingsDirty = false; | 517 | d->settingsDirty = false; |
511 | if ( d->settingsTimer ) | 518 | if ( d->settingsTimer ) |
512 | d->settingsTimer->stop(); | 519 | d->settingsTimer->stop(); |
513 | } | 520 | } |
514 | 521 | ||
515 | void KMainWindow::createGUI( const QString &xmlfile, bool _conserveMemory ) | 522 | void KMainWindow::createGUI( const QString &xmlfile, bool _conserveMemory ) |
516 | { | 523 | { |
517 | // disabling the updates prevents unnecessary redraws | 524 | // disabling the updates prevents unnecessary redraws |
518 | setUpdatesEnabled( false ); | 525 | setUpdatesEnabled( false ); |
@@ -630,25 +637,25 @@ void KMainWindow::saveMainWindowSettings(KConfig *config, const QString &configG | |||
630 | entryList.append("Enabled"); | 637 | entryList.append("Enabled"); |
631 | 638 | ||
632 | // By default we don't hide. | 639 | // By default we don't hide. |
633 | if(mb->isHidden()) | 640 | if(mb->isHidden()) |
634 | //US config->writeEntry(QString::fromLatin1("MenuBar"), entryList, ';'); | 641 | //US config->writeEntry(QString::fromLatin1("MenuBar"), entryList, ';'); |
635 | config->writeEntry(QString::fromLatin1("MenuBar"), entryList); | 642 | config->writeEntry(QString::fromLatin1("MenuBar"), entryList); |
636 | else | 643 | else |
637 | config->deleteEntry(QString::fromLatin1("MenuBar")); | 644 | config->deleteEntry(QString::fromLatin1("MenuBar")); |
638 | } | 645 | } |
639 | 646 | ||
640 | int n = 1; // Toolbar counter. toolbars are counted from 1, | 647 | int n = 1; // Toolbar counter. toolbars are counted from 1, |
641 | KToolBar *toolbar = 0; | 648 | KToolBar *toolbar = 0; |
642 | QPtrListIterator<KToolBar> it( toolBarIterator() ); | 649 | Q3PtrListIterator<KToolBar> it( toolBarIterator() ); |
643 | while ( ( toolbar = it.current() ) ) { | 650 | while ( ( toolbar = it.current() ) ) { |
644 | ++it; | 651 | ++it; |
645 | QString group; | 652 | QString group; |
646 | if (!configGroup.isEmpty()) | 653 | if (!configGroup.isEmpty()) |
647 | { | 654 | { |
648 | // Give a number to the toolbar, but prefer a name if there is one, | 655 | // Give a number to the toolbar, but prefer a name if there is one, |
649 | // because there's no real guarantee on the ordering of toolbars | 656 | // because there's no real guarantee on the ordering of toolbars |
650 | group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); | 657 | group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); |
651 | group.prepend(" Toolbar"); | 658 | group.prepend(" Toolbar"); |
652 | group.prepend(configGroup); | 659 | group.prepend(configGroup); |
653 | } | 660 | } |
654 | toolbar->saveSettings(config, group); | 661 | toolbar->saveSettings(config, group); |
@@ -705,37 +712,39 @@ void KMainWindow::applyMainWindowSettings(KConfig *config, const QString &config | |||
705 | sb->hide(); | 712 | sb->hide(); |
706 | else | 713 | else |
707 | sb->show(); | 714 | sb->show(); |
708 | if(d->showStatusBarAction) | 715 | if(d->showStatusBarAction) |
709 | d->showStatusBarAction->setChecked(!sb->isHidden()); | 716 | d->showStatusBarAction->setChecked(!sb->isHidden()); |
710 | } | 717 | } |
711 | 718 | ||
712 | QMenuBar* mb = internalMenuBar(); | 719 | QMenuBar* mb = internalMenuBar(); |
713 | if (mb) { | 720 | if (mb) { |
714 | entryList.clear(); | 721 | entryList.clear(); |
715 | //US i = config->readListEntry (QString::fromLatin1("MenuBar"), entryList, ';'); | 722 | //US i = config->readListEntry (QString::fromLatin1("MenuBar"), entryList, ';'); |
716 | entryList = config->readListEntry (QString::fromLatin1("MenuBar")); | 723 | entryList = config->readListEntry (QString::fromLatin1("MenuBar")); |
717 | entry = entryList.first(); | 724 | if(!entryList.empty()) { |
718 | if (entry==QString::fromLatin1("Disabled")) | 725 | entry = entryList.first(); |
719 | { | 726 | if (entry==QString::fromLatin1("Disabled")) |
720 | mb->hide(); | 727 | { |
721 | } else | 728 | mb->hide(); |
722 | { | 729 | } else |
723 | mb->show(); | 730 | { |
724 | } | 731 | mb->show(); |
732 | } | ||
733 | } | ||
725 | } | 734 | } |
726 | 735 | ||
727 | int n = 1; // Toolbar counter. toolbars are counted from 1, | 736 | int n = 1; // Toolbar counter. toolbars are counted from 1, |
728 | KToolBar *toolbar; | 737 | KToolBar *toolbar; |
729 | QPtrListIterator<KToolBar> it( toolBarIterator() ); // must use own iterator | 738 | Q3PtrListIterator<KToolBar> it( toolBarIterator() ); // must use own iterator |
730 | 739 | ||
731 | for ( ; it.current(); ++it) { | 740 | for ( ; it.current(); ++it) { |
732 | toolbar= it.current(); | 741 | toolbar= it.current(); |
733 | QString group; | 742 | QString group; |
734 | if (!configGroup.isEmpty()) | 743 | if (!configGroup.isEmpty()) |
735 | { | 744 | { |
736 | // Give a number to the toolbar, but prefer a name if there is one, | 745 | // Give a number to the toolbar, but prefer a name if there is one, |
737 | // because there's no real guarantee on the ordering of toolbars | 746 | // because there's no real guarantee on the ordering of toolbars |
738 | group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); | 747 | group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); |
739 | group.prepend(" Toolbar"); | 748 | group.prepend(" Toolbar"); |
740 | group.prepend(configGroup); | 749 | group.prepend(configGroup); |
741 | } | 750 | } |
@@ -747,25 +756,25 @@ void KMainWindow::applyMainWindowSettings(KConfig *config, const QString &config | |||
747 | } | 756 | } |
748 | 757 | ||
749 | void KMainWindow::finalizeGUI( bool force ) | 758 | void KMainWindow::finalizeGUI( bool force ) |
750 | { | 759 | { |
751 | //kdDebug(200) << "KMainWindow::finalizeGUI force=" << force << endl; | 760 | //kdDebug(200) << "KMainWindow::finalizeGUI force=" << force << endl; |
752 | // The whole reason for this is that moveToolBar relies on the indexes | 761 | // The whole reason for this is that moveToolBar relies on the indexes |
753 | // of the other toolbars, so in theory it should be called only once per | 762 | // of the other toolbars, so in theory it should be called only once per |
754 | // toolbar, but in increasing order of indexes. | 763 | // toolbar, but in increasing order of indexes. |
755 | // Since we can't do that immediately, we move them, and _then_ | 764 | // Since we can't do that immediately, we move them, and _then_ |
756 | // we call positionYourself again for each of them, but this time | 765 | // we call positionYourself again for each of them, but this time |
757 | // the toolbariterator should give them in the proper order. | 766 | // the toolbariterator should give them in the proper order. |
758 | // Both the XMLGUI and applySettings call this, hence "force" for the latter. | 767 | // Both the XMLGUI and applySettings call this, hence "force" for the latter. |
759 | QPtrListIterator<KToolBar> it( toolBarIterator() ); | 768 | Q3PtrListIterator<KToolBar> it( toolBarIterator() ); |
760 | for ( ; it.current() ; ++ it ) | 769 | for ( ; it.current() ; ++ it ) |
761 | it.current()->positionYourself( force ); | 770 | it.current()->positionYourself( force ); |
762 | 771 | ||
763 | d->settingsDirty = false; | 772 | d->settingsDirty = false; |
764 | } | 773 | } |
765 | 774 | ||
766 | void KMainWindow::saveWindowSize( KConfig * config ) const | 775 | void KMainWindow::saveWindowSize( KConfig * config ) const |
767 | { | 776 | { |
768 | /*US | 777 | /*US |
769 | int scnum = QApplication::desktop()->screenNumber(parentWidget()); | 778 | int scnum = QApplication::desktop()->screenNumber(parentWidget()); |
770 | QRect desk = QApplication::desktop()->screenGeometry(scnum); | 779 | QRect desk = QApplication::desktop()->screenGeometry(scnum); |
771 | */ | 780 | */ |
@@ -842,117 +851,105 @@ bool KMainWindow::settingsDirty() const | |||
842 | return d->settingsDirty; | 851 | return d->settingsDirty; |
843 | } | 852 | } |
844 | 853 | ||
845 | QString KMainWindow::settingsGroup() const | 854 | QString KMainWindow::settingsGroup() const |
846 | { | 855 | { |
847 | return d->autoSaveGroup; | 856 | return d->autoSaveGroup; |
848 | } | 857 | } |
849 | 858 | ||
850 | void KMainWindow::resizeEvent( QResizeEvent * e) | 859 | void KMainWindow::resizeEvent( QResizeEvent * e) |
851 | { | 860 | { |
852 | if ( d->autoSaveWindowSize ) | 861 | if ( d->autoSaveWindowSize ) |
853 | setSettingsDirty(); | 862 | setSettingsDirty(); |
854 | QMainWindow::resizeEvent( e ); | 863 | Q3MainWindow::resizeEvent( e ); |
855 | } | 864 | } |
856 | 865 | ||
857 | bool KMainWindow::hasMenuBar() | 866 | bool KMainWindow::hasMenuBar() |
858 | { | 867 | { |
859 | return (internalMenuBar()); | 868 | return (internalMenuBar()); |
860 | } | 869 | } |
861 | 870 | ||
862 | //US KMenuBar *KMainWindow::menuBar() | 871 | //US KMenuBar *KMainWindow::menuBar() |
863 | QMenuBar *KMainWindow::menuBar() | 872 | QMenuBar *KMainWindow::menuBar() |
864 | { | 873 | { |
865 | //US KMenuBar * mb = internalMenuBar(); | 874 | //US KMenuBar * mb = internalMenuBar(); |
866 | QMenuBar * mb = internalMenuBar(); | 875 | QMenuBar * mb = internalMenuBar(); |
867 | if ( !mb ) { | 876 | if ( !mb ) { |
868 | //US mb = new KMenuBar( this ); | 877 | //US mb = new KMenuBar( this ); |
869 | mb = new QMenuBar( this ); | 878 | mb = new QMenuBar( this ); |
870 | // trigger a re-layout and trigger a call to the private | 879 | // trigger a re-layout and trigger a call to the private |
871 | // setMenuBar method. | 880 | // setMenuBar method. |
872 | QMainWindow::menuBar(); | 881 | Q3MainWindow::menuBar(); |
873 | } | 882 | } |
874 | return mb; | 883 | return mb; |
875 | } | 884 | } |
876 | 885 | ||
877 | //US KStatusBar *KMainWindow::statusBar() | 886 | //US KStatusBar *KMainWindow::statusBar() |
878 | QStatusBar *KMainWindow::statusBar() | 887 | QStatusBar *KMainWindow::statusBar() |
879 | { | 888 | { |
880 | //US KStatusBar * sb = internalStatusBar(); | 889 | //US KStatusBar * sb = internalStatusBar(); |
881 | QStatusBar * sb = internalStatusBar(); | 890 | QStatusBar * sb = internalStatusBar(); |
882 | if ( !sb ) { | 891 | if ( !sb ) { |
883 | //US sb = new KStatusBar( this ); | 892 | //US sb = new KStatusBar( this ); |
884 | sb = new QStatusBar( this ); | 893 | sb = new QStatusBar( this ); |
885 | // trigger a re-layout and trigger a call to the private | 894 | // trigger a re-layout and trigger a call to the private |
886 | // setStatusBar method. | 895 | // setStatusBar method. |
887 | QMainWindow::statusBar(); | 896 | Q3MainWindow::statusBar(); |
888 | } | 897 | } |
889 | return sb; | 898 | return sb; |
890 | } | 899 | } |
891 | 900 | ||
892 | void KMainWindow::shuttingDown() | 901 | void KMainWindow::shuttingDown() |
893 | { | 902 | { |
894 | // Needed for Qt <= 3.0.3 at least to prevent reentrancy | 903 | // Needed for Qt <= 3.0.3 at least to prevent reentrancy |
895 | // when queryExit() shows a dialog. Check before removing! | 904 | // when queryExit() shows a dialog. Check before removing! |
896 | static bool reentrancy_protection = false; | 905 | static bool reentrancy_protection = false; |
897 | if (!reentrancy_protection) | 906 | if (!reentrancy_protection) |
898 | { | 907 | { |
899 | reentrancy_protection = true; | 908 | reentrancy_protection = true; |
900 | // call the virtual queryExit | 909 | // call the virtual queryExit |
901 | queryExit(); | 910 | queryExit(); |
902 | reentrancy_protection = false; | 911 | reentrancy_protection = false; |
903 | } | 912 | } |
904 | 913 | ||
905 | } | 914 | } |
906 | 915 | ||
907 | //US KMenuBar *KMainWindow::internalMenuBar() | 916 | //US KMenuBar *KMainWindow::internalMenuBar() |
908 | QMenuBar *KMainWindow::internalMenuBar() | 917 | QMenuBar *KMainWindow::internalMenuBar() |
909 | { | 918 | { |
910 | //US QObjectList *l = queryList( "KMenuBar", 0, false, false ); | 919 | //US QObjectList *l = queryList( "KMenuBar", 0, false, false ); |
911 | QObjectList *l = queryList( "QMenuBar", 0, false, false ); | 920 | QObjectList l = queryList( "QMenuBar", 0, false, false ); |
912 | if ( !l || !l->first() ) { | 921 | if(l.empty()) |
913 | delete l; | 922 | return 0; |
914 | return 0; | 923 | return (QMenuBar*)l.front(); |
915 | } | ||
916 | |||
917 | //US KMenuBar *m = (KMenuBar*)l->first(); | ||
918 | QMenuBar *m = (QMenuBar*)l->first(); | ||
919 | delete l; | ||
920 | return m; | ||
921 | } | 924 | } |
922 | 925 | ||
923 | //US KStatusBar *KMainWindow::internalStatusBar() | 926 | //US KStatusBar *KMainWindow::internalStatusBar() |
924 | QStatusBar *KMainWindow::internalStatusBar() | 927 | QStatusBar *KMainWindow::internalStatusBar() |
925 | { | 928 | { |
926 | //US QObjectList *l = queryList( "KStatusBar", 0, false, false ); | 929 | //US QObjectList *l = queryList( "KStatusBar", 0, false, false ); |
927 | QObjectList *l = queryList( "QStatusBar", 0, false, false ); | 930 | QObjectList l = queryList( "QStatusBar", 0, false, false ); |
928 | if ( !l || !l->first() ) { | 931 | if(l.empty()) |
929 | delete l; | 932 | return 0; |
930 | return 0; | 933 | return (QStatusBar*)l.front(); |
931 | } | ||
932 | |||
933 | //US KStatusBar *s = (KStatusBar*)l->first(); | ||
934 | QStatusBar *s = (QStatusBar*)l->first(); | ||
935 | delete l; | ||
936 | return s; | ||
937 | } | 934 | } |
938 | 935 | ||
939 | void KMainWindow::childEvent( QChildEvent* e) | 936 | void KMainWindow::childEvent( QChildEvent* e) |
940 | { | 937 | { |
941 | QMainWindow::childEvent( e ); | 938 | Q3MainWindow::childEvent( e ); |
942 | } | 939 | } |
943 | 940 | ||
944 | void KMainWindow::paintEvent( QPaintEvent * e) | 941 | void KMainWindow::paintEvent( QPaintEvent * e) |
945 | { | 942 | { |
946 | QMainWindow::paintEvent( e ); | 943 | Q3MainWindow::paintEvent( e ); |
947 | } | 944 | } |
948 | 945 | ||
949 | QSize KMainWindow::sizeForCentralWidgetSize(QSize size) | 946 | QSize KMainWindow::sizeForCentralWidgetSize(QSize size) |
950 | { | 947 | { |
951 | KToolBar *tb = (KToolBar*)child( "mainToolBar", "KToolBar" ); | 948 | KToolBar *tb = (KToolBar*)child( "mainToolBar", "KToolBar" ); |
952 | if (tb && !tb->isHidden()) { | 949 | if (tb && !tb->isHidden()) { |
953 | switch( tb->barPos() ) | 950 | switch( tb->barPos() ) |
954 | { | 951 | { |
955 | case KToolBar::Top: | 952 | case KToolBar::Top: |
956 | case KToolBar::Bottom: | 953 | case KToolBar::Bottom: |
957 | size += QSize(0, tb->sizeHint().height()); | 954 | size += QSize(0, tb->sizeHint().height()); |
958 | break; | 955 | break; |