Action::Action(QObject *parent) : QProcess(parent) , m_failed(false) , m_firstProcess(NULL) , m_currentLine(-1) { setProcessChannelMode(QProcess::SeparateChannels); connect( this, SIGNAL(error(QProcess::ProcessError)), SLOT(actionError(QProcess::ProcessError)) ); connect( this, SIGNAL(started()), SLOT(actionStarted()) ); connect( this, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(actionFinished()) ); connect( this, SIGNAL(readyReadStandardError()), SLOT(actionErrorOutput()) ); connect( this, SIGNAL(readyReadStandardOutput()), this, SLOT(actionOutput()) ); quintptr id = actionId(this); QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert("COPYQ_ACTION_ID", QString::number(id)); setProcessEnvironment(env); setProperty("COPYQ_ACTION_ID", id); const QMutexLocker lock(&actionsLock); actions.append(this); }
Action::Action(QObject *parent) : QObject(parent) , m_failed(false) , m_currentLine(-1) , m_exitCode(0) { setProperty("COPYQ_ACTION_ID", actionId(this)); const QMutexLocker lock(&actionsLock); actions.append(this); }
void Keymap::loadMappings(const HardwareInputSet *hwKeys) { if (!_configDomain) return; if (_actions.empty()) return; Common::KeymapperDefaultBindings *defaults = g_system->getKeymapperDefaultBindings(); HashMap<String, const HardwareInput *> mappedInputs; List<Action*>::iterator it; String prefix = KEYMAP_KEY_PREFIX + _name + "_"; for (it = _actions.begin(); it != _actions.end(); ++it) { Action* ua = *it; String actionId(ua->id); String confKey = prefix + actionId; String hwInputId = _configDomain->getVal(confKey); bool defaulted = false; // fall back to the platform-specific defaults if (hwInputId.empty() && defaults) { hwInputId = defaults->getDefaultBinding(_name, actionId); if (!hwInputId.empty()) defaulted = true; } // there's no mapping if (hwInputId.empty()) continue; const HardwareInput *hwInput = hwKeys->findHardwareInput(hwInputId.c_str()); if (!hwInput) { warning("HardwareInput with ID '%s' not known", hwInputId.c_str()); continue; } if (defaulted) { if (mappedInputs.contains(hwInputId)) { debug(1, "Action [%s] not falling back to hardcoded default value [%s] because the hardware input is in use", confKey.c_str(), hwInputId.c_str()); continue; } warning("Action [%s] fell back to hardcoded default value [%s]", confKey.c_str(), hwInputId.c_str()); } mappedInputs.setVal(hwInputId, hwInput); // map the key ua->mapInput(hwInput); } }
int Workspace::GetActionCount(const char* actionString) { behaviac::ScopedLock lock(m_cs); int count = 0; CStringID actionId(actionString); ActionCount_t::iterator it = m_actions_count.find(actionId); if (it != m_actions_count.end()) { count = m_actions_count[actionId]; } return count; }
//----------------------------------------------------------------------------- // CTestActionPlugIn::ExecuteL // Triggers an action. //----------------------------------------------------------------------------- // CCFActionPlugIn::TExecutionTime CTestActionPlugIn::ExecuteL( CCFActionIndication* aActionIndication ) { TPtrC actionId( aActionIndication->Identifier() ); // Check command type and handle the command if it is supported. if( actionId == KTestActionIdTestAc3 ) { StartTimer(); return CCFActionPlugIn::ESmall; } else if( actionId == KTestActionIdLeave ) { User::Leave( KErrArgument ); } return CCFActionPlugIn::ENone; }
int Workspace::UpdateActionCount(const char* actionString) { behaviac::ScopedLock lock(m_cs); int count = 1; CStringID actionId(actionString); ActionCount_t::iterator it = m_actions_count.find(actionId); if (it == m_actions_count.end()) { m_actions_count[actionId] = count; } else { count = m_actions_count[actionId]; count++; m_actions_count[actionId] = count; } return count; }
void QtDockRegion::addView(IView& view) { auto qMainWindow = qtWindow_.window(); assert(qMainWindow != nullptr); auto findIt = dockWidgetMap_.find(&view); if (findIt != dockWidgetMap_.end()) { // already added into the dockWidget return; } // IView will not control qWidget's life-cycle after this call. auto qtFramework = get<IQtFramework>(); assert(qtFramework != nullptr); auto qWidget = qtFramework->toQWidget(view); if (qWidget == nullptr) { return; } auto centralWidget = qMainWindow->centralWidget(); if (centralWidget != nullptr) { centralWidget->layout()->addWidget(qWidget); } qWidget->setSizePolicy(qDockWidget_.sizePolicy()); qWidget->setMinimumSize(qDockWidget_.minimumSize()); qWidget->setMaximumSize(qDockWidget_.maximumSize()); qWidget->setSizeIncrement(qDockWidget_.sizeIncrement()); qWidget->setBaseSize(qDockWidget_.baseSize()); qWidget->resize(qWidget->baseSize()); auto qDockWidget = new NGTDockWidget(&view); qDockWidget->setObjectName(view.id()); IView* pView = &view; QtWindow* pWindow = &qtWindow_; QObject::connect(qDockWidget, &QDockWidget::visibilityChanged, [qDockWidget, pWindow](bool visible) { qDockWidget->visibilityChanged(visible); if (visible) { if (pWindow->isLoadingPreferences()) { return; } QCoreApplication::postEvent(qDockWidget, new QEvent(QEvent::FocusIn)); } }); if (qtWindow_.isReady()) { bool isOk = qMainWindow->restoreDockWidget(qDockWidget); if (!isOk) { setDefaultPreferenceForDockWidget(qDockWidget); } QmlView* qmlView = dynamic_cast<QmlView*>(pView); if (qmlView != nullptr) { if (qDockWidget->isVisible() && qDockWidget->getVisibility()) { qmlView->setNeedsToLoad(true); } } } else { needToRestorePreference_.push_back(std::make_pair(qDockWidget, pView)); } qDockWidget->setWidget(qWidget); std::string actionId("View."); actionId += view.title(); auto action = qtFramework->createAction(actionId.c_str(), view.title(), "View", [pView, qDockWidget](IAction*) { qDockWidget->show(); qDockWidget->raise(); pView->focusInEvent(); }); auto application = get<IUIApplication>(); assert(application != nullptr); application->addAction(*action); dockWidgetMap_[&view] = std::make_pair(std::unique_ptr<QDockWidget>(qDockWidget), std::move(action)); }
const std::string &ZLToolbar::AbstractButtonItem::iconName() const { return actionId(); }
shared_ptr<ZLPopupData> ZLToolbar::MenuButtonItem::popupData() const { std::map<std::string,shared_ptr<ZLPopupData> >::const_iterator it = toolbar().myPopupDataMap.find(actionId()); return (it == toolbar().myPopupDataMap.end()) ? 0 : it->second; }