-rw-r--r-- | kaddressbook/mainembedded.cpp | 6 | ||||
-rw-r--r-- | microkde/kdeui/kmainwindow.cpp | 2 |
2 files changed, 3 insertions, 5 deletions
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp index c127601..dce6a88 100644 --- a/kaddressbook/mainembedded.cpp +++ b/kaddressbook/mainembedded.cpp | |||
@@ -1,191 +1,189 @@ | |||
1 | #ifndef DESKTOP_VERSION | 1 | #ifndef DESKTOP_VERSION |
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #else | 4 | #else |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include <qwindowsstyle.h> | 6 | #include <qwindowsstyle.h> |
7 | #include <qplatinumstyle.h> | 7 | #include <qplatinumstyle.h> |
8 | #include <qmainwindow.h> | 8 | #include <qmainwindow.h> |
9 | #endif | 9 | #endif |
10 | 10 | ||
11 | #include <kstandarddirs.h> | 11 | #include <kstandarddirs.h> |
12 | #include <kglobal.h> | 12 | #include <kglobal.h> |
13 | #include <stdio.h> | 13 | #include <stdio.h> |
14 | #include <qdir.h> | 14 | #include <qdir.h> |
15 | #include "kaddressbookmain.h" | 15 | #include "kaddressbookmain.h" |
16 | 16 | ||
17 | int main( int argc, char **argv ) | 17 | int main( int argc, char **argv ) |
18 | { | 18 | { |
19 | #ifndef DESKTOP_VERSION | 19 | #ifndef DESKTOP_VERSION |
20 | QPEApplication a( argc, argv ); | 20 | QPEApplication a( argc, argv ); |
21 | a.setKeepRunning (); | 21 | a.setKeepRunning (); |
22 | #else | 22 | #else |
23 | QApplication a( argc, argv ); | 23 | QApplication a( argc, argv ); |
24 | QApplication::setStyle( new QPlatinumStyle ()); | 24 | QApplication::setStyle( new QPlatinumStyle ()); |
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | bool exitHelp = false; | 27 | bool exitHelp = false; |
28 | if ( argc > 1 ) { | 28 | if ( argc > 1 ) { |
29 | QString command = argv[1]; | 29 | QString command = argv[1]; |
30 | if ( command == "-help" ){ | 30 | if ( command == "-help" ){ |
31 | printf("KA/E command line commands:\n"); | 31 | printf("KA/E command line commands:\n"); |
32 | printf(" no command: Start KA/E in usual way\n"); | 32 | printf(" no command: Start KA/E in usual way\n"); |
33 | printf(" -help: This output\n"); | 33 | printf(" -help: This output\n"); |
34 | printf(" KA/E is exiting now. Bye!\n"); | 34 | printf(" KA/E is exiting now. Bye!\n"); |
35 | exitHelp = true; | 35 | exitHelp = true; |
36 | } | 36 | } |
37 | } | 37 | } |
38 | if ( ! exitHelp ) { | 38 | if ( ! exitHelp ) { |
39 | 39 | ||
40 | KGlobal::setAppName( "kaddressbook" ); | 40 | KGlobal::setAppName( "kaddressbook" ); |
41 | #ifndef DESKTOP_VERSION | 41 | #ifndef DESKTOP_VERSION |
42 | if ( QApplication::desktop()->width() > 320 ) | 42 | if ( QApplication::desktop()->width() > 320 ) |
43 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); | 43 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); |
44 | else | 44 | else |
45 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); | 45 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); |
46 | #else | 46 | #else |
47 | QString fileName ; | 47 | QString fileName ; |
48 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/"; | 48 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/"; |
49 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); | 49 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); |
50 | 50 | ||
51 | #endif | 51 | #endif |
52 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); | 52 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); |
53 | KAddressBookMain* m = new KAddressBookMain(); | 53 | KAddressBookMain m ; |
54 | //US MainWindow m; | 54 | //US MainWindow m; |
55 | //US QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); | 55 | //US QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); |
56 | 56 | ||
57 | #ifndef DESKTOP_VERSION | 57 | #ifndef DESKTOP_VERSION |
58 | a.showMainWidget(m ); | 58 | a.showMainWidget( &m ); |
59 | m->showMaximized(); | ||
60 | #else | 59 | #else |
61 | a.setMainWidget(m ); | 60 | a.setMainWidget(m ); |
62 | m->show(); | 61 | m->show(); |
63 | //m->resize( 640, 480 ); | ||
64 | #endif | 62 | #endif |
65 | a.exec(); | 63 | a.exec(); |
66 | 64 | ||
67 | } | 65 | } |
68 | qDebug("KA: Bye! "); | 66 | qDebug("KA: Bye! "); |
69 | } | 67 | } |
70 | 68 | ||
71 | /* | 69 | /* |
72 | #include <stdlib.h> | 70 | #include <stdlib.h> |
73 | 71 | ||
74 | #include <qstring.h> | 72 | #include <qstring.h> |
75 | 73 | ||
76 | #include <kabc/stdaddressbook.h> | 74 | #include <kabc/stdaddressbook.h> |
77 | #include <kaboutdata.h> | 75 | #include <kaboutdata.h> |
78 | #include <kcmdlineargs.h> | 76 | #include <kcmdlineargs.h> |
79 | #include <kcrash.h> | 77 | #include <kcrash.h> |
80 | #include <kdebug.h> | 78 | #include <kdebug.h> |
81 | #include <klocale.h> | 79 | #include <klocale.h> |
82 | #include <kstartupinfo.h> | 80 | #include <kstartupinfo.h> |
83 | #include <kuniqueapplication.h> | 81 | #include <kuniqueapplication.h> |
84 | #include <kwin.h> | 82 | #include <kwin.h> |
85 | 83 | ||
86 | #include "kaddressbookmain.h" | 84 | #include "kaddressbookmain.h" |
87 | #include "kabcore.h" | 85 | #include "kabcore.h" |
88 | 86 | ||
89 | extern "C" { | 87 | extern "C" { |
90 | 88 | ||
91 | void crashHandler( int ) | 89 | void crashHandler( int ) |
92 | { | 90 | { |
93 | KABC::StdAddressBook::handleCrash(); | 91 | KABC::StdAddressBook::handleCrash(); |
94 | ::exit( 0 ); | 92 | ::exit( 0 ); |
95 | } | 93 | } |
96 | 94 | ||
97 | } | 95 | } |
98 | 96 | ||
99 | class KAddressBookApp : public KUniqueApplication { | 97 | class KAddressBookApp : public KUniqueApplication { |
100 | public: | 98 | public: |
101 | KAddressBookApp() : mMainWin( 0 ) {} | 99 | KAddressBookApp() : mMainWin( 0 ) {} |
102 | ~KAddressBookApp() {} | 100 | ~KAddressBookApp() {} |
103 | 101 | ||
104 | int newInstance(); | 102 | int newInstance(); |
105 | 103 | ||
106 | private: | 104 | private: |
107 | KAddressBookMain *mMainWin; | 105 | KAddressBookMain *mMainWin; |
108 | }; | 106 | }; |
109 | 107 | ||
110 | int KAddressBookApp::newInstance() | 108 | int KAddressBookApp::newInstance() |
111 | { | 109 | { |
112 | if ( isRestored() ) { | 110 | if ( isRestored() ) { |
113 | // There can only be one main window | 111 | // There can only be one main window |
114 | if ( KMainWindow::canBeRestored( 1 ) ) { | 112 | if ( KMainWindow::canBeRestored( 1 ) ) { |
115 | mMainWin = new KAddressBookMain; | 113 | mMainWin = new KAddressBookMain; |
116 | mMainWin->show(); | 114 | mMainWin->show(); |
117 | mMainWin->restore( 1 ); | 115 | mMainWin->restore( 1 ); |
118 | } | 116 | } |
119 | } else { | 117 | } else { |
120 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); | 118 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
121 | 119 | ||
122 | QCString addrStr = args->getOption( "addr" ); | 120 | QCString addrStr = args->getOption( "addr" ); |
123 | QCString uidStr = args->getOption( "uid" ); | 121 | QCString uidStr = args->getOption( "uid" ); |
124 | QString addr; | 122 | QString addr; |
125 | QString uid; | 123 | QString uid; |
126 | if ( !addrStr.isEmpty() ) | 124 | if ( !addrStr.isEmpty() ) |
127 | addr = QString::fromLocal8Bit( addrStr ); | 125 | addr = QString::fromLocal8Bit( addrStr ); |
128 | if ( !uidStr.isEmpty() ) | 126 | if ( !uidStr.isEmpty() ) |
129 | uid = QString::fromLocal8Bit( uidStr ); | 127 | uid = QString::fromLocal8Bit( uidStr ); |
130 | 128 | ||
131 | 129 | ||
132 | if ( args->isSet( "editor-only" ) ) { | 130 | if ( args->isSet( "editor-only" ) ) { |
133 | if ( !mMainWin ) | 131 | if ( !mMainWin ) |
134 | mMainWin = new KAddressBookMain; | 132 | mMainWin = new KAddressBookMain; |
135 | KStartupInfo::appStarted(); | 133 | KStartupInfo::appStarted(); |
136 | mMainWin->hide(); | 134 | mMainWin->hide(); |
137 | } else { | 135 | } else { |
138 | if ( mMainWin ) { | 136 | if ( mMainWin ) { |
139 | mMainWin->show(); | 137 | mMainWin->show(); |
140 | KWin::setActiveWindow( mMainWin->winId() ); | 138 | KWin::setActiveWindow( mMainWin->winId() ); |
141 | } else { | 139 | } else { |
142 | mMainWin = new KAddressBookMain; | 140 | mMainWin = new KAddressBookMain; |
143 | mMainWin->show(); | 141 | mMainWin->show(); |
144 | } | 142 | } |
145 | } | 143 | } |
146 | // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do | 144 | // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do |
147 | if ( !addr.isEmpty() ) | 145 | if ( !addr.isEmpty() ) |
148 | mMainWin->addEmail( addr ); | 146 | mMainWin->addEmail( addr ); |
149 | 147 | ||
150 | if ( !uid.isEmpty() ) | 148 | if ( !uid.isEmpty() ) |
151 | mMainWin->showContactEditor( uid ); | 149 | mMainWin->showContactEditor( uid ); |
152 | if ( args->isSet( "new-contact" ) ) { | 150 | if ( args->isSet( "new-contact" ) ) { |
153 | mMainWin->newContact(); | 151 | mMainWin->newContact(); |
154 | } | 152 | } |
155 | } | 153 | } |
156 | 154 | ||
157 | KCrash::setEmergencySaveFunction( crashHandler ); | 155 | KCrash::setEmergencySaveFunction( crashHandler ); |
158 | 156 | ||
159 | return 0; | 157 | return 0; |
160 | } | 158 | } |
161 | 159 | ||
162 | // the dummy argument is required, because KMail apparently sends an empty | 160 | // the dummy argument is required, because KMail apparently sends an empty |
163 | // argument. | 161 | // argument. |
164 | static KCmdLineOptions kmoptions[] = | 162 | static KCmdLineOptions kmoptions[] = |
165 | { | 163 | { |
166 | { "a", 0 , 0 }, | 164 | { "a", 0 , 0 }, |
167 | { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, | 165 | { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, |
168 | { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, | 166 | { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, |
169 | { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, | 167 | { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, |
170 | { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, | 168 | { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, |
171 | { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, | 169 | { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, |
172 | { 0, 0, 0} | 170 | { 0, 0, 0} |
173 | }; | 171 | }; |
174 | 172 | ||
175 | int main( int argc, char *argv[] ) | 173 | int main( int argc, char *argv[] ) |
176 | { | 174 | { |
177 | KLocale::setMainCatalogue( "kaddressbook" ); | 175 | KLocale::setMainCatalogue( "kaddressbook" ); |
178 | 176 | ||
179 | KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); | 177 | KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); |
180 | KCmdLineArgs::addCmdLineOptions( kmoptions ); | 178 | KCmdLineArgs::addCmdLineOptions( kmoptions ); |
181 | KUniqueApplication::addCmdLineOptions(); | 179 | KUniqueApplication::addCmdLineOptions(); |
182 | 180 | ||
183 | if ( !KAddressBookApp::start() ) | 181 | if ( !KAddressBookApp::start() ) |
184 | exit( 0 ); | 182 | exit( 0 ); |
185 | 183 | ||
186 | KAddressBookApp app; | 184 | KAddressBookApp app; |
187 | KGlobal::locale()->insertCatalogue( "libkdepim" ); | 185 | KGlobal::locale()->insertCatalogue( "libkdepim" ); |
188 | 186 | ||
189 | return app.exec(); | 187 | return app.exec(); |
190 | } | 188 | } |
191 | */ | 189 | */ |
diff --git a/microkde/kdeui/kmainwindow.cpp b/microkde/kdeui/kmainwindow.cpp index 3a2a4d0..bd5a2cc 100644 --- a/microkde/kdeui/kmainwindow.cpp +++ b/microkde/kdeui/kmainwindow.cpp | |||
@@ -1,994 +1,994 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright | 2 | Copyright |
3 | (C) 2000 Reginald Stadlbauer (reggie@kde.org) | 3 | (C) 2000 Reginald Stadlbauer (reggie@kde.org) |
4 | (C) 1997 Stephan Kulow (coolo@kde.org) | 4 | (C) 1997 Stephan Kulow (coolo@kde.org) |
5 | (C) 1997-2000 Sven Radej (radej@kde.org) | 5 | (C) 1997-2000 Sven Radej (radej@kde.org) |
6 | (C) 1997-2000 Matthias Ettrich (ettrich@kde.org) | 6 | (C) 1997-2000 Matthias Ettrich (ettrich@kde.org) |
7 | (C) 1999 Chris Schlaeger (cs@kde.org) | 7 | (C) 1999 Chris Schlaeger (cs@kde.org) |
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 | ||
37 | class KMainWindowPrivate { | 37 | class KMainWindowPrivate { |
38 | public: | 38 | public: |
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 | ||
54 | static bool no_query_exit = false; | 54 | static bool no_query_exit = false; |
55 | 55 | ||
56 | KMainWindow::KMainWindow( QWidget* parent, const char *name, WFlags f ) | 56 | KMainWindow::KMainWindow( QWidget* parent, const char *name, WFlags f ) |
57 | : QMainWindow( parent, name, f )/*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 | ||
63 | void KMainWindow::parseGeometry(bool parsewidth) | 63 | void 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 | ||
103 | KMainWindow::~KMainWindow() | 103 | KMainWindow::~KMainWindow() |
104 | { | 104 | { |
105 | delete d->settingsTimer; | 105 | delete d->settingsTimer; |
106 | QMenuBar* mb = internalMenuBar(); | 106 | QMenuBar* mb = internalMenuBar(); |
107 | delete mb; | 107 | delete mb; |
108 | //US delete d->m_interface; | 108 | //US delete d->m_interface; |
109 | 109 | ||
110 | delete d; | 110 | delete d; |
111 | //US memberList->remove( this ); | 111 | //US memberList->remove( this ); |
112 | } | 112 | } |
113 | 113 | ||
114 | void KMainWindow::initKMainWindow(const char *name) | 114 | void KMainWindow::initKMainWindow(const char *name) |
115 | { | 115 | { |
116 | setDockMenuEnabled( FALSE ); | 116 | setDockMenuEnabled( FALSE ); |
117 | //US mHelpMenu = 0; | 117 | //US mHelpMenu = 0; |
118 | 118 | ||
119 | //US kapp->setTopWidget( this ); | 119 | //US kapp->setTopWidget( this ); |
120 | actionCollection()->setWidget( this ); | 120 | actionCollection()->setWidget( this ); |
121 | //US connect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); | 121 | //US connect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); |
122 | //US if( !memberList ) | 122 | //US if( !memberList ) |
123 | //US memberList = new QPtrList<KMainWindow>; | 123 | //US memberList = new QPtrList<KMainWindow>; |
124 | /*US | 124 | /*US |
125 | 125 | ||
126 | if ( !ksm ) | 126 | if ( !ksm ) |
127 | ksm = ksmd.setObject(new KMWSessionManaged()); | 127 | ksm = ksmd.setObject(new KMWSessionManaged()); |
128 | // set a unique object name. Required by session management. | 128 | // set a unique object name. Required by session management. |
129 | QCString objname; | 129 | QCString objname; |
130 | QCString s; | 130 | QCString s; |
131 | int unusedNumber; | 131 | int unusedNumber; |
132 | if ( !name ) | 132 | if ( !name ) |
133 | { // no name given | 133 | { // no name given |
134 | objname = kapp->instanceName() + "-mainwindow#"; | 134 | objname = kapp->instanceName() + "-mainwindow#"; |
135 | s = objname + '1'; // start adding number immediately | 135 | s = objname + '1'; // start adding number immediately |
136 | unusedNumber = 1; | 136 | unusedNumber = 1; |
137 | } | 137 | } |
138 | else if( name[ strlen( name ) - 1 ] == '#' ) | 138 | else if( name[ strlen( name ) - 1 ] == '#' ) |
139 | { // trailing # - always add a number | 139 | { // trailing # - always add a number |
140 | objname = name; | 140 | objname = name; |
141 | s = objname + '1'; // start adding number immediately | 141 | s = objname + '1'; // start adding number immediately |
142 | unusedNumber = 1; | 142 | unusedNumber = 1; |
143 | } | 143 | } |
144 | else | 144 | else |
145 | { | 145 | { |
146 | objname = name; | 146 | objname = name; |
147 | s = objname; | 147 | s = objname; |
148 | unusedNumber = 0; // add numbers only when needed | 148 | unusedNumber = 0; // add numbers only when needed |
149 | } | 149 | } |
150 | for(;;) { | 150 | for(;;) { |
151 | QWidgetList* list = kapp->topLevelWidgets(); | 151 | QWidgetList* list = kapp->topLevelWidgets(); |
152 | QWidgetListIt it( *list ); | 152 | QWidgetListIt it( *list ); |
153 | bool found = false; | 153 | bool found = false; |
154 | for( QWidget* w = it.current(); | 154 | for( QWidget* w = it.current(); |
155 | w != NULL; | 155 | w != NULL; |
156 | ++it, w = it.current()) | 156 | ++it, w = it.current()) |
157 | if( w != this && w->name() == s ) | 157 | if( w != this && w->name() == s ) |
158 | { | 158 | { |
159 | found = true; | 159 | found = true; |
160 | break; | 160 | break; |
161 | } | 161 | } |
162 | delete list; | 162 | delete list; |
163 | if( !found ) | 163 | if( !found ) |
164 | break; | 164 | break; |
165 | s.setNum( ++unusedNumber ); | 165 | s.setNum( ++unusedNumber ); |
166 | s = objname + s; | 166 | s = objname + s; |
167 | } | 167 | } |
168 | setName( s ); | 168 | setName( s ); |
169 | memberList->append( this ); | 169 | memberList->append( this ); |
170 | */ | 170 | */ |
171 | 171 | ||
172 | d = new KMainWindowPrivate; | 172 | d = new KMainWindowPrivate; |
173 | //US d->showHelpMenu = true; | 173 | //US d->showHelpMenu = true; |
174 | d->settingsDirty = false; | 174 | d->settingsDirty = false; |
175 | d->autoSaveSettings = false; | 175 | d->autoSaveSettings = false; |
176 | d->autoSaveWindowSize = true; // for compatibility | 176 | d->autoSaveWindowSize = true; // for compatibility |
177 | //US d->kaccel = actionCollection()->kaccel(); | 177 | //US d->kaccel = actionCollection()->kaccel(); |
178 | d->toolBarHandler = 0; | 178 | d->toolBarHandler = 0; |
179 | d->settingsTimer = 0; | 179 | d->settingsTimer = 0; |
180 | d->showStatusBarAction = NULL; | 180 | d->showStatusBarAction = NULL; |
181 | /*US | 181 | /*US |
182 | if ((d->care_about_geometry == beeing_first)) { | 182 | if ((d->care_about_geometry == beeing_first)) { |
183 | beeing_first = false; | 183 | beeing_first = false; |
184 | if ( kapp->geometryArgument().isNull() ) // if there is no geometry, it doesn't mater | 184 | if ( kapp->geometryArgument().isNull() ) // if there is no geometry, it doesn't mater |
185 | d->care_about_geometry = false; | 185 | d->care_about_geometry = false; |
186 | else | 186 | else |
187 | parseGeometry(false); | 187 | parseGeometry(false); |
188 | } | 188 | } |
189 | */ | 189 | */ |
190 | d->care_about_geometry = false; | 190 | d->care_about_geometry = false; |
191 | 191 | ||
192 | //US setCaption( kapp->caption() ); | 192 | //US setCaption( kapp->caption() ); |
193 | // attach dcop interface | 193 | // attach dcop interface |
194 | //US d->m_interface = new KMainWindowInterface(this); | 194 | //US d->m_interface = new KMainWindowInterface(this); |
195 | 195 | ||
196 | //US if (!kapp->authorize("movable_toolbars")) | 196 | //US if (!kapp->authorize("movable_toolbars")) |
197 | //US setDockWindowsMovable(false); | 197 | //US setDockWindowsMovable(false); |
198 | } | 198 | } |
199 | 199 | ||
200 | KAction *KMainWindow::toolBarMenuAction() | 200 | KAction *KMainWindow::toolBarMenuAction() |
201 | { | 201 | { |
202 | if ( !d->toolBarHandler ) | 202 | if ( !d->toolBarHandler ) |
203 | return 0; | 203 | return 0; |
204 | 204 | ||
205 | return d->toolBarHandler->toolBarMenuAction(); | 205 | return d->toolBarHandler->toolBarMenuAction(); |
206 | } | 206 | } |
207 | 207 | ||
208 | bool KMainWindow::canBeRestored( int number ) | 208 | bool KMainWindow::canBeRestored( int number ) |
209 | { | 209 | { |
210 | /*US we do not have and want to save sessioninformation. Use info from the default | 210 | /*US we do not have and want to save sessioninformation. Use info from the default |
211 | application config. | 211 | application config. |
212 | */ | 212 | */ |
213 | //US if ( !kapp->isRestored() ) | 213 | //US if ( !kapp->isRestored() ) |
214 | //US return FALSE; | 214 | //US return FALSE; |
215 | //US KConfig *config = kapp->sessionConfig(); | 215 | //US KConfig *config = kapp->sessionConfig(); |
216 | KConfig *config = KGlobal::config(); | 216 | KConfig *config = KGlobal::config(); |
217 | if ( !config ) | 217 | if ( !config ) |
218 | return FALSE; | 218 | return FALSE; |
219 | config->setGroup( QString::fromLatin1("Number") ); | 219 | config->setGroup( QString::fromLatin1("Number") ); |
220 | int n = config->readNumEntry( QString::fromLatin1("NumberOfWindows") , 1 ); | 220 | int n = config->readNumEntry( QString::fromLatin1("NumberOfWindows") , 1 ); |
221 | return number >= 1 && number <= n; | 221 | return number >= 1 && number <= n; |
222 | 222 | ||
223 | } | 223 | } |
224 | 224 | ||
225 | const QString KMainWindow::classNameOfToplevel( int number ) | 225 | const QString KMainWindow::classNameOfToplevel( int number ) |
226 | { | 226 | { |
227 | /*US we do not have and want to save sessioninformation. Use info from the default | 227 | /*US we do not have and want to save sessioninformation. Use info from the default |
228 | application config. | 228 | application config. |
229 | */ | 229 | */ |
230 | //US if ( !kapp->isRestored() ) | 230 | //US if ( !kapp->isRestored() ) |
231 | //US return QString::null; | 231 | //US return QString::null; |
232 | //US KConfig *config = kapp->sessionConfig(); | 232 | //US KConfig *config = kapp->sessionConfig(); |
233 | KConfig *config = KGlobal::config(); | 233 | KConfig *config = KGlobal::config(); |
234 | if ( !config ) | 234 | if ( !config ) |
235 | return QString::null; | 235 | return QString::null; |
236 | QString s; | 236 | QString s; |
237 | s.setNum( number ); | 237 | s.setNum( number ); |
238 | s.prepend( QString::fromLatin1("WindowProperties") ); | 238 | s.prepend( QString::fromLatin1("WindowProperties") ); |
239 | config->setGroup( s ); | 239 | config->setGroup( s ); |
240 | if ( !config->hasKey( QString::fromLatin1("ClassName") ) ) | 240 | if ( !config->hasKey( QString::fromLatin1("ClassName") ) ) |
241 | return QString::null; | 241 | return QString::null; |
242 | else | 242 | else |
243 | return config->readEntry( QString::fromLatin1("ClassName") ); | 243 | return config->readEntry( QString::fromLatin1("ClassName") ); |
244 | } | 244 | } |
245 | 245 | ||
246 | bool KMainWindow::restore( int number, bool show ) | 246 | bool KMainWindow::restore( int number, bool show ) |
247 | { | 247 | { |
248 | /*US we do not have and want to save sessioninformation. Use info from the default | 248 | /*US we do not have and want to save sessioninformation. Use info from the default |
249 | application config. | 249 | application config. |
250 | */ | 250 | */ |
251 | if ( !canBeRestored( number ) ) | 251 | if ( !canBeRestored( number ) ) |
252 | return FALSE; | 252 | return FALSE; |
253 | //US KConfig *config = kapp->sessionConfig(); | 253 | //US KConfig *config = kapp->sessionConfig(); |
254 | KConfig *config = KGlobal::config(); | 254 | KConfig *config = KGlobal::config(); |
255 | 255 | ||
256 | if ( readPropertiesInternal( config, number ) ){ | 256 | if ( readPropertiesInternal( config, number ) ){ |
257 | if ( show ) | 257 | if ( show ) |
258 | KMainWindow::show(); | 258 | KMainWindow::show(); |
259 | return FALSE; | 259 | return FALSE; |
260 | } | 260 | } |
261 | return FALSE; | 261 | return FALSE; |
262 | 262 | ||
263 | } | 263 | } |
264 | 264 | ||
265 | void KMainWindow::setCaption( const QString &caption ) | 265 | void KMainWindow::setCaption( const QString &caption ) |
266 | { | 266 | { |
267 | //US setPlainCaption( kapp->makeStdCaption(caption) ); | 267 | //US setPlainCaption( kapp->makeStdCaption(caption) ); |
268 | setPlainCaption( caption ); | 268 | setPlainCaption( caption ); |
269 | } | 269 | } |
270 | 270 | ||
271 | void KMainWindow::setCaption( const QString &caption, bool modified ) | 271 | void KMainWindow::setCaption( const QString &caption, bool modified ) |
272 | { | 272 | { |
273 | //US setPlainCaption( kapp->makeStdCaption(caption, true, modified) ); | 273 | //US setPlainCaption( kapp->makeStdCaption(caption, true, modified) ); |
274 | setPlainCaption( caption + "modified:" ); | 274 | setPlainCaption( caption + "modified:" ); |
275 | } | 275 | } |
276 | 276 | ||
277 | void KMainWindow::setPlainCaption( const QString &caption ) | 277 | void KMainWindow::setPlainCaption( const QString &caption ) |
278 | { | 278 | { |
279 | QMainWindow::setCaption( caption ); | 279 | QMainWindow::setCaption( caption ); |
280 | #ifndef Q_WS_QWS | 280 | #ifndef Q_WS_QWS |
281 | //US the following is disabled for the embedded version | 281 | //US the following is disabled for the embedded version |
282 | //US NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 ); | 282 | //US NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 ); |
283 | //US info.setName( caption.utf8().data() ); | 283 | //US info.setName( caption.utf8().data() ); |
284 | #endif | 284 | #endif |
285 | } | 285 | } |
286 | 286 | ||
287 | void KMainWindow::slotStateChanged(const QString &newstate) | 287 | void KMainWindow::slotStateChanged(const QString &newstate) |
288 | { | 288 | { |
289 | stateChanged(newstate, KXMLGUIClient::StateNoReverse); | 289 | stateChanged(newstate, KXMLGUIClient::StateNoReverse); |
290 | } | 290 | } |
291 | 291 | ||
292 | /* | 292 | /* |
293 | * Get rid of this for KDE 4.0 | 293 | * Get rid of this for KDE 4.0 |
294 | */ | 294 | */ |
295 | void KMainWindow::slotStateChanged(const QString &newstate, | 295 | void KMainWindow::slotStateChanged(const QString &newstate, |
296 | KXMLGUIClient::ReverseStateChange reverse) | 296 | KXMLGUIClient::ReverseStateChange reverse) |
297 | { | 297 | { |
298 | stateChanged(newstate, reverse); | 298 | stateChanged(newstate, reverse); |
299 | } | 299 | } |
300 | 300 | ||
301 | void KMainWindow::closeEvent ( QCloseEvent *e ) | 301 | void KMainWindow::closeEvent ( QCloseEvent *e ) |
302 | { | 302 | { |
303 | // Save settings if auto-save is enabled, and settings have changed | 303 | // Save settings if auto-save is enabled, and settings have changed |
304 | if (d->settingsDirty && d->autoSaveSettings) | 304 | if (d->settingsDirty && d->autoSaveSettings) |
305 | saveAutoSaveSettings(); | 305 | saveAutoSaveSettings(); |
306 | 306 | ||
307 | if (queryClose()) { | 307 | if (queryClose()) { |
308 | e->accept(); | 308 | e->accept(); |
309 | 309 | ||
310 | int not_withdrawn = 0; | 310 | int not_withdrawn = 0; |
311 | /*US | 311 | /*US |
312 | QPtrListIterator<KMainWindow> it(*KMainWindow::memberList); | 312 | QPtrListIterator<KMainWindow> it(*KMainWindow::memberList); |
313 | for (it.toFirst(); it.current(); ++it){ | 313 | for (it.toFirst(); it.current(); ++it){ |
314 | if ( !it.current()->isHidden() && it.current()->isTopLevel() && it.current() != this ) | 314 | if ( !it.current()->isHidden() && it.current()->isTopLevel() && it.current() != this ) |
315 | not_withdrawn++; | 315 | not_withdrawn++; |
316 | } | 316 | } |
317 | */ | 317 | */ |
318 | if ( !no_query_exit && not_withdrawn <= 0 ) { // last window close accepted? | 318 | if ( !no_query_exit && not_withdrawn <= 0 ) { // last window close accepted? |
319 | /*US | 319 | /*US |
320 | if ( queryExit() && !kapp->sessionSaving()) { // Yes, Quit app? | 320 | if ( queryExit() && !kapp->sessionSaving()) { // Yes, Quit app? |
321 | // don't call queryExit() twice | 321 | // don't call queryExit() twice |
322 | disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); | 322 | disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); |
323 | kapp->deref(); // ...and quit aplication. | 323 | kapp->deref(); // ...and quit aplication. |
324 | } else { | 324 | } else { |
325 | // cancel closing, it's stupid to end up with no windows at all.... | 325 | // cancel closing, it's stupid to end up with no windows at all.... |
326 | e->ignore(); | 326 | e->ignore(); |
327 | } | 327 | } |
328 | */ | 328 | */ |
329 | //US we have no sessionmanagement. Simply close app. | 329 | //US we have no sessionmanagement. Simply close app. |
330 | if ( queryExit() ) { // Yes, Quit app? | 330 | if ( queryExit() ) { // Yes, Quit app? |
331 | qDebug("KMainWindow::closeEvent: Exit application ???"); | 331 | qDebug("KMainWindow::closeEvent: Exit application ???"); |
332 | // don't call queryExit() twice | 332 | // don't call queryExit() twice |
333 | //US disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); | 333 | //US disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); |
334 | } | 334 | } |
335 | 335 | ||
336 | } | 336 | } |
337 | } | 337 | } |
338 | } | 338 | } |
339 | 339 | ||
340 | bool KMainWindow::queryExit() | 340 | bool KMainWindow::queryExit() |
341 | { | 341 | { |
342 | return TRUE; | 342 | return TRUE; |
343 | } | 343 | } |
344 | 344 | ||
345 | bool KMainWindow::queryClose() | 345 | bool KMainWindow::queryClose() |
346 | { | 346 | { |
347 | return TRUE; | 347 | return TRUE; |
348 | } | 348 | } |
349 | 349 | ||
350 | void KMainWindow::saveGlobalProperties( KConfig* ) | 350 | void KMainWindow::saveGlobalProperties( KConfig* ) |
351 | { | 351 | { |
352 | } | 352 | } |
353 | 353 | ||
354 | void KMainWindow::readGlobalProperties( KConfig* ) | 354 | void KMainWindow::readGlobalProperties( KConfig* ) |
355 | { | 355 | { |
356 | } | 356 | } |
357 | 357 | ||
358 | void KMainWindow::savePropertiesInternal( KConfig *config, int number ) | 358 | void KMainWindow::savePropertiesInternal( KConfig *config, int number ) |
359 | { | 359 | { |
360 | bool oldASWS = d->autoSaveWindowSize; | 360 | bool oldASWS = d->autoSaveWindowSize; |
361 | d->autoSaveWindowSize = true; // make saveMainWindowSettings save the window size | 361 | d->autoSaveWindowSize = true; // make saveMainWindowSettings save the window size |
362 | 362 | ||
363 | QString s; | 363 | QString s; |
364 | s.setNum(number); | 364 | s.setNum(number); |
365 | s.prepend(QString::fromLatin1("WindowProperties")); | 365 | s.prepend(QString::fromLatin1("WindowProperties")); |
366 | config->setGroup(s); | 366 | config->setGroup(s); |
367 | 367 | ||
368 | // store objectName, className, Width and Height for later restoring | 368 | // store objectName, className, Width and Height for later restoring |
369 | // (Only useful for session management) | 369 | // (Only useful for session management) |
370 | config->writeEntry(QString::fromLatin1("ObjectName"), name()); | 370 | config->writeEntry(QString::fromLatin1("ObjectName"), name()); |
371 | config->writeEntry(QString::fromLatin1("ClassName"), className()); | 371 | config->writeEntry(QString::fromLatin1("ClassName"), className()); |
372 | 372 | ||
373 | saveMainWindowSettings(config); // Menubar, statusbar and Toolbar settings. | 373 | saveMainWindowSettings(config); // Menubar, statusbar and Toolbar settings. |
374 | 374 | ||
375 | s.setNum(number); | 375 | s.setNum(number); |
376 | config->setGroup(s); | 376 | config->setGroup(s); |
377 | saveProperties(config); | 377 | saveProperties(config); |
378 | 378 | ||
379 | d->autoSaveWindowSize = oldASWS; | 379 | d->autoSaveWindowSize = oldASWS; |
380 | } | 380 | } |
381 | 381 | ||
382 | void KMainWindow::setStandardToolBarMenuEnabled( bool enable ) | 382 | void KMainWindow::setStandardToolBarMenuEnabled( bool enable ) |
383 | { | 383 | { |
384 | if ( enable ) | 384 | if ( enable ) |
385 | { | 385 | { |
386 | if ( d->toolBarHandler ) | 386 | if ( d->toolBarHandler ) |
387 | return; | 387 | return; |
388 | 388 | ||
389 | d->toolBarHandler = new KDEPrivate::ToolBarHandler( this ); | 389 | d->toolBarHandler = new KDEPrivate::ToolBarHandler( this ); |
390 | 390 | ||
391 | /*US if ( factory() ) | 391 | /*US if ( factory() ) |
392 | factory()->addClient( d->toolBarHandler ); | 392 | factory()->addClient( d->toolBarHandler ); |
393 | */ | 393 | */ |
394 | } | 394 | } |
395 | else | 395 | else |
396 | { | 396 | { |
397 | if ( !d->toolBarHandler ) | 397 | if ( !d->toolBarHandler ) |
398 | return; | 398 | return; |
399 | /*US | 399 | /*US |
400 | if ( factory() ) | 400 | if ( factory() ) |
401 | factory()->removeClient( d->toolBarHandler ); | 401 | factory()->removeClient( d->toolBarHandler ); |
402 | */ | 402 | */ |
403 | delete d->toolBarHandler; | 403 | delete d->toolBarHandler; |
404 | d->toolBarHandler = 0; | 404 | d->toolBarHandler = 0; |
405 | } | 405 | } |
406 | 406 | ||
407 | } | 407 | } |
408 | 408 | ||
409 | bool KMainWindow::isStandardToolBarMenuEnabled() const | 409 | bool KMainWindow::isStandardToolBarMenuEnabled() const |
410 | { | 410 | { |
411 | return ( d->toolBarHandler != 0 ); | 411 | return ( d->toolBarHandler != 0 ); |
412 | } | 412 | } |
413 | 413 | ||
414 | void KMainWindow::createStandardStatusBarAction(){ | 414 | void KMainWindow::createStandardStatusBarAction(){ |
415 | if(!d->showStatusBarAction){ | 415 | if(!d->showStatusBarAction){ |
416 | d->showStatusBarAction = KStdAction::showStatusbar(this, SLOT(setSettingsDirty()), actionCollection()); | 416 | d->showStatusBarAction = KStdAction::showStatusbar(this, SLOT(setSettingsDirty()), actionCollection()); |
417 | connect(d->showStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setShown(bool))); | 417 | connect(d->showStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setShown(bool))); |
418 | if(internalStatusBar()) | 418 | if(internalStatusBar()) |
419 | d->showStatusBarAction->setChecked(!internalStatusBar()->isHidden()); | 419 | d->showStatusBarAction->setChecked(!internalStatusBar()->isHidden()); |
420 | } | 420 | } |
421 | } | 421 | } |
422 | 422 | ||
423 | QToolBar *KMainWindow::tBar( ) | 423 | QToolBar *KMainWindow::tBar( ) |
424 | { | 424 | { |
425 | if ( ! mQToolBar ) | 425 | if ( ! mQToolBar ) |
426 | mQToolBar = new QToolBar( this ); | 426 | mQToolBar = new QToolBar( this ); |
427 | return mQToolBar; | 427 | return mQToolBar; |
428 | } | 428 | } |
429 | 429 | ||
430 | KToolBar *KMainWindow::toolBar( const char * name ) | 430 | KToolBar *KMainWindow::toolBar( const char * name ) |
431 | { | 431 | { |
432 | 432 | ||
433 | if (!name) | 433 | if (!name) |
434 | name = "mainToolBar"; | 434 | name = "mainToolBar"; |
435 | KToolBar *tb = (KToolBar*)child( name, "KToolBar" ); | 435 | KToolBar *tb = (KToolBar*)child( name, "KToolBar" ); |
436 | if ( tb ) | 436 | if ( tb ) |
437 | return tb; | 437 | return tb; |
438 | bool honor_mode = (name == "mainToolBar"); | 438 | bool honor_mode = (name == "mainToolBar"); |
439 | 439 | ||
440 | /*US | 440 | /*US |
441 | if ( builderClient() ) | 441 | if ( builderClient() ) |
442 | return new KToolBar(this, name, honor_mode); // XMLGUI constructor | 442 | return new KToolBar(this, name, honor_mode); // XMLGUI constructor |
443 | else | 443 | else |
444 | */ | 444 | */ |
445 | return new KToolBar(this, Top, false, name, honor_mode ); // non-XMLGUI | 445 | return new KToolBar(this, Top, false, name, honor_mode ); // non-XMLGUI |
446 | } | 446 | } |
447 | 447 | ||
448 | QPtrListIterator<KToolBar> KMainWindow::toolBarIterator() | 448 | QPtrListIterator<KToolBar> KMainWindow::toolBarIterator() |
449 | { | 449 | { |
450 | toolbarList.clear(); | 450 | toolbarList.clear(); |
451 | QPtrList<QToolBar> lst; | 451 | QPtrList<QToolBar> lst; |
452 | for ( int i = (int)QMainWindow::Unmanaged; i <= (int)Minimized; ++i ) { | 452 | for ( int i = (int)QMainWindow::Unmanaged; i <= (int)Minimized; ++i ) { |
453 | lst = toolBars( (ToolBarDock)i ); | 453 | lst = toolBars( (ToolBarDock)i ); |
454 | for ( QToolBar *tb = lst.first(); tb; tb = lst.next() ) { | 454 | for ( QToolBar *tb = lst.first(); tb; tb = lst.next() ) { |
455 | if ( !tb->inherits( "KToolBar" ) ) | 455 | if ( !tb->inherits( "KToolBar" ) ) |
456 | continue; | 456 | continue; |
457 | toolbarList.append( (KToolBar*)tb ); | 457 | toolbarList.append( (KToolBar*)tb ); |
458 | } | 458 | } |
459 | } | 459 | } |
460 | return QPtrListIterator<KToolBar>( toolbarList ); | 460 | return QPtrListIterator<KToolBar>( toolbarList ); |
461 | } | 461 | } |
462 | 462 | ||
463 | void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize ) | 463 | void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize ) |
464 | { | 464 | { |
465 | d->autoSaveSettings = true; | 465 | d->autoSaveSettings = true; |
466 | d->autoSaveGroup = groupName; | 466 | d->autoSaveGroup = groupName; |
467 | d->autoSaveWindowSize = saveWindowSize; | 467 | d->autoSaveWindowSize = saveWindowSize; |
468 | // Get notified when the user moves a toolbar around | 468 | // Get notified when the user moves a toolbar around |
469 | //US connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ), | 469 | //US connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ), |
470 | //US this, SLOT( setSettingsDirty() ) ); | 470 | //US this, SLOT( setSettingsDirty() ) ); |
471 | connect( this, SIGNAL( toolBarPositionChanged(QToolBar *) ), | 471 | connect( this, SIGNAL( toolBarPositionChanged(QToolBar *) ), |
472 | this, SLOT( setSettingsDirty() ) ); | 472 | this, SLOT( setSettingsDirty() ) ); |
473 | 473 | ||
474 | 474 | ||
475 | // Get default values | 475 | // Get default values |
476 | //US int scnum = QApplication::desktop()->screenNumber(parentWidget()); | 476 | //US int scnum = QApplication::desktop()->screenNumber(parentWidget()); |
477 | //US QRect desk = QApplication::desktop()->screenGeometry(scnum); | 477 | //US QRect desk = QApplication::desktop()->screenGeometry(scnum); |
478 | QRect desk = KGlobalSettings::desktopGeometry(0); | 478 | QRect desk = KGlobalSettings::desktopGeometry(0); |
479 | 479 | ||
480 | d->defaultWindowSize = QRect(desk.width(), width(), desk.height(), height()); | 480 | d->defaultWindowSize = QRect(desk.width(), width(), desk.height(), height()); |
481 | // Now read the previously saved settings | 481 | // Now read the previously saved settings |
482 | applyMainWindowSettings( KGlobal::config(), groupName ); | 482 | applyMainWindowSettings( KGlobal::config(), groupName ); |
483 | } | 483 | } |
484 | 484 | ||
485 | 485 | ||
486 | void KMainWindow::resetAutoSaveSettings() | 486 | void KMainWindow::resetAutoSaveSettings() |
487 | { | 487 | { |
488 | d->autoSaveSettings = false; | 488 | d->autoSaveSettings = false; |
489 | if ( d->settingsTimer ) | 489 | if ( d->settingsTimer ) |
490 | d->settingsTimer->stop(); | 490 | d->settingsTimer->stop(); |
491 | } | 491 | } |
492 | 492 | ||
493 | bool KMainWindow::autoSaveSettings() const | 493 | bool KMainWindow::autoSaveSettings() const |
494 | { | 494 | { |
495 | return d->autoSaveSettings; | 495 | return d->autoSaveSettings; |
496 | } | 496 | } |
497 | 497 | ||
498 | QString KMainWindow::autoSaveGroup() const | 498 | QString KMainWindow::autoSaveGroup() const |
499 | { | 499 | { |
500 | return d->autoSaveGroup; | 500 | return d->autoSaveGroup; |
501 | } | 501 | } |
502 | 502 | ||
503 | void KMainWindow::saveAutoSaveSettings() | 503 | void KMainWindow::saveAutoSaveSettings() |
504 | { | 504 | { |
505 | ASSERT( d->autoSaveSettings ); | 505 | ASSERT( d->autoSaveSettings ); |
506 | //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl; | 506 | //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl; |
507 | saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup ); | 507 | saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup ); |
508 | KGlobal::config()->sync(); | 508 | KGlobal::config()->sync(); |
509 | d->settingsDirty = false; | 509 | d->settingsDirty = false; |
510 | if ( d->settingsTimer ) | 510 | if ( d->settingsTimer ) |
511 | d->settingsTimer->stop(); | 511 | d->settingsTimer->stop(); |
512 | } | 512 | } |
513 | 513 | ||
514 | void KMainWindow::createGUI( const QString &xmlfile, bool _conserveMemory ) | 514 | void KMainWindow::createGUI( const QString &xmlfile, bool _conserveMemory ) |
515 | { | 515 | { |
516 | // disabling the updates prevents unnecessary redraws | 516 | // disabling the updates prevents unnecessary redraws |
517 | setUpdatesEnabled( false ); | 517 | setUpdatesEnabled( false ); |
518 | 518 | ||
519 | // just in case we are rebuilding, let's remove our old client | 519 | // just in case we are rebuilding, let's remove our old client |
520 | //US guiFactory()->removeClient( this ); | 520 | //US guiFactory()->removeClient( this ); |
521 | 521 | ||
522 | // make sure to have an empty GUI | 522 | // make sure to have an empty GUI |
523 | QMenuBar* mb = internalMenuBar(); | 523 | QMenuBar* mb = internalMenuBar(); |
524 | if ( mb ) | 524 | if ( mb ) |
525 | mb->clear(); | 525 | mb->clear(); |
526 | 526 | ||
527 | (void)toolBarIterator(); // make sure toolbarList is most-up-to-date | 527 | (void)toolBarIterator(); // make sure toolbarList is most-up-to-date |
528 | toolbarList.setAutoDelete( true ); | 528 | toolbarList.setAutoDelete( true ); |
529 | toolbarList.clear(); | 529 | toolbarList.clear(); |
530 | toolbarList.setAutoDelete( false ); | 530 | toolbarList.setAutoDelete( false ); |
531 | /*US | 531 | /*US |
532 | // don't build a help menu unless the user ask for it | 532 | // don't build a help menu unless the user ask for it |
533 | if (d->showHelpMenu) { | 533 | if (d->showHelpMenu) { |
534 | // we always want a help menu | 534 | // we always want a help menu |
535 | if (helpMenu2 == 0) | 535 | if (helpMenu2 == 0) |
536 | helpMenu2 = new KHelpMenu(this, instance()->aboutData(), true, | 536 | helpMenu2 = new KHelpMenu(this, instance()->aboutData(), true, |
537 | actionCollection()); | 537 | actionCollection()); |
538 | } | 538 | } |
539 | 539 | ||
540 | // we always want to load in our global standards file | 540 | // we always want to load in our global standards file |
541 | setXMLFile( locate( "config", "ui/ui_standards.rc", instance() ) ); | 541 | setXMLFile( locate( "config", "ui/ui_standards.rc", instance() ) ); |
542 | 542 | ||
543 | // now, merge in our local xml file. if this is null, then that | 543 | // now, merge in our local xml file. if this is null, then that |
544 | // means that we will be only using the global file | 544 | // means that we will be only using the global file |
545 | if ( !xmlfile.isNull() ) { | 545 | if ( !xmlfile.isNull() ) { |
546 | setXMLFile( xmlfile, true ); | 546 | setXMLFile( xmlfile, true ); |
547 | } else { | 547 | } else { |
548 | QString auto_file(instance()->instanceName() + "ui.rc"); | 548 | QString auto_file(instance()->instanceName() + "ui.rc"); |
549 | setXMLFile( auto_file, true ); | 549 | setXMLFile( auto_file, true ); |
550 | } | 550 | } |
551 | 551 | ||
552 | // make sure we don't have any state saved already | 552 | // make sure we don't have any state saved already |
553 | setXMLGUIBuildDocument( QDomDocument() ); | 553 | setXMLGUIBuildDocument( QDomDocument() ); |
554 | 554 | ||
555 | // do the actual GUI building | 555 | // do the actual GUI building |
556 | guiFactory()->addClient( this ); | 556 | guiFactory()->addClient( this ); |
557 | 557 | ||
558 | // try and get back *some* of our memory | 558 | // try and get back *some* of our memory |
559 | if ( _conserveMemory ) | 559 | if ( _conserveMemory ) |
560 | { | 560 | { |
561 | // before freeing the memory allocated by the DOM document we also | 561 | // before freeing the memory allocated by the DOM document we also |
562 | // free all memory allocated internally in the KXMLGUIFactory for | 562 | // free all memory allocated internally in the KXMLGUIFactory for |
563 | // the menubar and the toolbars . This however implies that we | 563 | // the menubar and the toolbars . This however implies that we |
564 | // have to take care of deleting those widgets ourselves. For | 564 | // have to take care of deleting those widgets ourselves. For |
565 | // destruction this is no problem, but when rebuilding we have | 565 | // destruction this is no problem, but when rebuilding we have |
566 | // to take care of that (and we want to rebuild the GUI when | 566 | // to take care of that (and we want to rebuild the GUI when |
567 | // using stuff like the toolbar editor ). | 567 | // using stuff like the toolbar editor ). |
568 | // In addition we have to take care of not removing containers | 568 | // In addition we have to take care of not removing containers |
569 | // like popupmenus, defined in the XML document. | 569 | // like popupmenus, defined in the XML document. |
570 | // this code should probably go into a separate method in KMainWindow. | 570 | // this code should probably go into a separate method in KMainWindow. |
571 | // there's just one problem: I'm bad in finding names ;-) , so | 571 | // there's just one problem: I'm bad in finding names ;-) , so |
572 | // I skipped this ;-) | 572 | // I skipped this ;-) |
573 | 573 | ||
574 | QDomDocument doc = domDocument(); | 574 | QDomDocument doc = domDocument(); |
575 | 575 | ||
576 | QDomElement e = doc.documentElement().firstChild().toElement(); | 576 | QDomElement e = doc.documentElement().firstChild().toElement(); |
577 | for (; !e.isNull(); e = e.nextSibling().toElement() ) { | 577 | for (; !e.isNull(); e = e.nextSibling().toElement() ) { |
578 | if ( e.tagName().lower() == "toolbar" ) | 578 | if ( e.tagName().lower() == "toolbar" ) |
579 | factory_->resetContainer( e.attribute( "name" ) ); | 579 | factory_->resetContainer( e.attribute( "name" ) ); |
580 | else if ( e.tagName().lower() == "menubar" ) | 580 | else if ( e.tagName().lower() == "menubar" ) |
581 | factory_->resetContainer( e.tagName(), true ); | 581 | factory_->resetContainer( e.tagName(), true ); |
582 | } | 582 | } |
583 | 583 | ||
584 | conserveMemory(); | 584 | conserveMemory(); |
585 | } | 585 | } |
586 | */ | 586 | */ |
587 | setUpdatesEnabled( true ); | 587 | setUpdatesEnabled( true ); |
588 | updateGeometry(); | 588 | updateGeometry(); |
589 | } | 589 | } |
590 | 590 | ||
591 | void KMainWindow::saveMainWindowSettings(KConfig *config, const QString &configGroup) | 591 | void KMainWindow::saveMainWindowSettings(KConfig *config, const QString &configGroup) |
592 | { | 592 | { |
593 | kdDebug(200) << "KMainWindow::saveMainWindowSettings " << configGroup << endl; | 593 | kdDebug(200) << "KMainWindow::saveMainWindowSettings " << configGroup << endl; |
594 | //US QStrList entryList; | 594 | //US QStrList entryList; |
595 | QStringList entryList; | 595 | QStringList entryList; |
596 | QString oldGroup; | 596 | QString oldGroup; |
597 | 597 | ||
598 | if (!configGroup.isEmpty()) | 598 | if (!configGroup.isEmpty()) |
599 | { | 599 | { |
600 | oldGroup = config->group(); | 600 | oldGroup = config->group(); |
601 | config->setGroup(configGroup); | 601 | config->setGroup(configGroup); |
602 | } | 602 | } |
603 | 603 | ||
604 | // Called by session management - or if we want to save the window size anyway | 604 | // Called by session management - or if we want to save the window size anyway |
605 | if ( d->autoSaveWindowSize ) | 605 | if ( d->autoSaveWindowSize ) |
606 | saveWindowSize( config ); | 606 | saveWindowSize( config ); |
607 | 607 | ||
608 | QStatusBar* sb = internalStatusBar(); | 608 | QStatusBar* sb = internalStatusBar(); |
609 | if (sb) { | 609 | if (sb) { |
610 | entryList.clear(); | 610 | entryList.clear(); |
611 | if ( sb->isHidden() ) | 611 | if ( sb->isHidden() ) |
612 | entryList.append("Disabled"); | 612 | entryList.append("Disabled"); |
613 | else | 613 | else |
614 | entryList.append("Enabled"); | 614 | entryList.append("Enabled"); |
615 | 615 | ||
616 | if(sb->isHidden()) | 616 | if(sb->isHidden()) |
617 | //US config->writeEntry(QString::fromLatin1("StatusBar"), entryList, ';'); | 617 | //US config->writeEntry(QString::fromLatin1("StatusBar"), entryList, ';'); |
618 | config->writeEntry(QString::fromLatin1("StatusBar"), entryList); | 618 | config->writeEntry(QString::fromLatin1("StatusBar"), entryList); |
619 | else | 619 | else |
620 | config->deleteEntry(QString::fromLatin1("StatusBar")); | 620 | config->deleteEntry(QString::fromLatin1("StatusBar")); |
621 | } | 621 | } |
622 | 622 | ||
623 | QMenuBar* mb = internalMenuBar(); | 623 | QMenuBar* mb = internalMenuBar(); |
624 | if (mb) { | 624 | if (mb) { |
625 | entryList.clear(); | 625 | entryList.clear(); |
626 | if ( mb->isHidden() ) | 626 | if ( mb->isHidden() ) |
627 | entryList.append("Disabled"); | 627 | entryList.append("Disabled"); |
628 | else | 628 | else |
629 | entryList.append("Enabled"); | 629 | entryList.append("Enabled"); |
630 | 630 | ||
631 | // By default we don't hide. | 631 | // By default we don't hide. |
632 | if(mb->isHidden()) | 632 | if(mb->isHidden()) |
633 | //US config->writeEntry(QString::fromLatin1("MenuBar"), entryList, ';'); | 633 | //US config->writeEntry(QString::fromLatin1("MenuBar"), entryList, ';'); |
634 | config->writeEntry(QString::fromLatin1("MenuBar"), entryList); | 634 | config->writeEntry(QString::fromLatin1("MenuBar"), entryList); |
635 | else | 635 | else |
636 | config->deleteEntry(QString::fromLatin1("MenuBar")); | 636 | config->deleteEntry(QString::fromLatin1("MenuBar")); |
637 | } | 637 | } |
638 | 638 | ||
639 | int n = 1; // Toolbar counter. toolbars are counted from 1, | 639 | int n = 1; // Toolbar counter. toolbars are counted from 1, |
640 | KToolBar *toolbar = 0; | 640 | KToolBar *toolbar = 0; |
641 | QPtrListIterator<KToolBar> it( toolBarIterator() ); | 641 | QPtrListIterator<KToolBar> it( toolBarIterator() ); |
642 | while ( ( toolbar = it.current() ) ) { | 642 | while ( ( toolbar = it.current() ) ) { |
643 | ++it; | 643 | ++it; |
644 | QString group; | 644 | QString group; |
645 | if (!configGroup.isEmpty()) | 645 | if (!configGroup.isEmpty()) |
646 | { | 646 | { |
647 | // Give a number to the toolbar, but prefer a name if there is one, | 647 | // Give a number to the toolbar, but prefer a name if there is one, |
648 | // because there's no real guarantee on the ordering of toolbars | 648 | // because there's no real guarantee on the ordering of toolbars |
649 | group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); | 649 | group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); |
650 | group.prepend(" Toolbar"); | 650 | group.prepend(" Toolbar"); |
651 | group.prepend(configGroup); | 651 | group.prepend(configGroup); |
652 | } | 652 | } |
653 | toolbar->saveSettings(config, group); | 653 | toolbar->saveSettings(config, group); |
654 | n++; | 654 | n++; |
655 | } | 655 | } |
656 | if (!configGroup.isEmpty()) | 656 | if (!configGroup.isEmpty()) |
657 | config->setGroup(oldGroup); | 657 | config->setGroup(oldGroup); |
658 | } | 658 | } |
659 | 659 | ||
660 | bool KMainWindow::readPropertiesInternal( KConfig *config, int number ) | 660 | bool KMainWindow::readPropertiesInternal( KConfig *config, int number ) |
661 | { | 661 | { |
662 | if ( number == 1 ) | 662 | if ( number == 1 ) |
663 | readGlobalProperties( config ); | 663 | readGlobalProperties( config ); |
664 | 664 | ||
665 | // in order they are in toolbar list | 665 | // in order they are in toolbar list |
666 | QString s; | 666 | QString s; |
667 | s.setNum(number); | 667 | s.setNum(number); |
668 | s.prepend(QString::fromLatin1("WindowProperties")); | 668 | s.prepend(QString::fromLatin1("WindowProperties")); |
669 | 669 | ||
670 | config->setGroup(s); | 670 | config->setGroup(s); |
671 | 671 | ||
672 | // restore the object name (window role) | 672 | // restore the object name (window role) |
673 | if ( config->hasKey(QString::fromLatin1("ObjectName" )) ) | 673 | if ( config->hasKey(QString::fromLatin1("ObjectName" )) ) |
674 | setName( config->readEntry(QString::fromLatin1("ObjectName")).latin1()); // latin1 is right here | 674 | setName( config->readEntry(QString::fromLatin1("ObjectName")).latin1()); // latin1 is right here |
675 | 675 | ||
676 | applyMainWindowSettings(config); // Menubar, statusbar and toolbar settings. | 676 | applyMainWindowSettings(config); // Menubar, statusbar and toolbar settings. |
677 | 677 | ||
678 | s.setNum(number); | 678 | s.setNum(number); |
679 | config->setGroup(s); | 679 | config->setGroup(s); |
680 | readProperties(config); | 680 | readProperties(config); |
681 | return true; | 681 | return true; |
682 | } | 682 | } |
683 | 683 | ||
684 | void KMainWindow::applyMainWindowSettings(KConfig *config, const QString &configGroup) | 684 | void KMainWindow::applyMainWindowSettings(KConfig *config, const QString &configGroup) |
685 | { | 685 | { |
686 | kdDebug(200) << "KMainWindow::applyMainWindowSettings" << endl; | 686 | kdDebug(200) << "KMainWindow::applyMainWindowSettings" << endl; |
687 | QString entry; | 687 | QString entry; |
688 | //US QStrList entryList; | 688 | //US QStrList entryList; |
689 | QStringList entryList; | 689 | QStringList entryList; |
690 | int i = 0; // Number of entries in list | 690 | int i = 0; // Number of entries in list |
691 | 691 | ||
692 | if (!configGroup.isEmpty()) | 692 | if (!configGroup.isEmpty()) |
693 | config->setGroup(configGroup); | 693 | config->setGroup(configGroup); |
694 | 694 | ||
695 | restoreWindowSize(config); | 695 | restoreWindowSize(config); |
696 | 696 | ||
697 | QStatusBar* sb = internalStatusBar(); | 697 | QStatusBar* sb = internalStatusBar(); |
698 | if (sb) { | 698 | if (sb) { |
699 | entryList.clear(); | 699 | entryList.clear(); |
700 | //US i = config->readListEntry (QString::fromLatin1("StatusBar"), entryList, ';'); | 700 | //US i = config->readListEntry (QString::fromLatin1("StatusBar"), entryList, ';'); |
701 | entryList = config->readListEntry (QString::fromLatin1("StatusBar")); | 701 | entryList = config->readListEntry (QString::fromLatin1("StatusBar")); |
702 | entry = entryList.first(); | 702 | entry = entryList.first(); |
703 | if (entry == QString::fromLatin1("Disabled")) | 703 | if (entry == QString::fromLatin1("Disabled")) |
704 | sb->hide(); | 704 | sb->hide(); |
705 | else | 705 | else |
706 | sb->show(); | 706 | sb->show(); |
707 | if(d->showStatusBarAction) | 707 | if(d->showStatusBarAction) |
708 | d->showStatusBarAction->setChecked(!sb->isHidden()); | 708 | d->showStatusBarAction->setChecked(!sb->isHidden()); |
709 | } | 709 | } |
710 | 710 | ||
711 | QMenuBar* mb = internalMenuBar(); | 711 | QMenuBar* mb = internalMenuBar(); |
712 | if (mb) { | 712 | if (mb) { |
713 | entryList.clear(); | 713 | entryList.clear(); |
714 | //US i = config->readListEntry (QString::fromLatin1("MenuBar"), entryList, ';'); | 714 | //US i = config->readListEntry (QString::fromLatin1("MenuBar"), entryList, ';'); |
715 | entryList = config->readListEntry (QString::fromLatin1("MenuBar")); | 715 | entryList = config->readListEntry (QString::fromLatin1("MenuBar")); |
716 | entry = entryList.first(); | 716 | entry = entryList.first(); |
717 | if (entry==QString::fromLatin1("Disabled")) | 717 | if (entry==QString::fromLatin1("Disabled")) |
718 | { | 718 | { |
719 | mb->hide(); | 719 | mb->hide(); |
720 | } else | 720 | } else |
721 | { | 721 | { |
722 | mb->show(); | 722 | mb->show(); |
723 | } | 723 | } |
724 | } | 724 | } |
725 | 725 | ||
726 | int n = 1; // Toolbar counter. toolbars are counted from 1, | 726 | int n = 1; // Toolbar counter. toolbars are counted from 1, |
727 | KToolBar *toolbar; | 727 | KToolBar *toolbar; |
728 | QPtrListIterator<KToolBar> it( toolBarIterator() ); // must use own iterator | 728 | QPtrListIterator<KToolBar> it( toolBarIterator() ); // must use own iterator |
729 | 729 | ||
730 | for ( ; it.current(); ++it) { | 730 | for ( ; it.current(); ++it) { |
731 | toolbar= it.current(); | 731 | toolbar= it.current(); |
732 | QString group; | 732 | QString group; |
733 | if (!configGroup.isEmpty()) | 733 | if (!configGroup.isEmpty()) |
734 | { | 734 | { |
735 | // Give a number to the toolbar, but prefer a name if there is one, | 735 | // Give a number to the toolbar, but prefer a name if there is one, |
736 | // because there's no real guarantee on the ordering of toolbars | 736 | // because there's no real guarantee on the ordering of toolbars |
737 | group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); | 737 | group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); |
738 | group.prepend(" Toolbar"); | 738 | group.prepend(" Toolbar"); |
739 | group.prepend(configGroup); | 739 | group.prepend(configGroup); |
740 | } | 740 | } |
741 | toolbar->applySettings(config, group); | 741 | toolbar->applySettings(config, group); |
742 | n++; | 742 | n++; |
743 | } | 743 | } |
744 | 744 | ||
745 | finalizeGUI( true ); | 745 | finalizeGUI( true ); |
746 | } | 746 | } |
747 | 747 | ||
748 | void KMainWindow::finalizeGUI( bool force ) | 748 | void KMainWindow::finalizeGUI( bool force ) |
749 | { | 749 | { |
750 | //kdDebug(200) << "KMainWindow::finalizeGUI force=" << force << endl; | 750 | //kdDebug(200) << "KMainWindow::finalizeGUI force=" << force << endl; |
751 | // The whole reason for this is that moveToolBar relies on the indexes | 751 | // The whole reason for this is that moveToolBar relies on the indexes |
752 | // of the other toolbars, so in theory it should be called only once per | 752 | // of the other toolbars, so in theory it should be called only once per |
753 | // toolbar, but in increasing order of indexes. | 753 | // toolbar, but in increasing order of indexes. |
754 | // Since we can't do that immediately, we move them, and _then_ | 754 | // Since we can't do that immediately, we move them, and _then_ |
755 | // we call positionYourself again for each of them, but this time | 755 | // we call positionYourself again for each of them, but this time |
756 | // the toolbariterator should give them in the proper order. | 756 | // the toolbariterator should give them in the proper order. |
757 | // Both the XMLGUI and applySettings call this, hence "force" for the latter. | 757 | // Both the XMLGUI and applySettings call this, hence "force" for the latter. |
758 | QPtrListIterator<KToolBar> it( toolBarIterator() ); | 758 | QPtrListIterator<KToolBar> it( toolBarIterator() ); |
759 | for ( ; it.current() ; ++ it ) | 759 | for ( ; it.current() ; ++ it ) |
760 | it.current()->positionYourself( force ); | 760 | it.current()->positionYourself( force ); |
761 | 761 | ||
762 | d->settingsDirty = false; | 762 | d->settingsDirty = false; |
763 | } | 763 | } |
764 | 764 | ||
765 | void KMainWindow::saveWindowSize( KConfig * config ) const | 765 | void KMainWindow::saveWindowSize( KConfig * config ) const |
766 | { | 766 | { |
767 | /*US | 767 | /*US |
768 | int scnum = QApplication::desktop()->screenNumber(parentWidget()); | 768 | int scnum = QApplication::desktop()->screenNumber(parentWidget()); |
769 | QRect desk = QApplication::desktop()->screenGeometry(scnum); | 769 | QRect desk = QApplication::desktop()->screenGeometry(scnum); |
770 | */ | 770 | */ |
771 | QRect desk = KGlobalSettings::desktopGeometry(0); | 771 | QRect desk = KGlobalSettings::desktopGeometry(0); |
772 | 772 | ||
773 | QRect size( desk.width(), width(), desk.height(), height() ); | 773 | QRect size( desk.width(), width(), desk.height(), height() ); |
774 | if(size != d->defaultWindowSize){ | 774 | if(size != d->defaultWindowSize){ |
775 | config->writeEntry(QString::fromLatin1("Width %1").arg(desk.width()), width() ); | 775 | config->writeEntry(QString::fromLatin1("Width %1").arg(desk.width()), width() ); |
776 | config->writeEntry(QString::fromLatin1("Height %1").arg(desk.height()), height() ); | 776 | config->writeEntry(QString::fromLatin1("Height %1").arg(desk.height()), height() ); |
777 | } | 777 | } |
778 | else{ | 778 | else{ |
779 | config->deleteEntry(QString::fromLatin1("Width %1").arg(desk.width())); | 779 | config->deleteEntry(QString::fromLatin1("Width %1").arg(desk.width())); |
780 | config->deleteEntry(QString::fromLatin1("Height %1").arg(desk.height())); | 780 | config->deleteEntry(QString::fromLatin1("Height %1").arg(desk.height())); |
781 | } | 781 | } |
782 | } | 782 | } |
783 | 783 | ||
784 | void KMainWindow::restoreWindowSize( KConfig * config ) | 784 | void KMainWindow::restoreWindowSize( KConfig * config ) |
785 | { | 785 | { |
786 | if (d->care_about_geometry) { | 786 | if (d->care_about_geometry) { |
787 | parseGeometry(true); | 787 | parseGeometry(true); |
788 | } else { | 788 | } else { |
789 | // restore the size | 789 | // restore the size |
790 | /*US int scnum = QApplication::desktop()->screenNumber(parentWidget()); | 790 | /*US int scnum = QApplication::desktop()->screenNumber(parentWidget()); |
791 | QRect desk = QApplication::desktop()->screenGeometry(scnum); | 791 | QRect desk = QApplication::desktop()->screenGeometry(scnum); |
792 | */ | 792 | */ |
793 | QRect desk = KGlobalSettings::desktopGeometry(0); | 793 | QRect desk = KGlobalSettings::desktopGeometry(0); |
794 | 794 | ||
795 | QSize size( config->readNumEntry( QString::fromLatin1("Width %1").arg(desk.width()), 0 ), | 795 | QSize size( config->readNumEntry( QString::fromLatin1("Width %1").arg(desk.width()), 0 ), |
796 | config->readNumEntry( QString::fromLatin1("Height %1").arg(desk.height()), 0 ) ); | 796 | config->readNumEntry( QString::fromLatin1("Height %1").arg(desk.height()), 0 ) ); |
797 | if (size.isEmpty()) { | 797 | if (size.isEmpty()) { |
798 | // try the KDE 2.0 way | 798 | // try the KDE 2.0 way |
799 | size = QSize( config->readNumEntry( QString::fromLatin1("Width"), 0 ), | 799 | size = QSize( config->readNumEntry( QString::fromLatin1("Width"), 0 ), |
800 | config->readNumEntry( QString::fromLatin1("Height"), 0 ) ); | 800 | config->readNumEntry( QString::fromLatin1("Height"), 0 ) ); |
801 | if (!size.isEmpty()) { | 801 | if (!size.isEmpty()) { |
802 | // make sure the other resolutions don't get old settings | 802 | // make sure the other resolutions don't get old settings |
803 | config->writeEntry( QString::fromLatin1("Width"), 0 ); | 803 | config->writeEntry( QString::fromLatin1("Width"), 0 ); |
804 | config->writeEntry( QString::fromLatin1("Height"), 0 ); | 804 | config->writeEntry( QString::fromLatin1("Height"), 0 ); |
805 | } | 805 | } |
806 | } | 806 | } |
807 | if ( !size.isEmpty() ) | 807 | if ( !size.isEmpty() ) |
808 | resize( size ); | 808 | resize( size ); |
809 | } | 809 | } |
810 | } | 810 | } |
811 | 811 | ||
812 | bool KMainWindow::initialGeometrySet() const | 812 | bool KMainWindow::initialGeometrySet() const |
813 | { | 813 | { |
814 | return d->care_about_geometry; | 814 | return d->care_about_geometry; |
815 | } | 815 | } |
816 | 816 | ||
817 | void KMainWindow::ignoreInitialGeometry() | 817 | void KMainWindow::ignoreInitialGeometry() |
818 | { | 818 | { |
819 | d->care_about_geometry = false; | 819 | d->care_about_geometry = false; |
820 | } | 820 | } |
821 | 821 | ||
822 | void KMainWindow::setSettingsDirty() | 822 | void KMainWindow::setSettingsDirty() |
823 | { | 823 | { |
824 | //kdDebug(200) << "KMainWindow::setSettingsDirty" << endl; | 824 | //kdDebug(200) << "KMainWindow::setSettingsDirty" << endl; |
825 | d->settingsDirty = true; | 825 | d->settingsDirty = true; |
826 | if ( d->autoSaveSettings ) | 826 | if ( d->autoSaveSettings ) |
827 | { | 827 | { |
828 | // Use a timer to save "immediately" user-wise, but not too immediately | 828 | // Use a timer to save "immediately" user-wise, but not too immediately |
829 | // (to compress calls and save only once, in case of multiple changes) | 829 | // (to compress calls and save only once, in case of multiple changes) |
830 | if ( !d->settingsTimer ) | 830 | if ( !d->settingsTimer ) |
831 | { | 831 | { |
832 | d->settingsTimer = new QTimer( this ); | 832 | d->settingsTimer = new QTimer( this ); |
833 | connect( d->settingsTimer, SIGNAL( timeout() ), SLOT( saveAutoSaveSettings() ) ); | 833 | connect( d->settingsTimer, SIGNAL( timeout() ), SLOT( saveAutoSaveSettings() ) ); |
834 | } | 834 | } |
835 | d->settingsTimer->start( 500, true ); | 835 | d->settingsTimer->start( 500, true ); |
836 | } | 836 | } |
837 | } | 837 | } |
838 | 838 | ||
839 | bool KMainWindow::settingsDirty() const | 839 | bool KMainWindow::settingsDirty() const |
840 | { | 840 | { |
841 | return d->settingsDirty; | 841 | return d->settingsDirty; |
842 | } | 842 | } |
843 | 843 | ||
844 | QString KMainWindow::settingsGroup() const | 844 | QString KMainWindow::settingsGroup() const |
845 | { | 845 | { |
846 | return d->autoSaveGroup; | 846 | return d->autoSaveGroup; |
847 | } | 847 | } |
848 | 848 | ||
849 | void KMainWindow::resizeEvent( QResizeEvent * ) | 849 | void KMainWindow::resizeEvent( QResizeEvent * ) |
850 | { | 850 | { |
851 | if ( d->autoSaveWindowSize ) | 851 | if ( d->autoSaveWindowSize ) |
852 | setSettingsDirty(); | 852 | setSettingsDirty(); |
853 | } | 853 | } |
854 | 854 | ||
855 | bool KMainWindow::hasMenuBar() | 855 | bool KMainWindow::hasMenuBar() |
856 | { | 856 | { |
857 | return (internalMenuBar()); | 857 | return (internalMenuBar()); |
858 | } | 858 | } |
859 | 859 | ||
860 | //US KMenuBar *KMainWindow::menuBar() | 860 | //US KMenuBar *KMainWindow::menuBar() |
861 | QMenuBar *KMainWindow::menuBar() | 861 | QMenuBar *KMainWindow::menuBar() |
862 | { | 862 | { |
863 | //US KMenuBar * mb = internalMenuBar(); | 863 | //US KMenuBar * mb = internalMenuBar(); |
864 | QMenuBar * mb = internalMenuBar(); | 864 | QMenuBar * mb = internalMenuBar(); |
865 | if ( !mb ) { | 865 | if ( !mb ) { |
866 | //US mb = new KMenuBar( this ); | 866 | //US mb = new KMenuBar( this ); |
867 | mb = new QMenuBar( this ); | 867 | mb = new QMenuBar( this ); |
868 | // trigger a re-layout and trigger a call to the private | 868 | // trigger a re-layout and trigger a call to the private |
869 | // setMenuBar method. | 869 | // setMenuBar method. |
870 | QMainWindow::menuBar(); | 870 | QMainWindow::menuBar(); |
871 | } | 871 | } |
872 | return mb; | 872 | return mb; |
873 | } | 873 | } |
874 | 874 | ||
875 | //US KStatusBar *KMainWindow::statusBar() | 875 | //US KStatusBar *KMainWindow::statusBar() |
876 | QStatusBar *KMainWindow::statusBar() | 876 | QStatusBar *KMainWindow::statusBar() |
877 | { | 877 | { |
878 | //US KStatusBar * sb = internalStatusBar(); | 878 | //US KStatusBar * sb = internalStatusBar(); |
879 | QStatusBar * sb = internalStatusBar(); | 879 | QStatusBar * sb = internalStatusBar(); |
880 | if ( !sb ) { | 880 | if ( !sb ) { |
881 | //US sb = new KStatusBar( this ); | 881 | //US sb = new KStatusBar( this ); |
882 | sb = new QStatusBar( this ); | 882 | sb = new QStatusBar( this ); |
883 | // trigger a re-layout and trigger a call to the private | 883 | // trigger a re-layout and trigger a call to the private |
884 | // setStatusBar method. | 884 | // setStatusBar method. |
885 | QMainWindow::statusBar(); | 885 | QMainWindow::statusBar(); |
886 | } | 886 | } |
887 | return sb; | 887 | return sb; |
888 | } | 888 | } |
889 | 889 | ||
890 | void KMainWindow::shuttingDown() | 890 | void KMainWindow::shuttingDown() |
891 | { | 891 | { |
892 | // Needed for Qt <= 3.0.3 at least to prevent reentrancy | 892 | // Needed for Qt <= 3.0.3 at least to prevent reentrancy |
893 | // when queryExit() shows a dialog. Check before removing! | 893 | // when queryExit() shows a dialog. Check before removing! |
894 | static bool reentrancy_protection = false; | 894 | static bool reentrancy_protection = false; |
895 | if (!reentrancy_protection) | 895 | if (!reentrancy_protection) |
896 | { | 896 | { |
897 | reentrancy_protection = true; | 897 | reentrancy_protection = true; |
898 | // call the virtual queryExit | 898 | // call the virtual queryExit |
899 | queryExit(); | 899 | queryExit(); |
900 | reentrancy_protection = false; | 900 | reentrancy_protection = false; |
901 | } | 901 | } |
902 | 902 | ||
903 | } | 903 | } |
904 | 904 | ||
905 | //US KMenuBar *KMainWindow::internalMenuBar() | 905 | //US KMenuBar *KMainWindow::internalMenuBar() |
906 | QMenuBar *KMainWindow::internalMenuBar() | 906 | QMenuBar *KMainWindow::internalMenuBar() |
907 | { | 907 | { |
908 | //US QObjectList *l = queryList( "KMenuBar", 0, false, false ); | 908 | //US QObjectList *l = queryList( "KMenuBar", 0, false, false ); |
909 | QObjectList *l = queryList( "QMenuBar", 0, false, false ); | 909 | QObjectList *l = queryList( "QMenuBar", 0, false, false ); |
910 | if ( !l || !l->first() ) { | 910 | if ( !l || !l->first() ) { |
911 | delete l; | 911 | delete l; |
912 | return 0; | 912 | return 0; |
913 | } | 913 | } |
914 | 914 | ||
915 | //US KMenuBar *m = (KMenuBar*)l->first(); | 915 | //US KMenuBar *m = (KMenuBar*)l->first(); |
916 | QMenuBar *m = (QMenuBar*)l->first(); | 916 | QMenuBar *m = (QMenuBar*)l->first(); |
917 | delete l; | 917 | delete l; |
918 | return m; | 918 | return m; |
919 | } | 919 | } |
920 | 920 | ||
921 | //US KStatusBar *KMainWindow::internalStatusBar() | 921 | //US KStatusBar *KMainWindow::internalStatusBar() |
922 | QStatusBar *KMainWindow::internalStatusBar() | 922 | QStatusBar *KMainWindow::internalStatusBar() |
923 | { | 923 | { |
924 | //US QObjectList *l = queryList( "KStatusBar", 0, false, false ); | 924 | //US QObjectList *l = queryList( "KStatusBar", 0, false, false ); |
925 | QObjectList *l = queryList( "QStatusBar", 0, false, false ); | 925 | QObjectList *l = queryList( "QStatusBar", 0, false, false ); |
926 | if ( !l || !l->first() ) { | 926 | if ( !l || !l->first() ) { |
927 | delete l; | 927 | delete l; |
928 | return 0; | 928 | return 0; |
929 | } | 929 | } |
930 | 930 | ||
931 | //US KStatusBar *s = (KStatusBar*)l->first(); | 931 | //US KStatusBar *s = (KStatusBar*)l->first(); |
932 | QStatusBar *s = (QStatusBar*)l->first(); | 932 | QStatusBar *s = (QStatusBar*)l->first(); |
933 | delete l; | 933 | delete l; |
934 | return s; | 934 | return s; |
935 | } | 935 | } |
936 | 936 | ||
937 | void KMainWindow::childEvent( QChildEvent* e) | 937 | void KMainWindow::childEvent( QChildEvent* e) |
938 | { | 938 | { |
939 | QMainWindow::childEvent( e ); | 939 | QMainWindow::childEvent( e ); |
940 | } | 940 | } |
941 | 941 | ||
942 | void KMainWindow::paintEvent( QPaintEvent * ) | 942 | void KMainWindow::paintEvent( QPaintEvent * ) |
943 | { | 943 | { |
944 | // do nothing | 944 | // do nothing |
945 | } | 945 | } |
946 | 946 | ||
947 | QSize KMainWindow::sizeForCentralWidgetSize(QSize size) | 947 | QSize KMainWindow::sizeForCentralWidgetSize(QSize size) |
948 | { | 948 | { |
949 | KToolBar *tb = (KToolBar*)child( "mainToolBar", "KToolBar" ); | 949 | KToolBar *tb = (KToolBar*)child( "mainToolBar", "KToolBar" ); |
950 | if (tb && !tb->isHidden()) { | 950 | if (tb && !tb->isHidden()) { |
951 | switch( tb->barPos() ) | 951 | switch( tb->barPos() ) |
952 | { | 952 | { |
953 | case KToolBar::Top: | 953 | case KToolBar::Top: |
954 | case KToolBar::Bottom: | 954 | case KToolBar::Bottom: |
955 | size += QSize(0, tb->sizeHint().height()); | 955 | size += QSize(0, tb->sizeHint().height()); |
956 | break; | 956 | break; |
957 | 957 | ||
958 | case KToolBar::Left: | 958 | case KToolBar::Left: |
959 | case KToolBar::Right: | 959 | case KToolBar::Right: |
960 | size += QSize(toolBar()->sizeHint().width(), 0); | 960 | size += QSize(toolBar()->sizeHint().width(), 0); |
961 | break; | 961 | break; |
962 | 962 | ||
963 | case KToolBar::Flat: | 963 | case KToolBar::Flat: |
964 | //US size += QSize(0, 3+kapp->style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); | 964 | //US size += QSize(0, 3+kapp->style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); |
965 | size += QSize(0, tb->sizeHint().height()); | 965 | size += QSize(0, tb->sizeHint().height()); |
966 | break; | 966 | break; |
967 | 967 | ||
968 | default: | 968 | default: |
969 | break; | 969 | break; |
970 | } | 970 | } |
971 | } | 971 | } |
972 | //US KMenuBar *mb = menuBar(); | 972 | //US KMenuBar *mb = menuBar(); |
973 | QMenuBar *mb = menuBar(); | 973 | QMenuBar *mb = menuBar(); |
974 | if (!mb->isHidden()) { | 974 | if (!mb->isHidden()) { |
975 | size += QSize(0,mb->heightForWidth(size.width())); | 975 | size += QSize(0,mb->heightForWidth(size.width())); |
976 | /*US if (style().styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, this)) | 976 | /*US if (style().styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, this)) |
977 | size += QSize( 0, dockWindowsMovable() ? 1 : 2); | 977 | size += QSize( 0, dockWindowsMovable() ? 1 : 2); |
978 | */ | 978 | */ |
979 | size += QSize( 0, 2); | 979 | size += QSize( 0, 2); |
980 | } | 980 | } |
981 | QStatusBar *sb = internalStatusBar(); | 981 | QStatusBar *sb = internalStatusBar(); |
982 | if( sb && !sb->isHidden() ) | 982 | if( sb && !sb->isHidden() ) |
983 | size += QSize(0, sb->sizeHint().height()); | 983 | size += QSize(0, sb->sizeHint().height()); |
984 | 984 | ||
985 | return size; | 985 | return size; |
986 | } | 986 | } |
987 | 987 | ||
988 | // why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI; | 988 | // why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI; |
989 | void KMainWindow::finalizeGUI( KXMLGUIClient *client ) | 989 | void KMainWindow::finalizeGUI( KXMLGUIClient *client ) |
990 | { /*US KXMLGUIBuilder::finalizeGUI( client );*/ } | 990 | { /*US KXMLGUIBuilder::finalizeGUI( client );*/ } |
991 | 991 | ||
992 | void KMainWindow::virtual_hook( int id, void* data ) | 992 | void KMainWindow::virtual_hook( int id, void* data ) |
993 | { /*US KXMLGUIBuilder::virtual_hook( id, data );*/ | 993 | { /*US KXMLGUIBuilder::virtual_hook( id, data );*/ |
994 | KXMLGUIClient::virtual_hook( id, data ); } | 994 | KXMLGUIClient::virtual_hook( id, data ); } |