-rw-r--r-- | microkde/kdeui/ktoolbar.cpp | 185 |
1 files changed, 98 insertions, 87 deletions
diff --git a/microkde/kdeui/ktoolbar.cpp b/microkde/kdeui/ktoolbar.cpp index 027e5e9..02db316 100644 --- a/microkde/kdeui/ktoolbar.cpp +++ b/microkde/kdeui/ktoolbar.cpp | |||
@@ -1,388 +1,399 @@ | |||
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, 1998 Stephan Kulow (coolo@kde.org) | 4 | (C) 1997, 1998 Stephan Kulow (coolo@kde.org) |
5 | (C) 1997, 1998 Mark Donohoe (donohoe@kde.org) | 5 | (C) 1997, 1998 Mark Donohoe (donohoe@kde.org) |
6 | (C) 1997, 1998 Sven Radej (radej@kde.org) | 6 | (C) 1997, 1998 Sven Radej (radej@kde.org) |
7 | (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org) | 7 | (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org) |
8 | (C) 1999 Chris Schlaeger (cs@kde.org) | 8 | (C) 1999 Chris Schlaeger (cs@kde.org) |
9 | (C) 1999 Kurt Granroth (granroth@kde.org) | 9 | (C) 1999 Kurt Granroth (granroth@kde.org) |
10 | 10 | ||
11 | This library is free software; you can redistribute it and/or | 11 | This library is free software; you can redistribute it and/or |
12 | modify it under the terms of the GNU Library General Public | 12 | modify it under the terms of the GNU Library General Public |
13 | License version 2 as published by the Free Software Foundation. | 13 | License version 2 as published by the Free Software Foundation. |
14 | 14 | ||
15 | This library is distributed in the hope that it will be useful, | 15 | This library is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 | Library General Public License for more details. | 18 | Library General Public License for more details. |
19 | 19 | ||
20 | You should have received a copy of the GNU Library General Public License | 20 | You should have received a copy of the GNU Library General Public License |
21 | along with this library; see the file COPYING.LIB. If not, write to | 21 | along with this library; see the file COPYING.LIB. If not, write to |
22 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 22 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
23 | Boston, MA 02111-1307, USA. | 23 | Boston, MA 02111-1307, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #ifdef KDE_USE_FINAL | 26 | #ifdef KDE_USE_FINAL |
27 | #undef Always | 27 | #undef Always |
28 | #include <qdockwindow.h> | 28 | #include <q3dockwindow.h> |
29 | #endif | 29 | #endif |
30 | 30 | //Added by qt3to4: | |
31 | #include <Q3ValueList> | ||
32 | #include <Q3PtrList> | ||
33 | #include <QPixmap> | ||
34 | #include <Q3Frame> | ||
35 | #include <QResizeEvent> | ||
36 | #include <QMouseEvent> | ||
37 | #include <QChildEvent> | ||
38 | #include <QEvent> | ||
39 | #include <QShowEvent> | ||
40 | #include <QDesktopWidget> | ||
41 | #include <QBoxLayout> | ||
31 | 42 | ||
32 | 43 | ||
33 | #include "ktoolbar.h" | 44 | #include "ktoolbar.h" |
34 | #include "kmainwindow.h" | 45 | #include "kmainwindow.h" |
35 | 46 | ||
36 | #include <string.h> | 47 | #include <string.h> |
37 | 48 | ||
38 | #include <qpainter.h> | 49 | #include <qpainter.h> |
39 | #include <qtooltip.h> | 50 | #include <qtooltip.h> |
40 | #include <qdrawutil.h> | 51 | #include <qdrawutil.h> |
41 | #include <qstring.h> | 52 | #include <qstring.h> |
42 | #include <qrect.h> | 53 | #include <qrect.h> |
43 | #include <qobjectlist.h> | 54 | #include <qobject.h> |
44 | #include <qtimer.h> | 55 | #include <qtimer.h> |
45 | #include <qstyle.h> | 56 | #include <qstyle.h> |
46 | #include <qapplication.h> | 57 | #include <qapplication.h> |
47 | 58 | ||
48 | //US #include <config.h> | 59 | //US #include <config.h> |
49 | 60 | ||
50 | #include "klineedit.h" | 61 | #include "klineedit.h" |
51 | #include "kseparator.h" | 62 | #include "kseparator.h" |
52 | #include <klocale.h> | 63 | #include <klocale.h> |
53 | #include <kapplication.h> | 64 | #include <kapplication.h> |
54 | #include <kaction.h> | 65 | #include <kaction.h> |
55 | #include <kstdaction.h> | 66 | #include <kstdaction.h> |
56 | #include <kglobal.h> | 67 | #include <kglobal.h> |
57 | #include <kconfig.h> | 68 | #include <kconfig.h> |
58 | #include <kiconloader.h> | 69 | #include <kiconloader.h> |
59 | #include <kcombobox.h> | 70 | #include <kcombobox.h> |
60 | //US #include <kpopupmenu.h> | 71 | //US #include <kpopupmenu.h> |
61 | //US #include <kanimwidget.h> | 72 | //US #include <kanimwidget.h> |
62 | //US #include <kipc.h> | 73 | //US #include <kipc.h> |
63 | //US #include <kwin.h> | 74 | //US #include <kwin.h> |
64 | #include <kdebug.h> | 75 | #include <kdebug.h> |
65 | #include <qlayout.h> | 76 | #include <qlayout.h> |
66 | 77 | ||
67 | #include "ktoolbarbutton.h" | 78 | #include "ktoolbarbutton.h" |
68 | 79 | ||
69 | //US | 80 | //US |
70 | #include "kconfigbase.h" | 81 | #include "kconfigbase.h" |
71 | 82 | ||
72 | #include <qpopupmenu.h> | 83 | #include <q3popupmenu.h> |
73 | #include <qmainwindow.h> | 84 | #include <q3mainwindow.h> |
74 | 85 | ||
75 | enum { | 86 | enum { |
76 | CONTEXT_TOP = 0, | 87 | CONTEXT_TOP = 0, |
77 | CONTEXT_LEFT = 1, | 88 | CONTEXT_LEFT = 1, |
78 | CONTEXT_RIGHT = 2, | 89 | CONTEXT_RIGHT = 2, |
79 | CONTEXT_BOTTOM = 3, | 90 | CONTEXT_BOTTOM = 3, |
80 | CONTEXT_FLOAT = 4, | 91 | CONTEXT_FLOAT = 4, |
81 | CONTEXT_FLAT = 5, | 92 | CONTEXT_FLAT = 5, |
82 | CONTEXT_ICONS = 6, | 93 | CONTEXT_ICONS = 6, |
83 | CONTEXT_TEXT = 7, | 94 | CONTEXT_TEXT = 7, |
84 | CONTEXT_TEXTRIGHT = 8, | 95 | CONTEXT_TEXTRIGHT = 8, |
85 | CONTEXT_TEXTUNDER = 9, | 96 | CONTEXT_TEXTUNDER = 9, |
86 | CONTEXT_ICONSIZES = 50 // starting point for the icon size list, put everything else before | 97 | CONTEXT_ICONSIZES = 50 // starting point for the icon size list, put everything else before |
87 | }; | 98 | }; |
88 | 99 | ||
89 | class KToolBarPrivate | 100 | class KToolBarPrivate |
90 | { | 101 | { |
91 | public: | 102 | public: |
92 | KToolBarPrivate() { | 103 | KToolBarPrivate() { |
93 | m_iconSize = 0; | 104 | m_iconSize = 0; |
94 | m_iconText = KToolBar::IconOnly; | 105 | m_iconText = KToolBar::IconOnly; |
95 | m_highlight = true; | 106 | m_highlight = true; |
96 | m_transparent = true; | 107 | m_transparent = true; |
97 | m_honorStyle = false; | 108 | m_honorStyle = false; |
98 | 109 | ||
99 | m_enableContext = true; | 110 | m_enableContext = true; |
100 | 111 | ||
101 | m_xmlguiClient = 0; | 112 | m_xmlguiClient = 0; |
102 | m_configurePlugged = false; | 113 | m_configurePlugged = false; |
103 | 114 | ||
104 | //US oldPos = Qt::DockUnmanaged; | 115 | //US oldPos = Qt::DockUnmanaged; |
105 | oldPos = QMainWindow::Unmanaged; | 116 | oldPos = Qt::Unmanaged; |
106 | 117 | ||
107 | modified = m_isHorizontal = positioned = FALSE; | 118 | modified = m_isHorizontal = positioned = FALSE; |
108 | 119 | ||
109 | HiddenDefault = false; | 120 | HiddenDefault = false; |
110 | IconSizeDefault = 0; | 121 | IconSizeDefault = 0; |
111 | IconTextDefault = "IconOnly"; | 122 | IconTextDefault = "IconOnly"; |
112 | IndexDefault = -1; | 123 | IndexDefault = -1; |
113 | NewLineDefault = false; | 124 | NewLineDefault = false; |
114 | OffsetDefault = -1; | 125 | OffsetDefault = -1; |
115 | PositionDefault = "Top"; | 126 | PositionDefault = "Top"; |
116 | idleButtons.setAutoDelete(true); | 127 | idleButtons.setAutoDelete(true); |
117 | } | 128 | } |
118 | 129 | ||
119 | int m_iconSize; | 130 | int m_iconSize; |
120 | KToolBar::IconText m_iconText; | 131 | KToolBar::IconText m_iconText; |
121 | bool m_highlight : 1; | 132 | bool m_highlight : 1; |
122 | bool m_transparent : 1; | 133 | bool m_transparent : 1; |
123 | bool m_honorStyle : 1; | 134 | bool m_honorStyle : 1; |
124 | bool m_isHorizontal : 1; | 135 | bool m_isHorizontal : 1; |
125 | bool m_enableContext : 1; | 136 | bool m_enableContext : 1; |
126 | bool m_configurePlugged : 1; | 137 | bool m_configurePlugged : 1; |
127 | bool modified : 1; | 138 | bool modified : 1; |
128 | bool positioned : 1; | 139 | bool positioned : 1; |
129 | 140 | ||
130 | QWidget *m_parent; | 141 | QWidget *m_parent; |
131 | 142 | ||
132 | QMainWindow::ToolBarDock oldPos; | 143 | Qt::ToolBarDock oldPos; |
133 | 144 | ||
134 | KXMLGUIClient *m_xmlguiClient; | 145 | KXMLGUIClient *m_xmlguiClient; |
135 | 146 | ||
136 | struct ToolBarInfo | 147 | struct ToolBarInfo |
137 | { | 148 | { |
138 | //US ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {} | 149 | //US ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {} |
139 | ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( QMainWindow::Top ) {} | 150 | ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {} |
140 | //US ToolBarInfo( Qt::Dock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} | 151 | //US ToolBarInfo( Qt::Dock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} |
141 | ToolBarInfo( QMainWindow::ToolBarDock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} | 152 | ToolBarInfo( Qt::ToolBarDock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} |
142 | int index, offset; | 153 | int index, offset; |
143 | bool newline; | 154 | bool newline; |
144 | //US Qt::Dock dock; | 155 | //US Qt::Dock dock; |
145 | QMainWindow::ToolBarDock dock; | 156 | Qt::ToolBarDock dock; |
146 | }; | 157 | }; |
147 | 158 | ||
148 | ToolBarInfo toolBarInfo; | 159 | ToolBarInfo toolBarInfo; |
149 | QValueList<int> iconSizes; | 160 | Q3ValueList<int> iconSizes; |
150 | QTimer repaintTimer; | 161 | QTimer repaintTimer; |
151 | 162 | ||
152 | // Default Values. | 163 | // Default Values. |
153 | bool HiddenDefault; | 164 | bool HiddenDefault; |
154 | int IconSizeDefault; | 165 | int IconSizeDefault; |
155 | QString IconTextDefault; | 166 | QString IconTextDefault; |
156 | int IndexDefault; | 167 | int IndexDefault; |
157 | bool NewLineDefault; | 168 | bool NewLineDefault; |
158 | int OffsetDefault; | 169 | int OffsetDefault; |
159 | QString PositionDefault; | 170 | QString PositionDefault; |
160 | 171 | ||
161 | QPtrList<QWidget> idleButtons; | 172 | Q3PtrList<QWidget> idleButtons; |
162 | }; | 173 | }; |
163 | 174 | ||
164 | KToolBarSeparator::KToolBarSeparator(Orientation o , bool l, QToolBar *parent, | 175 | KToolBarSeparator::KToolBarSeparator(Qt::Orientation o , bool l, Q3ToolBar *parent, |
165 | const char* name ) | 176 | const char* name ) |
166 | :QFrame( parent, name ), line( l ) | 177 | :Q3Frame( parent, name ), line( l ) |
167 | { | 178 | { |
168 | connect( parent, SIGNAL(orientationChanged(Orientation)), | 179 | connect( parent, SIGNAL(orientationChanged(Qt::Orientation)), |
169 | this, SLOT(setOrientation(Orientation)) ); | 180 | this, SLOT(setOrientation(Qt::Orientation)) ); |
170 | setOrientation( o ); | 181 | setOrientation( o ); |
171 | setBackgroundMode( parent->backgroundMode() ); | 182 | setBackgroundMode( parent->backgroundMode() ); |
172 | setBackgroundOrigin( ParentOrigin ); | 183 | setBackgroundOrigin( ParentOrigin ); |
173 | } | 184 | } |
174 | 185 | ||
175 | void KToolBarSeparator::setOrientation( Orientation o ) | 186 | void KToolBarSeparator::setOrientation( Qt::Orientation o ) |
176 | { | 187 | { |
177 | orient = o; | 188 | orient = o; |
178 | if ( line ) { | 189 | if ( line ) { |
179 | if ( orientation() == Vertical ) | 190 | if ( orientation() == Qt::Vertical ) |
180 | setFrameStyle( HLine + Sunken ); | 191 | setFrameStyle( HLine + Sunken ); |
181 | else | 192 | else |
182 | setFrameStyle( VLine + Sunken ); | 193 | setFrameStyle( VLine + Sunken ); |
183 | } else { | 194 | } else { |
184 | setFrameStyle( NoFrame ); | 195 | setFrameStyle( NoFrame ); |
185 | } | 196 | } |
186 | } | 197 | } |
187 | 198 | ||
188 | void KToolBarSeparator::styleChange( QStyle& ) | 199 | void KToolBarSeparator::styleChange( QStyle& ) |
189 | { | 200 | { |
190 | setOrientation( orient ); | 201 | setOrientation( orient ); |
191 | } | 202 | } |
192 | 203 | ||
193 | QSize KToolBarSeparator::sizeHint() const | 204 | QSize KToolBarSeparator::sizeHint() const |
194 | { | 205 | { |
195 | return orientation() == Vertical ? QSize( 0, 6 ) : QSize( 6, 0 ); | 206 | return orientation() == Qt::Vertical ? QSize( 0, 6 ) : QSize( 6, 0 ); |
196 | } | 207 | } |
197 | 208 | ||
198 | QSizePolicy KToolBarSeparator::sizePolicy() const | 209 | QSizePolicy KToolBarSeparator::sizePolicy() const |
199 | { | 210 | { |
200 | return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); | 211 | return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); |
201 | } | 212 | } |
202 | 213 | ||
203 | KToolBar::KToolBar( QWidget *parent, const char *name, bool honorStyle, bool readConfig ) | 214 | KToolBar::KToolBar( QWidget *parent, const char *name, bool honorStyle, bool readConfig ) |
204 | #ifdef DESKTOP_VERSION | 215 | #ifdef DESKTOP_VERSION |
205 | : QToolBar( QString::fromLatin1( name ), | 216 | : Q3ToolBar( QString::fromLatin1( name ), |
206 | parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, | 217 | parent && parent->inherits( "Q3MainWindow" ) ? static_cast<Q3MainWindow*>(parent) : 0, |
207 | parent, FALSE, | 218 | parent, FALSE, |
208 | name ? name : "mainToolBar") | 219 | name ? name : "mainToolBar") |
209 | #else | 220 | #else |
210 | : QPEToolBar( parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, | 221 | : QPEToolBar( parent && parent->inherits( "Q3MainWindow" ) ? static_cast<Q3MainWindow*>(parent) : 0, |
211 | QString::fromLatin1( name )) | 222 | QString::fromLatin1( name )) |
212 | 223 | ||
213 | 224 | ||
214 | #endif | 225 | #endif |
215 | { | 226 | { |
216 | init( readConfig, honorStyle ); | 227 | init( readConfig, honorStyle ); |
217 | } | 228 | } |
218 | 229 | ||
219 | KToolBar::KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) | 230 | KToolBar::KToolBar( Q3MainWindow *parentWindow, Qt::ToolBarDock dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) |
220 | #ifdef DESKTOP_VERSION | 231 | #ifdef DESKTOP_VERSION |
221 | : QToolBar( QString::fromLatin1( name ), | 232 | : Q3ToolBar( QString::fromLatin1( name ), |
222 | parentWindow, dock, newLine, | 233 | parentWindow, dock, newLine, |
223 | name ? name : "mainToolBar") | 234 | name ? name : "mainToolBar") |
224 | #else | 235 | #else |
225 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) | 236 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) |
226 | 237 | ||
227 | 238 | ||
228 | #endif | 239 | #endif |
229 | 240 | ||
230 | { | 241 | { |
231 | init( readConfig, honorStyle ); | 242 | init( readConfig, honorStyle ); |
232 | } | 243 | } |
233 | 244 | ||
234 | KToolBar::KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) | 245 | KToolBar::KToolBar( Q3MainWindow *parentWindow, QWidget *dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) |
235 | #ifdef DESKTOP_VERSION | 246 | #ifdef DESKTOP_VERSION |
236 | : QToolBar( QString::fromLatin1( name ), | 247 | : Q3ToolBar( QString::fromLatin1( name ), |
237 | parentWindow, dock, newLine, | 248 | parentWindow, dock, newLine, |
238 | name ? name : "mainToolBar") | 249 | name ? name : "mainToolBar") |
239 | #else | 250 | #else |
240 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) | 251 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) |
241 | 252 | ||
242 | 253 | ||
243 | #endif | 254 | #endif |
244 | 255 | ||
245 | { | 256 | { |
246 | init( readConfig, honorStyle ); | 257 | init( readConfig, honorStyle ); |
247 | } | 258 | } |
248 | 259 | ||
249 | KToolBar::~KToolBar() | 260 | KToolBar::~KToolBar() |
250 | { | 261 | { |
251 | inshutdownprocess = true; | 262 | inshutdownprocess = true; |
252 | emit toolbarDestroyed(); | 263 | emit toolbarDestroyed(); |
253 | delete d; | 264 | delete d; |
254 | } | 265 | } |
255 | 266 | ||
256 | void KToolBar::init( bool readConfig, bool honorStyle ) | 267 | void KToolBar::init( bool readConfig, bool honorStyle ) |
257 | { | 268 | { |
258 | sizeHintW = 240; | 269 | sizeHintW = 240; |
259 | sizeHintH = 22; | 270 | sizeHintH = 22; |
260 | inshutdownprocess = false; | 271 | inshutdownprocess = false; |
261 | d = new KToolBarPrivate; | 272 | d = new KToolBarPrivate; |
262 | setFullSize( TRUE ); | 273 | setFullSize( TRUE ); |
263 | d->m_honorStyle = honorStyle; | 274 | d->m_honorStyle = honorStyle; |
264 | context = 0; | 275 | context = 0; |
265 | layoutTimer = new QTimer( this ); | 276 | layoutTimer = new QTimer( this ); |
266 | connect( layoutTimer, SIGNAL( timeout() ), | 277 | connect( layoutTimer, SIGNAL( timeout() ), |
267 | this, SLOT( rebuildLayout() ) ); | 278 | this, SLOT( rebuildLayout() ) ); |
268 | connect( &(d->repaintTimer), SIGNAL( timeout() ), | 279 | connect( &(d->repaintTimer), SIGNAL( timeout() ), |
269 | this, SLOT( slotRepaint() ) ); | 280 | this, SLOT( slotRepaint() ) ); |
270 | /*US | 281 | /*US |
271 | if ( kapp ) { // may be null when started inside designer | 282 | if ( kapp ) { // may be null when started inside designer |
272 | connect(kapp, SIGNAL(toolbarAppearanceChanged(int)), this, SLOT(slotAppearanceChanged())); | 283 | connect(kapp, SIGNAL(toolbarAppearanceChanged(int)), this, SLOT(slotAppearanceChanged())); |
273 | // request notification of changes in icon style | 284 | // request notification of changes in icon style |
274 | kapp->addKipcEventMask(KIPC::IconChanged); | 285 | kapp->addKipcEventMask(KIPC::IconChanged); |
275 | connect(kapp, SIGNAL(iconChanged(int)), this, SLOT(slotIconChanged(int))); | 286 | connect(kapp, SIGNAL(iconChanged(int)), this, SLOT(slotIconChanged(int))); |
276 | } | 287 | } |
277 | */ | 288 | */ |
278 | // finally, read in our configurable settings | 289 | // finally, read in our configurable settings |
279 | if ( readConfig ) | 290 | if ( readConfig ) |
280 | slotReadConfig(); | 291 | slotReadConfig(); |
281 | 292 | ||
282 | if ( mainWindow() ) | 293 | if ( mainWindow() ) |
283 | connect( mainWindow(), SIGNAL( toolBarPositionChanged( QToolBar * ) ), | 294 | connect( mainWindow(), SIGNAL( toolBarPositionChanged( Q3ToolBar * ) ), |
284 | this, SLOT( toolBarPosChanged( QToolBar * ) ) ); | 295 | this, SLOT( toolBarPosChanged( Q3ToolBar * ) ) ); |
285 | 296 | ||
286 | // Hack to make sure we recalculate our size when we dock. | 297 | // Hack to make sure we recalculate our size when we dock. |
287 | //US connect( this, SIGNAL(placeChanged(QDockWindow::Place)), SLOT(rebuildLayout()) ); | 298 | //US connect( this, SIGNAL(placeChanged(QDockWindow::Place)), SLOT(rebuildLayout()) ); |
288 | } | 299 | } |
289 | 300 | ||
290 | int KToolBar::insertButton(const QString& icon, int id, bool enabled, | 301 | int KToolBar::insertButton(const QString& icon, int id, bool enabled, |
291 | const QString& text, int index/*US, KInstance *_instance*/ ) | 302 | const QString& text, int index/*US, KInstance *_instance*/ ) |
292 | { | 303 | { |
293 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/ ); | 304 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/ ); |
294 | 305 | ||
295 | insertWidgetInternal( button, index, id ); | 306 | insertWidgetInternal( button, index, id ); |
296 | button->setEnabled( enabled ); | 307 | button->setEnabled( enabled ); |
297 | doConnections( button ); | 308 | doConnections( button ); |
298 | return index; | 309 | return index; |
299 | } | 310 | } |
300 | 311 | ||
301 | 312 | ||
302 | int KToolBar::insertButton(const QString& icon, int id, const char *signal, | 313 | int KToolBar::insertButton(const QString& icon, int id, const char *signal, |
303 | const QObject *receiver, const char *slot, | 314 | const QObject *receiver, const char *slot, |
304 | bool enabled, const QString& text, int index/*US, KInstance *_instance*/ ) | 315 | bool enabled, const QString& text, int index/*US, KInstance *_instance*/ ) |
305 | { | 316 | { |
306 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/); | 317 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/); |
307 | insertWidgetInternal( button, index, id ); | 318 | insertWidgetInternal( button, index, id ); |
308 | button->setEnabled( enabled ); | 319 | button->setEnabled( enabled ); |
309 | connect( button, signal, receiver, slot ); | 320 | connect( button, signal, receiver, slot ); |
310 | doConnections( button ); | 321 | doConnections( button ); |
311 | return index; | 322 | return index; |
312 | } | 323 | } |
313 | 324 | ||
314 | 325 | ||
315 | int KToolBar::insertButton(const QPixmap& pixmap, int id, bool enabled, | 326 | int KToolBar::insertButton(const QPixmap& pixmap, int id, bool enabled, |
316 | const QString& text, int index ) | 327 | const QString& text, int index ) |
317 | { | 328 | { |
318 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); | 329 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); |
319 | insertWidgetInternal( button, index, id ); | 330 | insertWidgetInternal( button, index, id ); |
320 | button->setEnabled( enabled ); | 331 | button->setEnabled( enabled ); |
321 | doConnections( button ); | 332 | doConnections( button ); |
322 | return index; | 333 | return index; |
323 | } | 334 | } |
324 | #if 0 | 335 | #if 0 |
325 | bar->insertButton( icon, id_, SIGNAL( clicked() ), this, | 336 | bar->insertButton( icon, id_, SIGNAL( clicked() ), this, |
326 | SLOT( slotActivated() ), | 337 | SLOT( slotActivated() ), |
327 | d->isEnabled(), d->plainText(), index/*US, instance*/ ); | 338 | d->isEnabled(), d->plainText(), index/*US, instance*/ ); |
328 | #endif | 339 | #endif |
329 | 340 | ||
330 | int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal, | 341 | int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal, |
331 | const QObject *receiver, const char *slot, | 342 | const QObject *receiver, const char *slot, |
332 | bool enabled, const QString& text, | 343 | bool enabled, const QString& text, |
333 | int index ) | 344 | int index ) |
334 | { | 345 | { |
335 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); | 346 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); |
336 | insertWidgetInternal( button, index, id ); | 347 | insertWidgetInternal( button, index, id ); |
337 | button->setEnabled( enabled ); | 348 | button->setEnabled( enabled ); |
338 | connect( button, signal, receiver, slot ); | 349 | connect( button, signal, receiver, slot ); |
339 | doConnections( button ); | 350 | doConnections( button ); |
340 | return index; | 351 | return index; |
341 | } | 352 | } |
342 | 353 | ||
343 | 354 | ||
344 | int KToolBar::insertButton(const QString& icon, int id, QPopupMenu *popup, | 355 | int KToolBar::insertButton(const QString& icon, int id, Q3PopupMenu *popup, |
345 | bool enabled, const QString &text, int index ) | 356 | bool enabled, const QString &text, int index ) |
346 | { | 357 | { |
347 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text ); | 358 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text ); |
348 | insertWidgetInternal( button, index, id ); | 359 | insertWidgetInternal( button, index, id ); |
349 | button->setEnabled( enabled ); | 360 | button->setEnabled( enabled ); |
350 | button->setPopup( popup ); | 361 | button->setPopup( popup ); |
351 | doConnections( button ); | 362 | doConnections( button ); |
352 | return index; | 363 | return index; |
353 | } | 364 | } |
354 | 365 | ||
355 | 366 | ||
356 | int KToolBar::insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup, | 367 | int KToolBar::insertButton(const QPixmap& pixmap, int id, Q3PopupMenu *popup, |
357 | bool enabled, const QString &text, int index ) | 368 | bool enabled, const QString &text, int index ) |
358 | { | 369 | { |
359 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text ); | 370 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text ); |
360 | insertWidgetInternal( button, index, id ); | 371 | insertWidgetInternal( button, index, id ); |
361 | button->setEnabled( enabled ); | 372 | button->setEnabled( enabled ); |
362 | button->setPopup( popup ); | 373 | button->setPopup( popup ); |
363 | doConnections( button ); | 374 | doConnections( button ); |
364 | return index; | 375 | return index; |
365 | } | 376 | } |
366 | 377 | ||
367 | 378 | ||
368 | int KToolBar::insertLined (const QString& text, int id, | 379 | int KToolBar::insertLined (const QString& text, int id, |
369 | const char *signal, | 380 | const char *signal, |
370 | const QObject *receiver, const char *slot, | 381 | const QObject *receiver, const char *slot, |
371 | bool enabled , | 382 | bool enabled , |
372 | const QString& toolTipText, | 383 | const QString& toolTipText, |
373 | int size, int index ) | 384 | int size, int index ) |
374 | { | 385 | { |
375 | KLineEdit *lined = new KLineEdit ( this, 0 ); | 386 | KLineEdit *lined = new KLineEdit ( this, 0 ); |
376 | if ( !toolTipText.isEmpty() ) | 387 | if ( !toolTipText.isEmpty() ) |
377 | QToolTip::add( lined, toolTipText ); | 388 | QToolTip::add( lined, toolTipText ); |
378 | if ( size > 0 ) | 389 | if ( size > 0 ) |
379 | lined->setMinimumWidth( size ); | 390 | lined->setMinimumWidth( size ); |
380 | insertWidgetInternal( lined, index, id ); | 391 | insertWidgetInternal( lined, index, id ); |
381 | connect( lined, signal, receiver, slot ); | 392 | connect( lined, signal, receiver, slot ); |
382 | lined->setText(text); | 393 | lined->setText(text); |
383 | lined->setEnabled( enabled ); | 394 | lined->setEnabled( enabled ); |
384 | return index; | 395 | return index; |
385 | } | 396 | } |
386 | 397 | ||
387 | int KToolBar::insertCombo (const QStringList &list, int id, bool writable, | 398 | int KToolBar::insertCombo (const QStringList &list, int id, bool writable, |
388 | const char *signal, const QObject *receiver, | 399 | const char *signal, const QObject *receiver, |
@@ -511,77 +522,77 @@ void KToolBar::setItemEnabled( int id, bool enabled ) | |||
511 | { | 522 | { |
512 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 523 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
513 | if ( it == id2widget.end() ) | 524 | if ( it == id2widget.end() ) |
514 | return; | 525 | return; |
515 | if ( (*it) ) | 526 | if ( (*it) ) |
516 | (*it)->setEnabled( enabled ); | 527 | (*it)->setEnabled( enabled ); |
517 | } | 528 | } |
518 | 529 | ||
519 | 530 | ||
520 | void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap ) | 531 | void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap ) |
521 | { | 532 | { |
522 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 533 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
523 | if ( it == id2widget.end() ) | 534 | if ( it == id2widget.end() ) |
524 | return; | 535 | return; |
525 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 536 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
526 | KToolBarButton * button = (KToolBarButton *)( *it ); | 537 | KToolBarButton * button = (KToolBarButton *)( *it ); |
527 | if ( button ) | 538 | if ( button ) |
528 | button->setPixmap( _pixmap ); | 539 | button->setPixmap( _pixmap ); |
529 | } | 540 | } |
530 | 541 | ||
531 | 542 | ||
532 | void KToolBar::setButtonIcon( int id, const QString& _icon ) | 543 | void KToolBar::setButtonIcon( int id, const QString& _icon ) |
533 | { | 544 | { |
534 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 545 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
535 | if ( it == id2widget.end() ) | 546 | if ( it == id2widget.end() ) |
536 | return; | 547 | return; |
537 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 548 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
538 | KToolBarButton * button = (KToolBarButton *)( *it ); | 549 | KToolBarButton * button = (KToolBarButton *)( *it ); |
539 | if ( button ) | 550 | if ( button ) |
540 | button->setIcon( _icon ); | 551 | button->setIcon( _icon ); |
541 | } | 552 | } |
542 | 553 | ||
543 | void KToolBar::setButtonIconSet( int id, const QIconSet& iconset ) | 554 | void KToolBar::setButtonIconSet( int id, const QIcon& iconset ) |
544 | { | 555 | { |
545 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 556 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
546 | if ( it == id2widget.end() ) | 557 | if ( it == id2widget.end() ) |
547 | return; | 558 | return; |
548 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 559 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
549 | KToolBarButton * button = (KToolBarButton *)( *it ); | 560 | KToolBarButton * button = (KToolBarButton *)( *it ); |
550 | if ( button ) | 561 | if ( button ) |
551 | button->setIconSet( iconset ); | 562 | button->setIconSet( iconset ); |
552 | } | 563 | } |
553 | 564 | ||
554 | 565 | ||
555 | void KToolBar::setDelayedPopup (int id , QPopupMenu *_popup, bool toggle ) | 566 | void KToolBar::setDelayedPopup (int id , Q3PopupMenu *_popup, bool toggle ) |
556 | { | 567 | { |
557 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 568 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
558 | if ( it == id2widget.end() ) | 569 | if ( it == id2widget.end() ) |
559 | return; | 570 | return; |
560 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 571 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
561 | KToolBarButton * button = (KToolBarButton *)( *it ); | 572 | KToolBarButton * button = (KToolBarButton *)( *it ); |
562 | if ( button ) | 573 | if ( button ) |
563 | button->setDelayedPopup( _popup, toggle ); | 574 | button->setDelayedPopup( _popup, toggle ); |
564 | } | 575 | } |
565 | 576 | ||
566 | 577 | ||
567 | void KToolBar::setAutoRepeat (int id, bool flag) | 578 | void KToolBar::setAutoRepeat (int id, bool flag) |
568 | { | 579 | { |
569 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 580 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
570 | if ( it == id2widget.end() ) | 581 | if ( it == id2widget.end() ) |
571 | return; | 582 | return; |
572 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 583 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
573 | KToolBarButton * button = (KToolBarButton *)( *it ); | 584 | KToolBarButton * button = (KToolBarButton *)( *it ); |
574 | if ( button ) | 585 | if ( button ) |
575 | button->setAutoRepeat( flag ); | 586 | button->setAutoRepeat( flag ); |
576 | } | 587 | } |
577 | 588 | ||
578 | 589 | ||
579 | void KToolBar::setToggle (int id, bool flag ) | 590 | void KToolBar::setToggle (int id, bool flag ) |
580 | { | 591 | { |
581 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 592 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
582 | if ( it == id2widget.end() ) | 593 | if ( it == id2widget.end() ) |
583 | return; | 594 | return; |
584 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 595 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
585 | KToolBarButton * button = (KToolBarButton *)( *it ); | 596 | KToolBarButton * button = (KToolBarButton *)( *it ); |
586 | if ( button ) | 597 | if ( button ) |
587 | button->setToggle( flag ); | 598 | button->setToggle( flag ); |
@@ -758,65 +769,65 @@ KToolBarButton * KToolBar::getButton (int id) | |||
758 | } | 769 | } |
759 | 770 | ||
760 | 771 | ||
761 | void KToolBar::alignItemRight (int id, bool right ) | 772 | void KToolBar::alignItemRight (int id, bool right ) |
762 | { | 773 | { |
763 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 774 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
764 | if ( it == id2widget.end() ) | 775 | if ( it == id2widget.end() ) |
765 | return; | 776 | return; |
766 | if ( rightAligned && !right && (*it) == rightAligned ) | 777 | if ( rightAligned && !right && (*it) == rightAligned ) |
767 | rightAligned = 0; | 778 | rightAligned = 0; |
768 | if ( (*it) && right ) | 779 | if ( (*it) && right ) |
769 | rightAligned = (*it); | 780 | rightAligned = (*it); |
770 | } | 781 | } |
771 | 782 | ||
772 | 783 | ||
773 | QWidget *KToolBar::getWidget (int id) | 784 | QWidget *KToolBar::getWidget (int id) |
774 | { | 785 | { |
775 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 786 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
776 | return ( it == id2widget.end() ) ? 0 : (*it); | 787 | return ( it == id2widget.end() ) ? 0 : (*it); |
777 | } | 788 | } |
778 | 789 | ||
779 | 790 | ||
780 | void KToolBar::setItemAutoSized (int id, bool yes ) | 791 | void KToolBar::setItemAutoSized (int id, bool yes ) |
781 | { | 792 | { |
782 | QWidget *w = getWidget(id); | 793 | QWidget *w = getWidget(id); |
783 | if ( w && yes ) | 794 | if ( w && yes ) |
784 | setStretchableWidget( w ); | 795 | setStretchableWidget( w ); |
785 | } | 796 | } |
786 | 797 | ||
787 | 798 | ||
788 | void KToolBar::clear () | 799 | void KToolBar::clear () |
789 | { | 800 | { |
790 | QToolBar::clear(); | 801 | Q3ToolBar::clear(); |
791 | widget2id.clear(); | 802 | widget2id.clear(); |
792 | id2widget.clear(); | 803 | id2widget.clear(); |
793 | } | 804 | } |
794 | 805 | ||
795 | 806 | ||
796 | void KToolBar::removeItem(int id) | 807 | void KToolBar::removeItem(int id) |
797 | { | 808 | { |
798 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 809 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
799 | if ( it == id2widget.end() ) | 810 | if ( it == id2widget.end() ) |
800 | { | 811 | { |
801 | kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; | 812 | kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; |
802 | return; | 813 | return; |
803 | } | 814 | } |
804 | QWidget * w = (*it); | 815 | QWidget * w = (*it); |
805 | id2widget.remove( id ); | 816 | id2widget.remove( id ); |
806 | widget2id.remove( w ); | 817 | widget2id.remove( w ); |
807 | widgets.removeRef( w ); | 818 | widgets.removeRef( w ); |
808 | delete w; | 819 | delete w; |
809 | } | 820 | } |
810 | 821 | ||
811 | 822 | ||
812 | void KToolBar::removeItemDelayed(int id) | 823 | void KToolBar::removeItemDelayed(int id) |
813 | { | 824 | { |
814 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 825 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
815 | if ( it == id2widget.end() ) | 826 | if ( it == id2widget.end() ) |
816 | { | 827 | { |
817 | kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; | 828 | kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; |
818 | return; | 829 | return; |
819 | } | 830 | } |
820 | QWidget * w = (*it); | 831 | QWidget * w = (*it); |
821 | id2widget.remove( id ); | 832 | id2widget.remove( id ); |
822 | widget2id.remove( w ); | 833 | widget2id.remove( w ); |
@@ -847,79 +858,79 @@ void KToolBar::showItem (int id) | |||
847 | int KToolBar::itemIndex (int id) | 858 | int KToolBar::itemIndex (int id) |
848 | { | 859 | { |
849 | QWidget *w = getWidget(id); | 860 | QWidget *w = getWidget(id); |
850 | return w ? widgets.findRef(w) : -1; | 861 | return w ? widgets.findRef(w) : -1; |
851 | } | 862 | } |
852 | 863 | ||
853 | 864 | ||
854 | void KToolBar::setFullSize(bool flag ) | 865 | void KToolBar::setFullSize(bool flag ) |
855 | { | 866 | { |
856 | setHorizontalStretchable( flag ); | 867 | setHorizontalStretchable( flag ); |
857 | setVerticalStretchable( flag ); | 868 | setVerticalStretchable( flag ); |
858 | } | 869 | } |
859 | 870 | ||
860 | 871 | ||
861 | bool KToolBar::fullSize() const | 872 | bool KToolBar::fullSize() const |
862 | { | 873 | { |
863 | return isHorizontalStretchable() || isVerticalStretchable(); | 874 | return isHorizontalStretchable() || isVerticalStretchable(); |
864 | } | 875 | } |
865 | 876 | ||
866 | 877 | ||
867 | void KToolBar::enableMoving(bool flag ) | 878 | void KToolBar::enableMoving(bool flag ) |
868 | { | 879 | { |
869 | //US setMovingEnabled(flag); | 880 | //US setMovingEnabled(flag); |
870 | this->mainWindow()->setToolBarsMovable(flag); | 881 | this->mainWindow()->setToolBarsMovable(flag); |
871 | } | 882 | } |
872 | 883 | ||
873 | 884 | ||
874 | void KToolBar::setBarPos (BarPosition bpos) | 885 | void KToolBar::setBarPos (BarPosition bpos) |
875 | { | 886 | { |
876 | if ( !mainWindow() ) | 887 | if ( !mainWindow() ) |
877 | return; | 888 | return; |
878 | //US mainWindow()->moveDockWindow( this, (Dock)bpos ); | 889 | //US mainWindow()->moveDockWindow( this, (Dock)bpos ); |
879 | mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos ); | 890 | mainWindow()->moveToolBar( this, (Qt::ToolBarDock)bpos ); |
880 | } | 891 | } |
881 | 892 | ||
882 | 893 | ||
883 | const KToolBar::BarPosition KToolBar::barPos() | 894 | const KToolBar::BarPosition KToolBar::barPos() |
884 | { | 895 | { |
885 | if ( !(QMainWindow*)mainWindow() ) | 896 | if ( !(Q3MainWindow*)mainWindow() ) |
886 | return KToolBar::Top; | 897 | return KToolBar::Top; |
887 | //US Dock dock; | 898 | //US Dock dock; |
888 | QMainWindow::ToolBarDock dock; | 899 | Qt::ToolBarDock dock; |
889 | int dm1, dm2; | 900 | int dm1, dm2; |
890 | bool dm3; | 901 | bool dm3; |
891 | ((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 ); | 902 | ((Q3MainWindow*)mainWindow())->getLocation( (Q3ToolBar*)this, dock, dm1, dm3, dm2 ); |
892 | //US if ( dock == DockUnmanaged ) { | 903 | //US if ( dock == DockUnmanaged ) { |
893 | if ( dock == QMainWindow::Unmanaged ) { | 904 | if ( dock == Qt::Unmanaged ) { |
894 | return (KToolBar::BarPosition)Top; | 905 | return (KToolBar::BarPosition)Top; |
895 | } | 906 | } |
896 | return (BarPosition)dock; | 907 | return (BarPosition)dock; |
897 | } | 908 | } |
898 | 909 | ||
899 | 910 | ||
900 | bool KToolBar::enable(BarStatus stat) | 911 | bool KToolBar::enable(BarStatus stat) |
901 | { | 912 | { |
902 | bool mystat = isVisible(); | 913 | bool mystat = isVisible(); |
903 | 914 | ||
904 | if ( (stat == Toggle && mystat) || stat == Hide ) | 915 | if ( (stat == Toggle && mystat) || stat == Hide ) |
905 | hide(); | 916 | hide(); |
906 | else | 917 | else |
907 | show(); | 918 | show(); |
908 | 919 | ||
909 | return isVisible() == mystat; | 920 | return isVisible() == mystat; |
910 | } | 921 | } |
911 | 922 | ||
912 | 923 | ||
913 | void KToolBar::setMaxHeight ( int h ) | 924 | void KToolBar::setMaxHeight ( int h ) |
914 | { | 925 | { |
915 | setMaximumHeight( h ); | 926 | setMaximumHeight( h ); |
916 | } | 927 | } |
917 | 928 | ||
918 | int KToolBar::maxHeight() | 929 | int KToolBar::maxHeight() |
919 | { | 930 | { |
920 | return maximumHeight(); | 931 | return maximumHeight(); |
921 | } | 932 | } |
922 | 933 | ||
923 | 934 | ||
924 | void KToolBar::setMaxWidth (int dw) | 935 | void KToolBar::setMaxWidth (int dw) |
925 | { | 936 | { |
@@ -938,163 +949,163 @@ void KToolBar::setTitle (const QString& _title) | |||
938 | setLabel( _title ); | 949 | setLabel( _title ); |
939 | } | 950 | } |
940 | 951 | ||
941 | 952 | ||
942 | void KToolBar::enableFloating (bool ) | 953 | void KToolBar::enableFloating (bool ) |
943 | { | 954 | { |
944 | } | 955 | } |
945 | 956 | ||
946 | 957 | ||
947 | void KToolBar::setIconText(IconText it) | 958 | void KToolBar::setIconText(IconText it) |
948 | { | 959 | { |
949 | setIconText( it, true ); | 960 | setIconText( it, true ); |
950 | } | 961 | } |
951 | 962 | ||
952 | 963 | ||
953 | void KToolBar::setIconText(IconText icontext, bool update) | 964 | void KToolBar::setIconText(IconText icontext, bool update) |
954 | { | 965 | { |
955 | bool doUpdate=false; | 966 | bool doUpdate=false; |
956 | 967 | ||
957 | if (icontext != d->m_iconText) { | 968 | if (icontext != d->m_iconText) { |
958 | d->m_iconText = icontext; | 969 | d->m_iconText = icontext; |
959 | doUpdate=true; | 970 | doUpdate=true; |
960 | } | 971 | } |
961 | 972 | ||
962 | if (update == false) | 973 | if (update == false) |
963 | return; | 974 | return; |
964 | 975 | ||
965 | if (doUpdate) | 976 | if (doUpdate) |
966 | emit modechange(); // tell buttons what happened | 977 | emit modechange(); // tell buttons what happened |
967 | 978 | ||
968 | // ugly hack to force a QMainWindow::triggerLayout( TRUE ) | 979 | // ugly hack to force a QMainWindow::triggerLayout( TRUE ) |
969 | if ( mainWindow() ) { | 980 | if ( mainWindow() ) { |
970 | QMainWindow *mw = mainWindow(); | 981 | Q3MainWindow *mw = mainWindow(); |
971 | mw->setUpdatesEnabled( FALSE ); | 982 | mw->setUpdatesEnabled( FALSE ); |
972 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); | 983 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); |
973 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); | 984 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); |
974 | mw->setUpdatesEnabled( TRUE ); | 985 | mw->setUpdatesEnabled( TRUE ); |
975 | } | 986 | } |
976 | } | 987 | } |
977 | 988 | ||
978 | 989 | ||
979 | KToolBar::IconText KToolBar::iconText() const | 990 | KToolBar::IconText KToolBar::iconText() const |
980 | { | 991 | { |
981 | return d->m_iconText; | 992 | return d->m_iconText; |
982 | } | 993 | } |
983 | 994 | ||
984 | 995 | ||
985 | void KToolBar::setIconSize(int size) | 996 | void KToolBar::setIconSize(int size) |
986 | { | 997 | { |
987 | setIconSize( size, true ); | 998 | setIconSize( size, true ); |
988 | } | 999 | } |
989 | 1000 | ||
990 | void KToolBar::setIconSize(int size, bool update) | 1001 | void KToolBar::setIconSize(int size, bool update) |
991 | { | 1002 | { |
992 | bool doUpdate=false; | 1003 | bool doUpdate=false; |
993 | 1004 | ||
994 | if ( size != d->m_iconSize ) { | 1005 | if ( size != d->m_iconSize ) { |
995 | d->m_iconSize = size; | 1006 | d->m_iconSize = size; |
996 | doUpdate=true; | 1007 | doUpdate=true; |
997 | } | 1008 | } |
998 | 1009 | ||
999 | if (update == false) | 1010 | if (update == false) |
1000 | return; | 1011 | return; |
1001 | 1012 | ||
1002 | if (doUpdate) | 1013 | if (doUpdate) |
1003 | emit modechange(); // tell buttons what happened | 1014 | emit modechange(); // tell buttons what happened |
1004 | 1015 | ||
1005 | // ugly hack to force a QMainWindow::triggerLayout( TRUE ) | 1016 | // ugly hack to force a QMainWindow::triggerLayout( TRUE ) |
1006 | if ( mainWindow() ) { | 1017 | if ( mainWindow() ) { |
1007 | QMainWindow *mw = mainWindow(); | 1018 | Q3MainWindow *mw = mainWindow(); |
1008 | mw->setUpdatesEnabled( FALSE ); | 1019 | mw->setUpdatesEnabled( FALSE ); |
1009 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); | 1020 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); |
1010 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); | 1021 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); |
1011 | mw->setUpdatesEnabled( TRUE ); | 1022 | mw->setUpdatesEnabled( TRUE ); |
1012 | } | 1023 | } |
1013 | } | 1024 | } |
1014 | 1025 | ||
1015 | 1026 | ||
1016 | int KToolBar::iconSize() const | 1027 | int KToolBar::iconSize() const |
1017 | { | 1028 | { |
1018 | /*US | 1029 | /*US |
1019 | if ( !d->m_iconSize ) // default value? | 1030 | if ( !d->m_iconSize ) // default value? |
1020 | { | 1031 | { |
1021 | if (!::qstrcmp(QObject::name(), "mainToolBar")) | 1032 | if (!::qstrcmp(QObject::name(), "mainToolBar")) |
1022 | return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar); | 1033 | return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar); |
1023 | else | 1034 | else |
1024 | return KGlobal::iconLoader()->currentSize(KIcon::Toolbar); | 1035 | return KGlobal::iconLoader()->currentSize(KIcon::Toolbar); |
1025 | } | 1036 | } |
1026 | return d->m_iconSize; | 1037 | return d->m_iconSize; |
1027 | */ | 1038 | */ |
1028 | int ret = 18; | 1039 | int ret = 18; |
1029 | if ( QApplication::desktop()->width() > 320 ) | 1040 | if ( QApplication::desktop()->width() > 320 ) |
1030 | ret = 30; | 1041 | ret = 30; |
1031 | return ret; | 1042 | return ret; |
1032 | } | 1043 | } |
1033 | 1044 | ||
1034 | 1045 | ||
1035 | void KToolBar::setEnableContextMenu(bool enable ) | 1046 | void KToolBar::setEnableContextMenu(bool enable ) |
1036 | { | 1047 | { |
1037 | d->m_enableContext = enable; | 1048 | d->m_enableContext = enable; |
1038 | } | 1049 | } |
1039 | 1050 | ||
1040 | 1051 | ||
1041 | bool KToolBar::contextMenuEnabled() const | 1052 | bool KToolBar::contextMenuEnabled() const |
1042 | { | 1053 | { |
1043 | return d->m_enableContext; | 1054 | return d->m_enableContext; |
1044 | } | 1055 | } |
1045 | 1056 | ||
1046 | 1057 | ||
1047 | void KToolBar::setItemNoStyle(int id, bool no_style ) | 1058 | void KToolBar::setItemNoStyle(int id, bool no_style ) |
1048 | { | 1059 | { |
1049 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 1060 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
1050 | if ( it == id2widget.end() ) | 1061 | if ( it == id2widget.end() ) |
1051 | return; | 1062 | return; |
1052 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 1063 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
1053 | KToolBarButton * button = (KToolBarButton *)( *it ); | 1064 | KToolBarButton * button = (KToolBarButton *)( *it ); |
1054 | if (button) | 1065 | if (button) |
1055 | button->setNoStyle( no_style ); | 1066 | button->setNoStyle( no_style ); |
1056 | } | 1067 | } |
1057 | 1068 | ||
1058 | 1069 | ||
1059 | void KToolBar::setFlat (bool flag) | 1070 | void KToolBar::setFlat (bool flag) |
1060 | { | 1071 | { |
1061 | if ( !mainWindow() ) | 1072 | if ( !mainWindow() ) |
1062 | return; | 1073 | return; |
1063 | if ( flag ) | 1074 | if ( flag ) |
1064 | //US mainWindow()->moveDockWindow( this, DockMinimized ); | 1075 | //US mainWindow()->moveDockWindow( this, DockMinimized ); |
1065 | mainWindow()->moveToolBar( this, QMainWindow::Minimized ); | 1076 | mainWindow()->moveToolBar( this, Qt::Minimized ); |
1066 | else | 1077 | else |
1067 | //US mainWindow()->moveDockWindow( this, DockTop ); | 1078 | //US mainWindow()->moveDockWindow( this, DockTop ); |
1068 | mainWindow()->moveToolBar( this, QMainWindow::Top ); | 1079 | mainWindow()->moveToolBar( this, Qt::Top ); |
1069 | // And remember to save the new look later | 1080 | // And remember to save the new look later |
1070 | /*US | 1081 | /*US |
1071 | if ( mainWindow()->inherits( "KMainWindow" ) ) | 1082 | if ( mainWindow()->inherits( "KMainWindow" ) ) |
1072 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); | 1083 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); |
1073 | */ | 1084 | */ |
1074 | } | 1085 | } |
1075 | 1086 | ||
1076 | 1087 | ||
1077 | int KToolBar::count() const | 1088 | int KToolBar::count() const |
1078 | { | 1089 | { |
1079 | return id2widget.count(); | 1090 | return id2widget.count(); |
1080 | } | 1091 | } |
1081 | 1092 | ||
1082 | 1093 | ||
1083 | void KToolBar::saveState() | 1094 | void KToolBar::saveState() |
1084 | { | 1095 | { |
1085 | /*US | 1096 | /*US |
1086 | // first, try to save to the xml file | 1097 | // first, try to save to the xml file |
1087 | if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) { | 1098 | if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) { |
1088 | // go down one level to get to the right tags | 1099 | // go down one level to get to the right tags |
1089 | QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement(); | 1100 | QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement(); |
1090 | elem = elem.firstChild().toElement(); | 1101 | elem = elem.firstChild().toElement(); |
1091 | QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name()); | 1102 | QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name()); |
1092 | QDomElement current; | 1103 | QDomElement current; |
1093 | // now try to find our toolbar | 1104 | // now try to find our toolbar |
1094 | d->modified = false; | 1105 | d->modified = false; |
1095 | for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { | 1106 | for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { |
1096 | current = elem; | 1107 | current = elem; |
1097 | 1108 | ||
1098 | if ( current.tagName().lower() != "toolbar" ) | 1109 | if ( current.tagName().lower() != "toolbar" ) |
1099 | continue; | 1110 | continue; |
1100 | 1111 | ||
@@ -1220,258 +1231,258 @@ void KToolBar::saveSettings(KConfig *config, const QString &_configGroup) | |||
1220 | void KToolBar::setXMLGUIClient( KXMLGUIClient *client ) | 1231 | void KToolBar::setXMLGUIClient( KXMLGUIClient *client ) |
1221 | { | 1232 | { |
1222 | d->m_xmlguiClient = client; | 1233 | d->m_xmlguiClient = client; |
1223 | } | 1234 | } |
1224 | 1235 | ||
1225 | void KToolBar::setText( const QString & txt ) | 1236 | void KToolBar::setText( const QString & txt ) |
1226 | { | 1237 | { |
1227 | //US setLabel( txt + " ( " + kapp->caption() + " ) " ); | 1238 | //US setLabel( txt + " ( " + kapp->caption() + " ) " ); |
1228 | setLabel( txt + " ( " + KGlobal::getAppName() + " ) " ); | 1239 | setLabel( txt + " ( " + KGlobal::getAppName() + " ) " ); |
1229 | } | 1240 | } |
1230 | 1241 | ||
1231 | 1242 | ||
1232 | QString KToolBar::text() const | 1243 | QString KToolBar::text() const |
1233 | { | 1244 | { |
1234 | return label(); | 1245 | return label(); |
1235 | } | 1246 | } |
1236 | 1247 | ||
1237 | 1248 | ||
1238 | void KToolBar::doConnections( KToolBarButton *button ) | 1249 | void KToolBar::doConnections( KToolBarButton *button ) |
1239 | { | 1250 | { |
1240 | connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) ); | 1251 | connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) ); |
1241 | connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) ); | 1252 | connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) ); |
1242 | connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) ); | 1253 | connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) ); |
1243 | connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) ); | 1254 | connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) ); |
1244 | connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) ); | 1255 | connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) ); |
1245 | connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) ); | 1256 | connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) ); |
1246 | } | 1257 | } |
1247 | 1258 | ||
1248 | void KToolBar::mousePressEvent ( QMouseEvent *m ) | 1259 | void KToolBar::mousePressEvent ( QMouseEvent *m ) |
1249 | { | 1260 | { |
1250 | if ( !mainWindow() ) | 1261 | if ( !mainWindow() ) |
1251 | return; | 1262 | return; |
1252 | QMainWindow *mw = mainWindow(); | 1263 | Q3MainWindow *mw = mainWindow(); |
1253 | if ( mw->toolBarsMovable() && d->m_enableContext ) { | 1264 | if ( mw->toolBarsMovable() && d->m_enableContext ) { |
1254 | if ( m->button() == RightButton ) { | 1265 | if ( m->button() == Qt::RightButton ) { |
1255 | int i = contextMenu()->exec( m->globalPos(), 0 ); | 1266 | int i = contextMenu()->exec( m->globalPos(), 0 ); |
1256 | switch ( i ) { | 1267 | switch ( i ) { |
1257 | case -1: | 1268 | case -1: |
1258 | return; // popup cancelled | 1269 | return; // popup cancelled |
1259 | case CONTEXT_LEFT: | 1270 | case CONTEXT_LEFT: |
1260 | //US mw->moveDockWindow( this, DockLeft ); | 1271 | //US mw->moveDockWindow( this, DockLeft ); |
1261 | mw->moveToolBar( this, QMainWindow::Left ); | 1272 | mw->moveToolBar( this, Qt::Left ); |
1262 | break; | 1273 | break; |
1263 | case CONTEXT_RIGHT: | 1274 | case CONTEXT_RIGHT: |
1264 | //US mw->moveDockWindow( this, DockRight ); | 1275 | //US mw->moveDockWindow( this, DockRight ); |
1265 | mw->moveToolBar( this, QMainWindow::Right ); | 1276 | mw->moveToolBar( this, Qt::Right ); |
1266 | break; | 1277 | break; |
1267 | case CONTEXT_TOP: | 1278 | case CONTEXT_TOP: |
1268 | //US mw->moveDockWindow( this, DockTop ); | 1279 | //US mw->moveDockWindow( this, DockTop ); |
1269 | mw->moveToolBar( this, QMainWindow::Top ); | 1280 | mw->moveToolBar( this, Qt::Top ); |
1270 | break; | 1281 | break; |
1271 | case CONTEXT_BOTTOM: | 1282 | case CONTEXT_BOTTOM: |
1272 | //US mw->moveDockWindow( this, DockBottom ); | 1283 | //US mw->moveDockWindow( this, DockBottom ); |
1273 | mw->moveToolBar( this, QMainWindow::Bottom ); | 1284 | mw->moveToolBar( this, Qt::Bottom ); |
1274 | break; | 1285 | break; |
1275 | case CONTEXT_FLOAT: | 1286 | case CONTEXT_FLOAT: |
1276 | break; | 1287 | break; |
1277 | case CONTEXT_FLAT: | 1288 | case CONTEXT_FLAT: |
1278 | //US mw->moveDockWindow( this, DockMinimized ); | 1289 | //US mw->moveDockWindow( this, DockMinimized ); |
1279 | mw->moveToolBar( this, QMainWindow::Minimized ); | 1290 | mw->moveToolBar( this, Qt::Minimized ); |
1280 | break; | 1291 | break; |
1281 | case CONTEXT_ICONS: | 1292 | case CONTEXT_ICONS: |
1282 | setIconText( IconOnly ); | 1293 | setIconText( IconOnly ); |
1283 | break; | 1294 | break; |
1284 | case CONTEXT_TEXTRIGHT: | 1295 | case CONTEXT_TEXTRIGHT: |
1285 | setIconText( IconTextRight ); | 1296 | setIconText( IconTextRight ); |
1286 | break; | 1297 | break; |
1287 | case CONTEXT_TEXT: | 1298 | case CONTEXT_TEXT: |
1288 | setIconText( TextOnly ); | 1299 | setIconText( TextOnly ); |
1289 | break; | 1300 | break; |
1290 | case CONTEXT_TEXTUNDER: | 1301 | case CONTEXT_TEXTUNDER: |
1291 | setIconText( IconTextBottom ); | 1302 | setIconText( IconTextBottom ); |
1292 | break; | 1303 | break; |
1293 | default: | 1304 | default: |
1294 | if ( i >= CONTEXT_ICONSIZES ) | 1305 | if ( i >= CONTEXT_ICONSIZES ) |
1295 | setIconSize( i - CONTEXT_ICONSIZES ); | 1306 | setIconSize( i - CONTEXT_ICONSIZES ); |
1296 | else | 1307 | else |
1297 | return; // assume this was an action handled elsewhere, no need for setSettingsDirty() | 1308 | return; // assume this was an action handled elsewhere, no need for setSettingsDirty() |
1298 | } | 1309 | } |
1299 | /*US | 1310 | /*US |
1300 | if ( mw->inherits("KMainWindow") ) | 1311 | if ( mw->inherits("KMainWindow") ) |
1301 | static_cast<KMainWindow *>(mw)->setSettingsDirty(); | 1312 | static_cast<KMainWindow *>(mw)->setSettingsDirty(); |
1302 | */ | 1313 | */ |
1303 | } | 1314 | } |
1304 | } | 1315 | } |
1305 | } | 1316 | } |
1306 | 1317 | ||
1307 | 1318 | ||
1308 | void KToolBar::rebuildLayout() | 1319 | void KToolBar::rebuildLayout() |
1309 | { | 1320 | { |
1310 | 1321 | ||
1311 | for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next()) | 1322 | for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next()) |
1312 | w->blockSignals(false); | 1323 | w->blockSignals(false); |
1313 | d->idleButtons.clear(); | 1324 | d->idleButtons.clear(); |
1314 | 1325 | ||
1315 | layoutTimer->stop(); | 1326 | layoutTimer->stop(); |
1316 | QApplication::sendPostedEvents( this, QEvent::ChildInserted ); | 1327 | QApplication::sendPostedEvents( this, QEvent::ChildInserted ); |
1317 | QBoxLayout *l = boxLayout(); | 1328 | QBoxLayout *l = boxLayout(); |
1318 | l->setMargin( 1 ); | 1329 | l->setMargin( 1 ); |
1319 | // clear the old layout | 1330 | // clear the old layout |
1320 | QLayoutIterator it = l->iterator(); | 1331 | QLayoutIterator it = l->iterator(); |
1321 | 1332 | ||
1322 | while ( it.current() ) { | 1333 | while ( it.current() ) { |
1323 | it.deleteCurrent(); | 1334 | it.deleteCurrent(); |
1324 | } | 1335 | } |
1325 | for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { | 1336 | for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { |
1326 | if ( w == rightAligned ) { | 1337 | if ( w == rightAligned ) { |
1327 | continue; | 1338 | continue; |
1328 | } | 1339 | } |
1329 | if ( w->inherits( "KToolBarSeparator" ) && | 1340 | if ( w->inherits( "KToolBarSeparator" ) && |
1330 | !( (KToolBarSeparator*)w )->showLine() ) { | 1341 | !( (KToolBarSeparator*)w )->showLine() ) { |
1331 | l->addSpacing( 6 ); | 1342 | l->addSpacing( 6 ); |
1332 | w->hide(); | 1343 | w->hide(); |
1333 | continue; | 1344 | continue; |
1334 | } | 1345 | } |
1335 | if ( w->inherits( "QPopupMenu" ) ) | 1346 | if ( w->inherits( "Q3PopupMenu" ) ) |
1336 | continue; | 1347 | continue; |
1337 | l->addWidget( w ); | 1348 | l->addWidget( w ); |
1338 | w->show(); | 1349 | w->show(); |
1339 | } | 1350 | } |
1340 | if ( rightAligned ) { | 1351 | if ( rightAligned ) { |
1341 | l->addStretch(); | 1352 | l->addStretch(); |
1342 | l->addWidget( rightAligned ); | 1353 | l->addWidget( rightAligned ); |
1343 | rightAligned->show(); | 1354 | rightAligned->show(); |
1344 | } | 1355 | } |
1345 | 1356 | ||
1346 | if ( fullSize() ) { | 1357 | if ( fullSize() ) { |
1347 | // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword). | 1358 | // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword). |
1348 | //if ( !stretchableWidget && widgets.last() && | 1359 | //if ( !stretchableWidget && widgets.last() && |
1349 | // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) | 1360 | // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) |
1350 | // setStretchableWidget( widgets.last() ); | 1361 | // setStretchableWidget( widgets.last() ); |
1351 | if ( !rightAligned ) | 1362 | if ( !rightAligned ) |
1352 | l->addStretch(); | 1363 | l->addStretch(); |
1353 | if ( stretchableWidget ) | 1364 | if ( stretchableWidget ) |
1354 | l->setStretchFactor( stretchableWidget, 10 ); | 1365 | l->setStretchFactor( stretchableWidget, 10 ); |
1355 | } | 1366 | } |
1356 | l->invalidate(); | 1367 | l->invalidate(); |
1357 | QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); | 1368 | QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); |
1358 | //#endif //DESKTOP_VERSION | 1369 | //#endif //DESKTOP_VERSION |
1359 | } | 1370 | } |
1360 | 1371 | ||
1361 | void KToolBar::childEvent( QChildEvent *e ) | 1372 | void KToolBar::childEvent( QChildEvent *e ) |
1362 | { | 1373 | { |
1363 | 1374 | ||
1364 | if ( e->child()->isWidgetType() ) { | 1375 | if ( e->child()->isWidgetType() ) { |
1365 | QWidget * w = (QWidget*)e->child(); | 1376 | QWidget * w = (QWidget*)e->child(); |
1366 | if ( e->type() == QEvent::ChildInserted ) { | 1377 | if ( e->type() == QEvent::ChildInserted ) { |
1367 | if ( !e->child()->inherits( "QPopupMenu" ) && | 1378 | if ( !e->child()->inherits( "Q3PopupMenu" ) && |
1368 | ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) { | 1379 | ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) { |
1369 | 1380 | ||
1370 | // prevent items that have been explicitly inserted by insert*() from | 1381 | // prevent items that have been explicitly inserted by insert*() from |
1371 | // being inserted again | 1382 | // being inserted again |
1372 | if ( !widget2id.contains( w ) ) | 1383 | if ( !widget2id.contains( w ) ) |
1373 | { | 1384 | { |
1374 | int dummy = -1; | 1385 | int dummy = -1; |
1375 | insertWidgetInternal( w, dummy, -1 ); | 1386 | insertWidgetInternal( w, dummy, -1 ); |
1376 | } | 1387 | } |
1377 | } | 1388 | } |
1378 | } else { | 1389 | } else if( e->type() == QEvent::ChildRemoved ) { |
1379 | removeWidgetInternal( w ); | 1390 | removeWidgetInternal( w ); |
1380 | } | 1391 | } |
1381 | if ( isVisibleTo( 0 ) ) | 1392 | /* TODO:hacker: if ( isVisibleTo( 0 ) ) |
1382 | { | 1393 | { |
1383 | QBoxLayout *l = boxLayout(); | 1394 | QBoxLayout *l = boxLayout(); |
1384 | // QLayout *l = layout(); | 1395 | // QLayout *l = layout(); |
1385 | 1396 | ||
1386 | // clear the old layout so that we don't get unnecassery layout | 1397 | // clear the old layout so that we don't get unnecassery layout |
1387 | // changes till we have rebuild the thing | 1398 | // changes till we have rebuild the thing |
1388 | QLayoutIterator it = l->iterator(); | 1399 | QLayoutIterator it = l->iterator(); |
1389 | while ( it.current() ) { | 1400 | while ( it.current() ) { |
1390 | it.deleteCurrent(); | 1401 | it.deleteCurrent(); |
1391 | } | 1402 | } |
1392 | layoutTimer->start( 50, TRUE ); | 1403 | layoutTimer->start( 50, TRUE ); |
1393 | } | 1404 | } */ |
1394 | } | 1405 | } |
1395 | QToolBar::childEvent( e ); | 1406 | Q3ToolBar::childEvent( e ); |
1396 | } | 1407 | } |
1397 | 1408 | ||
1398 | void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) | 1409 | void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) |
1399 | { | 1410 | { |
1400 | // we can't have it in widgets, or something is really wrong | 1411 | // we can't have it in widgets, or something is really wrong |
1401 | //widgets.removeRef( w ); | 1412 | //widgets.removeRef( w ); |
1402 | 1413 | ||
1403 | connect( w, SIGNAL( destroyed() ), | 1414 | connect( w, SIGNAL( destroyed() ), |
1404 | this, SLOT( widgetDestroyed() ) ); | 1415 | this, SLOT( widgetDestroyed() ) ); |
1405 | if ( index == -1 || index > (int)widgets.count() ) { | 1416 | if ( index == -1 || index > (int)widgets.count() ) { |
1406 | widgets.append( w ); | 1417 | widgets.append( w ); |
1407 | index = (int)widgets.count(); | 1418 | index = (int)widgets.count(); |
1408 | } | 1419 | } |
1409 | else | 1420 | else |
1410 | widgets.insert( index, w ); | 1421 | widgets.insert( index, w ); |
1411 | if ( id == -1 ) | 1422 | if ( id == -1 ) |
1412 | id = id2widget.count(); | 1423 | id = id2widget.count(); |
1413 | id2widget.insert( id, w ); | 1424 | id2widget.insert( id, w ); |
1414 | widget2id.insert( w, id ); | 1425 | widget2id.insert( w, id ); |
1415 | } | 1426 | } |
1416 | void KToolBar::repaintMe() | 1427 | void KToolBar::repaintMe() |
1417 | { | 1428 | { |
1418 | setUpdatesEnabled( true ); | 1429 | setUpdatesEnabled( true ); |
1419 | QToolBar::repaint( true ); | 1430 | Q3ToolBar::repaint( true ); |
1420 | qDebug(" KToolBar::repaintMe() "); | 1431 | qDebug(" KToolBar::repaintMe() "); |
1421 | } | 1432 | } |
1422 | 1433 | ||
1423 | void KToolBar::showEvent( QShowEvent *e ) | 1434 | void KToolBar::showEvent( QShowEvent *e ) |
1424 | { | 1435 | { |
1425 | rebuildLayout(); | 1436 | rebuildLayout(); |
1426 | QToolBar::showEvent( e ); | 1437 | Q3ToolBar::showEvent( e ); |
1427 | } | 1438 | } |
1428 | 1439 | ||
1429 | void KToolBar::setStretchableWidget( QWidget *w ) | 1440 | void KToolBar::setStretchableWidget( QWidget *w ) |
1430 | { | 1441 | { |
1431 | QToolBar::setStretchableWidget( w ); | 1442 | Q3ToolBar::setStretchableWidget( w ); |
1432 | stretchableWidget = w; | 1443 | stretchableWidget = w; |
1433 | } | 1444 | } |
1434 | 1445 | ||
1435 | QSizePolicy KToolBar::sizePolicy() const | 1446 | QSizePolicy KToolBar::sizePolicy() const |
1436 | { | 1447 | { |
1437 | if ( orientation() == Horizontal ) | 1448 | if ( orientation() == Qt::Horizontal ) |
1438 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); | 1449 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); |
1439 | else | 1450 | else |
1440 | return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); | 1451 | return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); |
1441 | } | 1452 | } |
1442 | 1453 | ||
1443 | QSize KToolBar::sizeHint() const | 1454 | QSize KToolBar::sizeHint() const |
1444 | { | 1455 | { |
1445 | QSize sh = QToolBar::sizeHint(); | 1456 | QSize sh = Q3ToolBar::sizeHint(); |
1446 | //qDebug("%x KToolBar::sizeHint() %d %d ",this, QToolBar::sizeHint().width(),QToolBar::sizeHint().height() ); | 1457 | //qDebug("%x KToolBar::sizeHint() %d %d ",this, QToolBar::sizeHint().width(),QToolBar::sizeHint().height() ); |
1447 | if ( sh.height() <= 20 || sh.width() < 60 ) | 1458 | if ( sh.height() <= 20 || sh.width() < 60 ) |
1448 | return QSize( sizeHintW, sizeHintH ); | 1459 | return QSize( sizeHintW, sizeHintH ); |
1449 | KToolBar* ttt = (KToolBar*) this; | 1460 | KToolBar* ttt = (KToolBar*) this; |
1450 | ttt->sizeHintW = sh.width(); | 1461 | ttt->sizeHintW = sh.width(); |
1451 | ttt->sizeHintH = sh.height(); | 1462 | ttt->sizeHintH = sh.height(); |
1452 | return sh; | 1463 | return sh; |
1453 | //return QToolBar::sizeHint(); | 1464 | //return QToolBar::sizeHint(); |
1454 | #if 0 | 1465 | #if 0 |
1455 | QWidget::polish(); | 1466 | QWidget::polish(); |
1456 | static int iii = 0; | 1467 | static int iii = 0; |
1457 | ++iii; | 1468 | ++iii; |
1458 | qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); | 1469 | qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); |
1459 | int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); | 1470 | int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); |
1460 | switch( barPos() ) | 1471 | switch( barPos() ) |
1461 | { | 1472 | { |
1462 | case KToolBar::Top: | 1473 | case KToolBar::Top: |
1463 | case KToolBar::Bottom: | 1474 | case KToolBar::Bottom: |
1464 | for ( QWidget *w = widgets.first(); w; w =widgets.next() ) | 1475 | for ( QWidget *w = widgets.first(); w; w =widgets.next() ) |
1465 | { | 1476 | { |
1466 | if ( w->inherits( "KToolBarSeparator" ) && | 1477 | if ( w->inherits( "KToolBarSeparator" ) && |
1467 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) | 1478 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) |
1468 | { | 1479 | { |
1469 | minSize += QSize(6, 0); | 1480 | minSize += QSize(6, 0); |
1470 | } | 1481 | } |
1471 | else | 1482 | else |
1472 | { | 1483 | { |
1473 | QSize sh = w->sizeHint(); | 1484 | QSize sh = w->sizeHint(); |
1474 | if (!sh.isValid()) | 1485 | if (!sh.isValid()) |
1475 | sh = w->minimumSize(); | 1486 | sh = w->minimumSize(); |
1476 | minSize = minSize.expandedTo(QSize(0, sh.height())); | 1487 | minSize = minSize.expandedTo(QSize(0, sh.height())); |
1477 | minSize += QSize(sh.width()+1, 0); | 1488 | minSize += QSize(sh.width()+1, 0); |
@@ -1479,101 +1490,101 @@ QSize KToolBar::sizeHint() const | |||
1479 | } | 1490 | } |
1480 | /*US | 1491 | /*US |
1481 | minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0); | 1492 | minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0); |
1482 | */ | 1493 | */ |
1483 | minSize += QSize(margin*2, margin*2); | 1494 | minSize += QSize(margin*2, margin*2); |
1484 | break; | 1495 | break; |
1485 | 1496 | ||
1486 | case KToolBar::Left: | 1497 | case KToolBar::Left: |
1487 | case KToolBar::Right: | 1498 | case KToolBar::Right: |
1488 | for ( QWidget *w = widgets.first(); w; w = widgets.next() ) | 1499 | for ( QWidget *w = widgets.first(); w; w = widgets.next() ) |
1489 | { | 1500 | { |
1490 | if ( w->inherits( "KToolBarSeparator" ) && | 1501 | if ( w->inherits( "KToolBarSeparator" ) && |
1491 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) | 1502 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) |
1492 | { | 1503 | { |
1493 | minSize += QSize(0, 6); | 1504 | minSize += QSize(0, 6); |
1494 | } | 1505 | } |
1495 | else | 1506 | else |
1496 | { | 1507 | { |
1497 | QSize sh = w->sizeHint(); | 1508 | QSize sh = w->sizeHint(); |
1498 | if (!sh.isValid()) | 1509 | if (!sh.isValid()) |
1499 | sh = w->minimumSize(); | 1510 | sh = w->minimumSize(); |
1500 | minSize = minSize.expandedTo(QSize(sh.width(), 0)); | 1511 | minSize = minSize.expandedTo(QSize(sh.width(), 0)); |
1501 | minSize += QSize(0, sh.height()+1); | 1512 | minSize += QSize(0, sh.height()+1); |
1502 | } | 1513 | } |
1503 | } | 1514 | } |
1504 | /*US | 1515 | /*US |
1505 | minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); | 1516 | minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); |
1506 | */ | 1517 | */ |
1507 | minSize += QSize(margin*2, margin*2); | 1518 | minSize += QSize(margin*2, margin*2); |
1508 | break; | 1519 | break; |
1509 | 1520 | ||
1510 | default: | 1521 | default: |
1511 | minSize = QToolBar::sizeHint(); | 1522 | minSize = Q3ToolBar::sizeHint(); |
1512 | break; | 1523 | break; |
1513 | } | 1524 | } |
1514 | return minSize; | 1525 | return minSize; |
1515 | #endif | 1526 | #endif |
1516 | } | 1527 | } |
1517 | 1528 | ||
1518 | QSize KToolBar::minimumSize() const | 1529 | QSize KToolBar::minimumSize() const |
1519 | { | 1530 | { |
1520 | return minimumSizeHint(); | 1531 | return minimumSizeHint(); |
1521 | } | 1532 | } |
1522 | 1533 | ||
1523 | QSize KToolBar::minimumSizeHint() const | 1534 | QSize KToolBar::minimumSizeHint() const |
1524 | { | 1535 | { |
1525 | return sizeHint(); | 1536 | return sizeHint(); |
1526 | } | 1537 | } |
1527 | 1538 | ||
1528 | bool KToolBar::highlight() const | 1539 | bool KToolBar::highlight() const |
1529 | { | 1540 | { |
1530 | return d->m_highlight; | 1541 | return d->m_highlight; |
1531 | } | 1542 | } |
1532 | 1543 | ||
1533 | void KToolBar::hide() | 1544 | void KToolBar::hide() |
1534 | { | 1545 | { |
1535 | QToolBar::hide(); | 1546 | Q3ToolBar::hide(); |
1536 | } | 1547 | } |
1537 | 1548 | ||
1538 | void KToolBar::show() | 1549 | void KToolBar::show() |
1539 | { | 1550 | { |
1540 | QToolBar::show(); | 1551 | Q3ToolBar::show(); |
1541 | } | 1552 | } |
1542 | 1553 | ||
1543 | void KToolBar::resizeEvent( QResizeEvent *e ) | 1554 | void KToolBar::resizeEvent( QResizeEvent *e ) |
1544 | { | 1555 | { |
1545 | bool b = isUpdatesEnabled(); | 1556 | bool b = isUpdatesEnabled(); |
1546 | setUpdatesEnabled( FALSE ); | 1557 | setUpdatesEnabled( FALSE ); |
1547 | QToolBar::resizeEvent( e ); | 1558 | Q3ToolBar::resizeEvent( e ); |
1548 | if (b) | 1559 | if (b) |
1549 | d->repaintTimer.start( 100, true ); | 1560 | d->repaintTimer.start( 100, true ); |
1550 | } | 1561 | } |
1551 | 1562 | ||
1552 | void KToolBar::slotIconChanged(int group) | 1563 | void KToolBar::slotIconChanged(int group) |
1553 | { | 1564 | { |
1554 | if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar)) | 1565 | if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar)) |
1555 | return; | 1566 | return; |
1556 | if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar")) | 1567 | if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar")) |
1557 | return; | 1568 | return; |
1558 | 1569 | ||
1559 | emit modechange(); | 1570 | emit modechange(); |
1560 | if (isVisible()) | 1571 | if (isVisible()) |
1561 | updateGeometry(); | 1572 | updateGeometry(); |
1562 | } | 1573 | } |
1563 | 1574 | ||
1564 | void KToolBar::slotReadConfig() | 1575 | void KToolBar::slotReadConfig() |
1565 | { | 1576 | { |
1566 | //kdDebug(220) << "KToolBar::slotReadConfig" << endl; | 1577 | //kdDebug(220) << "KToolBar::slotReadConfig" << endl; |
1567 | // Read appearance settings (hmm, we used to do both here, | 1578 | // Read appearance settings (hmm, we used to do both here, |
1568 | // but a well behaved application will call applyMainWindowSettings | 1579 | // but a well behaved application will call applyMainWindowSettings |
1569 | // anyway, right ?) | 1580 | // anyway, right ?) |
1570 | applyAppearanceSettings(KGlobal::config(), QString::null ); | 1581 | applyAppearanceSettings(KGlobal::config(), QString::null ); |
1571 | } | 1582 | } |
1572 | 1583 | ||
1573 | void KToolBar::slotAppearanceChanged() | 1584 | void KToolBar::slotAppearanceChanged() |
1574 | { | 1585 | { |
1575 | // Read appearance settings from global file. | 1586 | // Read appearance settings from global file. |
1576 | applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ ); | 1587 | applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ ); |
1577 | // And remember to save the new look later | 1588 | // And remember to save the new look later |
1578 | /*US | 1589 | /*US |
1579 | if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) | 1590 | if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) |
@@ -1697,65 +1708,65 @@ void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGr | |||
1697 | iconsize = d->IconSizeDefault; | 1708 | iconsize = d->IconSizeDefault; |
1698 | icontext = d->IconTextDefault; | 1709 | icontext = d->IconTextDefault; |
1699 | } | 1710 | } |
1700 | 1711 | ||
1701 | // revert back to the old group | 1712 | // revert back to the old group |
1702 | } // end block for KConfigGroupSaver | 1713 | } // end block for KConfigGroupSaver |
1703 | 1714 | ||
1704 | bool doUpdate = false; | 1715 | bool doUpdate = false; |
1705 | 1716 | ||
1706 | IconText icon_text; | 1717 | IconText icon_text; |
1707 | if ( icontext == "IconTextRight" ) | 1718 | if ( icontext == "IconTextRight" ) |
1708 | icon_text = IconTextRight; | 1719 | icon_text = IconTextRight; |
1709 | else if ( icontext == "IconTextBottom" ) | 1720 | else if ( icontext == "IconTextBottom" ) |
1710 | icon_text = IconTextBottom; | 1721 | icon_text = IconTextBottom; |
1711 | else if ( icontext == "TextOnly" ) | 1722 | else if ( icontext == "TextOnly" ) |
1712 | icon_text = TextOnly; | 1723 | icon_text = TextOnly; |
1713 | else | 1724 | else |
1714 | icon_text = IconOnly; | 1725 | icon_text = IconOnly; |
1715 | 1726 | ||
1716 | // check if the icon/text has changed | 1727 | // check if the icon/text has changed |
1717 | if (icon_text != d->m_iconText) { | 1728 | if (icon_text != d->m_iconText) { |
1718 | //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl; | 1729 | //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl; |
1719 | setIconText(icon_text, false); | 1730 | setIconText(icon_text, false); |
1720 | doUpdate = true; | 1731 | doUpdate = true; |
1721 | } | 1732 | } |
1722 | 1733 | ||
1723 | // ...and check if the icon size has changed | 1734 | // ...and check if the icon size has changed |
1724 | if (iconsize != d->m_iconSize) { | 1735 | if (iconsize != d->m_iconSize) { |
1725 | setIconSize(iconsize, false); | 1736 | setIconSize(iconsize, false); |
1726 | doUpdate = true; | 1737 | doUpdate = true; |
1727 | } | 1738 | } |
1728 | 1739 | ||
1729 | QMainWindow *mw = mainWindow(); | 1740 | Q3MainWindow *mw = mainWindow(); |
1730 | 1741 | ||
1731 | // ...and if we should highlight | 1742 | // ...and if we should highlight |
1732 | if ( highlight != d->m_highlight ) { | 1743 | if ( highlight != d->m_highlight ) { |
1733 | d->m_highlight = highlight; | 1744 | d->m_highlight = highlight; |
1734 | doUpdate = true; | 1745 | doUpdate = true; |
1735 | } | 1746 | } |
1736 | 1747 | ||
1737 | // ...and if we should move transparently | 1748 | // ...and if we should move transparently |
1738 | if ( mw && transparent != (!mw->opaqueMoving()) ) { | 1749 | if ( mw && transparent != (!mw->opaqueMoving()) ) { |
1739 | mw->setOpaqueMoving( !transparent ); | 1750 | mw->setOpaqueMoving( !transparent ); |
1740 | } | 1751 | } |
1741 | 1752 | ||
1742 | if (doUpdate) | 1753 | if (doUpdate) |
1743 | emit modechange(); // tell buttons what happened | 1754 | emit modechange(); // tell buttons what happened |
1744 | if (isVisible ()) | 1755 | if (isVisible ()) |
1745 | updateGeometry(); | 1756 | updateGeometry(); |
1746 | } | 1757 | } |
1747 | 1758 | ||
1748 | void KToolBar::applySettings(KConfig *config, const QString &_configGroup) | 1759 | void KToolBar::applySettings(KConfig *config, const QString &_configGroup) |
1749 | { | 1760 | { |
1750 | //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl; | 1761 | //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl; |
1751 | 1762 | ||
1752 | QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; | 1763 | QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; |
1753 | 1764 | ||
1754 | /* | 1765 | /* |
1755 | Let's explain this a bit more in details. | 1766 | Let's explain this a bit more in details. |
1756 | The order in which we apply settings is : | 1767 | The order in which we apply settings is : |
1757 | Global config / <appnamerc> user settings if no XMLGUI is used | 1768 | Global config / <appnamerc> user settings if no XMLGUI is used |
1758 | Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used | 1769 | Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used |
1759 | 1770 | ||
1760 | So in the first case, we simply read everything from KConfig as below, | 1771 | So in the first case, we simply read everything from KConfig as below, |
1761 | but in the second case we don't do anything here if there is no app-specific config, | 1772 | but in the second case we don't do anything here if there is no app-specific config, |
@@ -1776,147 +1787,147 @@ void KToolBar::applySettings(KConfig *config, const QString &_configGroup) | |||
1776 | static const QString &attrIndex = KGlobal::staticQString("Index"); | 1787 | static const QString &attrIndex = KGlobal::staticQString("Index"); |
1777 | static const QString &attrOffset = KGlobal::staticQString("Offset"); | 1788 | static const QString &attrOffset = KGlobal::staticQString("Offset"); |
1778 | static const QString &attrNewLine = KGlobal::staticQString("NewLine"); | 1789 | static const QString &attrNewLine = KGlobal::staticQString("NewLine"); |
1779 | static const QString &attrHidden = KGlobal::staticQString("Hidden"); | 1790 | static const QString &attrHidden = KGlobal::staticQString("Hidden"); |
1780 | 1791 | ||
1781 | QString position = config->readEntry(attrPosition, d->PositionDefault); | 1792 | QString position = config->readEntry(attrPosition, d->PositionDefault); |
1782 | int index = config->readNumEntry(attrIndex, d->IndexDefault); | 1793 | int index = config->readNumEntry(attrIndex, d->IndexDefault); |
1783 | int offset = config->readNumEntry(attrOffset, d->OffsetDefault); | 1794 | int offset = config->readNumEntry(attrOffset, d->OffsetDefault); |
1784 | bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault); | 1795 | bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault); |
1785 | bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault); | 1796 | bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault); |
1786 | */ | 1797 | */ |
1787 | 1798 | ||
1788 | QString position = config->readEntry("Position", d->PositionDefault); | 1799 | QString position = config->readEntry("Position", d->PositionDefault); |
1789 | int index = config->readNumEntry("Index", d->IndexDefault); | 1800 | int index = config->readNumEntry("Index", d->IndexDefault); |
1790 | int offset = config->readNumEntry("Offset", d->OffsetDefault); | 1801 | int offset = config->readNumEntry("Offset", d->OffsetDefault); |
1791 | bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault); | 1802 | bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault); |
1792 | bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault); | 1803 | bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault); |
1793 | 1804 | ||
1794 | /*US Dock pos(DockTop); | 1805 | /*US Dock pos(DockTop); |
1795 | if ( position == "Top" ) | 1806 | if ( position == "Top" ) |
1796 | pos = DockTop; | 1807 | pos = DockTop; |
1797 | else if ( position == "Bottom" ) | 1808 | else if ( position == "Bottom" ) |
1798 | pos = DockBottom; | 1809 | pos = DockBottom; |
1799 | else if ( position == "Left" ) | 1810 | else if ( position == "Left" ) |
1800 | pos = DockLeft; | 1811 | pos = DockLeft; |
1801 | else if ( position == "Right" ) | 1812 | else if ( position == "Right" ) |
1802 | pos = DockRight; | 1813 | pos = DockRight; |
1803 | else if ( position == "Floating" ) | 1814 | else if ( position == "Floating" ) |
1804 | pos = DockTornOff; | 1815 | pos = DockTornOff; |
1805 | else if ( position == "Flat" ) | 1816 | else if ( position == "Flat" ) |
1806 | pos = DockMinimized; | 1817 | pos = DockMinimized; |
1807 | */ | 1818 | */ |
1808 | QMainWindow::ToolBarDock pos(QMainWindow::Top); | 1819 | Qt::ToolBarDock pos(Qt::DockTop); |
1809 | if ( position == "Top" ) | 1820 | if ( position == "Top" ) |
1810 | pos = QMainWindow::Top; | 1821 | pos = Qt::Top; |
1811 | else if ( position == "Bottom" ) | 1822 | else if ( position == "Bottom" ) |
1812 | pos = QMainWindow::Bottom; | 1823 | pos = Qt::Bottom; |
1813 | else if ( position == "Left" ) | 1824 | else if ( position == "Left" ) |
1814 | pos = QMainWindow::Left; | 1825 | pos = Qt::Left; |
1815 | else if ( position == "Right" ) | 1826 | else if ( position == "Right" ) |
1816 | pos = QMainWindow::Right; | 1827 | pos = Qt::Right; |
1817 | else if ( position == "Floating" ) | 1828 | else if ( position == "Floating" ) |
1818 | pos = QMainWindow::TornOff; | 1829 | pos = Qt::TornOff; |
1819 | else if ( position == "Flat" ) | 1830 | else if ( position == "Flat" ) |
1820 | pos = QMainWindow::Minimized; | 1831 | pos = Qt::Minimized; |
1821 | 1832 | ||
1822 | //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl; | 1833 | //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl; |
1823 | if (hidden) | 1834 | if (hidden) |
1824 | hide(); | 1835 | hide(); |
1825 | else | 1836 | else |
1826 | show(); | 1837 | show(); |
1827 | 1838 | ||
1828 | if ( mainWindow() ) | 1839 | if ( mainWindow() ) |
1829 | { | 1840 | { |
1830 | QMainWindow *mw = mainWindow(); | 1841 | Q3MainWindow *mw = mainWindow(); |
1831 | 1842 | ||
1832 | //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl; | 1843 | //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl; |
1833 | d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset ); | 1844 | d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset ); |
1834 | 1845 | ||
1835 | // moveDockWindow calls QDockArea which does a reparent() on us with | 1846 | // moveDockWindow calls QDockArea which does a reparent() on us with |
1836 | // showIt = true, so we loose our visibility status | 1847 | // showIt = true, so we loose our visibility status |
1837 | bool doHide = isHidden(); | 1848 | bool doHide = isHidden(); |
1838 | 1849 | ||
1839 | //US mw->moveDockWindow( this, pos, newLine, index, offset ); | 1850 | //US mw->moveDockWindow( this, pos, newLine, index, offset ); |
1840 | mw->moveToolBar( this, pos, newLine, index, offset ); | 1851 | mw->moveToolBar( this, pos, newLine, index, offset ); |
1841 | 1852 | ||
1842 | //kdDebug(220) << "KToolBar::applySettings " << name() << " moveDockWindow with pos=" << pos << " newLine=" << newLine << " idx=" << index << " offs=" << offset << endl; | 1853 | //kdDebug(220) << "KToolBar::applySettings " << name() << " moveDockWindow with pos=" << pos << " newLine=" << newLine << " idx=" << index << " offs=" << offset << endl; |
1843 | if ( doHide ) | 1854 | if ( doHide ) |
1844 | hide(); | 1855 | hide(); |
1845 | } | 1856 | } |
1846 | if (isVisible ()) | 1857 | if (isVisible ()) |
1847 | updateGeometry(); | 1858 | updateGeometry(); |
1848 | } | 1859 | } |
1849 | } | 1860 | } |
1850 | 1861 | ||
1851 | bool KToolBar::event( QEvent *e ) | 1862 | bool KToolBar::event( QEvent *e ) |
1852 | { | 1863 | { |
1853 | if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() ) | 1864 | if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() ) |
1854 | d->repaintTimer.start( 100, true ); | 1865 | d->repaintTimer.start( 100, true ); |
1855 | 1866 | ||
1856 | if (e->type() == QEvent::ChildInserted ) | 1867 | if (e->type() == QEvent::ChildInserted ) |
1857 | { | 1868 | { |
1858 | // By pass QToolBar::event, | 1869 | // By pass QToolBar::event, |
1859 | // it will show() the inserted child and we don't want to | 1870 | // it will show() the inserted child and we don't want to |
1860 | // do that until we have rebuild the layout. | 1871 | // do that until we have rebuild the layout. |
1861 | childEvent((QChildEvent *)e); | 1872 | childEvent((QChildEvent *)e); |
1862 | return true; | 1873 | return true; |
1863 | } | 1874 | } |
1864 | 1875 | ||
1865 | return QToolBar::event( e ); | 1876 | return Q3ToolBar::event( e ); |
1866 | } | 1877 | } |
1867 | 1878 | ||
1868 | void KToolBar::slotRepaint() | 1879 | void KToolBar::slotRepaint() |
1869 | { | 1880 | { |
1870 | setUpdatesEnabled( FALSE ); | 1881 | setUpdatesEnabled( FALSE ); |
1871 | // Send a resizeEvent to update the "toolbar extension arrow" | 1882 | // Send a resizeEvent to update the "toolbar extension arrow" |
1872 | // (The button you get when your toolbar-items don't fit in | 1883 | // (The button you get when your toolbar-items don't fit in |
1873 | // the available space) | 1884 | // the available space) |
1874 | QResizeEvent ev(size(), size()); | 1885 | QResizeEvent ev(size(), size()); |
1875 | resizeEvent(&ev); | 1886 | resizeEvent(&ev); |
1876 | //#ifdef DESKTOP_VERSION | 1887 | //#ifdef DESKTOP_VERSION |
1877 | QApplication::sendPostedEvents( this, QEvent::LayoutHint ); | 1888 | QApplication::sendPostedEvents( this, QEvent::LayoutHint ); |
1878 | //#endif //DESKTOP_VERSION | 1889 | //#endif //DESKTOP_VERSION |
1879 | setUpdatesEnabled( TRUE ); | 1890 | setUpdatesEnabled( TRUE ); |
1880 | repaint( TRUE ); | 1891 | repaint( TRUE ); |
1881 | } | 1892 | } |
1882 | 1893 | ||
1883 | void KToolBar::toolBarPosChanged( QToolBar *tb ) | 1894 | void KToolBar::toolBarPosChanged( Q3ToolBar *tb ) |
1884 | { | 1895 | { |
1885 | if ( tb != this ) | 1896 | if ( tb != this ) |
1886 | return; | 1897 | return; |
1887 | //US if ( d->oldPos == DockMinimized ) | 1898 | //US if ( d->oldPos == DockMinimized ) |
1888 | if ( d->oldPos == QMainWindow::Minimized ) | 1899 | if ( d->oldPos == Qt::Minimized ) |
1889 | rebuildLayout(); | 1900 | rebuildLayout(); |
1890 | d->oldPos = (QMainWindow::ToolBarDock)barPos(); | 1901 | d->oldPos = (Qt::ToolBarDock)barPos(); |
1891 | /*US | 1902 | /*US |
1892 | if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) | 1903 | if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) |
1893 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); | 1904 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); |
1894 | */ | 1905 | */ |
1895 | } | 1906 | } |
1896 | 1907 | ||
1897 | /*US | 1908 | /*US |
1898 | void KToolBar::loadState( const QDomElement &element ) | 1909 | void KToolBar::loadState( const QDomElement &element ) |
1899 | { | 1910 | { |
1900 | //kdDebug(220) << "KToolBar::loadState " << this << endl; | 1911 | //kdDebug(220) << "KToolBar::loadState " << this << endl; |
1901 | if ( !mainWindow() ) | 1912 | if ( !mainWindow() ) |
1902 | return; | 1913 | return; |
1903 | 1914 | ||
1904 | { | 1915 | { |
1905 | QCString text = element.namedItem( "text" ).toElement().text().utf8(); | 1916 | QCString text = element.namedItem( "text" ).toElement().text().utf8(); |
1906 | if ( text.isEmpty() ) | 1917 | if ( text.isEmpty() ) |
1907 | text = element.namedItem( "Text" ).toElement().text().utf8(); | 1918 | text = element.namedItem( "Text" ).toElement().text().utf8(); |
1908 | if ( !text.isEmpty() ) | 1919 | if ( !text.isEmpty() ) |
1909 | setText( i18n( text ) ); | 1920 | setText( i18n( text ) ); |
1910 | } | 1921 | } |
1911 | 1922 | ||
1912 | { | 1923 | { |
1913 | QCString attrFullWidth = element.attribute( "fullWidth" ).lower().latin1(); | 1924 | QCString attrFullWidth = element.attribute( "fullWidth" ).lower().latin1(); |
1914 | if ( !attrFullWidth.isEmpty() ) | 1925 | if ( !attrFullWidth.isEmpty() ) |
1915 | setFullSize( attrFullWidth == "true" ); | 1926 | setFullSize( attrFullWidth == "true" ); |
1916 | } | 1927 | } |
1917 | 1928 | ||
1918 | Dock dock = DockTop; | 1929 | Dock dock = DockTop; |
1919 | { | 1930 | { |
1920 | QCString attrPosition = element.attribute( "position" ).lower().latin1(); | 1931 | QCString attrPosition = element.attribute( "position" ).lower().latin1(); |
1921 | //kdDebug(220) << "KToolBar::loadState attrPosition=" << attrPosition << endl; | 1932 | //kdDebug(220) << "KToolBar::loadState attrPosition=" << attrPosition << endl; |
1922 | if ( !attrPosition.isEmpty() ) { | 1933 | if ( !attrPosition.isEmpty() ) { |
@@ -2002,65 +2013,65 @@ void KToolBar::loadState( const QDomElement &element ) | |||
2002 | show(); | 2013 | show(); |
2003 | 2014 | ||
2004 | getAttributes( d->PositionDefault, d->IconTextDefault, d->IndexDefault ); | 2015 | getAttributes( d->PositionDefault, d->IconTextDefault, d->IndexDefault ); |
2005 | } | 2016 | } |
2006 | */ | 2017 | */ |
2007 | 2018 | ||
2008 | void KToolBar::getAttributes( QString &position, QString &icontext, int &index ) | 2019 | void KToolBar::getAttributes( QString &position, QString &icontext, int &index ) |
2009 | { | 2020 | { |
2010 | // get all of the stuff to save | 2021 | // get all of the stuff to save |
2011 | switch ( barPos() ) { | 2022 | switch ( barPos() ) { |
2012 | case KToolBar::Flat: | 2023 | case KToolBar::Flat: |
2013 | position = "Flat"; | 2024 | position = "Flat"; |
2014 | break; | 2025 | break; |
2015 | case KToolBar::Bottom: | 2026 | case KToolBar::Bottom: |
2016 | position = "Bottom"; | 2027 | position = "Bottom"; |
2017 | break; | 2028 | break; |
2018 | case KToolBar::Left: | 2029 | case KToolBar::Left: |
2019 | position = "Left"; | 2030 | position = "Left"; |
2020 | break; | 2031 | break; |
2021 | case KToolBar::Right: | 2032 | case KToolBar::Right: |
2022 | position = "Right"; | 2033 | position = "Right"; |
2023 | break; | 2034 | break; |
2024 | case KToolBar::Floating: | 2035 | case KToolBar::Floating: |
2025 | position = "Floating"; | 2036 | position = "Floating"; |
2026 | break; | 2037 | break; |
2027 | case KToolBar::Top: | 2038 | case KToolBar::Top: |
2028 | default: | 2039 | default: |
2029 | position = "Top"; | 2040 | position = "Top"; |
2030 | break; | 2041 | break; |
2031 | } | 2042 | } |
2032 | 2043 | ||
2033 | if ( mainWindow() ) { | 2044 | if ( mainWindow() ) { |
2034 | QMainWindow::ToolBarDock dock; | 2045 | Qt::ToolBarDock dock; |
2035 | bool newLine; | 2046 | bool newLine; |
2036 | int offset; | 2047 | int offset; |
2037 | mainWindow()->getLocation( this, dock, index, newLine, offset ); | 2048 | mainWindow()->getLocation( this, dock, index, newLine, offset ); |
2038 | } | 2049 | } |
2039 | 2050 | ||
2040 | switch (d->m_iconText) { | 2051 | switch (d->m_iconText) { |
2041 | case KToolBar::IconTextRight: | 2052 | case KToolBar::IconTextRight: |
2042 | icontext = "IconTextRight"; | 2053 | icontext = "IconTextRight"; |
2043 | break; | 2054 | break; |
2044 | case KToolBar::IconTextBottom: | 2055 | case KToolBar::IconTextBottom: |
2045 | icontext = "IconTextBottom"; | 2056 | icontext = "IconTextBottom"; |
2046 | break; | 2057 | break; |
2047 | case KToolBar::TextOnly: | 2058 | case KToolBar::TextOnly: |
2048 | icontext = "TextOnly"; | 2059 | icontext = "TextOnly"; |
2049 | break; | 2060 | break; |
2050 | case KToolBar::IconOnly: | 2061 | case KToolBar::IconOnly: |
2051 | default: | 2062 | default: |
2052 | icontext = "IconOnly"; | 2063 | icontext = "IconOnly"; |
2053 | break; | 2064 | break; |
2054 | } | 2065 | } |
2055 | } | 2066 | } |
2056 | /*US | 2067 | /*US |
2057 | void KToolBar::saveState( QDomElement ¤t ) | 2068 | void KToolBar::saveState( QDomElement ¤t ) |
2058 | { | 2069 | { |
2059 | QString position, icontext; | 2070 | QString position, icontext; |
2060 | int index = -1; | 2071 | int index = -1; |
2061 | getAttributes( position, icontext, index ); | 2072 | getAttributes( position, icontext, index ); |
2062 | 2073 | ||
2063 | current.setAttribute( "noMerge", "1" ); | 2074 | current.setAttribute( "noMerge", "1" ); |
2064 | current.setAttribute( "position", position ); | 2075 | current.setAttribute( "position", position ); |
2065 | current.setAttribute( "iconText", icontext ); | 2076 | current.setAttribute( "iconText", icontext ); |
2066 | current.setAttribute( "index", index ); | 2077 | current.setAttribute( "index", index ); |
@@ -2071,110 +2082,110 @@ void KToolBar::saveState( QDomElement ¤t ) | |||
2071 | d->modified = true; | 2082 | d->modified = true; |
2072 | } | 2083 | } |
2073 | */ | 2084 | */ |
2074 | 2085 | ||
2075 | void KToolBar::positionYourself( bool force ) | 2086 | void KToolBar::positionYourself( bool force ) |
2076 | { | 2087 | { |
2077 | if (force) | 2088 | if (force) |
2078 | d->positioned = false; | 2089 | d->positioned = false; |
2079 | 2090 | ||
2080 | if ( d->positioned || !mainWindow() ) | 2091 | if ( d->positioned || !mainWindow() ) |
2081 | { | 2092 | { |
2082 | //kdDebug(220) << "KToolBar::positionYourself d->positioned=true ALREADY DONE" << endl; | 2093 | //kdDebug(220) << "KToolBar::positionYourself d->positioned=true ALREADY DONE" << endl; |
2083 | return; | 2094 | return; |
2084 | } | 2095 | } |
2085 | // we can't test for ForceHide after moveDockWindow because QDockArea | 2096 | // we can't test for ForceHide after moveDockWindow because QDockArea |
2086 | // does a reparent() with showIt == true | 2097 | // does a reparent() with showIt == true |
2087 | bool doHide = isHidden(); | 2098 | bool doHide = isHidden(); |
2088 | //kdDebug(220) << "positionYourself " << name() << " dock=" << d->toolBarInfo.dock << " newLine=" << d->toolBarInfo.newline << " offset=" << d->toolBarInfo.offset << endl; | 2099 | //kdDebug(220) << "positionYourself " << name() << " dock=" << d->toolBarInfo.dock << " newLine=" << d->toolBarInfo.newline << " offset=" << d->toolBarInfo.offset << endl; |
2089 | /*US mainWindow()->moveDockWindow( this, d->toolBarInfo.dock, | 2100 | /*US mainWindow()->moveDockWindow( this, d->toolBarInfo.dock, |
2090 | d->toolBarInfo.newline, | 2101 | d->toolBarInfo.newline, |
2091 | d->toolBarInfo.index, | 2102 | d->toolBarInfo.index, |
2092 | d->toolBarInfo.offset ); | 2103 | d->toolBarInfo.offset ); |
2093 | */ | 2104 | */ |
2094 | mainWindow()->moveToolBar( this, d->toolBarInfo.dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); | 2105 | mainWindow()->moveToolBar( this, d->toolBarInfo.dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); |
2095 | 2106 | ||
2096 | if ( doHide ) | 2107 | if ( doHide ) |
2097 | hide(); | 2108 | hide(); |
2098 | // This method can only have an effect once - unless force is set | 2109 | // This method can only have an effect once - unless force is set |
2099 | d->positioned = TRUE; | 2110 | d->positioned = TRUE; |
2100 | } | 2111 | } |
2101 | 2112 | ||
2102 | //US KPopupMenu *KToolBar::contextMenu() | 2113 | //US KPopupMenu *KToolBar::contextMenu() |
2103 | QPopupMenu *KToolBar::contextMenu() | 2114 | Q3PopupMenu *KToolBar::contextMenu() |
2104 | { | 2115 | { |
2105 | if ( context ) | 2116 | if ( context ) |
2106 | return context; | 2117 | return context; |
2107 | 2118 | ||
2108 | // Construct our context popup menu. Name it qt_dockwidget_internal so it | 2119 | // Construct our context popup menu. Name it qt_dockwidget_internal so it |
2109 | // won't be deleted by QToolBar::clear(). | 2120 | // won't be deleted by QToolBar::clear(). |
2110 | //US context = new KPopupMenu( this, "qt_dockwidget_internal" ); | 2121 | //US context = new KPopupMenu( this, "qt_dockwidget_internal" ); |
2111 | context = new QPopupMenu( this, "qt_dockwidget_internal" ); | 2122 | context = new Q3PopupMenu( this, "qt_dockwidget_internal" ); |
2112 | //US context->insertTitle(i18n("Toolbar Menu")); | 2123 | //US context->insertTitle(i18n("Toolbar Menu")); |
2113 | 2124 | ||
2114 | //US KPopupMenu *orient = new KPopupMenu( context, "orient" ); | 2125 | //US KPopupMenu *orient = new KPopupMenu( context, "orient" ); |
2115 | QPopupMenu *orient = new QPopupMenu( context, "orient" ); | 2126 | Q3PopupMenu *orient = new Q3PopupMenu( context, "orient" ); |
2116 | orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP ); | 2127 | orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP ); |
2117 | orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT ); | 2128 | orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT ); |
2118 | orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT ); | 2129 | orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT ); |
2119 | orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM ); | 2130 | orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM ); |
2120 | orient->insertSeparator(-1); | 2131 | orient->insertSeparator(-1); |
2121 | //orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT ); | 2132 | //orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT ); |
2122 | orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT ); | 2133 | orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT ); |
2123 | 2134 | ||
2124 | //US KPopupMenu *mode = new KPopupMenu( context, "mode" ); | 2135 | //US KPopupMenu *mode = new KPopupMenu( context, "mode" ); |
2125 | QPopupMenu *mode = new QPopupMenu( context, "mode" ); | 2136 | Q3PopupMenu *mode = new Q3PopupMenu( context, "mode" ); |
2126 | mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS ); | 2137 | mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS ); |
2127 | mode->insertItem( i18n("Text Only"), CONTEXT_TEXT ); | 2138 | mode->insertItem( i18n("Text Only"), CONTEXT_TEXT ); |
2128 | mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT ); | 2139 | mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT ); |
2129 | mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER ); | 2140 | mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER ); |
2130 | 2141 | ||
2131 | //US KPopupMenu *size = new KPopupMenu( context, "size" ); | 2142 | //US KPopupMenu *size = new KPopupMenu( context, "size" ); |
2132 | QPopupMenu *size = new QPopupMenu( context, "size" ); | 2143 | Q3PopupMenu *size = new Q3PopupMenu( context, "size" ); |
2133 | size->insertItem( i18n("Default"), CONTEXT_ICONSIZES ); | 2144 | size->insertItem( i18n("Default"), CONTEXT_ICONSIZES ); |
2134 | // Query the current theme for available sizes | 2145 | // Query the current theme for available sizes |
2135 | QValueList<int> avSizes; | 2146 | Q3ValueList<int> avSizes; |
2136 | /*US | 2147 | /*US |
2137 | KIconTheme *theme = KGlobal::instance()->iconLoader()->theme(); | 2148 | KIconTheme *theme = KGlobal::instance()->iconLoader()->theme(); |
2138 | if (!::qstrcmp(QObject::name(), "mainToolBar")) | 2149 | if (!::qstrcmp(QObject::name(), "mainToolBar")) |
2139 | avSizes = theme->querySizes( KIcon::MainToolbar); | 2150 | avSizes = theme->querySizes( KIcon::MainToolbar); |
2140 | else | 2151 | else |
2141 | avSizes = theme->querySizes( KIcon::Toolbar); | 2152 | avSizes = theme->querySizes( KIcon::Toolbar); |
2142 | */ | 2153 | */ |
2143 | avSizes << 16; | 2154 | avSizes << 16; |
2144 | avSizes << 32; | 2155 | avSizes << 32; |
2145 | 2156 | ||
2146 | d->iconSizes = avSizes; | 2157 | d->iconSizes = avSizes; |
2147 | 2158 | ||
2148 | QValueList<int>::Iterator it; | 2159 | Q3ValueList<int>::Iterator it; |
2149 | for (it=avSizes.begin(); it!=avSizes.end(); it++) { | 2160 | for (it=avSizes.begin(); it!=avSizes.end(); it++) { |
2150 | QString text; | 2161 | QString text; |
2151 | if ( *it < 19 ) | 2162 | if ( *it < 19 ) |
2152 | text = i18n("Small (%1x%2)").arg(*it).arg(*it); | 2163 | text = i18n("Small (%1x%2)").arg(*it).arg(*it); |
2153 | else if (*it < 25) | 2164 | else if (*it < 25) |
2154 | text = i18n("Medium (%1x%2)").arg(*it).arg(*it); | 2165 | text = i18n("Medium (%1x%2)").arg(*it).arg(*it); |
2155 | else | 2166 | else |
2156 | text = i18n("Large (%1x%2)").arg(*it).arg(*it); | 2167 | text = i18n("Large (%1x%2)").arg(*it).arg(*it); |
2157 | //we use the size as an id, with an offset | 2168 | //we use the size as an id, with an offset |
2158 | size->insertItem( text, CONTEXT_ICONSIZES + *it ); | 2169 | size->insertItem( text, CONTEXT_ICONSIZES + *it ); |
2159 | } | 2170 | } |
2160 | 2171 | ||
2161 | context->insertItem( i18n("Orientation"), orient ); | 2172 | context->insertItem( i18n("Orientation"), orient ); |
2162 | orient->setItemChecked(CONTEXT_TOP, true); | 2173 | orient->setItemChecked(CONTEXT_TOP, true); |
2163 | context->insertItem( i18n("Text Position"), mode ); | 2174 | context->insertItem( i18n("Text Position"), mode ); |
2164 | context->setItemChecked(CONTEXT_ICONS, true); | 2175 | context->setItemChecked(CONTEXT_ICONS, true); |
2165 | context->insertItem( i18n("Icon Size"), size ); | 2176 | context->insertItem( i18n("Icon Size"), size ); |
2166 | 2177 | ||
2167 | /*US | 2178 | /*US |
2168 | if (mainWindow()->inherits("KMainWindow")) | 2179 | if (mainWindow()->inherits("KMainWindow")) |
2169 | { | 2180 | { |
2170 | if ( (static_cast<KMainWindow*>(mainWindow())->toolBarMenuAction()) && | 2181 | if ( (static_cast<KMainWindow*>(mainWindow())->toolBarMenuAction()) && |
2171 | (static_cast<KMainWindow*>(mainWindow())->hasMenuBar()) ) | 2182 | (static_cast<KMainWindow*>(mainWindow())->hasMenuBar()) ) |
2172 | 2183 | ||
2173 | (static_cast<KMainWindow*>(mainWindow()))->toolBarMenuAction()->plug(context); | 2184 | (static_cast<KMainWindow*>(mainWindow()))->toolBarMenuAction()->plug(context); |
2174 | } | 2185 | } |
2175 | */ | 2186 | */ |
2176 | 2187 | ||
2177 | connect( context, SIGNAL( aboutToShow() ), this, SLOT( slotContextAboutToShow() ) ); | 2188 | connect( context, SIGNAL( aboutToShow() ), this, SLOT( slotContextAboutToShow() ) ); |
2178 | return context; | 2189 | return context; |
2179 | } | 2190 | } |
2180 | 2191 | ||
@@ -2189,66 +2200,66 @@ void KToolBar::slotContextAboutToShow() | |||
2189 | xmlGuiClient = (KXMLGUIClient *)mainWindow(); | 2200 | xmlGuiClient = (KXMLGUIClient *)mainWindow(); |
2190 | if ( xmlGuiClient ) | 2201 | if ( xmlGuiClient ) |
2191 | { | 2202 | { |
2192 | KAction *configureAction = xmlGuiClient->actionCollection()->action(KStdAction::stdName(KStdAction::ConfigureToolbars)); | 2203 | KAction *configureAction = xmlGuiClient->actionCollection()->action(KStdAction::stdName(KStdAction::ConfigureToolbars)); |
2193 | if ( configureAction ) | 2204 | if ( configureAction ) |
2194 | { | 2205 | { |
2195 | configureAction->plug(context); | 2206 | configureAction->plug(context); |
2196 | d->m_configurePlugged = true; | 2207 | d->m_configurePlugged = true; |
2197 | } | 2208 | } |
2198 | } | 2209 | } |
2199 | } | 2210 | } |
2200 | 2211 | ||
2201 | for(int i = CONTEXT_ICONS; i <= CONTEXT_TEXTUNDER; ++i) | 2212 | for(int i = CONTEXT_ICONS; i <= CONTEXT_TEXTUNDER; ++i) |
2202 | context->setItemChecked(i, false); | 2213 | context->setItemChecked(i, false); |
2203 | 2214 | ||
2204 | switch( d->m_iconText ) | 2215 | switch( d->m_iconText ) |
2205 | { | 2216 | { |
2206 | case IconOnly: | 2217 | case IconOnly: |
2207 | default: | 2218 | default: |
2208 | context->setItemChecked(CONTEXT_ICONS, true); | 2219 | context->setItemChecked(CONTEXT_ICONS, true); |
2209 | break; | 2220 | break; |
2210 | case IconTextRight: | 2221 | case IconTextRight: |
2211 | context->setItemChecked(CONTEXT_TEXTRIGHT, true); | 2222 | context->setItemChecked(CONTEXT_TEXTRIGHT, true); |
2212 | break; | 2223 | break; |
2213 | case TextOnly: | 2224 | case TextOnly: |
2214 | context->setItemChecked(CONTEXT_TEXT, true); | 2225 | context->setItemChecked(CONTEXT_TEXT, true); |
2215 | break; | 2226 | break; |
2216 | case IconTextBottom: | 2227 | case IconTextBottom: |
2217 | context->setItemChecked(CONTEXT_TEXTUNDER, true); | 2228 | context->setItemChecked(CONTEXT_TEXTUNDER, true); |
2218 | break; | 2229 | break; |
2219 | } | 2230 | } |
2220 | 2231 | ||
2221 | QValueList<int>::ConstIterator iIt = d->iconSizes.begin(); | 2232 | Q3ValueList<int>::ConstIterator iIt = d->iconSizes.begin(); |
2222 | QValueList<int>::ConstIterator iEnd = d->iconSizes.end(); | 2233 | Q3ValueList<int>::ConstIterator iEnd = d->iconSizes.end(); |
2223 | for (; iIt != iEnd; ++iIt ) | 2234 | for (; iIt != iEnd; ++iIt ) |
2224 | context->setItemChecked( CONTEXT_ICONSIZES + *iIt, false ); | 2235 | context->setItemChecked( CONTEXT_ICONSIZES + *iIt, false ); |
2225 | 2236 | ||
2226 | context->setItemChecked( CONTEXT_ICONSIZES, false ); | 2237 | context->setItemChecked( CONTEXT_ICONSIZES, false ); |
2227 | 2238 | ||
2228 | context->setItemChecked( CONTEXT_ICONSIZES + d->m_iconSize, true ); | 2239 | context->setItemChecked( CONTEXT_ICONSIZES + d->m_iconSize, true ); |
2229 | 2240 | ||
2230 | for ( int i = CONTEXT_TOP; i <= CONTEXT_FLAT; ++i ) | 2241 | for ( int i = CONTEXT_TOP; i <= CONTEXT_FLAT; ++i ) |
2231 | context->setItemChecked( i, false ); | 2242 | context->setItemChecked( i, false ); |
2232 | 2243 | ||
2233 | switch ( barPos() ) | 2244 | switch ( barPos() ) |
2234 | { | 2245 | { |
2235 | case KToolBar::Flat: | 2246 | case KToolBar::Flat: |
2236 | context->setItemChecked( CONTEXT_FLAT, true ); | 2247 | context->setItemChecked( CONTEXT_FLAT, true ); |
2237 | break; | 2248 | break; |
2238 | case KToolBar::Bottom: | 2249 | case KToolBar::Bottom: |
2239 | context->setItemChecked( CONTEXT_BOTTOM, true ); | 2250 | context->setItemChecked( CONTEXT_BOTTOM, true ); |
2240 | break; | 2251 | break; |
2241 | case KToolBar::Left: | 2252 | case KToolBar::Left: |
2242 | context->setItemChecked( CONTEXT_LEFT, true ); | 2253 | context->setItemChecked( CONTEXT_LEFT, true ); |
2243 | break; | 2254 | break; |
2244 | case KToolBar::Right: | 2255 | case KToolBar::Right: |
2245 | context->setItemChecked( CONTEXT_RIGHT, true ); | 2256 | context->setItemChecked( CONTEXT_RIGHT, true ); |
2246 | break; | 2257 | break; |
2247 | case KToolBar::Floating: | 2258 | case KToolBar::Floating: |
2248 | context->setItemChecked( CONTEXT_FLOAT, true ); | 2259 | context->setItemChecked( CONTEXT_FLOAT, true ); |
2249 | break; | 2260 | break; |
2250 | case KToolBar::Top: | 2261 | case KToolBar::Top: |
2251 | context->setItemChecked( CONTEXT_TOP, true ); | 2262 | context->setItemChecked( CONTEXT_TOP, true ); |
2252 | break; | 2263 | break; |
2253 | default: break; | 2264 | default: break; |
2254 | } | 2265 | } |