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.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/microkde/kdeui/kmainwindow.cpp b/microkde/kdeui/kmainwindow.cpp
index 3ae4c87..fa678f2 100644
--- a/microkde/kdeui/kmainwindow.cpp
+++ b/microkde/kdeui/kmainwindow.cpp
@@ -8,97 +8,97 @@
8 (C) 2002 Joseph Wenninger (jowenn@kde.org) 8 (C) 2002 Joseph Wenninger (jowenn@kde.org)
9 9
10 This library is free software; you can redistribute it and/or 10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Library General Public 11 modify it under the terms of the GNU Library General Public
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 <qobjectlist.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 30
31 31
32#include "kdebug.h" 32#include "kdebug.h"
33#include "kmainwindow.h" 33#include "kmainwindow.h"
34#include "kglobalsettings.h" 34#include "kglobalsettings.h"
35#include "kactioncollection.h" 35#include "kactioncollection.h"
36 36
37class KMainWindowPrivate { 37class KMainWindowPrivate {
38public: 38public:
39//US bool showHelpMenu:1; 39//US bool showHelpMenu:1;
40 40
41 bool autoSaveSettings:1; 41 bool autoSaveSettings:1;
42 bool settingsDirty:1; 42 bool settingsDirty:1;
43 bool autoSaveWindowSize:1; 43 bool autoSaveWindowSize:1;
44 bool care_about_geometry:1; 44 bool care_about_geometry:1;
45 QString autoSaveGroup; 45 QString autoSaveGroup;
46//US KAccel * kaccel; 46//US KAccel * kaccel;
47//US KMainWindowInterface *m_interface; 47//US KMainWindowInterface *m_interface;
48 KDEPrivate::ToolBarHandler *toolBarHandler; 48 KDEPrivate::ToolBarHandler *toolBarHandler;
49 QTimer* settingsTimer; 49 QTimer* settingsTimer;
50 KToggleAction *showStatusBarAction; 50 KToggleAction *showStatusBarAction;
51 QRect defaultWindowSize; 51 QRect defaultWindowSize;
52}; 52};
53 53
54static bool no_query_exit = false; 54static bool no_query_exit = false;
55 55
56KMainWindow::KMainWindow( QWidget* parent, const char *name, WFlags f ) 56KMainWindow::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 )*/ 57 : QMainWindow( parent, name ) /*LR, f ) with the default widget flag we cannot have fastload */ /*US, KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )*/
58{ 58{
59 mQToolBar = 0; 59 mQToolBar = 0;
60 initKMainWindow(name); 60 initKMainWindow(name);
61} 61}
62 62
63void KMainWindow::parseGeometry(bool parsewidth) 63void KMainWindow::parseGeometry(bool parsewidth)
64{ 64{
65//US the following code is not getting used in the embedded version !! So disable it for now 65//US the following code is not getting used in the embedded version !! So disable it for now
66/*US 66/*US
67 67
68 assert ( !kapp->geometryArgument().isNull() ); 68 assert ( !kapp->geometryArgument().isNull() );
69 assert ( d->care_about_geometry ); 69 assert ( d->care_about_geometry );
70 70
71#ifndef Q_WS_QWS 71#ifndef Q_WS_QWS
72 // FIXME: (E) Implement something similar for Qt Embedded (or decide we don't need it) 72 // FIXME: (E) Implement something similar for Qt Embedded (or decide we don't need it)
73 int x, y; 73 int x, y;
74 int w, h; 74 int w, h;
75 int m = XParseGeometry( kapp->geometryArgument().latin1(), &x, &y, (unsigned int*)&w, (unsigned int*)&h); 75 int m = XParseGeometry( kapp->geometryArgument().latin1(), &x, &y, (unsigned int*)&w, (unsigned int*)&h);
76 if (parsewidth) { 76 if (parsewidth) {
77 QSize minSize = minimumSize(); 77 QSize minSize = minimumSize();
78 QSize maxSize = maximumSize(); 78 QSize maxSize = maximumSize();
79 if ( (m & WidthValue) == 0 ) 79 if ( (m & WidthValue) == 0 )
80 w = width(); 80 w = width();
81 if ( (m & HeightValue) == 0 ) 81 if ( (m & HeightValue) == 0 )
82 h = height(); 82 h = height();
83 w = QMIN(w,maxSize.width()); 83 w = QMIN(w,maxSize.width());
84 h = QMIN(h,maxSize.height()); 84 h = QMIN(h,maxSize.height());
85 w = QMAX(w,minSize.width()); 85 w = QMAX(w,minSize.width());
86 h = QMAX(h,minSize.height()); 86 h = QMAX(h,minSize.height());
87 resize(w, h); 87 resize(w, h);
88 } else { 88 } else {
89 if ( parsewidth && (m & XValue) == 0 ) 89 if ( parsewidth && (m & XValue) == 0 )
90 x = geometry().x(); 90 x = geometry().x();
91 if ( parsewidth && (m & YValue) == 0 ) 91 if ( parsewidth && (m & YValue) == 0 )
92 y = geometry().y(); 92 y = geometry().y();
93 if ( (m & XNegative) ) 93 if ( (m & XNegative) )
94 x = KApplication::desktop()->width() + x - w; 94 x = KApplication::desktop()->width() + x - w;
95 if ( (m & YNegative) ) 95 if ( (m & YNegative) )
96 y = KApplication::desktop()->height() + y - h; 96 y = KApplication::desktop()->height() + y - h;
97 move(x, y); 97 move(x, y);
98 } 98 }
99#endif 99#endif
100*/ 100*/
101} 101}
102 102
103KMainWindow::~KMainWindow() 103KMainWindow::~KMainWindow()
104{ 104{
@@ -802,192 +802,193 @@ void KMainWindow::restoreWindowSize( KConfig * config )
802 if (!size.isEmpty()) { 802 if (!size.isEmpty()) {
803 // make sure the other resolutions don't get old settings 803 // make sure the other resolutions don't get old settings
804 config->writeEntry( QString::fromLatin1("Width"), 0 ); 804 config->writeEntry( QString::fromLatin1("Width"), 0 );
805 config->writeEntry( QString::fromLatin1("Height"), 0 ); 805 config->writeEntry( QString::fromLatin1("Height"), 0 );
806 } 806 }
807 } 807 }
808 if ( !size.isEmpty() ) 808 if ( !size.isEmpty() )
809 resize( size ); 809 resize( size );
810 } 810 }
811} 811}
812 812
813bool KMainWindow::initialGeometrySet() const 813bool KMainWindow::initialGeometrySet() const
814{ 814{
815 return d->care_about_geometry; 815 return d->care_about_geometry;
816} 816}
817 817
818void KMainWindow::ignoreInitialGeometry() 818void KMainWindow::ignoreInitialGeometry()
819{ 819{
820 d->care_about_geometry = false; 820 d->care_about_geometry = false;
821} 821}
822 822
823void KMainWindow::setSettingsDirty() 823void KMainWindow::setSettingsDirty()
824{ 824{
825 //kdDebug(200) << "KMainWindow::setSettingsDirty" << endl; 825 //kdDebug(200) << "KMainWindow::setSettingsDirty" << endl;
826 d->settingsDirty = true; 826 d->settingsDirty = true;
827 if ( d->autoSaveSettings ) 827 if ( d->autoSaveSettings )
828 { 828 {
829 // Use a timer to save "immediately" user-wise, but not too immediately 829 // Use a timer to save "immediately" user-wise, but not too immediately
830 // (to compress calls and save only once, in case of multiple changes) 830 // (to compress calls and save only once, in case of multiple changes)
831 if ( !d->settingsTimer ) 831 if ( !d->settingsTimer )
832 { 832 {
833 d->settingsTimer = new QTimer( this ); 833 d->settingsTimer = new QTimer( this );
834 connect( d->settingsTimer, SIGNAL( timeout() ), SLOT( saveAutoSaveSettings() ) ); 834 connect( d->settingsTimer, SIGNAL( timeout() ), SLOT( saveAutoSaveSettings() ) );
835 } 835 }
836 d->settingsTimer->start( 500, true ); 836 d->settingsTimer->start( 500, true );
837 } 837 }
838} 838}
839 839
840bool KMainWindow::settingsDirty() const 840bool KMainWindow::settingsDirty() const
841{ 841{
842 return d->settingsDirty; 842 return d->settingsDirty;
843} 843}
844 844
845QString KMainWindow::settingsGroup() const 845QString KMainWindow::settingsGroup() const
846{ 846{
847 return d->autoSaveGroup; 847 return d->autoSaveGroup;
848} 848}
849 849
850void KMainWindow::resizeEvent( QResizeEvent * ) 850void KMainWindow::resizeEvent( QResizeEvent * e)
851{ 851{
852 if ( d->autoSaveWindowSize ) 852 if ( d->autoSaveWindowSize )
853 setSettingsDirty(); 853 setSettingsDirty();
854 QMainWindow::resizeEvent( e );
854} 855}
855 856
856bool KMainWindow::hasMenuBar() 857bool KMainWindow::hasMenuBar()
857{ 858{
858 return (internalMenuBar()); 859 return (internalMenuBar());
859} 860}
860 861
861//US KMenuBar *KMainWindow::menuBar() 862//US KMenuBar *KMainWindow::menuBar()
862QMenuBar *KMainWindow::menuBar() 863QMenuBar *KMainWindow::menuBar()
863{ 864{
864//US KMenuBar * mb = internalMenuBar(); 865//US KMenuBar * mb = internalMenuBar();
865 QMenuBar * mb = internalMenuBar(); 866 QMenuBar * mb = internalMenuBar();
866 if ( !mb ) { 867 if ( !mb ) {
867//US mb = new KMenuBar( this ); 868//US mb = new KMenuBar( this );
868 mb = new QMenuBar( this ); 869 mb = new QMenuBar( this );
869 // trigger a re-layout and trigger a call to the private 870 // trigger a re-layout and trigger a call to the private
870 // setMenuBar method. 871 // setMenuBar method.
871 QMainWindow::menuBar(); 872 QMainWindow::menuBar();
872 } 873 }
873 return mb; 874 return mb;
874} 875}
875 876
876//US KStatusBar *KMainWindow::statusBar() 877//US KStatusBar *KMainWindow::statusBar()
877QStatusBar *KMainWindow::statusBar() 878QStatusBar *KMainWindow::statusBar()
878{ 879{
879//US KStatusBar * sb = internalStatusBar(); 880//US KStatusBar * sb = internalStatusBar();
880 QStatusBar * sb = internalStatusBar(); 881 QStatusBar * sb = internalStatusBar();
881 if ( !sb ) { 882 if ( !sb ) {
882//US sb = new KStatusBar( this ); 883//US sb = new KStatusBar( this );
883 sb = new QStatusBar( this ); 884 sb = new QStatusBar( this );
884 // trigger a re-layout and trigger a call to the private 885 // trigger a re-layout and trigger a call to the private
885 // setStatusBar method. 886 // setStatusBar method.
886 QMainWindow::statusBar(); 887 QMainWindow::statusBar();
887 } 888 }
888 return sb; 889 return sb;
889} 890}
890 891
891void KMainWindow::shuttingDown() 892void KMainWindow::shuttingDown()
892{ 893{
893 // Needed for Qt <= 3.0.3 at least to prevent reentrancy 894 // Needed for Qt <= 3.0.3 at least to prevent reentrancy
894 // when queryExit() shows a dialog. Check before removing! 895 // when queryExit() shows a dialog. Check before removing!
895 static bool reentrancy_protection = false; 896 static bool reentrancy_protection = false;
896 if (!reentrancy_protection) 897 if (!reentrancy_protection)
897 { 898 {
898 reentrancy_protection = true; 899 reentrancy_protection = true;
899 // call the virtual queryExit 900 // call the virtual queryExit
900 queryExit(); 901 queryExit();
901 reentrancy_protection = false; 902 reentrancy_protection = false;
902 } 903 }
903 904
904} 905}
905 906
906//US KMenuBar *KMainWindow::internalMenuBar() 907//US KMenuBar *KMainWindow::internalMenuBar()
907QMenuBar *KMainWindow::internalMenuBar() 908QMenuBar *KMainWindow::internalMenuBar()
908{ 909{
909//US QObjectList *l = queryList( "KMenuBar", 0, false, false ); 910//US QObjectList *l = queryList( "KMenuBar", 0, false, false );
910 QObjectList *l = queryList( "QMenuBar", 0, false, false ); 911 QObjectList *l = queryList( "QMenuBar", 0, false, false );
911 if ( !l || !l->first() ) { 912 if ( !l || !l->first() ) {
912 delete l; 913 delete l;
913 return 0; 914 return 0;
914 } 915 }
915 916
916//US KMenuBar *m = (KMenuBar*)l->first(); 917//US KMenuBar *m = (KMenuBar*)l->first();
917 QMenuBar *m = (QMenuBar*)l->first(); 918 QMenuBar *m = (QMenuBar*)l->first();
918 delete l; 919 delete l;
919 return m; 920 return m;
920} 921}
921 922
922//US KStatusBar *KMainWindow::internalStatusBar() 923//US KStatusBar *KMainWindow::internalStatusBar()
923QStatusBar *KMainWindow::internalStatusBar() 924QStatusBar *KMainWindow::internalStatusBar()
924{ 925{
925//US QObjectList *l = queryList( "KStatusBar", 0, false, false ); 926//US QObjectList *l = queryList( "KStatusBar", 0, false, false );
926 QObjectList *l = queryList( "QStatusBar", 0, false, false ); 927 QObjectList *l = queryList( "QStatusBar", 0, false, false );
927 if ( !l || !l->first() ) { 928 if ( !l || !l->first() ) {
928 delete l; 929 delete l;
929 return 0; 930 return 0;
930 } 931 }
931 932
932//US KStatusBar *s = (KStatusBar*)l->first(); 933//US KStatusBar *s = (KStatusBar*)l->first();
933 QStatusBar *s = (QStatusBar*)l->first(); 934 QStatusBar *s = (QStatusBar*)l->first();
934 delete l; 935 delete l;
935 return s; 936 return s;
936} 937}
937 938
938void KMainWindow::childEvent( QChildEvent* e) 939void KMainWindow::childEvent( QChildEvent* e)
939{ 940{
940 QMainWindow::childEvent( e ); 941 QMainWindow::childEvent( e );
941} 942}
942 943
943void KMainWindow::paintEvent( QPaintEvent * ) 944void KMainWindow::paintEvent( QPaintEvent * e)
944{ 945{
945 // do nothing 946 QMainWindow::paintEvent( e );
946} 947}
947 948
948QSize KMainWindow::sizeForCentralWidgetSize(QSize size) 949QSize KMainWindow::sizeForCentralWidgetSize(QSize size)
949{ 950{
950 KToolBar *tb = (KToolBar*)child( "mainToolBar", "KToolBar" ); 951 KToolBar *tb = (KToolBar*)child( "mainToolBar", "KToolBar" );
951 if (tb && !tb->isHidden()) { 952 if (tb && !tb->isHidden()) {
952 switch( tb->barPos() ) 953 switch( tb->barPos() )
953 { 954 {
954 case KToolBar::Top: 955 case KToolBar::Top:
955 case KToolBar::Bottom: 956 case KToolBar::Bottom:
956 size += QSize(0, tb->sizeHint().height()); 957 size += QSize(0, tb->sizeHint().height());
957 break; 958 break;
958 959
959 case KToolBar::Left: 960 case KToolBar::Left:
960 case KToolBar::Right: 961 case KToolBar::Right:
961 size += QSize(toolBar()->sizeHint().width(), 0); 962 size += QSize(toolBar()->sizeHint().width(), 0);
962 break; 963 break;
963 964
964 case KToolBar::Flat: 965 case KToolBar::Flat:
965//US size += QSize(0, 3+kapp->style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); 966//US size += QSize(0, 3+kapp->style().pixelMetric( QStyle::PM_DockWindowHandleExtent ));
966 size += QSize(0, tb->sizeHint().height()); 967 size += QSize(0, tb->sizeHint().height());
967 break; 968 break;
968 969
969 default: 970 default:
970 break; 971 break;
971 } 972 }
972 } 973 }
973//US KMenuBar *mb = menuBar(); 974//US KMenuBar *mb = menuBar();
974 QMenuBar *mb = menuBar(); 975 QMenuBar *mb = menuBar();
975 if (!mb->isHidden()) { 976 if (!mb->isHidden()) {
976 size += QSize(0,mb->heightForWidth(size.width())); 977 size += QSize(0,mb->heightForWidth(size.width()));
977/*US if (style().styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, this)) 978/*US if (style().styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, this))
978 size += QSize( 0, dockWindowsMovable() ? 1 : 2); 979 size += QSize( 0, dockWindowsMovable() ? 1 : 2);
979*/ 980*/
980 size += QSize( 0, 2); 981 size += QSize( 0, 2);
981 } 982 }
982 QStatusBar *sb = internalStatusBar(); 983 QStatusBar *sb = internalStatusBar();
983 if( sb && !sb->isHidden() ) 984 if( sb && !sb->isHidden() )
984 size += QSize(0, sb->sizeHint().height()); 985 size += QSize(0, sb->sizeHint().height());
985 986
986 return size; 987 return size;
987} 988}
988 989
989// why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI; 990// why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI;
990void KMainWindow::finalizeGUI( KXMLGUIClient *client ) 991void KMainWindow::finalizeGUI( KXMLGUIClient *client )
991{ /*US KXMLGUIBuilder::finalizeGUI( client );*/ } 992{ /*US KXMLGUIBuilder::finalizeGUI( client );*/ }
992 993
993void KMainWindow::virtual_hook( int id, void* data ) 994void KMainWindow::virtual_hook( int id, void* data )