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

Method addAction

kdevplatform/sublime/idealbuttonbarwidget.cpp:402–435  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

400}
401
402void IdealButtonBarWidget::addAction(QAction* qaction)
403{
404 const QScopeGuard emptyChangedGuard([wasEmpty = isEmpty(), this] {
405 if (wasEmpty) {
406 emit emptyChanged();
407 }
408 });
409
410 QWidget::addAction(qaction);
411
412 auto action = qobject_cast<ToolViewAction*>(qaction);
413 if (!action || action->button()) {
414 return;
415 }
416
417 auto *button = new IdealToolButton(m_area);
418 //apol: here we set the usual width of a button for the vertical toolbars as the minimumWidth
419 //this is done because otherwise when we remove all the buttons and re-add new ones we get all
420 //the screen flickering. This is solved by not defaulting to a smaller width when it's empty
421 int w = button->sizeHint().width();
422 if (orientation() == Qt::Vertical && w > minimumWidth()) {
423 setMinimumWidth(w);
424 }
425
426 action->setButton(button);
427 button->setDefaultAction(action);
428
429 connect(action, &QAction::toggled, this, &IdealButtonBarWidget::showWidget);
430 connect(button, &IdealToolButton::customContextMenuRequested,
431 action->dockWidget(), &IdealDockWidget::contextMenuRequested);
432
433 addButtonToOrder(button);
434 applyOrderToLayout();
435}
436
437void IdealButtonBarWidget::removeAction(QAction* widgetAction)
438{

Callers

nothing calls this directly

Calls 3

buttonMethod · 0.80
isEmptyFunction · 0.50
sizeHintMethod · 0.45

Tested by

no test coverage detected