当前位置: 首页>>代码示例>>C++>>正文


C++ IAction::execute方法代码示例

本文整理汇总了C++中IAction::execute方法的典型用法代码示例。如果您正苦于以下问题:C++ IAction::execute方法的具体用法?C++ IAction::execute怎么用?C++ IAction::execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAction的用法示例。


在下文中一共展示了IAction::execute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: actionTriggeredSlot

	void IToolBar::actionTriggeredSlot(bool checked)
	{
		IAction* action = dynamic_cast<IAction*> (sender());
		if(action)
		{
			action->execute();
		}					
	}
开发者ID:sld666666,项目名称:HtmlWriter,代码行数:8,代码来源:IToolBar.cpp

示例2: execute

void Console::execute(const string& line) {
  vector<string> parts = StringUtil::split(line, ' ');
  if(parts.size() > 0) {
    string command = parts[0];
    IAction* action = basicLanguage[command];
    if(action) {
      string param;
      if(parts.size() > 1) {
        param = parts[1];
      }
      else {
        param = "";
      }

      action->execute(param);
    }
  }
}
开发者ID:dasaro77,项目名称:OGLText,代码行数:18,代码来源:Console.cpp

示例3: getSharedQAction

QSharedPointer<QAction> QtMenu::createSharedQAction(IAction& action)
{
	auto qAction = getSharedQAction(action);
	if (qAction)
	{
		return qAction;
	}

	qAction.reset(new QForwardingAction(action.text(), QApplication::instance()), &QObject::deleteLater);
	sharedQActions_[&action] = qAction;

	qAction->setProperty("order", action.order());
	qAction->setEnabled(action.enabled());
	qAction->setVisible(action.visible());

	if (action.isSeparator())
	{
		qAction->setSeparator(true);
	}
	else
	{
		std::vector<QIcon> qIcons;
		auto icons = StringUtils::split(std::string(action.icon()), '|');
		for(auto& icon : icons)
		{			
			StringUtils::trim_string(icon);
			qIcons.push_back(QtMenu_Locals::generateIcon(icon.c_str()));
		}

		if(!qIcons.empty())
		{
			qAction->setIcon(qIcons[0]);
		}

		qAction->setShortcut(QKeySequence(action.shortcut()));

		if (action.isCheckable())
		{
			qAction->setCheckable(true);
			qAction->setChecked(action.checked());
		}

		QObject::connect(qAction.data(), &QAction::triggered, [&action]() {
			if (!action.enabled())
			{
				return;
			}
			action.execute();
		});

		connections_[&action] = action.signalShortcutChanged.connect([qAction](const char* shortcut) {
			TF_ASSERT(qAction != nullptr);
			qAction->setShortcut(QKeySequence(shortcut));
		});

		connections_[&action] = action.signalTextChanged.connect([qAction](const char* text) {
			TF_ASSERT(qAction != nullptr);
			qAction->setText(text);
		});

		connections_[&action] = action.signalVisibilityChanged.connect([qAction](bool visible) {
			TF_ASSERT(qAction != nullptr);
			qAction->setVisible(visible);
		});

		connections_[&action] = action.signalIconChanged.connect([qAction, qIcons](int index) {
			TF_ASSERT(qAction != nullptr);
			if(index >= 0 && index < (int)qIcons.size())
			{
				qAction->setIcon(qIcons[index]);
			}
		});

		const std::string groupID(action.group());
		if (!groupID.empty())
		{
			auto itr = groups_.find(groupID);
			if (itr == groups_.end())
			{
				groups_[groupID].reset(new QActionGroup(&menu_));
			}

			groups_.at(groupID)->addAction(qAction.data());
			TF_ASSERT(qAction->actionGroup());
		}
	}

	return qAction;
}
开发者ID:wgsyd,项目名称:wgtf,代码行数:89,代码来源:qt_menu.cpp


注:本文中的IAction::execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。