Changeset View
Changeset View
Standalone View
Standalone View
src/kedittoolbar.cpp
Show First 20 Lines • Show All 680 Lines • ▼ Show 20 Line(s) | 680 | if (KMessageBox::warningContinueCancel(q, i18n("Do you really want to reset all toolbars of this application to their default? The changes will be applied immediately."), i18n("Reset Toolbars"), KGuiItem(i18n("Reset"))) != KMessageBox::Continue) { | |||
---|---|---|---|---|---|
681 | return; | 681 | return; | ||
682 | } | 682 | } | ||
683 | 683 | | |||
684 | KEditToolBarWidget *oldWidget = m_widget; | 684 | KEditToolBarWidget *oldWidget = m_widget; | ||
685 | m_widget = nullptr; | 685 | m_widget = nullptr; | ||
686 | m_accept = false; | 686 | m_accept = false; | ||
687 | 687 | | |||
688 | if (m_factory) { | 688 | if (m_factory) { | ||
689 | foreach (KXMLGUIClient *client, m_factory->clients()) { | 689 | const auto clients = m_factory->clients(); | ||
690 | for (KXMLGUIClient *client : clients) { | ||||
690 | const QString file = client->localXMLFile(); | 691 | const QString file = client->localXMLFile(); | ||
691 | if (file.isEmpty()) { | 692 | if (file.isEmpty()) { | ||
692 | continue; | 693 | continue; | ||
693 | } | 694 | } | ||
694 | //qDebug(240) << "Deleting local xml file" << file; | 695 | //qDebug(240) << "Deleting local xml file" << file; | ||
695 | // << "for client" << client << typeid(*client).name(); | 696 | // << "for client" << client << typeid(*client).name(); | ||
696 | if (QFile::exists(file)) | 697 | if (QFile::exists(file)) | ||
697 | if (!QFile::remove(file)) { | 698 | if (!QFile::remove(file)) { | ||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Line(s) | 861 | { | |||
864 | } | 865 | } | ||
865 | 866 | | |||
866 | m_loadedOnce = true; | 867 | m_loadedOnce = true; | ||
867 | 868 | | |||
868 | m_factory = factory; | 869 | m_factory = factory; | ||
869 | 870 | | |||
870 | // add all of the client data | 871 | // add all of the client data | ||
871 | bool first = true; | 872 | bool first = true; | ||
872 | foreach (KXMLGUIClient *client, factory->clients()) { | 873 | const auto clients = factory->clients(); | ||
874 | for (KXMLGUIClient *client : clients) { | ||||
873 | if (client->xmlFile().isEmpty()) { | 875 | if (client->xmlFile().isEmpty()) { | ||
874 | continue; | 876 | continue; | ||
875 | } | 877 | } | ||
876 | 878 | | |||
877 | XmlData::XmlType type = XmlData::Part; | 879 | XmlData::XmlType type = XmlData::Part; | ||
878 | if (first) { | 880 | if (first) { | ||
879 | type = XmlData::Shell; | 881 | type = XmlData::Shell; | ||
880 | first = false; | 882 | first = false; | ||
Show All 13 Lines | |||||
894 | #endif | 896 | #endif | ||
895 | 897 | | |||
896 | // now load in our toolbar combo box | 898 | // now load in our toolbar combo box | ||
897 | loadToolBarCombo(defaultToolBar); | 899 | loadToolBarCombo(defaultToolBar); | ||
898 | m_widget->adjustSize(); | 900 | m_widget->adjustSize(); | ||
899 | m_widget->setMinimumSize(m_widget->sizeHint()); | 901 | m_widget->setMinimumSize(m_widget->sizeHint()); | ||
900 | 902 | | |||
901 | m_widget->actionCollection()->addAssociatedWidget(m_widget); | 903 | m_widget->actionCollection()->addAssociatedWidget(m_widget); | ||
902 | foreach (QAction *action, m_widget->actionCollection()->actions()) { | 904 | const auto widgetActions = m_widget->actionCollection()->actions(); | ||
905 | for (QAction *action : widgetActions) { | ||||
903 | action->setShortcutContext(Qt::WidgetWithChildrenShortcut); | 906 | action->setShortcutContext(Qt::WidgetWithChildrenShortcut); | ||
904 | } | 907 | } | ||
905 | } | 908 | } | ||
906 | 909 | | |||
907 | void KEditToolBarWidget::save() | 910 | void KEditToolBarWidget::save() | ||
908 | { | 911 | { | ||
909 | //qDebug(240) << "KEditToolBarWidget::save"; | 912 | //qDebug(240) << "KEditToolBarWidget::save"; | ||
910 | XmlDataList::Iterator it = d->m_xmlFiles.begin(); | 913 | XmlDataList::Iterator it = d->m_xmlFiles.begin(); | ||
▲ Show 20 Lines • Show All 344 Lines • ▼ Show 20 Line(s) | 1257 | if (it.tagName() == tagActionList) { | |||
1255 | ToolBarItem *act = new ToolBarItem(m_activeList, tagActionList, it.attribute(attrName), i18n("This is a dynamic list of actions. You can move it, but if you remove it you will not be able to re-add it.")); | 1258 | ToolBarItem *act = new ToolBarItem(m_activeList, tagActionList, it.attribute(attrName), i18n("This is a dynamic list of actions. You can move it, but if you remove it you will not be able to re-add it.")); | ||
1256 | act->setText(i18n("ActionList: %1", it.attribute(attrName))); | 1259 | act->setText(i18n("ActionList: %1", it.attribute(attrName))); | ||
1257 | continue; | 1260 | continue; | ||
1258 | } | 1261 | } | ||
1259 | 1262 | | |||
1260 | // iterate through this client's actions | 1263 | // iterate through this client's actions | ||
1261 | // This used to iterate through _all_ actions, but we don't support | 1264 | // This used to iterate through _all_ actions, but we don't support | ||
1262 | // putting any action into any client... | 1265 | // putting any action into any client... | ||
1263 | foreach (QAction *action, actionCollection->actions()) { | 1266 | const auto actions = actionCollection->actions(); | ||
1267 | for (QAction *action : actions) { | ||||
1264 | // do we have a match? | 1268 | // do we have a match? | ||
1265 | if (it.attribute(attrName) == action->objectName()) { | 1269 | if (it.attribute(attrName) == action->objectName()) { | ||
1266 | // we have a match! | 1270 | // we have a match! | ||
1267 | ToolBarItem *act = new ToolBarItem(m_activeList, it.tagName(), action->objectName(), action->toolTip()); | 1271 | ToolBarItem *act = new ToolBarItem(m_activeList, it.tagName(), action->objectName(), action->toolTip()); | ||
1268 | act->setText(nameFilter.subs(KLocalizedString::removeAcceleratorMarker(action->iconText())).toString()); | 1272 | act->setText(nameFilter.subs(KLocalizedString::removeAcceleratorMarker(action->iconText())).toString()); | ||
1269 | act->setIcon(!action->icon().isNull() ? action->icon() : m_emptyIcon); | 1273 | act->setIcon(!action->icon().isNull() ? action->icon() : m_emptyIcon); | ||
1270 | act->setTextAlongsideIconHidden(action->priority() < QAction::NormalPriority); | 1274 | act->setTextAlongsideIconHidden(action->priority() < QAction::NormalPriority); | ||
1271 | 1275 | | |||
1272 | active_list.insert(action->objectName()); | 1276 | active_list.insert(action->objectName()); | ||
1273 | break; | 1277 | break; | ||
1274 | } | 1278 | } | ||
1275 | } | 1279 | } | ||
1276 | } | 1280 | } | ||
1277 | 1281 | | |||
1278 | // go through the rest of the collection | 1282 | // go through the rest of the collection | ||
1279 | foreach (QAction *action, actionCollection->actions()) { | 1283 | const auto actions = actionCollection->actions(); | ||
1284 | for (QAction *action : actions) { | ||||
1280 | // skip our active ones | 1285 | // skip our active ones | ||
1281 | if (active_list.contains(action->objectName())) { | 1286 | if (active_list.contains(action->objectName())) { | ||
1282 | continue; | 1287 | continue; | ||
1283 | } | 1288 | } | ||
1284 | 1289 | | |||
1285 | ToolBarItem *act = new ToolBarItem(m_inactiveList, tagAction, action->objectName(), action->toolTip()); | 1290 | ToolBarItem *act = new ToolBarItem(m_inactiveList, tagAction, action->objectName(), action->toolTip()); | ||
1286 | act->setText(nameFilter.subs(KLocalizedString::removeAcceleratorMarker(action->text())).toString()); | 1291 | act->setText(nameFilter.subs(KLocalizedString::removeAcceleratorMarker(action->text())).toString()); | ||
1287 | act->setIcon(!action->icon().isNull() ? action->icon() : m_emptyIcon); | 1292 | act->setIcon(!action->icon().isNull() ? action->icon() : m_emptyIcon); | ||
▲ Show 20 Lines • Show All 455 Lines • Show Last 20 Lines |