-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 | |||
@@ -226,64 +226,66 @@ KToolBar::KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock, bo | |||
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*/ ) |
@@ -1410,66 +1412,74 @@ void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) | |||
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 | ||
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 | |||
@@ -1052,57 +1052,59 @@ public: | |||
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 |