-rw-r--r-- | microkde/kdeui/ktoolbar.cpp | 14 | ||||
-rw-r--r-- | microkde/kdeui/ktoolbar.h | 4 |
2 files changed, 15 insertions, 3 deletions
diff --git a/microkde/kdeui/ktoolbar.cpp b/microkde/kdeui/ktoolbar.cpp index df2aad8..027e5e9 100644 --- a/microkde/kdeui/ktoolbar.cpp +++ b/microkde/kdeui/ktoolbar.cpp | |||
@@ -162,192 +162,194 @@ public: | |||
162 | }; | 162 | }; |
163 | 163 | ||
164 | KToolBarSeparator::KToolBarSeparator(Orientation o , bool l, QToolBar *parent, | 164 | KToolBarSeparator::KToolBarSeparator(Orientation o , bool l, QToolBar *parent, |
165 | const char* name ) | 165 | const char* name ) |
166 | :QFrame( parent, name ), line( l ) | 166 | :QFrame( parent, name ), line( l ) |
167 | { | 167 | { |
168 | connect( parent, SIGNAL(orientationChanged(Orientation)), | 168 | connect( parent, SIGNAL(orientationChanged(Orientation)), |
169 | this, SLOT(setOrientation(Orientation)) ); | 169 | this, SLOT(setOrientation(Orientation)) ); |
170 | setOrientation( o ); | 170 | setOrientation( o ); |
171 | setBackgroundMode( parent->backgroundMode() ); | 171 | setBackgroundMode( parent->backgroundMode() ); |
172 | setBackgroundOrigin( ParentOrigin ); | 172 | setBackgroundOrigin( ParentOrigin ); |
173 | } | 173 | } |
174 | 174 | ||
175 | void KToolBarSeparator::setOrientation( Orientation o ) | 175 | void KToolBarSeparator::setOrientation( Orientation o ) |
176 | { | 176 | { |
177 | orient = o; | 177 | orient = o; |
178 | if ( line ) { | 178 | if ( line ) { |
179 | if ( orientation() == Vertical ) | 179 | if ( orientation() == Vertical ) |
180 | setFrameStyle( HLine + Sunken ); | 180 | setFrameStyle( HLine + Sunken ); |
181 | else | 181 | else |
182 | setFrameStyle( VLine + Sunken ); | 182 | setFrameStyle( VLine + Sunken ); |
183 | } else { | 183 | } else { |
184 | setFrameStyle( NoFrame ); | 184 | setFrameStyle( NoFrame ); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | void KToolBarSeparator::styleChange( QStyle& ) | 188 | void KToolBarSeparator::styleChange( QStyle& ) |
189 | { | 189 | { |
190 | setOrientation( orient ); | 190 | setOrientation( orient ); |
191 | } | 191 | } |
192 | 192 | ||
193 | QSize KToolBarSeparator::sizeHint() const | 193 | QSize KToolBarSeparator::sizeHint() const |
194 | { | 194 | { |
195 | return orientation() == Vertical ? QSize( 0, 6 ) : QSize( 6, 0 ); | 195 | return orientation() == Vertical ? QSize( 0, 6 ) : QSize( 6, 0 ); |
196 | } | 196 | } |
197 | 197 | ||
198 | QSizePolicy KToolBarSeparator::sizePolicy() const | 198 | QSizePolicy KToolBarSeparator::sizePolicy() const |
199 | { | 199 | { |
200 | return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); | 200 | return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); |
201 | } | 201 | } |
202 | 202 | ||
203 | KToolBar::KToolBar( QWidget *parent, const char *name, bool honorStyle, bool readConfig ) | 203 | KToolBar::KToolBar( QWidget *parent, const char *name, bool honorStyle, bool readConfig ) |
204 | #ifdef DESKTOP_VERSION | 204 | #ifdef DESKTOP_VERSION |
205 | : QToolBar( QString::fromLatin1( name ), | 205 | : QToolBar( QString::fromLatin1( name ), |
206 | parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, | 206 | parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, |
207 | parent, FALSE, | 207 | parent, FALSE, |
208 | name ? name : "mainToolBar") | 208 | name ? name : "mainToolBar") |
209 | #else | 209 | #else |
210 | : QPEToolBar( parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, | 210 | : QPEToolBar( parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, |
211 | QString::fromLatin1( name )) | 211 | QString::fromLatin1( name )) |
212 | 212 | ||
213 | 213 | ||
214 | #endif | 214 | #endif |
215 | { | 215 | { |
216 | init( readConfig, honorStyle ); | 216 | init( readConfig, honorStyle ); |
217 | } | 217 | } |
218 | 218 | ||
219 | KToolBar::KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) | 219 | KToolBar::KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) |
220 | #ifdef DESKTOP_VERSION | 220 | #ifdef DESKTOP_VERSION |
221 | : QToolBar( QString::fromLatin1( name ), | 221 | : QToolBar( QString::fromLatin1( name ), |
222 | parentWindow, dock, newLine, | 222 | parentWindow, dock, newLine, |
223 | name ? name : "mainToolBar") | 223 | name ? name : "mainToolBar") |
224 | #else | 224 | #else |
225 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) | 225 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) |
226 | 226 | ||
227 | 227 | ||
228 | #endif | 228 | #endif |
229 | 229 | ||
230 | { | 230 | { |
231 | init( readConfig, honorStyle ); | 231 | init( readConfig, honorStyle ); |
232 | } | 232 | } |
233 | 233 | ||
234 | KToolBar::KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) | 234 | KToolBar::KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) |
235 | #ifdef DESKTOP_VERSION | 235 | #ifdef DESKTOP_VERSION |
236 | : QToolBar( QString::fromLatin1( name ), | 236 | : QToolBar( QString::fromLatin1( name ), |
237 | parentWindow, dock, newLine, | 237 | parentWindow, dock, newLine, |
238 | name ? name : "mainToolBar") | 238 | name ? name : "mainToolBar") |
239 | #else | 239 | #else |
240 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) | 240 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) |
241 | 241 | ||
242 | 242 | ||
243 | #endif | 243 | #endif |
244 | 244 | ||
245 | { | 245 | { |
246 | init( readConfig, honorStyle ); | 246 | init( readConfig, honorStyle ); |
247 | } | 247 | } |
248 | 248 | ||
249 | KToolBar::~KToolBar() | 249 | KToolBar::~KToolBar() |
250 | { | 250 | { |
251 | inshutdownprocess = true; | 251 | inshutdownprocess = true; |
252 | emit toolbarDestroyed(); | 252 | emit toolbarDestroyed(); |
253 | delete d; | 253 | delete d; |
254 | } | 254 | } |
255 | 255 | ||
256 | void KToolBar::init( bool readConfig, bool honorStyle ) | 256 | void KToolBar::init( bool readConfig, bool honorStyle ) |
257 | { | 257 | { |
258 | sizeHintW = 240; | ||
259 | sizeHintH = 22; | ||
258 | inshutdownprocess = false; | 260 | inshutdownprocess = false; |
259 | d = new KToolBarPrivate; | 261 | d = new KToolBarPrivate; |
260 | setFullSize( TRUE ); | 262 | setFullSize( TRUE ); |
261 | d->m_honorStyle = honorStyle; | 263 | d->m_honorStyle = honorStyle; |
262 | context = 0; | 264 | context = 0; |
263 | layoutTimer = new QTimer( this ); | 265 | layoutTimer = new QTimer( this ); |
264 | connect( layoutTimer, SIGNAL( timeout() ), | 266 | connect( layoutTimer, SIGNAL( timeout() ), |
265 | this, SLOT( rebuildLayout() ) ); | 267 | this, SLOT( rebuildLayout() ) ); |
266 | connect( &(d->repaintTimer), SIGNAL( timeout() ), | 268 | connect( &(d->repaintTimer), SIGNAL( timeout() ), |
267 | this, SLOT( slotRepaint() ) ); | 269 | this, SLOT( slotRepaint() ) ); |
268 | /*US | 270 | /*US |
269 | if ( kapp ) { // may be null when started inside designer | 271 | if ( kapp ) { // may be null when started inside designer |
270 | connect(kapp, SIGNAL(toolbarAppearanceChanged(int)), this, SLOT(slotAppearanceChanged())); | 272 | connect(kapp, SIGNAL(toolbarAppearanceChanged(int)), this, SLOT(slotAppearanceChanged())); |
271 | // request notification of changes in icon style | 273 | // request notification of changes in icon style |
272 | kapp->addKipcEventMask(KIPC::IconChanged); | 274 | kapp->addKipcEventMask(KIPC::IconChanged); |
273 | connect(kapp, SIGNAL(iconChanged(int)), this, SLOT(slotIconChanged(int))); | 275 | connect(kapp, SIGNAL(iconChanged(int)), this, SLOT(slotIconChanged(int))); |
274 | } | 276 | } |
275 | */ | 277 | */ |
276 | // finally, read in our configurable settings | 278 | // finally, read in our configurable settings |
277 | if ( readConfig ) | 279 | if ( readConfig ) |
278 | slotReadConfig(); | 280 | slotReadConfig(); |
279 | 281 | ||
280 | if ( mainWindow() ) | 282 | if ( mainWindow() ) |
281 | connect( mainWindow(), SIGNAL( toolBarPositionChanged( QToolBar * ) ), | 283 | connect( mainWindow(), SIGNAL( toolBarPositionChanged( QToolBar * ) ), |
282 | this, SLOT( toolBarPosChanged( QToolBar * ) ) ); | 284 | this, SLOT( toolBarPosChanged( QToolBar * ) ) ); |
283 | 285 | ||
284 | // Hack to make sure we recalculate our size when we dock. | 286 | // Hack to make sure we recalculate our size when we dock. |
285 | //US connect( this, SIGNAL(placeChanged(QDockWindow::Place)), SLOT(rebuildLayout()) ); | 287 | //US connect( this, SIGNAL(placeChanged(QDockWindow::Place)), SLOT(rebuildLayout()) ); |
286 | } | 288 | } |
287 | 289 | ||
288 | int KToolBar::insertButton(const QString& icon, int id, bool enabled, | 290 | int KToolBar::insertButton(const QString& icon, int id, bool enabled, |
289 | const QString& text, int index/*US, KInstance *_instance*/ ) | 291 | const QString& text, int index/*US, KInstance *_instance*/ ) |
290 | { | 292 | { |
291 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/ ); | 293 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/ ); |
292 | 294 | ||
293 | insertWidgetInternal( button, index, id ); | 295 | insertWidgetInternal( button, index, id ); |
294 | button->setEnabled( enabled ); | 296 | button->setEnabled( enabled ); |
295 | doConnections( button ); | 297 | doConnections( button ); |
296 | return index; | 298 | return index; |
297 | } | 299 | } |
298 | 300 | ||
299 | 301 | ||
300 | int KToolBar::insertButton(const QString& icon, int id, const char *signal, | 302 | int KToolBar::insertButton(const QString& icon, int id, const char *signal, |
301 | const QObject *receiver, const char *slot, | 303 | const QObject *receiver, const char *slot, |
302 | bool enabled, const QString& text, int index/*US, KInstance *_instance*/ ) | 304 | bool enabled, const QString& text, int index/*US, KInstance *_instance*/ ) |
303 | { | 305 | { |
304 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/); | 306 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/); |
305 | insertWidgetInternal( button, index, id ); | 307 | insertWidgetInternal( button, index, id ); |
306 | button->setEnabled( enabled ); | 308 | button->setEnabled( enabled ); |
307 | connect( button, signal, receiver, slot ); | 309 | connect( button, signal, receiver, slot ); |
308 | doConnections( button ); | 310 | doConnections( button ); |
309 | return index; | 311 | return index; |
310 | } | 312 | } |
311 | 313 | ||
312 | 314 | ||
313 | int KToolBar::insertButton(const QPixmap& pixmap, int id, bool enabled, | 315 | int KToolBar::insertButton(const QPixmap& pixmap, int id, bool enabled, |
314 | const QString& text, int index ) | 316 | const QString& text, int index ) |
315 | { | 317 | { |
316 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); | 318 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); |
317 | insertWidgetInternal( button, index, id ); | 319 | insertWidgetInternal( button, index, id ); |
318 | button->setEnabled( enabled ); | 320 | button->setEnabled( enabled ); |
319 | doConnections( button ); | 321 | doConnections( button ); |
320 | return index; | 322 | return index; |
321 | } | 323 | } |
322 | #if 0 | 324 | #if 0 |
323 | bar->insertButton( icon, id_, SIGNAL( clicked() ), this, | 325 | bar->insertButton( icon, id_, SIGNAL( clicked() ), this, |
324 | SLOT( slotActivated() ), | 326 | SLOT( slotActivated() ), |
325 | d->isEnabled(), d->plainText(), index/*US, instance*/ ); | 327 | d->isEnabled(), d->plainText(), index/*US, instance*/ ); |
326 | #endif | 328 | #endif |
327 | 329 | ||
328 | int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal, | 330 | int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal, |
329 | const QObject *receiver, const char *slot, | 331 | const QObject *receiver, const char *slot, |
330 | bool enabled, const QString& text, | 332 | bool enabled, const QString& text, |
331 | int index ) | 333 | int index ) |
332 | { | 334 | { |
333 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); | 335 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); |
334 | insertWidgetInternal( button, index, id ); | 336 | insertWidgetInternal( button, index, id ); |
335 | button->setEnabled( enabled ); | 337 | button->setEnabled( enabled ); |
336 | connect( button, signal, receiver, slot ); | 338 | connect( button, signal, receiver, slot ); |
337 | doConnections( button ); | 339 | doConnections( button ); |
338 | return index; | 340 | return index; |
339 | } | 341 | } |
340 | 342 | ||
341 | 343 | ||
342 | int KToolBar::insertButton(const QString& icon, int id, QPopupMenu *popup, | 344 | int KToolBar::insertButton(const QString& icon, int id, QPopupMenu *popup, |
343 | bool enabled, const QString &text, int index ) | 345 | bool enabled, const QString &text, int index ) |
344 | { | 346 | { |
345 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text ); | 347 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text ); |
346 | insertWidgetInternal( button, index, id ); | 348 | insertWidgetInternal( button, index, id ); |
347 | button->setEnabled( enabled ); | 349 | button->setEnabled( enabled ); |
348 | button->setPopup( popup ); | 350 | button->setPopup( popup ); |
349 | doConnections( button ); | 351 | doConnections( button ); |
350 | return index; | 352 | return index; |
351 | } | 353 | } |
352 | 354 | ||
353 | 355 | ||
@@ -1346,194 +1348,202 @@ void KToolBar::rebuildLayout() | |||
1346 | //if ( !stretchableWidget && widgets.last() && | 1348 | //if ( !stretchableWidget && widgets.last() && |
1347 | // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) | 1349 | // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) |
1348 | // setStretchableWidget( widgets.last() ); | 1350 | // setStretchableWidget( widgets.last() ); |
1349 | if ( !rightAligned ) | 1351 | if ( !rightAligned ) |
1350 | l->addStretch(); | 1352 | l->addStretch(); |
1351 | if ( stretchableWidget ) | 1353 | if ( stretchableWidget ) |
1352 | l->setStretchFactor( stretchableWidget, 10 ); | 1354 | l->setStretchFactor( stretchableWidget, 10 ); |
1353 | } | 1355 | } |
1354 | l->invalidate(); | 1356 | l->invalidate(); |
1355 | QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); | 1357 | QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); |
1356 | //#endif //DESKTOP_VERSION | 1358 | //#endif //DESKTOP_VERSION |
1357 | } | 1359 | } |
1358 | 1360 | ||
1359 | void KToolBar::childEvent( QChildEvent *e ) | 1361 | void KToolBar::childEvent( QChildEvent *e ) |
1360 | { | 1362 | { |
1361 | 1363 | ||
1362 | if ( e->child()->isWidgetType() ) { | 1364 | if ( e->child()->isWidgetType() ) { |
1363 | QWidget * w = (QWidget*)e->child(); | 1365 | QWidget * w = (QWidget*)e->child(); |
1364 | if ( e->type() == QEvent::ChildInserted ) { | 1366 | if ( e->type() == QEvent::ChildInserted ) { |
1365 | if ( !e->child()->inherits( "QPopupMenu" ) && | 1367 | if ( !e->child()->inherits( "QPopupMenu" ) && |
1366 | ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) { | 1368 | ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) { |
1367 | 1369 | ||
1368 | // prevent items that have been explicitly inserted by insert*() from | 1370 | // prevent items that have been explicitly inserted by insert*() from |
1369 | // being inserted again | 1371 | // being inserted again |
1370 | if ( !widget2id.contains( w ) ) | 1372 | if ( !widget2id.contains( w ) ) |
1371 | { | 1373 | { |
1372 | int dummy = -1; | 1374 | int dummy = -1; |
1373 | insertWidgetInternal( w, dummy, -1 ); | 1375 | insertWidgetInternal( w, dummy, -1 ); |
1374 | } | 1376 | } |
1375 | } | 1377 | } |
1376 | } else { | 1378 | } else { |
1377 | removeWidgetInternal( w ); | 1379 | removeWidgetInternal( w ); |
1378 | } | 1380 | } |
1379 | if ( isVisibleTo( 0 ) ) | 1381 | if ( isVisibleTo( 0 ) ) |
1380 | { | 1382 | { |
1381 | QBoxLayout *l = boxLayout(); | 1383 | QBoxLayout *l = boxLayout(); |
1382 | // QLayout *l = layout(); | 1384 | // QLayout *l = layout(); |
1383 | 1385 | ||
1384 | // clear the old layout so that we don't get unnecassery layout | 1386 | // clear the old layout so that we don't get unnecassery layout |
1385 | // changes till we have rebuild the thing | 1387 | // changes till we have rebuild the thing |
1386 | QLayoutIterator it = l->iterator(); | 1388 | QLayoutIterator it = l->iterator(); |
1387 | while ( it.current() ) { | 1389 | while ( it.current() ) { |
1388 | it.deleteCurrent(); | 1390 | it.deleteCurrent(); |
1389 | } | 1391 | } |
1390 | layoutTimer->start( 50, TRUE ); | 1392 | layoutTimer->start( 50, TRUE ); |
1391 | } | 1393 | } |
1392 | } | 1394 | } |
1393 | QToolBar::childEvent( e ); | 1395 | QToolBar::childEvent( e ); |
1394 | } | 1396 | } |
1395 | 1397 | ||
1396 | void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) | 1398 | void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) |
1397 | { | 1399 | { |
1398 | // we can't have it in widgets, or something is really wrong | 1400 | // we can't have it in widgets, or something is really wrong |
1399 | //widgets.removeRef( w ); | 1401 | //widgets.removeRef( w ); |
1400 | 1402 | ||
1401 | connect( w, SIGNAL( destroyed() ), | 1403 | connect( w, SIGNAL( destroyed() ), |
1402 | this, SLOT( widgetDestroyed() ) ); | 1404 | this, SLOT( widgetDestroyed() ) ); |
1403 | if ( index == -1 || index > (int)widgets.count() ) { | 1405 | if ( index == -1 || index > (int)widgets.count() ) { |
1404 | widgets.append( w ); | 1406 | widgets.append( w ); |
1405 | index = (int)widgets.count(); | 1407 | index = (int)widgets.count(); |
1406 | } | 1408 | } |
1407 | else | 1409 | else |
1408 | widgets.insert( index, w ); | 1410 | widgets.insert( index, w ); |
1409 | if ( id == -1 ) | 1411 | if ( id == -1 ) |
1410 | id = id2widget.count(); | 1412 | id = id2widget.count(); |
1411 | id2widget.insert( id, w ); | 1413 | id2widget.insert( id, w ); |
1412 | widget2id.insert( w, id ); | 1414 | widget2id.insert( w, id ); |
1413 | } | 1415 | } |
1414 | void KToolBar::repaintMe() | 1416 | void KToolBar::repaintMe() |
1415 | { | 1417 | { |
1416 | setUpdatesEnabled( true ); | 1418 | setUpdatesEnabled( true ); |
1417 | QToolBar::repaint( true ); | 1419 | QToolBar::repaint( true ); |
1418 | qDebug(" KToolBar::repaintMe() "); | 1420 | qDebug(" KToolBar::repaintMe() "); |
1419 | } | 1421 | } |
1420 | 1422 | ||
1421 | void KToolBar::showEvent( QShowEvent *e ) | 1423 | void KToolBar::showEvent( QShowEvent *e ) |
1422 | { | 1424 | { |
1423 | rebuildLayout(); | 1425 | rebuildLayout(); |
1424 | QToolBar::showEvent( e ); | 1426 | QToolBar::showEvent( e ); |
1425 | } | 1427 | } |
1426 | 1428 | ||
1427 | void KToolBar::setStretchableWidget( QWidget *w ) | 1429 | void KToolBar::setStretchableWidget( QWidget *w ) |
1428 | { | 1430 | { |
1429 | QToolBar::setStretchableWidget( w ); | 1431 | QToolBar::setStretchableWidget( w ); |
1430 | stretchableWidget = w; | 1432 | stretchableWidget = w; |
1431 | } | 1433 | } |
1432 | 1434 | ||
1433 | QSizePolicy KToolBar::sizePolicy() const | 1435 | QSizePolicy KToolBar::sizePolicy() const |
1434 | { | 1436 | { |
1435 | if ( orientation() == Horizontal ) | 1437 | if ( orientation() == Horizontal ) |
1436 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); | 1438 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); |
1437 | else | 1439 | else |
1438 | return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); | 1440 | return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); |
1439 | } | 1441 | } |
1440 | 1442 | ||
1441 | QSize KToolBar::sizeHint() const | 1443 | QSize KToolBar::sizeHint() const |
1442 | { | 1444 | { |
1443 | return QToolBar::sizeHint(); | 1445 | QSize sh = QToolBar::sizeHint(); |
1446 | //qDebug("%x KToolBar::sizeHint() %d %d ",this, QToolBar::sizeHint().width(),QToolBar::sizeHint().height() ); | ||
1447 | if ( sh.height() <= 20 || sh.width() < 60 ) | ||
1448 | return QSize( sizeHintW, sizeHintH ); | ||
1449 | KToolBar* ttt = (KToolBar*) this; | ||
1450 | ttt->sizeHintW = sh.width(); | ||
1451 | ttt->sizeHintH = sh.height(); | ||
1452 | return sh; | ||
1453 | //return QToolBar::sizeHint(); | ||
1444 | #if 0 | 1454 | #if 0 |
1445 | QWidget::polish(); | 1455 | QWidget::polish(); |
1446 | static int iii = 0; | 1456 | static int iii = 0; |
1447 | ++iii; | 1457 | ++iii; |
1448 | qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); | 1458 | qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); |
1449 | int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); | 1459 | int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); |
1450 | switch( barPos() ) | 1460 | switch( barPos() ) |
1451 | { | 1461 | { |
1452 | case KToolBar::Top: | 1462 | case KToolBar::Top: |
1453 | case KToolBar::Bottom: | 1463 | case KToolBar::Bottom: |
1454 | for ( QWidget *w = widgets.first(); w; w =widgets.next() ) | 1464 | for ( QWidget *w = widgets.first(); w; w =widgets.next() ) |
1455 | { | 1465 | { |
1456 | if ( w->inherits( "KToolBarSeparator" ) && | 1466 | if ( w->inherits( "KToolBarSeparator" ) && |
1457 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) | 1467 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) |
1458 | { | 1468 | { |
1459 | minSize += QSize(6, 0); | 1469 | minSize += QSize(6, 0); |
1460 | } | 1470 | } |
1461 | else | 1471 | else |
1462 | { | 1472 | { |
1463 | QSize sh = w->sizeHint(); | 1473 | QSize sh = w->sizeHint(); |
1464 | if (!sh.isValid()) | 1474 | if (!sh.isValid()) |
1465 | sh = w->minimumSize(); | 1475 | sh = w->minimumSize(); |
1466 | minSize = minSize.expandedTo(QSize(0, sh.height())); | 1476 | minSize = minSize.expandedTo(QSize(0, sh.height())); |
1467 | minSize += QSize(sh.width()+1, 0); | 1477 | minSize += QSize(sh.width()+1, 0); |
1468 | } | 1478 | } |
1469 | } | 1479 | } |
1470 | /*US | 1480 | /*US |
1471 | minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0); | 1481 | minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0); |
1472 | */ | 1482 | */ |
1473 | minSize += QSize(margin*2, margin*2); | 1483 | minSize += QSize(margin*2, margin*2); |
1474 | break; | 1484 | break; |
1475 | 1485 | ||
1476 | case KToolBar::Left: | 1486 | case KToolBar::Left: |
1477 | case KToolBar::Right: | 1487 | case KToolBar::Right: |
1478 | for ( QWidget *w = widgets.first(); w; w = widgets.next() ) | 1488 | for ( QWidget *w = widgets.first(); w; w = widgets.next() ) |
1479 | { | 1489 | { |
1480 | if ( w->inherits( "KToolBarSeparator" ) && | 1490 | if ( w->inherits( "KToolBarSeparator" ) && |
1481 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) | 1491 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) |
1482 | { | 1492 | { |
1483 | minSize += QSize(0, 6); | 1493 | minSize += QSize(0, 6); |
1484 | } | 1494 | } |
1485 | else | 1495 | else |
1486 | { | 1496 | { |
1487 | QSize sh = w->sizeHint(); | 1497 | QSize sh = w->sizeHint(); |
1488 | if (!sh.isValid()) | 1498 | if (!sh.isValid()) |
1489 | sh = w->minimumSize(); | 1499 | sh = w->minimumSize(); |
1490 | minSize = minSize.expandedTo(QSize(sh.width(), 0)); | 1500 | minSize = minSize.expandedTo(QSize(sh.width(), 0)); |
1491 | minSize += QSize(0, sh.height()+1); | 1501 | minSize += QSize(0, sh.height()+1); |
1492 | } | 1502 | } |
1493 | } | 1503 | } |
1494 | /*US | 1504 | /*US |
1495 | minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); | 1505 | minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); |
1496 | */ | 1506 | */ |
1497 | minSize += QSize(margin*2, margin*2); | 1507 | minSize += QSize(margin*2, margin*2); |
1498 | break; | 1508 | break; |
1499 | 1509 | ||
1500 | default: | 1510 | default: |
1501 | minSize = QToolBar::sizeHint(); | 1511 | minSize = QToolBar::sizeHint(); |
1502 | break; | 1512 | break; |
1503 | } | 1513 | } |
1504 | return minSize; | 1514 | return minSize; |
1505 | #endif | 1515 | #endif |
1506 | } | 1516 | } |
1507 | 1517 | ||
1508 | QSize KToolBar::minimumSize() const | 1518 | QSize KToolBar::minimumSize() const |
1509 | { | 1519 | { |
1510 | return minimumSizeHint(); | 1520 | return minimumSizeHint(); |
1511 | } | 1521 | } |
1512 | 1522 | ||
1513 | QSize KToolBar::minimumSizeHint() const | 1523 | QSize KToolBar::minimumSizeHint() const |
1514 | { | 1524 | { |
1515 | return sizeHint(); | 1525 | return sizeHint(); |
1516 | } | 1526 | } |
1517 | 1527 | ||
1518 | bool KToolBar::highlight() const | 1528 | bool KToolBar::highlight() const |
1519 | { | 1529 | { |
1520 | return d->m_highlight; | 1530 | return d->m_highlight; |
1521 | } | 1531 | } |
1522 | 1532 | ||
1523 | void KToolBar::hide() | 1533 | void KToolBar::hide() |
1524 | { | 1534 | { |
1525 | QToolBar::hide(); | 1535 | QToolBar::hide(); |
1526 | } | 1536 | } |
1527 | 1537 | ||
1528 | void KToolBar::show() | 1538 | void KToolBar::show() |
1529 | { | 1539 | { |
1530 | QToolBar::show(); | 1540 | QToolBar::show(); |
1531 | } | 1541 | } |
1532 | 1542 | ||
1533 | void KToolBar::resizeEvent( QResizeEvent *e ) | 1543 | void KToolBar::resizeEvent( QResizeEvent *e ) |
1534 | { | 1544 | { |
1535 | bool b = isUpdatesEnabled(); | 1545 | bool b = isUpdatesEnabled(); |
1536 | setUpdatesEnabled( FALSE ); | 1546 | setUpdatesEnabled( FALSE ); |
1537 | QToolBar::resizeEvent( e ); | 1547 | QToolBar::resizeEvent( e ); |
1538 | if (b) | 1548 | if (b) |
1539 | d->repaintTimer.start( 100, true ); | 1549 | d->repaintTimer.start( 100, true ); |
diff --git a/microkde/kdeui/ktoolbar.h b/microkde/kdeui/ktoolbar.h index 7a5c114..3319fa8 100644 --- a/microkde/kdeui/ktoolbar.h +++ b/microkde/kdeui/ktoolbar.h | |||
@@ -988,121 +988,123 @@ signals: | |||
988 | * setToggle(false), this signal won't | 988 | * setToggle(false), this signal won't |
989 | * be emitted. | 989 | * be emitted. |
990 | */ | 990 | */ |
991 | void toggled(int); | 991 | void toggled(int); |
992 | 992 | ||
993 | /** | 993 | /** |
994 | * This signal is emitted when item id gets highlighted/unhighlighted | 994 | * This signal is emitted when item id gets highlighted/unhighlighted |
995 | * (i.e when mouse enters/exits). | 995 | * (i.e when mouse enters/exits). |
996 | * | 996 | * |
997 | * Note that this signal is emitted from | 997 | * Note that this signal is emitted from |
998 | * all buttons (normal, disabled and toggle) even when there is no visible | 998 | * all buttons (normal, disabled and toggle) even when there is no visible |
999 | * change in buttons (i.e., buttons do not raise when mouse enters). | 999 | * change in buttons (i.e., buttons do not raise when mouse enters). |
1000 | * The parameter @p isHighlighted is @p true when mouse enters and @p false when | 1000 | * The parameter @p isHighlighted is @p true when mouse enters and @p false when |
1001 | * mouse exits. | 1001 | * mouse exits. |
1002 | */ | 1002 | */ |
1003 | void highlighted(int id, bool isHighlighted); | 1003 | void highlighted(int id, bool isHighlighted); |
1004 | 1004 | ||
1005 | /** | 1005 | /** |
1006 | * This signal is emitted when item id gets highlighted/unhighlighted | 1006 | * This signal is emitted when item id gets highlighted/unhighlighted |
1007 | * (i.e when mouse enters/exits). | 1007 | * (i.e when mouse enters/exits). |
1008 | * | 1008 | * |
1009 | * Note that this signal is emitted from | 1009 | * Note that this signal is emitted from |
1010 | * all buttons (normal, disabled and toggle) even when there is no visible | 1010 | * all buttons (normal, disabled and toggle) even when there is no visible |
1011 | * change in buttons (i.e., buttons do not raise when mouse enters). | 1011 | * change in buttons (i.e., buttons do not raise when mouse enters). |
1012 | */ | 1012 | */ |
1013 | void highlighted(int id ); | 1013 | void highlighted(int id ); |
1014 | 1014 | ||
1015 | /** | 1015 | /** |
1016 | * Emitted when toolbar changes position, or when | 1016 | * Emitted when toolbar changes position, or when |
1017 | * an item is removed from toolbar. | 1017 | * an item is removed from toolbar. |
1018 | * | 1018 | * |
1019 | * If you subclass @ref KMainWindow and reimplement | 1019 | * If you subclass @ref KMainWindow and reimplement |
1020 | * @ref KMainWindow::resizeEvent() be sure to connect to | 1020 | * @ref KMainWindow::resizeEvent() be sure to connect to |
1021 | * this signal. Note: You can connect this signal to a slot that | 1021 | * this signal. Note: You can connect this signal to a slot that |
1022 | * doesn't take parameter. | 1022 | * doesn't take parameter. |
1023 | */ | 1023 | */ |
1024 | void moved( BarPosition ); | 1024 | void moved( BarPosition ); |
1025 | 1025 | ||
1026 | /** | 1026 | /** |
1027 | * @internal | 1027 | * @internal |
1028 | * This signal is emitted when toolbar detects changing of | 1028 | * This signal is emitted when toolbar detects changing of |
1029 | * following parameters: | 1029 | * following parameters: |
1030 | * highlighting, button-size, button-mode. This signal is | 1030 | * highlighting, button-size, button-mode. This signal is |
1031 | * internal, aimed to buttons. | 1031 | * internal, aimed to buttons. |
1032 | */ | 1032 | */ |
1033 | void modechange (); | 1033 | void modechange (); |
1034 | 1034 | ||
1035 | /** | 1035 | /** |
1036 | * This signal is emitted when the toolbar is getting deleted, | 1036 | * This signal is emitted when the toolbar is getting deleted, |
1037 | * and before ~KToolbar finishes (so it's still time to remove | 1037 | * and before ~KToolbar finishes (so it's still time to remove |
1038 | * widgets from the toolbar). | 1038 | * widgets from the toolbar). |
1039 | * Used by KWidgetAction. | 1039 | * Used by KWidgetAction. |
1040 | * @since 3.2 | 1040 | * @since 3.2 |
1041 | */ | 1041 | */ |
1042 | void toolbarDestroyed(); | 1042 | void toolbarDestroyed(); |
1043 | 1043 | ||
1044 | public: | 1044 | public: |
1045 | /** | 1045 | /** |
1046 | * @return global setting for "Highlight buttons under mouse" | 1046 | * @return global setting for "Highlight buttons under mouse" |
1047 | */ | 1047 | */ |
1048 | void repaintMe(); | 1048 | void repaintMe(); |
1049 | static bool highlightSetting(); | 1049 | static bool highlightSetting(); |
1050 | 1050 | ||
1051 | /** | 1051 | /** |
1052 | * @return global setting for "Toolbars transparent when moving" | 1052 | * @return global setting for "Toolbars transparent when moving" |
1053 | */ | 1053 | */ |
1054 | static bool transparentSetting(); | 1054 | static bool transparentSetting(); |
1055 | 1055 | ||
1056 | /** | 1056 | /** |
1057 | * @return global setting for "Icon Text" | 1057 | * @return global setting for "Icon Text" |
1058 | */ | 1058 | */ |
1059 | static IconText iconTextSetting(); | 1059 | static IconText iconTextSetting(); |
1060 | 1060 | ||
1061 | public slots: | 1061 | public slots: |
1062 | virtual void setIconText( const QString &txt ) | 1062 | virtual void setIconText( const QString &txt ) |
1063 | { QToolBar::setIconText( txt ); } | 1063 | { QToolBar::setIconText( txt ); } |
1064 | void slotRepaint(); | 1064 | void slotRepaint(); |
1065 | 1065 | ||
1066 | protected: | 1066 | protected: |
1067 | void mousePressEvent( QMouseEvent * ); | 1067 | void mousePressEvent( QMouseEvent * ); |
1068 | void childEvent( QChildEvent *e ); | 1068 | void childEvent( QChildEvent *e ); |
1069 | void showEvent( QShowEvent *e ); | 1069 | void showEvent( QShowEvent *e ); |
1070 | void resizeEvent( QResizeEvent *e ); | 1070 | void resizeEvent( QResizeEvent *e ); |
1071 | bool event( QEvent *e ); | 1071 | bool event( QEvent *e ); |
1072 | void applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal = false); | 1072 | void applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal = false); |
1073 | QString settingsGroup(); | 1073 | QString settingsGroup(); |
1074 | 1074 | ||
1075 | private slots: | 1075 | private slots: |
1076 | void rebuildLayout(); | 1076 | void rebuildLayout(); |
1077 | void slotReadConfig (); | 1077 | void slotReadConfig (); |
1078 | void slotAppearanceChanged(); | 1078 | void slotAppearanceChanged(); |
1079 | void slotIconChanged(int); | 1079 | void slotIconChanged(int); |
1080 | void toolBarPosChanged( QToolBar *tb ); | 1080 | void toolBarPosChanged( QToolBar *tb ); |
1081 | void slotContextAboutToShow(); | 1081 | void slotContextAboutToShow(); |
1082 | void widgetDestroyed(); | 1082 | void widgetDestroyed(); |
1083 | 1083 | ||
1084 | private: | 1084 | private: |
1085 | int sizeHintW; | ||
1086 | int sizeHintH; | ||
1085 | void init( bool readConfig = true, bool honorStyle = false ); | 1087 | void init( bool readConfig = true, bool honorStyle = false ); |
1086 | void doConnections( KToolBarButton *button ); | 1088 | void doConnections( KToolBarButton *button ); |
1087 | void insertWidgetInternal( QWidget *w, int &index, int id ); | 1089 | void insertWidgetInternal( QWidget *w, int &index, int id ); |
1088 | void removeWidgetInternal( QWidget *w ); | 1090 | void removeWidgetInternal( QWidget *w ); |
1089 | void getAttributes( QString &position, QString &icontext, int &index ); | 1091 | void getAttributes( QString &position, QString &icontext, int &index ); |
1090 | //US KPopupMenu *contextMenu(); | 1092 | //US KPopupMenu *contextMenu(); |
1091 | QPopupMenu *contextMenu(); | 1093 | QPopupMenu *contextMenu(); |
1092 | 1094 | ||
1093 | QMap<QWidget*, int > widget2id; | 1095 | QMap<QWidget*, int > widget2id; |
1094 | typedef QMap<int, QWidget* > Id2WidgetMap; | 1096 | typedef QMap<int, QWidget* > Id2WidgetMap; |
1095 | Id2WidgetMap id2widget; | 1097 | Id2WidgetMap id2widget; |
1096 | //US KPopupMenu *context; | 1098 | //US KPopupMenu *context; |
1097 | QPopupMenu *context; | 1099 | QPopupMenu *context; |
1098 | QPtrList<QWidget> widgets; | 1100 | QPtrList<QWidget> widgets; |
1099 | QTimer *layoutTimer; | 1101 | QTimer *layoutTimer; |
1100 | QGuardedPtr<QWidget> stretchableWidget, rightAligned; | 1102 | QGuardedPtr<QWidget> stretchableWidget, rightAligned; |
1101 | protected: | 1103 | protected: |
1102 | virtual void virtual_hook( int id, void* data ); | 1104 | virtual void virtual_hook( int id, void* data ); |
1103 | private: | 1105 | private: |
1104 | KToolBarPrivate *d; | 1106 | KToolBarPrivate *d; |
1105 | bool inshutdownprocess; | 1107 | bool inshutdownprocess; |
1106 | }; | 1108 | }; |
1107 | 1109 | ||
1108 | #endif | 1110 | #endif |