| 14 | namespace utils { |
| 15 | |
| 16 | static DToolButton* createIconButton(QAction *action, QWidget *parent) { |
| 17 | DToolButton *iconBtn = new DToolButton(parent); |
| 18 | iconBtn->setFocusPolicy(Qt::NoFocus); |
| 19 | iconBtn->setEnabled(action->isEnabled()); |
| 20 | iconBtn->setIcon(action->icon()); |
| 21 | iconBtn->setFixedSize(QSize(36, 36)); |
| 22 | |
| 23 | QString toolTipStr = action->text(); |
| 24 | if (!action->shortcut().isEmpty()) { |
| 25 | toolTipStr = toolTipStr + " " + action->shortcut().toString(); |
| 26 | } |
| 27 | |
| 28 | if (!toolTipStr.isEmpty()) |
| 29 | iconBtn->setToolTip(toolTipStr); |
| 30 | |
| 31 | QObject::connect(iconBtn, &DToolButton::clicked, action, &QAction::triggered); |
| 32 | QObject::connect(action, &QAction::changed, iconBtn, [=] { |
| 33 | QString toolTipStr = action->text() + " " + action->shortcut().toString(); |
| 34 | iconBtn->setToolTip(toolTipStr); |
| 35 | iconBtn->setIcon(action->icon()); |
| 36 | iconBtn->setEnabled(action->isEnabled()); |
| 37 | }); |
| 38 | |
| 39 | return iconBtn; |
| 40 | } |
| 41 | |
| 42 | static bool isWayland() |
| 43 | { |
no test coverage detected