示例#1
0
void CustomActions::set(QList<Command> cmds)
{
    qSort(cmds);
    bool diff=cmds.length()!=commands.length();

    if (!diff) {
        for (int i=0; i<cmds.length() && !diff; ++i) {
            if (commands[i]!=cmds[i]) {
                diff=true;
            }
        }
    }
    QMenu *m=menu();
    if (diff) {
        foreach (const Command &cmd, commands) {
            m->removeAction(cmd.act);
            disconnect(cmd.act, SIGNAL(triggered()), this, SLOT(doAction()));
            cmd.act->deleteLater();
        }
        commands.clear();

        foreach (const Command &cmd, cmds) {
            Command c(cmd);
            c.act=new Action(c.name, this);
            m->addAction(c.act);
            commands.append(c);
            connect(c.act, SIGNAL(triggered()), this, SLOT(doAction()));
        }
示例#2
0
static int hotKeyShowList(
	GOC_HANDLER uchwyt, GOC_MSG wiesc, void *pBuf, unsigned int nBuf)
{
	GOC_FLAGS f = goc_elementGetFlag(lLista);
	if ( f & GOC_EFLAGA_PAINTED )
	{
		goc_listClear(lLista);
		goc_elementIsFlag(lLista, GOC_EFLAGA_PAINTED | GOC_EFLAGA_ENABLE);
		//goc_elementSetFlag(lLista, f);
		goc_systemRepaintUnder(lLista);
		fflush(stdout);
	}
	else
	{
		int size = 0;
		const char **ptr;
		doAction(ACTION_PLAYLIST_GETSIZE, &size);
		doAction(ACTION_PLAYLIST_GETTABLE, &ptr);
		goc_listSetExtTable(lLista, ptr, size);
		doAction(ACTION_PLAYLIST_GETACTUAL, &size);
		goc_sellistSelect(lLista, size);
		goc_listSetCursor(lLista, size);
		goc_elementOrFlag(lLista, GOC_EFLAGA_PAINTED | GOC_EFLAGA_ENABLE);
		goc_systemFocusOn(lLista);
	}
	goc_systemSendMsg(lLista, GOC_MSG_PAINT, 0, 0);
}
示例#3
0
static int nasluch(GOC_HANDLER uchwyt, GOC_MSG wiesc, void *pBuf, unsigned int nBuf)
{
	if ( uchwyt == GOC_HANDLER_SYSTEM )
	{
		if ( wiesc == GOC_MSG_CHAR )
		{
			if ( nBuf == 27 )
				return GOC_ERR_OK;
		}
	}
	else if ( uchwyt == lLista )
	{
		if ( wiesc == GOC_MSG_CHAR )
		{
			if ( nBuf == 0x0D )
			{
				char *selFile = goc_listGetUnderCursor( lLista );
				if ( selFile )
					doAction(ACTION_PLAY, selFile);
				return GOC_ERR_OK;
			}
			else if ( nBuf == 0x116 )
			{
				int pos = goc_listGetCursor(lLista);
				if ( pos > 0 )
				{
					int size = 0;
					const char **ptr;
					doAction(ACTION_PLAYLIST_REMOVEFILE, &pos);
					doAction(ACTION_PLAYLIST_GETSIZE, &size);
					doAction(ACTION_PLAYLIST_GETTABLE, &ptr);
					goc_listSetExtTable(lLista, ptr, size);
					doAction(ACTION_PLAYLIST_GETACTUAL, &size);
					goc_sellistSelect(lLista, size);
					goc_listSetCursor(lLista, pos);
//		goc_elementOrFlag(lLista, GOC_EFLAGA_PAINTED | GOC_EFLAGA_ENABLE);
//		goc_systemFocusOn(lLista);
					goc_systemSendMsg(lLista, GOC_MSG_PAINT, 0, 0);
				}
				return GOC_ERR_OK;
			}
		}
		else if ( wiesc == GOC_MSG_LISTCHANGE )
		{
			// TODO: Opis zaznaczonej pozycji
			return GOC_ERR_OK;
		}
	}
/*	else if ( uchwyt == pLista )
	{
		// selekcjonuj tylko katalogi do dodawania
		if ( wiesc == GOC_MSG_FILELISTADDFILE )
		{
			if ( nBuf != GOC_FILELISTFLAG_FOLDER )
				return GOC_ERR_REFUSE;
		}
	}*/
	return goc_systemDefaultAction(uchwyt, wiesc, pBuf, nBuf);
}
示例#4
0
void PolycodeEditor::handleEvent(Event *event) {    
    
	if(event->getDispatcher() == CoreServices::getInstance()->getCore() && enabled) {
		switch(event->getEventCode()) {

			// Only copypaste of more complex IDE entities is handled here.
			// Pure text copy/paste is handled in:
			// Modules/Contents/UI/Source/PolyUITextInput.cpp
			case Core::EVENT_SELECT_ALL:
			{
                selectAll();
            }
            break;
			case Core::EVENT_COPY:
			{
				void *data = NULL;
				String dataType = Copy(&data);
				if(data) {
					globalClipboard->setData(data, dataType, this);
				}
			}
			break;
			case Core::EVENT_PASTE:
			{
				if(globalClipboard->getData()) {
					Paste(globalClipboard->getData(), globalClipboard->getType());
				}
			}
			break;
			case Core::EVENT_UNDO:
			{
				if(editorActions.size() > 0 && currentUndoPosition >= 0) {
				doAction(editorActions[currentUndoPosition].actionName, editorActions[currentUndoPosition].beforeData);
				currentUndoPosition--;
				if(currentUndoPosition < -1) {
					currentUndoPosition = -1;
				}
				}				
			}
			break;
			case Core::EVENT_REDO:
			{
				if(editorActions.size() > 0) {			
				currentUndoPosition++;
				if(currentUndoPosition > editorActions.size()-1) {
					currentUndoPosition = editorActions.size()-1;
				} else {
					doAction(editorActions[currentUndoPosition].actionName, editorActions[currentUndoPosition].afterData);
				}
				}
			}
			break;			
		}
	}
}
示例#5
0
void printMixer()
{
	int param;
	param = AUMIX_CURRNAME;
	doAction(ACTION_AUMIX, &param);
	goc_labelSetText(nMixer, (char*)param, GOC_FALSE);
	param = AUMIX_CURRDEV;
	doAction(ACTION_AUMIX, &param);
	param &= 0x7F;
	goc_precentSetPosition(pMixer, param);
	goc_systemSendMsg(nMixer, GOC_MSG_PAINT, 0, 0);
	goc_systemSendMsg(pMixer, GOC_MSG_PAINT, 0, 0);
	fflush(stdout);
}
示例#6
0
bool Monopoly::CardDeck::drawCard(int player, int roll)
{
  int type=0;
  bool prision=false;
  int cardIndex;
  Card card;				// holds card which has been drawn
  
  if(strcmp(m_fileName,"chance.deck")==0) type =1;
  else if(strcmp(m_fileName,"community.deck")==0) type =2;

  cardIndex = takeCardFromPile();  	// draws a card and takes it from the deck
  m_theGame->notifyCardDrawn(type, cardIndex);
  

  card=m_cardDefinitions[cardIndex-1];
  putCardBack(cardIndex);			//put a card back into the deck
  if(card.actionParam==6)
  {
    m_numberCards--;
    prision=true;
  }
 doAction(card, player, roll);
  
  
  return prision;
}
示例#7
0
/** Intersection with an object */
bool Wall::whenIntersect(WObject *pcur, WObject *pold)
{
  switch (pcur->type) {
  case USER_TYPE:
  case THING_TYPE:
  case BALL_TYPE:
    projectPosition(pcur, pold);
    break;
  case ICON_TYPE:
    // stick the icon on the wall
    doAction(ICON_TYPE, Icon::STICK, this, pcur, 0, 0);
    pold->copyPosAndBB(pcur->pos);
    break;
  case BULLET_TYPE:
  case DART_TYPE:
    pcur->toDelete();
    break;
  case STEP_TYPE:	// escalator
  case GUIDE_TYPE:
  case WEB_TYPE:
    return false;
  default:
    pold->copyPosAndBB(pcur->pos);
  }
  return true;
}
示例#8
0
void QgsMapToolFeatureAction::canvasReleaseEvent( QMouseEvent *e )
{
  QgsMapLayer *layer = mCanvas->currentLayer();

  if ( !layer || layer->type() != QgsMapLayer::VectorLayer )
  {
    QMessageBox::warning( mCanvas,
                          tr( "No active vector layer" ),
                          tr( "To run an action, you must choose a vector layer by clicking on its name in the legend" ) );
    return;
  }

  if ( !mCanvas->layers().contains( layer ) )
  {
    // do not run actions on hidden layers
    return;
  }

  QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
  if ( vlayer->actions()->size() == 0 && QgsMapLayerActionRegistry::instance()->mapLayerActions( vlayer ).size() == 0 )
  {
    QMessageBox::warning( mCanvas,
                          tr( "No actions available" ),
                          tr( "The active vector layer has no defined actions" ) );
    return;
  }

  if ( !doAction( vlayer, e->x(), e->y() ) )
    QgisApp::instance()->statusBar()->showMessage( tr( "No features at this position found." ) );
}
示例#9
0
static p_action doParse( parse_stack *resource_state )
{
    p_action    what;
    bool        error_state;
    YYTOKENTYPE token;
    int         token_count = 0;

    error_state = false;

    do {
        token = yylexOS2();
        if( error_state ) {
            token_count++;
            if( token_count >= YYERRORTHRESHOLD ) {
                error_state = false;
            }
        }

        what = doAction( token, resource_state );

        if( what == P_SYNTAX ) {
            handleError( token, resource_state, error_state );
            error_state = true;
            yysyntaxerror = true;
            ErrorHasOccured = true;
            token_count = 0;
        } else if( token == Y_INTEGER && yylval.intinfo.str != NULL ) {
            RcMemFree( yylval.intinfo.str );
            yylval.intinfo.str = NULL;
        }
    } while( what != P_ACCEPT && what != P_ERROR );

    return( what );
}
示例#10
0
    bool Session::contentRemove( const Content* content )
    {
      if( m_state < Pending )
        return false;

      return doAction( ContentRemove, content );
    }
示例#11
0
    bool Session::contentAdd( const PluginList& contents )
    {
      if( m_state < Pending )
        return false;

      return doAction( ContentAdd, contents );
    }
bool Plant::startAction()
{
    if (!isAction) {
        doAction(0.0f);
    }
    return true;
}
示例#13
0
// TODO: Check if clickables overlap and warn accordingly
void gsGame::switchToView() {
	for (auto& pair : directions) {
		pair.second = "";
	}
	clickAreas.clear();
	sprites.clear();
	items.clear();
	line1.setText("");
	line2.setText("");

	for (auto module : activeModules) {
		module->leave();
	}
	activeModules.clear();

	bg = g_tm->getTexture("game", "black.png");

	if (transitionStart != -1 && SDL_GetTicks() - transitionStart < transitionTime) {
		return;
	}

	if (view.find("onLeave") != view.end()) {
		for (auto action : view["onLeave"]) {
			doAction(action.get<std::string>());
		}
	}

	std::string file = "media/views/" + nextView + ".json";
	view = jsonFromFile(file);

	if (view.find("bg") != view.end()) {
		bg = g_tm->getTexture("views", view["bg"]);
	} else {
		bg = g_tm->getTexture("views", nextView + ".png");
	}

	for (auto dir : possibleDirections) {
		directions[dir] = "";
		if (view.find(dir) != view.end()) {
			directions[dir] = view[dir].get<std::string>();
		}
	}

	extractModifiers(view);

	if (view.find("triggers") != view.end()) {
		json triggers = view["triggers"];
		for (auto trigger : triggers) {
			if (checkCondition(trigger["condition"].get<std::string>())) {
				extractModifiers(trigger["modifiers"]);
				break;
			}
		}
	}

	// Make sure we don't change view again
	transitionStart = -1;
	transitionTime = -1;
	nextView = "";
}
示例#14
0
    bool Session::transportReplace( const Content* content )
    {
      if( m_state < Pending )
        return false;

      return doAction( TransportReplace, content );
    }
示例#15
0
    bool Session::transportInfo( const Plugin* info )
    {
      if( m_state < Pending )
        return false;

      return doAction( TransportInfo, info );
    }
示例#16
0
    bool Session::transportAccept( const Content* content )
    {
      if( m_state < Pending )
        return false;

      return doAction( TransportAccept, content );
    }
示例#17
0
    bool Session::sessionInfo( const Plugin* info )
    {
      if( m_state < Pending )
        return false;

      return doAction( SessionInfo, info );
    }
示例#18
0
void PutInfo::putIconCB()
{
  char infos[BUFSIZ];
  memset(infos, 0, sizeof(infos));
  if (url.c_str()) {
    strcat(infos, "<url=\"");
    strcat(infos, url.c_str());
    strcat(infos, "\">&");
  }
  if (file.c_str()) {
    strcat(infos, "<file=\"");
    strcat(infos, file.c_str());
    strcat(infos, "\">&");
  }
  if (ofile.c_str()) {
    strcat(infos, "<ofile=\"");
    strcat(infos, ofile.c_str());
    strcat(infos, "\">&");
  }
  if (name.c_str()) {
    strcat(infos, "<name=\"");
    strcat(infos, name.c_str());
    strcat(infos, "\">&");
  }
  if (icon.c_str()) {
    strcat(infos, "<icon=\"");
    strcat(infos, icon.c_str());
    strcat(infos, "\">&");
  }
  doAction(ICON_TYPE, Icon::CREATE, localuser, infos, 0, 0);
}
bool Monkey::startAction()
{
    if (!isAction) {
        doAction(0.0f);
    }
    return true;
}
示例#20
0
// NPP_ call translator
DWORD nsPluginThread::callNPP(npapiAction aAction, DWORD aP1, DWORD aP2, 
                              DWORD aP3, DWORD aP4, DWORD aP5, 
                              DWORD aP6, DWORD aP7)
{
  // don't enter untill thread is ready
  while (isBusy()) {
    Sleep(0);
  }

  mP1 = aP1;
  mP2 = aP2;
  mP3 = aP3;
  mP4 = aP4;
  mP5 = aP5;
  mP6 = aP6;
  mP7 = aP7;

  doAction(aAction);

  // don't return untill thread is ready
  while (isBusy()) {
    Sleep(0);
  }

  return NPERR_NO_ERROR;
}
bool Spider::startAction()
{
    if (!isAction) {
        doAction(0.0f);
    }
    return true;
}
示例#22
0
文件: main.cpp 项目: app/ananas-labs
int main(int argc, char** argv)
{
	aLog::init("c:\\file.log",aLog::MT_DEBUG);
	printf("dwd1\n");
	if(argc <=1) 
	{
		showError("", invalid_usage);
		return 1;
	}
	printf("dwd\n");
	QStringList args;
	fillArgsFromArgv(&args, argv, argc);
	QString command = parseCommand(&args);
	if(!isValidCommand(command))
	{
		showError(command, invalid_command);
		return 1;
	}
	QString argument = parseArgument(&args);
	if(!isValidArgument(argument))
	{
		showError(argument, invalid_argument);
		return 2;
	}
	QStringList options;
	parseOptions(&args, &options);
	removeInvalidOptions(&options);
	int res = doAction(command, argument, &options);
	aLog::close();
	return res;
} 
示例#23
0
文件: rmp3.c 项目: rojekabc/okienkoc
void *playFile(void *arg)
{
//	int old = MODE_PLAY;

	// graj dopóty nie ma nakazano koñca
	while ( mode != MODE_QUIT )
	{
		pthread_mutex_lock(&mutexPlay);
		if ( mode == MODE_PLAY )
		{
			// próba wej¶cia w tryb grania
			while (( mode == MODE_PLAY ) && (playOneFrame()));
			pthread_mutex_unlock(&mutexPlay);
			if ( mode == MODE_PLAY )
			{
				doAction(ACTION_NEXT, NULL);
			}
		}
		else
		{
			pthread_mutex_unlock(&mutexPlay);
		}
	}

	return NULL;
}
示例#24
0
    bool Session::contentModify( const Content* content )
    {
      if( m_state < Pending )
        return false;

      return doAction( ContentModify, content );
    }
void LidWatcherd::lidChanged(bool closed)
{
    if (closed)
    {
        doAction(mSettings.value(LIDCLOSEDACTION_KEY).toInt());
    }
}
示例#26
0
static int hotKeyAumixNext(
	GOC_HANDLER uchwyt, GOC_MSG wiesc, void *pBuf, unsigned int nBuf)
{
	int arg=AUMIX_NEXTDEV;
	doAction(ACTION_AUMIX, &arg);
	printMixer();
}
示例#27
0
int DeviceManager::executeScene(std::wstring singledevice, int groupDeviceId) {
	std::wstringstream devicestream(singledevice);

	const int deviceParameterLength = 3;
	std::wstring deviceParts[deviceParameterLength] = {L"", L"", L""};
	std::wstring devicePart = L"";
	int i = 0;
	while(std::getline(devicestream, devicePart, L':') && i < deviceParameterLength) {
		deviceParts[i] = devicePart;
		i++;
	}

	if(deviceParts[0] == L"" || deviceParts[1] == L"") {
		return TELLSTICK_ERROR_UNKNOWN;  // malformed or missing parameter
	}

	int deviceId = TelldusCore::wideToInteger(deviceParts[0]);
	if(deviceId == groupDeviceId) {
		return TELLSTICK_ERROR_UNKNOWN;  // the scene itself has been added to its devices, avoid infinite loop
	}
	int method = Device::methodId(TelldusCore::wideToString(deviceParts[1]));  // support methodparts both in the form of integers (e.g. TELLSTICK_TURNON) or text (e.g. "turnon")
	if(method == 0) {
		method = TelldusCore::wideToInteger(deviceParts[1]);
	}
	unsigned char devicedata = 0;
	if(deviceParts[2] != L"") {
		devicedata = TelldusCore::wideToInteger(deviceParts[2]);
	}

	if(deviceId > 0 && method > 0) {  // check for format error in parameter "devices"
		return doAction(deviceId, method, devicedata);
	}

	return TELLSTICK_ERROR_UNKNOWN;
}
示例#28
0
// sprawdz, czy plik to MP3 i dodaj, je¶li tak
static void checkAddFile(const char *fullname)
{
	AVFormatContext *pFormatCtx = NULL;
	int i = av_open_input_file( &pFormatCtx, fullname, NULL, 0, NULL);
	// Cannot open file
	if ( i != 0 )
		return;
	i = av_find_stream_info( pFormatCtx );
	// No info about opened file
	if ( i < 0 )
	{
		av_close_input_file( pFormatCtx );
		return;
	}
	// wyszukaj strumien audio
	for (i=0; i<pFormatCtx->nb_streams; i++)
	{
		if (pFormatCtx->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO )
		{
			doAction(ACTION_PLAYLIST_ADDFILE, fullname);
			av_close_input_file( pFormatCtx );
			return;
		}
	}
	av_close_input_file( pFormatCtx );
	return;
}
示例#29
0
void QgsMapToolFeatureAction::canvasReleaseEvent( QMouseEvent *e )
{
  QgsMapLayer *layer = mCanvas->currentLayer();

  if ( !layer || layer->type() != QgsMapLayer::VectorLayer )
  {
    emit messageEmitted( tr( "To run an action, you must choose an active vector layer." ), QgsMessageBar::INFO );
    return;
  }

  if ( !mCanvas->layers().contains( layer ) )
  {
    // do not run actions on hidden layers
    return;
  }

  QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
  if ( vlayer->actions()->size() == 0 && QgsMapLayerActionRegistry::instance()->mapLayerActions( vlayer ).size() == 0 )
  {
    emit messageEmitted( tr( "The active vector layer has no defined actions" ), QgsMessageBar::INFO );
    return;
  }

  if ( !doAction( vlayer, e->x(), e->y() ) )
    QgisApp::instance()->statusBar()->showMessage( tr( "No features at this position found." ) );
}
示例#30
0
	void ZombieEngine::carEvent(Car* car, int eventType) {
		switch (eventType) {
			case Car::ACTION:
				doAction(car);
				break;
		}
	}