Пример #1
0
DMenu *DMenu::addMenu(const QString &title)
{
    DMenu *menu = new DMenu(this);

    DAction *action = addMenu(menu);

    action->setText(title);

    return menu;
}
Пример #2
0
DAction *DMenu::addMenu(DMenu *menu)
{
    D_D(DMenu);

    DAction *action = new DAction(this);

    menu->d_func()->parent = this;
    action->setMenu(menu);
    d->menuActions << action;

    return action;
}
Пример #3
0
QHash<QString, DAction *> AGenericBrush::actions()
{
	QHash<QString, DAction *> hash;
	
	DAction *pencil = new DAction( QIcon(brush_xpm), tr("Pencil"), this);
	pencil->setShortcut( QKeySequence(tr("Ctrl+B")) );
	
	QPixmap pix(THEME_DIR+"/cursors/pencil.png");
	pencil->setCursor( QCursor(pix, 0, pix.height()) );
	
	hash.insert( tr("Pencil"), pencil );
	
	return hash;
}
Пример #4
0
bool DAction::operator== ( const DAction& ac ) const
{
    if ( * ( ac.templ ) == * ( templ ) )
        return hash() == ac.hash();

    return false;
}
Пример #5
0
void communiquer(void *arg) {
    DMessage *msg = d_new_message();
    int var1 = 1;
    int num_msg = 0;
 
    rt_printf("tserver : Début de l'exécution de serveur\n");
    serveur->open(serveur, "8000");
    rt_printf("tserver : Connexion\n");
 
    rt_mutex_acquire(&mutexEtat, TM_INFINITE);
    etatCommMoniteur = 0;
    rt_mutex_release(&mutexEtat);
 
    while (var1 > 0) {
        rt_printf("tserver : Attente d'un message\n");
        var1 = serveur->receive(serveur, msg);
        num_msg++;
        if (var1 > 0) {
            switch (msg->get_type(msg)) {
                case MESSAGE_TYPE_ACTION:
                    rt_printf("tserver : Le message %d reçu est une action\n",
                            num_msg);
                    DAction *action = d_new_action();
                    action->from_message(action, msg);
                    switch (action->get_order(action)) {
                        case ACTION_CONNECT_ROBOT:
                            rt_printf("tserver : Action connecter robot\n");
                            rt_sem_v(&semConnecterRobot);
                            break;
                    }
                    break;
                case MESSAGE_TYPE_MOVEMENT:
                    rt_printf("tserver : Le message reçu %d est un mouvement\n",
                            num_msg);
                    rt_mutex_acquire(&mutexMove, TM_INFINITE);
                    move->from_message(move, msg);
                    move->print(move);
                    rt_mutex_release(&mutexMove);
                    break;
            }
        }
    }
}
Пример #6
0
void DMenuPrivate::_q_onItemInvoked(const QString &actionId, bool checked)
{
    DAction *action = actionToId.key(actionId);

    lastTriggerAction = action;

    if(!action)
        return;

    action->setChecked(checked);
    action->trigger();

    D_Q(DMenu);

    Q_EMIT q->triggered(action);

    if(!menuActions.contains(action)) {
        DMenu *actionMenu = qobject_cast<DMenu*>(action->parent());

        if(actionMenu) {
            actionMenu->triggered(action);
        }
    }
}
Пример #7
0
bool DAction::operator< ( const DAction& ac ) const
{
    return hash() < ac.hash();
}
Пример #8
0
void communiquer(void *arg) {
    DMessage *msg = d_new_message();
    DMessage *to_send = d_new_message();
    DAction *action = d_new_action();
    int var1 = 1;
    int num_msg = 0;

    while (1) {
        rt_printf("tserver : Début de l'exécution de serveur\n");
        serveur->open(serveur, "8000");
        rt_printf("tserver : Connexion\n");

        rt_mutex_acquire(&mutexEtat, TM_INFINITE);
        etatCommMoniteur = 0;
        rt_mutex_release(&mutexEtat);

        while (var1 > 0) {
            //rt_printf("tserver : Attente d'un message\n");
            var1 = serveur->receive(serveur, msg);
            num_msg++;
            if (var1 > 0) {
                switch (msg->get_type(msg)) {
                case MESSAGE_TYPE_ACTION:
                    rt_printf("tserver : Le message %d reçu est une action\n", num_msg);
                    action->from_message(action, msg);
                    switch (action->get_order(action)) {
                    case ACTION_CONNECT_ROBOT:
                        rt_printf("tserver : Action connecter robot\n");
                        rt_sem_v(&semConnecterRobot);
                        break;
                    case ACTION_FIND_ARENA:
                        rt_printf("tserver : Demande de detection de l'arene\n");
                        rt_mutex_acquire(&mutexEtatCamera, TM_INFINITE);
                        if (etat_camera == 2) etat_camera = 3;
                        else etat_camera = 1;
                        rt_mutex_release(&mutexEtatCamera);
                        break;
                    case ACTION_COMPUTE_CONTINUOUSLY_POSITION:
                        rt_printf("tserver : Demande de detection du robot\n");
                        rt_mutex_acquire(&mutexEtatCamera, TM_INFINITE);
                        if (etat_camera == 1) etat_camera = 3;
                        else etat_camera = 2;
                        rt_mutex_release(&mutexEtatCamera);
                        break;
                    case ACTION_STOP_COMPUTE_POSITION:
                        rt_printf("tserver : Fin de detection\n");
                        rt_mutex_acquire(&mutexEtatCamera, TM_INFINITE);
                        etat_camera = 0;
                        rt_mutex_release(&mutexEtatCamera);
                        break;
                    }
                    break;

                case MESSAGE_TYPE_MOVEMENT:
                    rt_printf("tserver : Le message reçu %d est un mouvement\n", num_msg);
                    rt_mutex_acquire(&mutexMove, TM_INFINITE);
                    move->from_message(move, msg);
                    //move->print(move);
                    rt_mutex_release(&mutexMove);
                    break;

                case MESSAGE_TYPE_MISSION:
                    rt_printf("tserver : Nouvelle mission\n", num_msg);
                    mission_s->from_message(mission_s, msg);
                    mission_s->print(mission_s);
                    mission_s->get_position(mission_s, position_dest);
                    position_dest->print(position_dest);
                    mission_s->print(mission_s);
                    rt_sem_v(&semMissionLancee);
                    break;

                case MISSION_TYPE_STOP:
                    to_send->mission_terminate(to_send, mission_s->get_id(mission_s));
                    serveur->send(serveur, to_send);
                    //rt_sem_p(&semMissionLancee, TM_INFINITE);
                    break;
                }
            } else {
                rt_printf("tserver : Perte de communication avec le moniteur\n");
                serveur->close(serveur);
                rt_mutex_acquire(&mutexEtat, TM_INFINITE);
                etatCommMoniteur = 1;
                rt_mutex_release(&mutexEtat);
            }
        }
    }
}