summaryrefslogtreecommitdiffabout
path: root/microkde
authorzautrix <zautrix>2004-12-05 12:12:10 (UTC)
committer zautrix <zautrix>2004-12-05 12:12:10 (UTC)
commit5ab47964d8b52897bb0662ef4a5fcf9604acaf6c (patch) (unidiff)
tree0f80433206ddd6b4ef901cb346d0f06caf76b20f /microkde
parent196365e533c6fd1a8f47aa9579763ef5afcebcda (diff)
downloadkdepimpi-5ab47964d8b52897bb0662ef4a5fcf9604acaf6c.zip
kdepimpi-5ab47964d8b52897bb0662ef4a5fcf9604acaf6c.tar.gz
kdepimpi-5ab47964d8b52897bb0662ef4a5fcf9604acaf6c.tar.bz2
fixed kapi toolbar repaint problem
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/ktoolbar.cpp6
-rw-r--r--microkde/kdeui/ktoolbar.h3
2 files changed, 8 insertions, 1 deletions
diff --git a/microkde/kdeui/ktoolbar.cpp b/microkde/kdeui/ktoolbar.cpp
index 79b0f9d..e9226c0 100644
--- a/microkde/kdeui/ktoolbar.cpp
+++ b/microkde/kdeui/ktoolbar.cpp
@@ -1029,768 +1029,774 @@ int KToolBar::iconSize() const
1029 return ret; 1029 return ret;
1030} 1030}
1031 1031
1032 1032
1033void KToolBar::setEnableContextMenu(bool enable ) 1033void KToolBar::setEnableContextMenu(bool enable )
1034{ 1034{
1035 d->m_enableContext = enable; 1035 d->m_enableContext = enable;
1036} 1036}
1037 1037
1038 1038
1039bool KToolBar::contextMenuEnabled() const 1039bool KToolBar::contextMenuEnabled() const
1040{ 1040{
1041 return d->m_enableContext; 1041 return d->m_enableContext;
1042} 1042}
1043 1043
1044 1044
1045void KToolBar::setItemNoStyle(int id, bool no_style ) 1045void KToolBar::setItemNoStyle(int id, bool no_style )
1046{ 1046{
1047 Id2WidgetMap::Iterator it = id2widget.find( id ); 1047 Id2WidgetMap::Iterator it = id2widget.find( id );
1048 if ( it == id2widget.end() ) 1048 if ( it == id2widget.end() )
1049 return; 1049 return;
1050//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 1050//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
1051 KToolBarButton * button = (KToolBarButton *)( *it ); 1051 KToolBarButton * button = (KToolBarButton *)( *it );
1052 if (button) 1052 if (button)
1053 button->setNoStyle( no_style ); 1053 button->setNoStyle( no_style );
1054} 1054}
1055 1055
1056 1056
1057void KToolBar::setFlat (bool flag) 1057void KToolBar::setFlat (bool flag)
1058{ 1058{
1059 if ( !mainWindow() ) 1059 if ( !mainWindow() )
1060 return; 1060 return;
1061 if ( flag ) 1061 if ( flag )
1062//US mainWindow()->moveDockWindow( this, DockMinimized ); 1062//US mainWindow()->moveDockWindow( this, DockMinimized );
1063 mainWindow()->moveToolBar( this, QMainWindow::Minimized ); 1063 mainWindow()->moveToolBar( this, QMainWindow::Minimized );
1064 else 1064 else
1065//US mainWindow()->moveDockWindow( this, DockTop ); 1065//US mainWindow()->moveDockWindow( this, DockTop );
1066 mainWindow()->moveToolBar( this, QMainWindow::Top ); 1066 mainWindow()->moveToolBar( this, QMainWindow::Top );
1067 // And remember to save the new look later 1067 // And remember to save the new look later
1068/*US 1068/*US
1069 if ( mainWindow()->inherits( "KMainWindow" ) ) 1069 if ( mainWindow()->inherits( "KMainWindow" ) )
1070 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1070 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1071*/ 1071*/
1072} 1072}
1073 1073
1074 1074
1075int KToolBar::count() const 1075int KToolBar::count() const
1076{ 1076{
1077 return id2widget.count(); 1077 return id2widget.count();
1078} 1078}
1079 1079
1080 1080
1081void KToolBar::saveState() 1081void KToolBar::saveState()
1082{ 1082{
1083/*US 1083/*US
1084 // first, try to save to the xml file 1084 // first, try to save to the xml file
1085 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) { 1085 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) {
1086 // go down one level to get to the right tags 1086 // go down one level to get to the right tags
1087 QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement(); 1087 QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement();
1088 elem = elem.firstChild().toElement(); 1088 elem = elem.firstChild().toElement();
1089 QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name()); 1089 QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name());
1090 QDomElement current; 1090 QDomElement current;
1091 // now try to find our toolbar 1091 // now try to find our toolbar
1092 d->modified = false; 1092 d->modified = false;
1093 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { 1093 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) {
1094 current = elem; 1094 current = elem;
1095 1095
1096 if ( current.tagName().lower() != "toolbar" ) 1096 if ( current.tagName().lower() != "toolbar" )
1097 continue; 1097 continue;
1098 1098
1099 QString curname(current.attribute( "name" )); 1099 QString curname(current.attribute( "name" ));
1100 1100
1101 if ( curname == barname ) { 1101 if ( curname == barname ) {
1102 saveState( current ); 1102 saveState( current );
1103 break; 1103 break;
1104 } 1104 }
1105 } 1105 }
1106 // if we didn't make changes, then just return 1106 // if we didn't make changes, then just return
1107 if ( !d->modified ) 1107 if ( !d->modified )
1108 return; 1108 return;
1109 1109
1110 // now we load in the (non-merged) local file 1110 // now we load in the (non-merged) local file
1111 QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance())); 1111 QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance()));
1112 QDomDocument local; 1112 QDomDocument local;
1113 local.setContent(local_xml); 1113 local.setContent(local_xml);
1114 1114
1115 // make sure we don't append if this toolbar already exists locally 1115 // make sure we don't append if this toolbar already exists locally
1116 bool just_append = true; 1116 bool just_append = true;
1117 elem = local.documentElement().toElement(); 1117 elem = local.documentElement().toElement();
1118 KXMLGUIFactory::removeDOMComments( elem ); 1118 KXMLGUIFactory::removeDOMComments( elem );
1119 elem = elem.firstChild().toElement(); 1119 elem = elem.firstChild().toElement();
1120 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { 1120 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) {
1121 if ( elem.tagName().lower() != "toolbar" ) 1121 if ( elem.tagName().lower() != "toolbar" )
1122 continue; 1122 continue;
1123 1123
1124 QString curname(elem.attribute( "name" )); 1124 QString curname(elem.attribute( "name" ));
1125 1125
1126 if ( curname == barname ) { 1126 if ( curname == barname ) {
1127 just_append = false; 1127 just_append = false;
1128 local.documentElement().replaceChild( current, elem ); 1128 local.documentElement().replaceChild( current, elem );
1129 break; 1129 break;
1130 } 1130 }
1131 } 1131 }
1132 1132
1133 if (just_append) 1133 if (just_append)
1134 local.documentElement().appendChild( current ); 1134 local.documentElement().appendChild( current );
1135 1135
1136 KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() ); 1136 KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() );
1137 1137
1138 return; 1138 return;
1139 } 1139 }
1140*/ 1140*/
1141 // if that didn't work, we save to the config file 1141 // if that didn't work, we save to the config file
1142 KConfig *config = KGlobal::config(); 1142 KConfig *config = KGlobal::config();
1143 saveSettings(config, QString::null); 1143 saveSettings(config, QString::null);
1144 config->sync(); 1144 config->sync();
1145} 1145}
1146 1146
1147QString KToolBar::settingsGroup() 1147QString KToolBar::settingsGroup()
1148{ 1148{
1149 QString configGroup; 1149 QString configGroup;
1150 if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar")) 1150 if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar"))
1151 configGroup = "Toolbar style"; 1151 configGroup = "Toolbar style";
1152 else 1152 else
1153 configGroup = QString(name()) + " Toolbar style"; 1153 configGroup = QString(name()) + " Toolbar style";
1154 if ( this->mainWindow() ) 1154 if ( this->mainWindow() )
1155 { 1155 {
1156 configGroup.prepend(" "); 1156 configGroup.prepend(" ");
1157 configGroup.prepend( this->mainWindow()->name() ); 1157 configGroup.prepend( this->mainWindow()->name() );
1158 } 1158 }
1159 return configGroup; 1159 return configGroup;
1160} 1160}
1161 1161
1162void KToolBar::saveSettings(KConfig *config, const QString &_configGroup) 1162void KToolBar::saveSettings(KConfig *config, const QString &_configGroup)
1163{ 1163{
1164 QString configGroup = _configGroup; 1164 QString configGroup = _configGroup;
1165 if (configGroup.isEmpty()) 1165 if (configGroup.isEmpty())
1166 configGroup = settingsGroup(); 1166 configGroup = settingsGroup();
1167 //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl; 1167 //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl;
1168 1168
1169 QString position, icontext; 1169 QString position, icontext;
1170 int index; 1170 int index;
1171 getAttributes( position, icontext, index ); 1171 getAttributes( position, icontext, index );
1172 1172
1173 //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl; 1173 //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl;
1174 1174
1175 KConfigGroupSaver saver(config, configGroup); 1175 KConfigGroupSaver saver(config, configGroup);
1176 1176
1177 if ( position != d->PositionDefault ) 1177 if ( position != d->PositionDefault )
1178 config->writeEntry("Position", position); 1178 config->writeEntry("Position", position);
1179 else 1179 else
1180 config->deleteEntry("Position"); 1180 config->deleteEntry("Position");
1181 1181
1182 if ( icontext != d->IconTextDefault ) 1182 if ( icontext != d->IconTextDefault )
1183 config->writeEntry("IconText", icontext); 1183 config->writeEntry("IconText", icontext);
1184 else 1184 else
1185 config->deleteEntry("IconText"); 1185 config->deleteEntry("IconText");
1186 1186
1187 if ( iconSize() != d->IconSizeDefault ) 1187 if ( iconSize() != d->IconSizeDefault )
1188 config->writeEntry("IconSize", iconSize()); 1188 config->writeEntry("IconSize", iconSize());
1189 else 1189 else
1190 config->deleteEntry("IconSize"); 1190 config->deleteEntry("IconSize");
1191 1191
1192 if ( isHidden() != d->HiddenDefault ) 1192 if ( isHidden() != d->HiddenDefault )
1193 config->writeEntry("Hidden", isHidden()); 1193 config->writeEntry("Hidden", isHidden());
1194 else 1194 else
1195 config->deleteEntry("Hidden"); 1195 config->deleteEntry("Hidden");
1196 1196
1197 if ( index != d->IndexDefault ) 1197 if ( index != d->IndexDefault )
1198 config->writeEntry( "Index", index ); 1198 config->writeEntry( "Index", index );
1199 else 1199 else
1200 config->deleteEntry("Index"); 1200 config->deleteEntry("Index");
1201//US the older version of KDE (used on the Zaurus) has no Offset property 1201//US the older version of KDE (used on the Zaurus) has no Offset property
1202/* if ( offset() != d->OffsetDefault ) 1202/* if ( offset() != d->OffsetDefault )
1203 config->writeEntry( "Offset", offset() ); 1203 config->writeEntry( "Offset", offset() );
1204 else 1204 else
1205*/ 1205*/
1206 config->deleteEntry("Offset"); 1206 config->deleteEntry("Offset");
1207 1207
1208//US the older version of KDE (used on the Zaurus) has no NewLine property 1208//US the older version of KDE (used on the Zaurus) has no NewLine property
1209/* 1209/*
1210 if ( newLine() != d->NewLineDefault ) 1210 if ( newLine() != d->NewLineDefault )
1211 config->writeEntry( "NewLine", newLine() ); 1211 config->writeEntry( "NewLine", newLine() );
1212 else 1212 else
1213*/ 1213*/
1214 config->deleteEntry("NewLine"); 1214 config->deleteEntry("NewLine");
1215} 1215}
1216 1216
1217void KToolBar::setXMLGUIClient( KXMLGUIClient *client ) 1217void KToolBar::setXMLGUIClient( KXMLGUIClient *client )
1218{ 1218{
1219 d->m_xmlguiClient = client; 1219 d->m_xmlguiClient = client;
1220} 1220}
1221 1221
1222void KToolBar::setText( const QString & txt ) 1222void KToolBar::setText( const QString & txt )
1223{ 1223{
1224//US setLabel( txt + " ( " + kapp->caption() + " ) " ); 1224//US setLabel( txt + " ( " + kapp->caption() + " ) " );
1225 setLabel( txt + " ( " + KGlobal::getAppName() + " ) " ); 1225 setLabel( txt + " ( " + KGlobal::getAppName() + " ) " );
1226} 1226}
1227 1227
1228 1228
1229QString KToolBar::text() const 1229QString KToolBar::text() const
1230{ 1230{
1231 return label(); 1231 return label();
1232} 1232}
1233 1233
1234 1234
1235void KToolBar::doConnections( KToolBarButton *button ) 1235void KToolBar::doConnections( KToolBarButton *button )
1236{ 1236{
1237 connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) ); 1237 connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) );
1238 connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) ); 1238 connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) );
1239 connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) ); 1239 connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) );
1240 connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) ); 1240 connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) );
1241 connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) ); 1241 connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) );
1242 connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) ); 1242 connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) );
1243} 1243}
1244 1244
1245void KToolBar::mousePressEvent ( QMouseEvent *m ) 1245void KToolBar::mousePressEvent ( QMouseEvent *m )
1246{ 1246{
1247 if ( !mainWindow() ) 1247 if ( !mainWindow() )
1248 return; 1248 return;
1249 QMainWindow *mw = mainWindow(); 1249 QMainWindow *mw = mainWindow();
1250 if ( mw->toolBarsMovable() && d->m_enableContext ) { 1250 if ( mw->toolBarsMovable() && d->m_enableContext ) {
1251 if ( m->button() == RightButton ) { 1251 if ( m->button() == RightButton ) {
1252 int i = contextMenu()->exec( m->globalPos(), 0 ); 1252 int i = contextMenu()->exec( m->globalPos(), 0 );
1253 switch ( i ) { 1253 switch ( i ) {
1254 case -1: 1254 case -1:
1255 return; // popup cancelled 1255 return; // popup cancelled
1256 case CONTEXT_LEFT: 1256 case CONTEXT_LEFT:
1257//US mw->moveDockWindow( this, DockLeft ); 1257//US mw->moveDockWindow( this, DockLeft );
1258 mw->moveToolBar( this, QMainWindow::Left ); 1258 mw->moveToolBar( this, QMainWindow::Left );
1259 break; 1259 break;
1260 case CONTEXT_RIGHT: 1260 case CONTEXT_RIGHT:
1261//US mw->moveDockWindow( this, DockRight ); 1261//US mw->moveDockWindow( this, DockRight );
1262 mw->moveToolBar( this, QMainWindow::Right ); 1262 mw->moveToolBar( this, QMainWindow::Right );
1263 break; 1263 break;
1264 case CONTEXT_TOP: 1264 case CONTEXT_TOP:
1265//US mw->moveDockWindow( this, DockTop ); 1265//US mw->moveDockWindow( this, DockTop );
1266 mw->moveToolBar( this, QMainWindow::Top ); 1266 mw->moveToolBar( this, QMainWindow::Top );
1267 break; 1267 break;
1268 case CONTEXT_BOTTOM: 1268 case CONTEXT_BOTTOM:
1269//US mw->moveDockWindow( this, DockBottom ); 1269//US mw->moveDockWindow( this, DockBottom );
1270 mw->moveToolBar( this, QMainWindow::Bottom ); 1270 mw->moveToolBar( this, QMainWindow::Bottom );
1271 break; 1271 break;
1272 case CONTEXT_FLOAT: 1272 case CONTEXT_FLOAT:
1273 break; 1273 break;
1274 case CONTEXT_FLAT: 1274 case CONTEXT_FLAT:
1275//US mw->moveDockWindow( this, DockMinimized ); 1275//US mw->moveDockWindow( this, DockMinimized );
1276 mw->moveToolBar( this, QMainWindow::Minimized ); 1276 mw->moveToolBar( this, QMainWindow::Minimized );
1277 break; 1277 break;
1278 case CONTEXT_ICONS: 1278 case CONTEXT_ICONS:
1279 setIconText( IconOnly ); 1279 setIconText( IconOnly );
1280 break; 1280 break;
1281 case CONTEXT_TEXTRIGHT: 1281 case CONTEXT_TEXTRIGHT:
1282 setIconText( IconTextRight ); 1282 setIconText( IconTextRight );
1283 break; 1283 break;
1284 case CONTEXT_TEXT: 1284 case CONTEXT_TEXT:
1285 setIconText( TextOnly ); 1285 setIconText( TextOnly );
1286 break; 1286 break;
1287 case CONTEXT_TEXTUNDER: 1287 case CONTEXT_TEXTUNDER:
1288 setIconText( IconTextBottom ); 1288 setIconText( IconTextBottom );
1289 break; 1289 break;
1290 default: 1290 default:
1291 if ( i >= CONTEXT_ICONSIZES ) 1291 if ( i >= CONTEXT_ICONSIZES )
1292 setIconSize( i - CONTEXT_ICONSIZES ); 1292 setIconSize( i - CONTEXT_ICONSIZES );
1293 else 1293 else
1294 return; // assume this was an action handled elsewhere, no need for setSettingsDirty() 1294 return; // assume this was an action handled elsewhere, no need for setSettingsDirty()
1295 } 1295 }
1296/*US 1296/*US
1297 if ( mw->inherits("KMainWindow") ) 1297 if ( mw->inherits("KMainWindow") )
1298 static_cast<KMainWindow *>(mw)->setSettingsDirty(); 1298 static_cast<KMainWindow *>(mw)->setSettingsDirty();
1299*/ 1299*/
1300 } 1300 }
1301 } 1301 }
1302} 1302}
1303 1303
1304 1304
1305void KToolBar::rebuildLayout() 1305void KToolBar::rebuildLayout()
1306{ 1306{
1307 1307
1308 for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next()) 1308 for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next())
1309 w->blockSignals(false); 1309 w->blockSignals(false);
1310 d->idleButtons.clear(); 1310 d->idleButtons.clear();
1311 1311
1312 layoutTimer->stop(); 1312 layoutTimer->stop();
1313 QApplication::sendPostedEvents( this, QEvent::ChildInserted ); 1313 QApplication::sendPostedEvents( this, QEvent::ChildInserted );
1314 QBoxLayout *l = boxLayout(); 1314 QBoxLayout *l = boxLayout();
1315 l->setMargin( 1 ); 1315 l->setMargin( 1 );
1316 // clear the old layout 1316 // clear the old layout
1317 QLayoutIterator it = l->iterator(); 1317 QLayoutIterator it = l->iterator();
1318 1318
1319 while ( it.current() ) { 1319 while ( it.current() ) {
1320 it.deleteCurrent(); 1320 it.deleteCurrent();
1321 } 1321 }
1322 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { 1322 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
1323 if ( w == rightAligned ) { 1323 if ( w == rightAligned ) {
1324 continue; 1324 continue;
1325 } 1325 }
1326 if ( w->inherits( "KToolBarSeparator" ) && 1326 if ( w->inherits( "KToolBarSeparator" ) &&
1327 !( (KToolBarSeparator*)w )->showLine() ) { 1327 !( (KToolBarSeparator*)w )->showLine() ) {
1328 l->addSpacing( 6 ); 1328 l->addSpacing( 6 );
1329 w->hide(); 1329 w->hide();
1330 continue; 1330 continue;
1331 } 1331 }
1332 if ( w->inherits( "QPopupMenu" ) ) 1332 if ( w->inherits( "QPopupMenu" ) )
1333 continue; 1333 continue;
1334 l->addWidget( w ); 1334 l->addWidget( w );
1335 w->show(); 1335 w->show();
1336 } 1336 }
1337 if ( rightAligned ) { 1337 if ( rightAligned ) {
1338 l->addStretch(); 1338 l->addStretch();
1339 l->addWidget( rightAligned ); 1339 l->addWidget( rightAligned );
1340 rightAligned->show(); 1340 rightAligned->show();
1341 } 1341 }
1342 1342
1343 if ( fullSize() ) { 1343 if ( fullSize() ) {
1344 // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword). 1344 // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword).
1345 //if ( !stretchableWidget && widgets.last() && 1345 //if ( !stretchableWidget && widgets.last() &&
1346 // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) 1346 // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) )
1347 // setStretchableWidget( widgets.last() ); 1347 // setStretchableWidget( widgets.last() );
1348 if ( !rightAligned ) 1348 if ( !rightAligned )
1349 l->addStretch(); 1349 l->addStretch();
1350 if ( stretchableWidget ) 1350 if ( stretchableWidget )
1351 l->setStretchFactor( stretchableWidget, 10 ); 1351 l->setStretchFactor( stretchableWidget, 10 );
1352 } 1352 }
1353 l->invalidate(); 1353 l->invalidate();
1354 QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); 1354 QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) );
1355 //#endif //DESKTOP_VERSION 1355 //#endif //DESKTOP_VERSION
1356} 1356}
1357 1357
1358void KToolBar::childEvent( QChildEvent *e ) 1358void KToolBar::childEvent( QChildEvent *e )
1359{ 1359{
1360 1360
1361 if ( e->child()->isWidgetType() ) { 1361 if ( e->child()->isWidgetType() ) {
1362 QWidget * w = (QWidget*)e->child(); 1362 QWidget * w = (QWidget*)e->child();
1363 if ( e->type() == QEvent::ChildInserted ) { 1363 if ( e->type() == QEvent::ChildInserted ) {
1364 if ( !e->child()->inherits( "QPopupMenu" ) && 1364 if ( !e->child()->inherits( "QPopupMenu" ) &&
1365 ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) { 1365 ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) {
1366 1366
1367 // prevent items that have been explicitly inserted by insert*() from 1367 // prevent items that have been explicitly inserted by insert*() from
1368 // being inserted again 1368 // being inserted again
1369 if ( !widget2id.contains( w ) ) 1369 if ( !widget2id.contains( w ) )
1370 { 1370 {
1371 int dummy = -1; 1371 int dummy = -1;
1372 insertWidgetInternal( w, dummy, -1 ); 1372 insertWidgetInternal( w, dummy, -1 );
1373 } 1373 }
1374 } 1374 }
1375 } else { 1375 } else {
1376 removeWidgetInternal( w ); 1376 removeWidgetInternal( w );
1377 } 1377 }
1378 if ( isVisibleTo( 0 ) ) 1378 if ( isVisibleTo( 0 ) )
1379 { 1379 {
1380 QBoxLayout *l = boxLayout(); 1380 QBoxLayout *l = boxLayout();
1381 // QLayout *l = layout(); 1381 // QLayout *l = layout();
1382 1382
1383 // clear the old layout so that we don't get unnecassery layout 1383 // clear the old layout so that we don't get unnecassery layout
1384 // changes till we have rebuild the thing 1384 // changes till we have rebuild the thing
1385 QLayoutIterator it = l->iterator(); 1385 QLayoutIterator it = l->iterator();
1386 while ( it.current() ) { 1386 while ( it.current() ) {
1387 it.deleteCurrent(); 1387 it.deleteCurrent();
1388 } 1388 }
1389 layoutTimer->start( 50, TRUE ); 1389 layoutTimer->start( 50, TRUE );
1390 } 1390 }
1391 } 1391 }
1392 QToolBar::childEvent( e ); 1392 QToolBar::childEvent( e );
1393} 1393}
1394 1394
1395void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) 1395void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id )
1396{ 1396{
1397 // we can't have it in widgets, or something is really wrong 1397 // we can't have it in widgets, or something is really wrong
1398 //widgets.removeRef( w ); 1398 //widgets.removeRef( w );
1399 1399
1400 connect( w, SIGNAL( destroyed() ), 1400 connect( w, SIGNAL( destroyed() ),
1401 this, SLOT( widgetDestroyed() ) ); 1401 this, SLOT( widgetDestroyed() ) );
1402 if ( index == -1 || index > (int)widgets.count() ) { 1402 if ( index == -1 || index > (int)widgets.count() ) {
1403 widgets.append( w ); 1403 widgets.append( w );
1404 index = (int)widgets.count(); 1404 index = (int)widgets.count();
1405 } 1405 }
1406 else 1406 else
1407 widgets.insert( index, w ); 1407 widgets.insert( index, w );
1408 if ( id == -1 ) 1408 if ( id == -1 )
1409 id = id2widget.count(); 1409 id = id2widget.count();
1410 id2widget.insert( id, w ); 1410 id2widget.insert( id, w );
1411 widget2id.insert( w, id ); 1411 widget2id.insert( w, id );
1412} 1412}
1413void KToolBar::repaintMe()
1414{
1415 setUpdatesEnabled( true );
1416 QToolBar::repaint( true );
1417 qDebug(" KToolBar::repaintMe() ");
1418}
1413 1419
1414void KToolBar::showEvent( QShowEvent *e ) 1420void KToolBar::showEvent( QShowEvent *e )
1415{ 1421{
1416 QToolBar::showEvent( e ); 1422 QToolBar::showEvent( e );
1417 rebuildLayout(); 1423 rebuildLayout();
1418} 1424}
1419 1425
1420void KToolBar::setStretchableWidget( QWidget *w ) 1426void KToolBar::setStretchableWidget( QWidget *w )
1421{ 1427{
1422 QToolBar::setStretchableWidget( w ); 1428 QToolBar::setStretchableWidget( w );
1423 stretchableWidget = w; 1429 stretchableWidget = w;
1424} 1430}
1425 1431
1426QSizePolicy KToolBar::sizePolicy() const 1432QSizePolicy KToolBar::sizePolicy() const
1427{ 1433{
1428 if ( orientation() == Horizontal ) 1434 if ( orientation() == Horizontal )
1429 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); 1435 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
1430 else 1436 else
1431 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); 1437 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding );
1432} 1438}
1433 1439
1434QSize KToolBar::sizeHint() const 1440QSize KToolBar::sizeHint() const
1435{ 1441{
1436 return QToolBar::sizeHint(); 1442 return QToolBar::sizeHint();
1437#if 0 1443#if 0
1438 QWidget::polish(); 1444 QWidget::polish();
1439 static int iii = 0; 1445 static int iii = 0;
1440 ++iii; 1446 ++iii;
1441 qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); 1447 qDebug("++++++++ KToolBar::sizeHint() %d ", iii );
1442 int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); 1448 int margin = static_cast<QWidget*>(ncThis)->layout()->margin();
1443 switch( barPos() ) 1449 switch( barPos() )
1444 { 1450 {
1445 case KToolBar::Top: 1451 case KToolBar::Top:
1446 case KToolBar::Bottom: 1452 case KToolBar::Bottom:
1447 for ( QWidget *w = widgets.first(); w; w =widgets.next() ) 1453 for ( QWidget *w = widgets.first(); w; w =widgets.next() )
1448 { 1454 {
1449 if ( w->inherits( "KToolBarSeparator" ) && 1455 if ( w->inherits( "KToolBarSeparator" ) &&
1450 !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) 1456 !( static_cast<KToolBarSeparator*>(w)->showLine() ) )
1451 { 1457 {
1452 minSize += QSize(6, 0); 1458 minSize += QSize(6, 0);
1453 } 1459 }
1454 else 1460 else
1455 { 1461 {
1456 QSize sh = w->sizeHint(); 1462 QSize sh = w->sizeHint();
1457 if (!sh.isValid()) 1463 if (!sh.isValid())
1458 sh = w->minimumSize(); 1464 sh = w->minimumSize();
1459 minSize = minSize.expandedTo(QSize(0, sh.height())); 1465 minSize = minSize.expandedTo(QSize(0, sh.height()));
1460 minSize += QSize(sh.width()+1, 0); 1466 minSize += QSize(sh.width()+1, 0);
1461 } 1467 }
1462 } 1468 }
1463/*US 1469/*US
1464 minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0); 1470 minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0);
1465*/ 1471*/
1466 minSize += QSize(margin*2, margin*2); 1472 minSize += QSize(margin*2, margin*2);
1467 break; 1473 break;
1468 1474
1469 case KToolBar::Left: 1475 case KToolBar::Left:
1470 case KToolBar::Right: 1476 case KToolBar::Right:
1471 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) 1477 for ( QWidget *w = widgets.first(); w; w = widgets.next() )
1472 { 1478 {
1473 if ( w->inherits( "KToolBarSeparator" ) && 1479 if ( w->inherits( "KToolBarSeparator" ) &&
1474 !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) 1480 !( static_cast<KToolBarSeparator*>(w)->showLine() ) )
1475 { 1481 {
1476 minSize += QSize(0, 6); 1482 minSize += QSize(0, 6);
1477 } 1483 }
1478 else 1484 else
1479 { 1485 {
1480 QSize sh = w->sizeHint(); 1486 QSize sh = w->sizeHint();
1481 if (!sh.isValid()) 1487 if (!sh.isValid())
1482 sh = w->minimumSize(); 1488 sh = w->minimumSize();
1483 minSize = minSize.expandedTo(QSize(sh.width(), 0)); 1489 minSize = minSize.expandedTo(QSize(sh.width(), 0));
1484 minSize += QSize(0, sh.height()+1); 1490 minSize += QSize(0, sh.height()+1);
1485 } 1491 }
1486 } 1492 }
1487/*US 1493/*US
1488 minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); 1494 minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ));
1489*/ 1495*/
1490 minSize += QSize(margin*2, margin*2); 1496 minSize += QSize(margin*2, margin*2);
1491 break; 1497 break;
1492 1498
1493 default: 1499 default:
1494 minSize = QToolBar::sizeHint(); 1500 minSize = QToolBar::sizeHint();
1495 break; 1501 break;
1496 } 1502 }
1497 return minSize; 1503 return minSize;
1498#endif 1504#endif
1499} 1505}
1500 1506
1501QSize KToolBar::minimumSize() const 1507QSize KToolBar::minimumSize() const
1502{ 1508{
1503 return minimumSizeHint(); 1509 return minimumSizeHint();
1504} 1510}
1505 1511
1506QSize KToolBar::minimumSizeHint() const 1512QSize KToolBar::minimumSizeHint() const
1507{ 1513{
1508 return sizeHint(); 1514 return sizeHint();
1509} 1515}
1510 1516
1511bool KToolBar::highlight() const 1517bool KToolBar::highlight() const
1512{ 1518{
1513 return d->m_highlight; 1519 return d->m_highlight;
1514} 1520}
1515 1521
1516void KToolBar::hide() 1522void KToolBar::hide()
1517{ 1523{
1518 QToolBar::hide(); 1524 QToolBar::hide();
1519} 1525}
1520 1526
1521void KToolBar::show() 1527void KToolBar::show()
1522{ 1528{
1523 QToolBar::show(); 1529 QToolBar::show();
1524} 1530}
1525 1531
1526void KToolBar::resizeEvent( QResizeEvent *e ) 1532void KToolBar::resizeEvent( QResizeEvent *e )
1527{ 1533{
1528 bool b = isUpdatesEnabled(); 1534 bool b = isUpdatesEnabled();
1529 setUpdatesEnabled( FALSE ); 1535 setUpdatesEnabled( FALSE );
1530 QToolBar::resizeEvent( e ); 1536 QToolBar::resizeEvent( e );
1531 if (b) 1537 if (b)
1532 d->repaintTimer.start( 100, true ); 1538 d->repaintTimer.start( 100, true );
1533} 1539}
1534 1540
1535void KToolBar::slotIconChanged(int group) 1541void KToolBar::slotIconChanged(int group)
1536{ 1542{
1537 if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar)) 1543 if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar))
1538 return; 1544 return;
1539 if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar")) 1545 if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar"))
1540 return; 1546 return;
1541 1547
1542 emit modechange(); 1548 emit modechange();
1543 if (isVisible()) 1549 if (isVisible())
1544 updateGeometry(); 1550 updateGeometry();
1545} 1551}
1546 1552
1547void KToolBar::slotReadConfig() 1553void KToolBar::slotReadConfig()
1548{ 1554{
1549 //kdDebug(220) << "KToolBar::slotReadConfig" << endl; 1555 //kdDebug(220) << "KToolBar::slotReadConfig" << endl;
1550 // Read appearance settings (hmm, we used to do both here, 1556 // Read appearance settings (hmm, we used to do both here,
1551 // but a well behaved application will call applyMainWindowSettings 1557 // but a well behaved application will call applyMainWindowSettings
1552 // anyway, right ?) 1558 // anyway, right ?)
1553 applyAppearanceSettings(KGlobal::config(), QString::null ); 1559 applyAppearanceSettings(KGlobal::config(), QString::null );
1554} 1560}
1555 1561
1556void KToolBar::slotAppearanceChanged() 1562void KToolBar::slotAppearanceChanged()
1557{ 1563{
1558 // Read appearance settings from global file. 1564 // Read appearance settings from global file.
1559 applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ ); 1565 applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ );
1560 // And remember to save the new look later 1566 // And remember to save the new look later
1561/*US 1567/*US
1562 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) 1568 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) )
1563 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1569 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1564*/ 1570*/
1565} 1571}
1566 1572
1567//static 1573//static
1568bool KToolBar::highlightSetting() 1574bool KToolBar::highlightSetting()
1569{ 1575{
1570 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1576 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1571 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1577 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1572 return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true); 1578 return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true);
1573} 1579}
1574 1580
1575//static 1581//static
1576bool KToolBar::transparentSetting() 1582bool KToolBar::transparentSetting()
1577{ 1583{
1578 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1584 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1579 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1585 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1580 return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true); 1586 return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true);
1581} 1587}
1582 1588
1583//static 1589//static
1584KToolBar::IconText KToolBar::iconTextSetting() 1590KToolBar::IconText KToolBar::iconTextSetting()
1585{ 1591{
1586 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1592 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1587 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1593 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1588 QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly")); 1594 QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly"));
1589 if ( icontext == "IconTextRight" ) 1595 if ( icontext == "IconTextRight" )
1590 return IconTextRight; 1596 return IconTextRight;
1591 else if ( icontext == "IconTextBottom" ) 1597 else if ( icontext == "IconTextBottom" )
1592 return IconTextBottom; 1598 return IconTextBottom;
1593 else if ( icontext == "TextOnly" ) 1599 else if ( icontext == "TextOnly" )
1594 return TextOnly; 1600 return TextOnly;
1595 else 1601 else
1596 return IconOnly; 1602 return IconOnly;
1597} 1603}
1598 1604
1599void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal) 1605void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal)
1600{ 1606{
1601 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; 1607 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup;
1602 //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl; 1608 //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl;
1603 // We have application-specific settings in the XML file, 1609 // We have application-specific settings in the XML file,
1604 // and nothing in the application's config file 1610 // and nothing in the application's config file
1605 // -> don't apply the global defaults, the XML ones are preferred 1611 // -> don't apply the global defaults, the XML ones are preferred
1606 // See applySettings for a full explanation 1612 // See applySettings for a full explanation
1607/*US :we do not support xml files 1613/*US :we do not support xml files
1608 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() && 1614 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() &&
1609 !config->hasGroup(configGroup) ) 1615 !config->hasGroup(configGroup) )
1610 { 1616 {
1611 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; 1617 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl;
1612 return; 1618 return;
1613 } 1619 }
1614*/ 1620*/
1615 if ( !config->hasGroup(configGroup) ) 1621 if ( !config->hasGroup(configGroup) )
1616 { 1622 {
1617 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; 1623 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl;
1618 return; 1624 return;
1619 } 1625 }
1620 1626
1621 1627
1622 KConfig *gconfig = KGlobal::config(); 1628 KConfig *gconfig = KGlobal::config();
1623/*US 1629/*US
1624 static const QString &attrIconText = KGlobal::staticQString("IconText"); 1630 static const QString &attrIconText = KGlobal::staticQString("IconText");
1625 static const QString &attrHighlight = KGlobal::staticQString("Highlighting"); 1631 static const QString &attrHighlight = KGlobal::staticQString("Highlighting");
1626 static const QString &attrTrans = KGlobal::staticQString("TransparentMoving"); 1632 static const QString &attrTrans = KGlobal::staticQString("TransparentMoving");
1627 static const QString &attrSize = KGlobal::staticQString("IconSize"); 1633 static const QString &attrSize = KGlobal::staticQString("IconSize");
1628*/ 1634*/
1629 // we actually do this in two steps. 1635 // we actually do this in two steps.
1630 // First, we read in the global styles [Toolbar style] (from the KControl module). 1636 // First, we read in the global styles [Toolbar style] (from the KControl module).
1631 // Then, if the toolbar is NOT 'mainToolBar', we will also try to read in [barname Toolbar style] 1637 // Then, if the toolbar is NOT 'mainToolBar', we will also try to read in [barname Toolbar style]
1632 bool highlight; 1638 bool highlight;
1633 int transparent; 1639 int transparent;
1634 QString icontext; 1640 QString icontext;
1635 int iconsize = 0; 1641 int iconsize = 0;
1636 1642
1637 // this is the first iteration 1643 // this is the first iteration
1638 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1644 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1639 { // start block for KConfigGroupSaver 1645 { // start block for KConfigGroupSaver
1640 KConfigGroupSaver saver(gconfig, grpToolbar); 1646 KConfigGroupSaver saver(gconfig, grpToolbar);
1641 1647
1642 // first, get the generic settings 1648 // first, get the generic settings
1643//US highlight = gconfig->readBoolEntry(attrHighlight, true); 1649//US highlight = gconfig->readBoolEntry(attrHighlight, true);
1644 highlight = gconfig->readBoolEntry("Highlighting", true); 1650 highlight = gconfig->readBoolEntry("Highlighting", true);
1645//US transparent = gconfig->readBoolEntry(attrTrans, true); 1651//US transparent = gconfig->readBoolEntry(attrTrans, true);
1646 transparent = gconfig->readBoolEntry("TransparentMoving", true); 1652 transparent = gconfig->readBoolEntry("TransparentMoving", true);
1647 1653
1648 // we read in the IconText property *only* if we intend on actually 1654 // we read in the IconText property *only* if we intend on actually
1649 // honoring it 1655 // honoring it
1650 if (d->m_honorStyle) 1656 if (d->m_honorStyle)
1651//US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault); 1657//US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault);
1652 d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault); 1658 d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault);
1653 else 1659 else
1654 d->IconTextDefault = "IconOnly"; 1660 d->IconTextDefault = "IconOnly";
1655 1661
1656 // Use the default icon size for toolbar icons. 1662 // Use the default icon size for toolbar icons.
1657//US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault); 1663//US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault);
1658 d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault); 1664 d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault);
1659 1665
1660 if ( !forceGlobal && config->hasGroup(configGroup) ) 1666 if ( !forceGlobal && config->hasGroup(configGroup) )
1661 { 1667 {
1662 config->setGroup(configGroup); 1668 config->setGroup(configGroup);
1663 1669
1664 // first, get the generic settings 1670 // first, get the generic settings
1665//US highlight = config->readBoolEntry(attrHighlight, highlight); 1671//US highlight = config->readBoolEntry(attrHighlight, highlight);
1666 highlight = config->readBoolEntry("Highlighting", highlight); 1672 highlight = config->readBoolEntry("Highlighting", highlight);
1667//US transparent = config->readBoolEntry(attrTrans, transparent); 1673//US transparent = config->readBoolEntry(attrTrans, transparent);
1668 transparent = config->readBoolEntry("TransparentMoving", transparent); 1674 transparent = config->readBoolEntry("TransparentMoving", transparent);
1669 // now we always read in the IconText property 1675 // now we always read in the IconText property
1670//US icontext = config->readEntry(attrIconText, d->IconTextDefault); 1676//US icontext = config->readEntry(attrIconText, d->IconTextDefault);
1671 icontext = config->readEntry("IconText", d->IconTextDefault); 1677 icontext = config->readEntry("IconText", d->IconTextDefault);
1672 1678
1673 // now get the size 1679 // now get the size
1674//US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault); 1680//US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault);
1675 iconsize = config->readNumEntry("IconSize", d->IconSizeDefault); 1681 iconsize = config->readNumEntry("IconSize", d->IconSizeDefault);
1676 } 1682 }
1677 else 1683 else
1678 { 1684 {
1679 iconsize = d->IconSizeDefault; 1685 iconsize = d->IconSizeDefault;
1680 icontext = d->IconTextDefault; 1686 icontext = d->IconTextDefault;
1681 } 1687 }
1682 1688
1683 // revert back to the old group 1689 // revert back to the old group
1684 } // end block for KConfigGroupSaver 1690 } // end block for KConfigGroupSaver
1685 1691
1686 bool doUpdate = false; 1692 bool doUpdate = false;
1687 1693
1688 IconText icon_text; 1694 IconText icon_text;
1689 if ( icontext == "IconTextRight" ) 1695 if ( icontext == "IconTextRight" )
1690 icon_text = IconTextRight; 1696 icon_text = IconTextRight;
1691 else if ( icontext == "IconTextBottom" ) 1697 else if ( icontext == "IconTextBottom" )
1692 icon_text = IconTextBottom; 1698 icon_text = IconTextBottom;
1693 else if ( icontext == "TextOnly" ) 1699 else if ( icontext == "TextOnly" )
1694 icon_text = TextOnly; 1700 icon_text = TextOnly;
1695 else 1701 else
1696 icon_text = IconOnly; 1702 icon_text = IconOnly;
1697 1703
1698 // check if the icon/text has changed 1704 // check if the icon/text has changed
1699 if (icon_text != d->m_iconText) { 1705 if (icon_text != d->m_iconText) {
1700 //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl; 1706 //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl;
1701 setIconText(icon_text, false); 1707 setIconText(icon_text, false);
1702 doUpdate = true; 1708 doUpdate = true;
1703 } 1709 }
1704 1710
1705 // ...and check if the icon size has changed 1711 // ...and check if the icon size has changed
1706 if (iconsize != d->m_iconSize) { 1712 if (iconsize != d->m_iconSize) {
1707 setIconSize(iconsize, false); 1713 setIconSize(iconsize, false);
1708 doUpdate = true; 1714 doUpdate = true;
1709 } 1715 }
1710 1716
1711 QMainWindow *mw = mainWindow(); 1717 QMainWindow *mw = mainWindow();
1712 1718
1713 // ...and if we should highlight 1719 // ...and if we should highlight
1714 if ( highlight != d->m_highlight ) { 1720 if ( highlight != d->m_highlight ) {
1715 d->m_highlight = highlight; 1721 d->m_highlight = highlight;
1716 doUpdate = true; 1722 doUpdate = true;
1717 } 1723 }
1718 1724
1719 // ...and if we should move transparently 1725 // ...and if we should move transparently
1720 if ( mw && transparent != (!mw->opaqueMoving()) ) { 1726 if ( mw && transparent != (!mw->opaqueMoving()) ) {
1721 mw->setOpaqueMoving( !transparent ); 1727 mw->setOpaqueMoving( !transparent );
1722 } 1728 }
1723 1729
1724 if (doUpdate) 1730 if (doUpdate)
1725 emit modechange(); // tell buttons what happened 1731 emit modechange(); // tell buttons what happened
1726 if (isVisible ()) 1732 if (isVisible ())
1727 updateGeometry(); 1733 updateGeometry();
1728} 1734}
1729 1735
1730void KToolBar::applySettings(KConfig *config, const QString &_configGroup) 1736void KToolBar::applySettings(KConfig *config, const QString &_configGroup)
1731{ 1737{
1732 //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl; 1738 //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl;
1733 1739
1734 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; 1740 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup;
1735 1741
1736 /* 1742 /*
1737 Let's explain this a bit more in details. 1743 Let's explain this a bit more in details.
1738 The order in which we apply settings is : 1744 The order in which we apply settings is :
1739 Global config / <appnamerc> user settings if no XMLGUI is used 1745 Global config / <appnamerc> user settings if no XMLGUI is used
1740 Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used 1746 Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used
1741 1747
1742 So in the first case, we simply read everything from KConfig as below, 1748 So in the first case, we simply read everything from KConfig as below,
1743 but in the second case we don't do anything here if there is no app-specific config, 1749 but in the second case we don't do anything here if there is no app-specific config,
1744 and the XMLGUI uses the static methods of this class to get the global defaults. 1750 and the XMLGUI uses the static methods of this class to get the global defaults.
1745 1751
1746 Global config doesn't include position (index, offset, newline and hidden/shown). 1752 Global config doesn't include position (index, offset, newline and hidden/shown).
1747 */ 1753 */
1748 1754
1749 // First the appearance stuff - the one which has a global config 1755 // First the appearance stuff - the one which has a global config
1750 applyAppearanceSettings( config, _configGroup ); 1756 applyAppearanceSettings( config, _configGroup );
1751 1757
1752 // ...and now the position stuff 1758 // ...and now the position stuff
1753 if ( config->hasGroup(configGroup) ) 1759 if ( config->hasGroup(configGroup) )
1754 { 1760 {
1755 KConfigGroupSaver cgs(config, configGroup); 1761 KConfigGroupSaver cgs(config, configGroup);
1756/*US 1762/*US
1757 static const QString &attrPosition = KGlobal::staticQString("Position"); 1763 static const QString &attrPosition = KGlobal::staticQString("Position");
1758 static const QString &attrIndex = KGlobal::staticQString("Index"); 1764 static const QString &attrIndex = KGlobal::staticQString("Index");
1759 static const QString &attrOffset = KGlobal::staticQString("Offset"); 1765 static const QString &attrOffset = KGlobal::staticQString("Offset");
1760 static const QString &attrNewLine = KGlobal::staticQString("NewLine"); 1766 static const QString &attrNewLine = KGlobal::staticQString("NewLine");
1761 static const QString &attrHidden = KGlobal::staticQString("Hidden"); 1767 static const QString &attrHidden = KGlobal::staticQString("Hidden");
1762 1768
1763 QString position = config->readEntry(attrPosition, d->PositionDefault); 1769 QString position = config->readEntry(attrPosition, d->PositionDefault);
1764 int index = config->readNumEntry(attrIndex, d->IndexDefault); 1770 int index = config->readNumEntry(attrIndex, d->IndexDefault);
1765 int offset = config->readNumEntry(attrOffset, d->OffsetDefault); 1771 int offset = config->readNumEntry(attrOffset, d->OffsetDefault);
1766 bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault); 1772 bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault);
1767 bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault); 1773 bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault);
1768*/ 1774*/
1769 1775
1770 QString position = config->readEntry("Position", d->PositionDefault); 1776 QString position = config->readEntry("Position", d->PositionDefault);
1771 int index = config->readNumEntry("Index", d->IndexDefault); 1777 int index = config->readNumEntry("Index", d->IndexDefault);
1772 int offset = config->readNumEntry("Offset", d->OffsetDefault); 1778 int offset = config->readNumEntry("Offset", d->OffsetDefault);
1773 bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault); 1779 bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault);
1774 bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault); 1780 bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault);
1775 1781
1776/*US Dock pos(DockTop); 1782/*US Dock pos(DockTop);
1777 if ( position == "Top" ) 1783 if ( position == "Top" )
1778 pos = DockTop; 1784 pos = DockTop;
1779 else if ( position == "Bottom" ) 1785 else if ( position == "Bottom" )
1780 pos = DockBottom; 1786 pos = DockBottom;
1781 else if ( position == "Left" ) 1787 else if ( position == "Left" )
1782 pos = DockLeft; 1788 pos = DockLeft;
1783 else if ( position == "Right" ) 1789 else if ( position == "Right" )
1784 pos = DockRight; 1790 pos = DockRight;
1785 else if ( position == "Floating" ) 1791 else if ( position == "Floating" )
1786 pos = DockTornOff; 1792 pos = DockTornOff;
1787 else if ( position == "Flat" ) 1793 else if ( position == "Flat" )
1788 pos = DockMinimized; 1794 pos = DockMinimized;
1789*/ 1795*/
1790 QMainWindow::ToolBarDock pos(QMainWindow::Top); 1796 QMainWindow::ToolBarDock pos(QMainWindow::Top);
1791 if ( position == "Top" ) 1797 if ( position == "Top" )
1792 pos = QMainWindow::Top; 1798 pos = QMainWindow::Top;
1793 else if ( position == "Bottom" ) 1799 else if ( position == "Bottom" )
1794 pos = QMainWindow::Bottom; 1800 pos = QMainWindow::Bottom;
1795 else if ( position == "Left" ) 1801 else if ( position == "Left" )
1796 pos = QMainWindow::Left; 1802 pos = QMainWindow::Left;
diff --git a/microkde/kdeui/ktoolbar.h b/microkde/kdeui/ktoolbar.h
index 2c061b5..61b5ea3 100644
--- a/microkde/kdeui/ktoolbar.h
+++ b/microkde/kdeui/ktoolbar.h
@@ -664,444 +664,445 @@ public:
664 * This works only if the toolbar is set to full width. 664 * This works only if the toolbar is set to full width.
665 * Only @p one item can be autosized, and it has to be 665 * Only @p one item can be autosized, and it has to be
666 * the last left-aligned item. Items that come after this must be right 666 * the last left-aligned item. Items that come after this must be right
667 * aligned. Items that can be right aligned are Lineds, Frames, Widgets and 667 * aligned. Items that can be right aligned are Lineds, Frames, Widgets and
668 * Combos. An autosized item will resize itself whenever the toolbar geometry 668 * Combos. An autosized item will resize itself whenever the toolbar geometry
669 * changes to the last right-aligned item (or to end of toolbar if there 669 * changes to the last right-aligned item (or to end of toolbar if there
670 * are no right-aligned items.) 670 * are no right-aligned items.)
671 * @see setFullWidth() 671 * @see setFullWidth()
672 * @see alignItemRight() 672 * @see alignItemRight()
673 */ 673 */
674 void setItemAutoSized (int id, bool yes = true); 674 void setItemAutoSized (int id, bool yes = true);
675 675
676 /** 676 /**
677 * Remove all items. 677 * Remove all items.
678 * 678 *
679 * The toolbar is redrawn after it. 679 * The toolbar is redrawn after it.
680 */ 680 */
681 void clear (); 681 void clear ();
682 682
683 /** 683 /**
684 * Remove item @p id. 684 * Remove item @p id.
685 * 685 *
686 * Item is deleted. Toolbar is redrawn after it. 686 * Item is deleted. Toolbar is redrawn after it.
687 */ 687 */
688 void removeItem (int id); 688 void removeItem (int id);
689 689
690 /** 690 /**
691 * Remove item @p id. 691 * Remove item @p id.
692 * 692 *
693 * Item is deleted when toolbar is redrawn. 693 * Item is deleted when toolbar is redrawn.
694 */ 694 */
695 void removeItemDelayed (int id); 695 void removeItemDelayed (int id);
696 696
697 /** 697 /**
698 * Hide item. 698 * Hide item.
699 */ 699 */
700 void hideItem (int id); 700 void hideItem (int id);
701 701
702 /** 702 /**
703 * Show item. 703 * Show item.
704 */ 704 */
705 void showItem (int id); 705 void showItem (int id);
706 706
707 /** 707 /**
708 * Returns the index of the given item. 708 * Returns the index of the given item.
709 * 709 *
710 * KDE4: make this const! 710 * KDE4: make this const!
711 */ 711 */
712 int itemIndex (int id); 712 int itemIndex (int id);
713 713
714 /** 714 /**
715 * Set toolbar to full parent size (default). 715 * Set toolbar to full parent size (default).
716 * 716 *
717 * In full size mode the bar 717 * In full size mode the bar
718 * extends over the parent's full width or height. If the mode is disabled 718 * extends over the parent's full width or height. If the mode is disabled
719 * the toolbar tries to take as much space as it needs without wrapping, but 719 * the toolbar tries to take as much space as it needs without wrapping, but
720 * it does not exceed the parent box. You can force a certain width or 720 * it does not exceed the parent box. You can force a certain width or
721 * height with @ref setMaxWidth() or @ref setMaxHeight(). 721 * height with @ref setMaxWidth() or @ref setMaxHeight().
722 * 722 *
723 * If you want to use right-aligned items or auto-sized items you must use 723 * If you want to use right-aligned items or auto-sized items you must use
724 * full size mode. 724 * full size mode.
725 */ 725 */
726 void setFullSize(bool flag = true); 726 void setFullSize(bool flag = true);
727 727
728 /** 728 /**
729 * @return @p true if the full-size mode is enabled. Otherwise 729 * @return @p true if the full-size mode is enabled. Otherwise
730 * it returns @false. 730 * it returns @false.
731 */ 731 */
732 bool fullSize() const; 732 bool fullSize() const;
733 733
734 /** 734 /**
735 * @deprecated use setMovingEnabled(bool) instead. 735 * @deprecated use setMovingEnabled(bool) instead.
736 * Enable or disable moving of toolbar. 736 * Enable or disable moving of toolbar.
737 */ 737 */
738 void enableMoving(bool flag = true); 738 void enableMoving(bool flag = true);
739 739
740 /** 740 /**
741 * Set position of toolbar. 741 * Set position of toolbar.
742 * @see BarPosition() 742 * @see BarPosition()
743 */ 743 */
744 void setBarPos (BarPosition bpos); 744 void setBarPos (BarPosition bpos);
745 745
746 /** 746 /**
747 * Returns position of toolbar. 747 * Returns position of toolbar.
748 */ 748 */
749 BarPosition barPos(); 749 BarPosition barPos();
750 750
751 /** 751 /**
752 * @deprecated 752 * @deprecated
753 * Show, hide, or toggle toolbar. 753 * Show, hide, or toggle toolbar.
754 * 754 *
755 * This method is provided for compatibility only, 755 * This method is provided for compatibility only,
756 * please use show() and/or hide() instead. 756 * please use show() and/or hide() instead.
757 * @see BarStatus 757 * @see BarStatus
758 */ 758 */
759 bool enable(BarStatus stat); 759 bool enable(BarStatus stat);
760 760
761 /** 761 /**
762 * @deprecated 762 * @deprecated
763 * Use setMaximumHeight() instead. 763 * Use setMaximumHeight() instead.
764 */ 764 */
765 void setMaxHeight (int h); // Set max height for vertical toolbars 765 void setMaxHeight (int h); // Set max height for vertical toolbars
766 766
767 /** 767 /**
768 * @deprecated 768 * @deprecated
769 * Use maximumHeight() instead. 769 * Use maximumHeight() instead.
770 * Returns the value that was set with @ref setMaxHeight(). 770 * Returns the value that was set with @ref setMaxHeight().
771 */ 771 */
772 int maxHeight(); 772 int maxHeight();
773 773
774 /** 774 /**
775 * @deprecated 775 * @deprecated
776 * Use setMaximumWidth() instead. 776 * Use setMaximumWidth() instead.
777 * Set maximal width of horizontal (top or bottom) toolbar. 777 * Set maximal width of horizontal (top or bottom) toolbar.
778 */ 778 */
779 void setMaxWidth (int dw); 779 void setMaxWidth (int dw);
780 780
781 /** 781 /**
782 * @deprecated 782 * @deprecated
783 * Use maximumWidth() instead. 783 * Use maximumWidth() instead.
784 * Returns the value that was set with @ref setMaxWidth(). 784 * Returns the value that was set with @ref setMaxWidth().
785 */ 785 */
786 int maxWidth(); 786 int maxWidth();
787 787
788 /** 788 /**
789 * Set title for toolbar when it floats. 789 * Set title for toolbar when it floats.
790 * 790 *
791 * Titles are however not (yet) 791 * Titles are however not (yet)
792 * visible. You can't change toolbar's title while it's floating. 792 * visible. You can't change toolbar's title while it's floating.
793 */ 793 */
794 void setTitle (const QString& _title); 794 void setTitle (const QString& _title);
795 795
796 /** 796 /**
797 * @deprecated 797 * @deprecated
798 * Use enableMoving() instead. 798 * Use enableMoving() instead.
799 */ 799 */
800 void enableFloating (bool arrrrrrgh); 800 void enableFloating (bool arrrrrrgh);
801 801
802 /** 802 /**
803 * Set the kind of painting for buttons. 803 * Set the kind of painting for buttons.
804 * 804 *
805 * Choose from: 805 * Choose from:
806 * @li IconOnly (only icons), 806 * @li IconOnly (only icons),
807 * @li IconTextRight (icon and text, text is left from icons), 807 * @li IconTextRight (icon and text, text is left from icons),
808 * @li TextOnly (only text), 808 * @li TextOnly (only text),
809 * @li IconTextBottom (icons and text, text is under icons). 809 * @li IconTextBottom (icons and text, text is under icons).
810 * @see IconText 810 * @see IconText
811 * 811 *
812 */ 812 */
813 void setIconText(IconText it); 813 void setIconText(IconText it);
814 // Note: don't merge with the next one, it breaks Qt properties 814 // Note: don't merge with the next one, it breaks Qt properties
815 815
816 /** 816 /**
817 * Similar to @ref setIconText(IconText it) but allows you to 817 * Similar to @ref setIconText(IconText it) but allows you to
818 * disable or enable updating. If @p update is false, then the 818 * disable or enable updating. If @p update is false, then the
819 * buttons will not be updated. This is useful only if you know 819 * buttons will not be updated. This is useful only if you know
820 * that you will be forcing an update later. 820 * that you will be forcing an update later.
821 */ 821 */
822 void setIconText(IconText it, bool update); 822 void setIconText(IconText it, bool update);
823 823
824 /** 824 /**
825 * @return The current text style for buttons. 825 * @return The current text style for buttons.
826 */ 826 */
827 IconText iconText() const; 827 IconText iconText() const;
828 828
829 /** 829 /**
830 * Set the icon size to load. Usually you should not call 830 * Set the icon size to load. Usually you should not call
831 * this, the icon size is taken care of by KIconLoader 831 * this, the icon size is taken care of by KIconLoader
832 * and globally configured. 832 * and globally configured.
833 * By default, the toolbar will load icons of size 32 for main 833 * By default, the toolbar will load icons of size 32 for main
834 * toolbars and 22 for other toolbars 834 * toolbars and 22 for other toolbars
835 * @see KIconLoader. 835 * @see KIconLoader.
836 * 836 *
837 * @param size The size to use 837 * @param size The size to use
838 */ 838 */
839 void setIconSize(int size); 839 void setIconSize(int size);
840 // Note: don't merge with the next one, it breaks Qt properties 840 // Note: don't merge with the next one, it breaks Qt properties
841 841
842 /** 842 /**
843 * Same as @ref setIconText(int size) but allows you 843 * Same as @ref setIconText(int size) but allows you
844 * to disable the toolbar update. 844 * to disable the toolbar update.
845 * 845 *
846 * @param size The size to use 846 * @param size The size to use
847 * @param update If true, then the toolbar will be updated after 847 * @param update If true, then the toolbar will be updated after
848 * this 848 * this
849 */ 849 */
850 void setIconSize(int size, bool update); 850 void setIconSize(int size, bool update);
851 851
852 /** 852 /**
853 * @return The current icon size for buttons. 853 * @return The current icon size for buttons.
854 */ 854 */
855 int iconSize() const; 855 int iconSize() const;
856 856
857 /** 857 /**
858 * This allows you to enable or disable the context menu. 858 * This allows you to enable or disable the context menu.
859 * 859 *
860 * @param enable If false, then the context menu will be disabled 860 * @param enable If false, then the context menu will be disabled
861 */ 861 */
862 void setEnableContextMenu(bool enable = true); 862 void setEnableContextMenu(bool enable = true);
863 863
864 /** 864 /**
865 * Returns whether or not the context menu is disabled 865 * Returns whether or not the context menu is disabled
866 * 866 *
867 * @return The context menu state 867 * @return The context menu state
868 */ 868 */
869 bool contextMenuEnabled() const; 869 bool contextMenuEnabled() const;
870 870
871 /** 871 /**
872 * This will inform a toolbar button to ignore certain style 872 * This will inform a toolbar button to ignore certain style
873 * changes. Specifically, it will ignore IconText (always IconOnly) 873 * changes. Specifically, it will ignore IconText (always IconOnly)
874 * and will not allow image effects to apply. 874 * and will not allow image effects to apply.
875 * 875 *
876 * @param id The button to exclude from styles 876 * @param id The button to exclude from styles
877 * @param no_style If true, then it is excluded (default: true). 877 * @param no_style If true, then it is excluded (default: true).
878 */ 878 */
879 void setItemNoStyle(int id, bool no_style = true); 879 void setItemNoStyle(int id, bool no_style = true);
880 880
881 void setFlat (bool flag); 881 void setFlat (bool flag);
882 882
883 /** 883 /**
884 * @return the number of items in the toolbar 884 * @return the number of items in the toolbar
885 */ 885 */
886 int count() const; 886 int count() const;
887 887
888 /** 888 /**
889 * Instruct the toolbar to save it's current state to either the app 889 * Instruct the toolbar to save it's current state to either the app
890 * config file or to the XML-GUI resource file (whichever has 890 * config file or to the XML-GUI resource file (whichever has
891 * precedence). 891 * precedence).
892 */ 892 */
893 void saveState(); 893 void saveState();
894 894
895 /** 895 /**
896 * Save the toolbar settings to group @p configGroup in @p config. 896 * Save the toolbar settings to group @p configGroup in @p config.
897 */ 897 */
898 void saveSettings(KConfig *config, const QString &configGroup); 898 void saveSettings(KConfig *config, const QString &configGroup);
899 899
900 /** 900 /**
901 * Read the toolbar settings from group @p configGroup in @p config 901 * Read the toolbar settings from group @p configGroup in @p config
902 * and apply them. 902 * and apply them.
903 */ 903 */
904 void applySettings(KConfig *config, const QString &configGroup); 904 void applySettings(KConfig *config, const QString &configGroup);
905 905
906 /** 906 /**
907 * Tell the toolbar what XML-GUI resource file it should use to save 907 * Tell the toolbar what XML-GUI resource file it should use to save
908 * it's state. The state of the toolbar (position, size, etc) is 908 * it's state. The state of the toolbar (position, size, etc) is
909 * saved in KConfig files if the application does not use XML-GUI.. 909 * saved in KConfig files if the application does not use XML-GUI..
910 * but if the app does, then it's saved the XML file. This function 910 * but if the app does, then it's saved the XML file. This function
911 * allows this to happen. 911 * allows this to happen.
912 * 912 *
913 * @param xmlfile The XML-GUI resource file to write to 913 * @param xmlfile The XML-GUI resource file to write to
914 * @param xml The DOM document for the XML-GUI building 914 * @param xml The DOM document for the XML-GUI building
915 */ 915 */
916 // void setXML(const QString& xmlfile, const QDomDocument& xml); 916 // void setXML(const QString& xmlfile, const QDomDocument& xml);
917 /* @internal */ 917 /* @internal */
918 void setXMLGUIClient( KXMLGUIClient *client ); 918 void setXMLGUIClient( KXMLGUIClient *client );
919 919
920 /** 920 /**
921 * Assign a (translated) text to this toolbar. This is used 921 * Assign a (translated) text to this toolbar. This is used
922 * for the tooltip on the handle, and when listing the toolbars. 922 * for the tooltip on the handle, and when listing the toolbars.
923 */ 923 */
924 void setText( const QString & txt ); 924 void setText( const QString & txt );
925 925
926 /** 926 /**
927 * @return the toolbar's text. 927 * @return the toolbar's text.
928 */ 928 */
929 QString text() const; 929 QString text() const;
930 930
931 void setStretchableWidget( QWidget *w ); 931 void setStretchableWidget( QWidget *w );
932 QSizePolicy sizePolicy() const; 932 QSizePolicy sizePolicy() const;
933 bool highlight() const; 933 bool highlight() const;
934 QSize sizeHint() const; 934 QSize sizeHint() const;
935 QSize minimumSizeHint() const; 935 QSize minimumSizeHint() const;
936 QSize minimumSize() const; 936 QSize minimumSize() const;
937 937
938 void hide(); 938 void hide();
939 void show(); 939 void show();
940 940
941 void updateRects( bool = FALSE ) {} 941 void updateRects( bool = FALSE ) {}
942 942
943//US void loadState( const QDomElement &e ); 943//US void loadState( const QDomElement &e );
944//US void saveState( QDomElement &e ); 944//US void saveState( QDomElement &e );
945 945
946 /** 946 /**
947 * @internal 947 * @internal
948 */ 948 */
949 void positionYourself( bool force = false); 949 void positionYourself( bool force = false);
950 950
951signals: 951signals:
952 /** 952 /**
953 * Emitted when button @p id is clicked. 953 * Emitted when button @p id is clicked.
954 */ 954 */
955 void clicked(int id); 955 void clicked(int id);
956 956
957 /** 957 /**
958 * Emitted when button @p id is double-clicked. 958 * Emitted when button @p id is double-clicked.
959 * 959 *
960 * Note: you will always 960 * Note: you will always
961 * recive two @ref clicked() , @ref pressed() and @ref released() signals. 961 * recive two @ref clicked() , @ref pressed() and @ref released() signals.
962 * There is no way to avoid it - at least no easy way. 962 * There is no way to avoid it - at least no easy way.
963 * If you need to resolve this all you can do is set up timers 963 * If you need to resolve this all you can do is set up timers
964 * which wait for @ref QApplication::doubleClickInterval() to expire. 964 * which wait for @ref QApplication::doubleClickInterval() to expire.
965 * If in that time you don't get this signal, you may belive that 965 * If in that time you don't get this signal, you may belive that
966 * button was only clicked and not double-clicked. 966 * button was only clicked and not double-clicked.
967 * And please note that butons with popup menus do not emit this signal, 967 * And please note that butons with popup menus do not emit this signal,
968 * but those with delayed popup do. 968 * but those with delayed popup do.
969 */ 969 */
970 void doubleClicked (int id); 970 void doubleClicked (int id);
971 971
972 /** 972 /**
973 * Emitted when button @p id is pressed. 973 * Emitted when button @p id is pressed.
974 */ 974 */
975 void pressed(int); 975 void pressed(int);
976 976
977 /** 977 /**
978 * Emits when button @p id is released. 978 * Emits when button @p id is released.
979 */ 979 */
980 void released(int); 980 void released(int);
981 981
982 /** 982 /**
983 * Emitted when a toggle button changes state. 983 * Emitted when a toggle button changes state.
984 * 984 *
985 * Emitted also if you change state 985 * Emitted also if you change state
986 * with @ref setButton() or @ref toggleButton() 986 * with @ref setButton() or @ref toggleButton()
987 * If you make a button normal again, with 987 * If you make a button normal again, with
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
1044public: 1044public:
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 static bool highlightSetting(); 1049 static bool highlightSetting();
1049 1050
1050 /** 1051 /**
1051 * @return global setting for "Toolbars transparent when moving" 1052 * @return global setting for "Toolbars transparent when moving"
1052 */ 1053 */
1053 static bool transparentSetting(); 1054 static bool transparentSetting();
1054 1055
1055 /** 1056 /**
1056 * @return global setting for "Icon Text" 1057 * @return global setting for "Icon Text"
1057 */ 1058 */
1058 static IconText iconTextSetting(); 1059 static IconText iconTextSetting();
1059 1060
1060public slots: 1061public slots:
1061 virtual void setIconText( const QString &txt ) 1062 virtual void setIconText( const QString &txt )
1062 { QToolBar::setIconText( txt ); } 1063 { QToolBar::setIconText( txt ); }
1064 void slotRepaint();
1063 1065
1064protected: 1066protected:
1065 void mousePressEvent( QMouseEvent * ); 1067 void mousePressEvent( QMouseEvent * );
1066 void childEvent( QChildEvent *e ); 1068 void childEvent( QChildEvent *e );
1067 void showEvent( QShowEvent *e ); 1069 void showEvent( QShowEvent *e );
1068 void resizeEvent( QResizeEvent *e ); 1070 void resizeEvent( QResizeEvent *e );
1069 bool event( QEvent *e ); 1071 bool event( QEvent *e );
1070 void applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal = false); 1072 void applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal = false);
1071 QString settingsGroup(); 1073 QString settingsGroup();
1072 1074
1073private slots: 1075private slots:
1074 void rebuildLayout(); 1076 void rebuildLayout();
1075 void slotReadConfig (); 1077 void slotReadConfig ();
1076 void slotAppearanceChanged(); 1078 void slotAppearanceChanged();
1077 void slotIconChanged(int); 1079 void slotIconChanged(int);
1078 void slotRepaint();
1079 void toolBarPosChanged( QToolBar *tb ); 1080 void toolBarPosChanged( QToolBar *tb );
1080 void slotContextAboutToShow(); 1081 void slotContextAboutToShow();
1081 void widgetDestroyed(); 1082 void widgetDestroyed();
1082 1083
1083private: 1084private:
1084 void init( bool readConfig = true, bool honorStyle = false ); 1085 void init( bool readConfig = true, bool honorStyle = false );
1085 void doConnections( KToolBarButton *button ); 1086 void doConnections( KToolBarButton *button );
1086 void insertWidgetInternal( QWidget *w, int &index, int id ); 1087 void insertWidgetInternal( QWidget *w, int &index, int id );
1087 void removeWidgetInternal( QWidget *w ); 1088 void removeWidgetInternal( QWidget *w );
1088 void getAttributes( QString &position, QString &icontext, int &index ); 1089 void getAttributes( QString &position, QString &icontext, int &index );
1089//US KPopupMenu *contextMenu(); 1090//US KPopupMenu *contextMenu();
1090 QPopupMenu *contextMenu(); 1091 QPopupMenu *contextMenu();
1091 1092
1092 QMap<QWidget*, int > widget2id; 1093 QMap<QWidget*, int > widget2id;
1093 typedef QMap<int, QWidget* > Id2WidgetMap; 1094 typedef QMap<int, QWidget* > Id2WidgetMap;
1094 Id2WidgetMap id2widget; 1095 Id2WidgetMap id2widget;
1095//US KPopupMenu *context; 1096//US KPopupMenu *context;
1096 QPopupMenu *context; 1097 QPopupMenu *context;
1097 QPtrList<QWidget> widgets; 1098 QPtrList<QWidget> widgets;
1098 QTimer *layoutTimer; 1099 QTimer *layoutTimer;
1099 QGuardedPtr<QWidget> stretchableWidget, rightAligned; 1100 QGuardedPtr<QWidget> stretchableWidget, rightAligned;
1100protected: 1101protected:
1101 virtual void virtual_hook( int id, void* data ); 1102 virtual void virtual_hook( int id, void* data );
1102private: 1103private:
1103 KToolBarPrivate *d; 1104 KToolBarPrivate *d;
1104 bool inshutdownprocess; 1105 bool inshutdownprocess;
1105}; 1106};
1106 1107
1107#endif 1108#endif