unsigned int GnomeGrabber::Impl::grabAccelerator(char const* accelerator, unsigned int flags) { CompAction action; action.keyFromString(accelerator); if (action.key().toString().empty()) { CompString prefixed = "XF86" + CompString(accelerator); LOG_DEBUG(logger) << "Can't grab \"" << accelerator << "\", trying \"" << prefixed << "\""; action.keyFromString(prefixed); } else { LOG_DEBUG(logger) << "grabAccelerator \"" << accelerator << "\""; } if (!isActionPostponed(action)) { action.setState(CompAction::StateInitKey); action.setInitiate([this](CompAction* action, CompAction::State state, CompOption::Vector& options) { LOG_DEBUG(logger) << "pressed \"" << action->keyToString() << "\""; activateAction(action, 0); return true; }); } else { action.setState(CompAction::StateInitKey | CompAction::StateTermKey); action.setTerminate([this](CompAction* action, CompAction::State state, CompOption::Vector& options) { auto key = action->keyToString(); LOG_DEBUG(logger) << "released \"" << key << "\""; if (state & CompAction::StateTermTapped) { LOG_DEBUG(logger) << "tapped \"" << key << "\""; activateAction(action, 0); return true; } return false; }); } return addAction(action, false); }
void QRibbonSection::addAction(QAction * a, const QString &name) { QGridLayout *l = (QGridLayout *) buttons->layout(); QRibbonButton *btn = new QRibbonButton(a->icon(), a->text(), name, buttons); btn->setAction(a); connect(btn, SIGNAL(clicked()), this, SLOT(activateAction())); if (&name != 0) { btn->setObjectName(name); } else { btn->setObjectName(a->objectName()); } l->addWidget(btn, row, col, 1, 1); col += 1; _widgets.append(btn); }
void QRibbonSection::addLargeAction(QAction * a, const QString &name) { QGridLayout *l = (QGridLayout *) buttons->layout(); QRibbonButton *btn = new QRibbonButton(a->icon(), a->text(), name, buttons); btn->setAction(a); connect(btn, SIGNAL(clicked()), this, SLOT(activateAction())); if (&name != 0) { btn->setObjectName(name); } else { btn->setObjectName(a->objectName()); } nextColumn(); btn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); btn->setIconSize(QSize(btn->iconSize().width() * 2, btn->iconSize().height() * 2)); l->addWidget(btn, row, col, 2, 2); col += 2; _widgets.append(btn); }
QAction *QMenuPrivate::wceCommands(uint command) { QAction *foundAction = 0; for (int i = 0; i < wce_menu->actionItems.size(); ++i) { if (foundAction) break; QWceMenuAction *action = wce_menu->actionItems.at(i); if (action->action->menu()) { foundAction = action->action->menu()->d_func()->wceCommands(command); } else if (action->command == command) { activateAction(action->action, QAction::Trigger); return action->action; } } if (foundAction) emit q_func()->triggered(foundAction); return foundAction; }
PythonTool::PythonTool(QObject *parent, const QString &filename) : Tool(parent), m_script(0), m_settingsWidget(0) { loadScript(filename); QAction *action = activateAction(); action->setIcon(QIcon(QString::fromUtf8(":/python/python.png"))); PythonThread pt; if (PyObject_HasAttrString(m_instance.ptr(), "toolTip")) { try { prepareToCatchError(); const char *toolTip = extract<const char*>(m_instance.attr("toolTip")()); action->setToolTip(QString(toolTip)); } catch(error_already_set const &) { catchError(); } } }
ZMatrixTool::ZMatrixTool(QObject *parent) : Tool(parent), m_molecule(0), m_settingsWidget(0), m_zMatrixDialog(0) { QAction *action = activateAction(); action->setIcon(QIcon(QLatin1String(":/zmatrix/zmatrix.png"))); }