Changeset View
Changeset View
Standalone View
Standalone View
src/kmenumenuhandler_p.cpp
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Line(s) | |||||
93 | 93 | | |||
94 | void KMenuMenuHandler::buildToolbarAction() | 94 | void KMenuMenuHandler::buildToolbarAction() | ||
95 | { | 95 | { | ||
96 | KMainWindow *window = qobject_cast<KMainWindow *>(m_builder->widget()); | 96 | KMainWindow *window = qobject_cast<KMainWindow *>(m_builder->widget()); | ||
97 | if (!window) { | 97 | if (!window) { | ||
98 | return; | 98 | return; | ||
99 | } | 99 | } | ||
100 | QStringList toolbarlist; | 100 | QStringList toolbarlist; | ||
101 | foreach (KToolBar *b, window->toolBars()) { | 101 | const auto toolbars = window->toolBars(); | ||
102 | for (KToolBar *b : toolbars) { | ||||
102 | toolbarlist << (b->windowTitle().isEmpty() ? b->objectName() : b->windowTitle()); | 103 | toolbarlist << (b->windowTitle().isEmpty() ? b->objectName() : b->windowTitle()); | ||
103 | } | 104 | } | ||
104 | m_toolbarAction->setItems(toolbarlist); | 105 | m_toolbarAction->setItems(toolbarlist); | ||
105 | } | 106 | } | ||
106 | 107 | | |||
107 | static KActionCollection *findParentCollection(KXMLGUIFactory *factory, QAction *action) | 108 | static KActionCollection *findParentCollection(KXMLGUIFactory *factory, QAction *action) | ||
108 | { | 109 | { | ||
109 | foreach (KXMLGUIClient *client, factory->clients()) { | 110 | const auto clients = factory->clients(); | ||
111 | for (KXMLGUIClient *client : clients) { | ||||
110 | KActionCollection *collection = client->actionCollection(); | 112 | KActionCollection *collection = client->actionCollection(); | ||
111 | // if the call to actions() is too slow, add KActionCollection::contains(QAction*). | 113 | // if the call to actions() is too slow, add KActionCollection::contains(QAction*). | ||
112 | if (collection->actions().contains(action)) { | 114 | if (collection->actions().contains(action)) { | ||
113 | return collection; | 115 | return collection; | ||
114 | } | 116 | } | ||
115 | } | 117 | } | ||
116 | return nullptr; | 118 | return nullptr; | ||
117 | } | 119 | } | ||
Show All 17 Lines | 122 | { | |||
135 | connect(&box, &QDialogButtonBox::rejected, &dialog, &QDialog::reject); | 137 | connect(&box, &QDialogButtonBox::rejected, &dialog, &QDialog::reject); | ||
136 | dialog.layout()->addWidget(&box); | 138 | dialog.layout()->addWidget(&box); | ||
137 | 139 | | |||
138 | KActionCollection *parentCollection = nullptr; | 140 | KActionCollection *parentCollection = nullptr; | ||
139 | if (dynamic_cast<KXMLGUIClient *>(m_builder)) { | 141 | if (dynamic_cast<KXMLGUIClient *>(m_builder)) { | ||
140 | QList<KActionCollection *> checkCollections; | 142 | QList<KActionCollection *> checkCollections; | ||
141 | KXMLGUIFactory *factory = dynamic_cast<KXMLGUIClient *>(m_builder)->factory(); | 143 | KXMLGUIFactory *factory = dynamic_cast<KXMLGUIClient *>(m_builder)->factory(); | ||
142 | parentCollection = findParentCollection(factory, m_popupAction); | 144 | parentCollection = findParentCollection(factory, m_popupAction); | ||
143 | foreach (KXMLGUIClient *client, factory->clients()) { | 145 | const auto clients = factory->clients(); | ||
146 | for (KXMLGUIClient *client : clients) { | ||||
144 | checkCollections += client->actionCollection(); | 147 | checkCollections += client->actionCollection(); | ||
145 | } | 148 | } | ||
146 | swidget.setCheckActionCollections(checkCollections); | 149 | swidget.setCheckActionCollections(checkCollections); | ||
147 | } | 150 | } | ||
148 | 151 | | |||
149 | if (dialog.exec()) { | 152 | if (dialog.exec()) { | ||
150 | m_popupAction->setShortcuts(swidget.shortcut()); | 153 | m_popupAction->setShortcuts(swidget.shortcut()); | ||
151 | swidget.applyStealShortcut(); | 154 | swidget.applyStealShortcut(); | ||
▲ Show 20 Lines • Show All 98 Lines • Show Last 20 Lines |