summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/kmainwindow.cpp
Unidiff
Diffstat (limited to 'microkde/kdeui/kmainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/kmainwindow.cpp97
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
@@ -18,18 +18,24 @@
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"
@@ -51,13 +57,13 @@ public:
51 QRect defaultWindowSize; 57 QRect defaultWindowSize;
52}; 58};
53 59
54static bool no_query_exit = false; 60static bool no_query_exit = false;
55 61
56KMainWindow::KMainWindow( QWidget* parent, const char *name ) 62KMainWindow::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
63void KMainWindow::parseGeometry(bool parsewidth) 69void KMainWindow::parseGeometry(bool parsewidth)
@@ -273,13 +279,13 @@ void KMainWindow::setCaption( const QString &caption, bool modified )
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
277void KMainWindow::setPlainCaption( const QString &caption ) 283void 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}
@@ -418,16 +424,16 @@ void KMainWindow::createStandardStatusBarAction(){
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
424QToolBar *KMainWindow::tBar( ) 430Q3ToolBar *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
431KToolBar *KMainWindow::toolBar( const char * name ) 437KToolBar *KMainWindow::toolBar( const char * name )
432{ 438{
433 439
@@ -440,39 +446,40 @@ KToolBar *KMainWindow::toolBar( const char * name )
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
449QPtrListIterator<KToolBar> KMainWindow::toolBarIterator() 455Q3PtrListIterator<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
464void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize ) 471void 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);
@@ -500,13 +507,13 @@ QString KMainWindow::autoSaveGroup() const
500{ 507{
501 return d->autoSaveGroup; 508 return d->autoSaveGroup;
502} 509}
503 510
504void KMainWindow::saveAutoSaveSettings() 511void 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();
@@ -636,13 +643,13 @@ void KMainWindow::saveMainWindowSettings(KConfig *config, const QString &configG
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,
@@ -711,25 +718,27 @@ void KMainWindow::applyMainWindowSettings(KConfig *config, const QString &config
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 {
@@ -753,13 +762,13 @@ void KMainWindow::finalizeGUI( bool force )
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
@@ -848,13 +857,13 @@ QString KMainWindow::settingsGroup() const
848} 857}
849 858
850void KMainWindow::resizeEvent( QResizeEvent * e) 859void 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
857bool KMainWindow::hasMenuBar() 866bool KMainWindow::hasMenuBar()
858{ 867{
859 return (internalMenuBar()); 868 return (internalMenuBar());
860} 869}
@@ -866,13 +875,13 @@ QMenuBar *KMainWindow::menuBar()
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()
878QStatusBar *KMainWindow::statusBar() 887QStatusBar *KMainWindow::statusBar()
@@ -881,13 +890,13 @@ QStatusBar *KMainWindow::statusBar()
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
892void KMainWindow::shuttingDown() 901void KMainWindow::shuttingDown()
893{ 902{
@@ -905,48 +914,36 @@ void KMainWindow::shuttingDown()
905} 914}
906 915
907//US KMenuBar *KMainWindow::internalMenuBar() 916//US KMenuBar *KMainWindow::internalMenuBar()
908QMenuBar *KMainWindow::internalMenuBar() 917QMenuBar *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()
924QStatusBar *KMainWindow::internalStatusBar() 927QStatusBar *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
939void KMainWindow::childEvent( QChildEvent* e) 936void KMainWindow::childEvent( QChildEvent* e)
940{ 937{
941 QMainWindow::childEvent( e ); 938 Q3MainWindow::childEvent( e );
942} 939}
943 940
944void KMainWindow::paintEvent( QPaintEvent * e) 941void KMainWindow::paintEvent( QPaintEvent * e)
945{ 942{
946 QMainWindow::paintEvent( e ); 943 Q3MainWindow::paintEvent( e );
947} 944}
948 945
949QSize KMainWindow::sizeForCentralWidgetSize(QSize size) 946QSize 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()) {