MCPcopy Create free account
hub / github.com/KDE/labplot / eventFilter

Method eventFilter

src/frontend/TemplateHandler.cpp:191–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191bool TemplateHandler::eventFilter(QObject* obj, QEvent* event) {
192 if (event->type() == QEvent::MouseButtonPress) {
193 auto* mouseEvent = static_cast<QMouseEvent*>(event);
194 if (mouseEvent->button() == Qt::RightButton) {
195 if (!m_textPositionMenu) {
196 auto style = m_tbLoad->toolButtonStyle();
197
198 m_textPositionMenu = new QMenu(this);
199 m_textPositionMenu->addSection(i18n("Toolbar Settings"));
200
201 auto* actionGroup = new QActionGroup(this);
202 actionGroup->setExclusive(true);
203 connect(actionGroup, &QActionGroup::triggered, this, &TemplateHandler::updateTextPosition);
204
205 auto* subMenu = new QMenu(i18n("Text position"), m_textPositionMenu);
206
207 QAction* action = new QAction(i18n("Icons only"), actionGroup);
208 action->setCheckable(true);
209 action->setData((int)Qt::ToolButtonIconOnly);
210 if (style == Qt::ToolButtonIconOnly)
211 action->setChecked(true);
212 subMenu->addAction(action);
213
214 action = new QAction(i18n("Text only"), actionGroup);
215 action->setCheckable(true);
216 action->setData((int)Qt::ToolButtonTextOnly);
217 if (style == Qt::ToolButtonTextOnly)
218 action->setChecked(true);
219 subMenu->addAction(action);
220
221 action = new QAction(i18n("Text Alongside Icons"), actionGroup);
222 action->setCheckable(true);
223 action->setData((int)Qt::ToolButtonTextBesideIcon);
224 if (style == Qt::ToolButtonTextBesideIcon)
225 action->setChecked(true);
226 subMenu->addAction(action);
227
228 action = new QAction(i18n("Text Under Icons"), actionGroup);
229 action->setCheckable(true);
230 action->setData((int)Qt::ToolButtonTextUnderIcon);
231 if (style == Qt::ToolButtonTextUnderIcon)
232 action->setChecked(true);
233 subMenu->addAction(action);
234 m_textPositionMenu->addMenu(subMenu);
235 }
236
237 auto* widget = static_cast<QWidget*>(obj);
238 m_textPositionMenu->exec(widget->mapToGlobal(mouseEvent->pos()));
239 }
240 }
241 return QWidget::eventFilter(obj, event);
242}
243
244void TemplateHandler::updateTextPosition(QAction* action) {
245 auto style = static_cast<Qt::ToolButtonStyle>(action->data().toInt());

Callers

nothing calls this directly

Calls 4

buttonMethod · 0.80
execMethod · 0.80
typeMethod · 0.45
setDataMethod · 0.45

Tested by

no test coverage detected