MCPcopy Create free account
hub / github.com/KDE/kdevelop / contextMenuRequested

Method contextMenuRequested

kdevplatform/sublime/idealdockwidget.cpp:93–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93void IdealDockWidget::contextMenuRequested(const QPoint &point)
94{
95 QWidget* senderWidget = qobject_cast<QWidget*>(sender());
96 Q_ASSERT(senderWidget);
97
98 auto* const menu = new QMenu(senderWidget);
99 menu->addSection(windowIcon(), m_view->document()->title());
100
101 const QList<QAction*> viewActions = m_view->contextMenuActions();
102 if(!viewActions.isEmpty()) {
103 // add the view's actions to the context menu,
104 // checking each if it can be represented
105 for (const auto action : viewActions) {
106 if (!action->text().isEmpty() && !action->iconText().isEmpty()) {
107 // avoid adding empty menu items
108 menu->addAction(action);
109 }
110 }
111 menu->addSeparator();
112 }
113
114 ///TODO: can this be cleaned up?
115 if(auto* toolBar = widget()->findChild<QToolBar*>()) {
116 menu->addAction(toolBar->toggleViewAction());
117 menu->addSeparator();
118 }
119
120 /// start position menu
121 QMenu* positionMenu = menu->addMenu(i18nc("@title:menu", "Tool View Position"));
122
123 auto* g = new QActionGroup(positionMenu);
124
125 auto* left = new QAction(i18nc("@option:radio tool view position", "Left"), g);
126 auto* bottom = new QAction(i18nc("@option:radio tool view position", "Bottom"), g);
127 auto* right = new QAction(i18nc("@option:radio tool view position", "Right"), g);
128 auto* detach = new QAction(i18nc("@option:radio tool view position", "Detached"), g);
129
130 for (auto action : {left, bottom, right, detach}) {
131 positionMenu->addAction(action);
132 action->setCheckable(true);
133 }
134
135 QAction* currentPositionAction = nullptr;
136 if (isFloating()) {
137 currentPositionAction = detach;
138 } else if (m_docking_area == Qt::BottomDockWidgetArea)
139 currentPositionAction = bottom;
140 else if (m_docking_area == Qt::LeftDockWidgetArea)
141 currentPositionAction = left;
142 else if (m_docking_area == Qt::RightDockWidgetArea)
143 currentPositionAction = right;
144 Q_ASSERT_X(currentPositionAction, Q_FUNC_INFO, "unsupported dock widget area");
145 currentPositionAction->setChecked(true);
146 /// end position menu
147
148 menu->addSeparator();
149
150 QAction *setShortcut = menu->addAction(QIcon::fromTheme(QStringLiteral("configure-shortcuts")), i18nc("@action:inmenu", "Assign Shortcut..."));

Callers

nothing calls this directly

Calls 14

setToolTipMethod · 0.80
setAttributeMethod · 0.80
execMethod · 0.80
actionForViewMethod · 0.80
writeEntryMethod · 0.80
titleMethod · 0.45
documentMethod · 0.45
contextMenuActionsMethod · 0.45
isEmptyMethod · 0.45
textMethod · 0.45
addActionMethod · 0.45
addWidgetMethod · 0.45

Tested by

no test coverage detected