示例#1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    convert_value = 1.2607;
    coma_here = false;
    current_op = NONE;
    operand_1 = 0.;
    operand_2 = 0.;

    connect(ui->actionQuitter, SIGNAL(triggered()), this, SLOT(close()));
    connect(ui->actionA_propos, SIGNAL(triggered()), this, SLOT(onAPropos()));
    connect(ui->actionA_propos_de_Qt, SIGNAL(triggered()), this, SLOT(onAProposDeQt()));
    connect(ui->actionParam_tres_conversion, SIGNAL(triggered()), this, SLOT(onParametreConversion()));

    connect(ui->pushButton_0, SIGNAL(clicked()), this, SLOT(on0()));
    connect(ui->pushButton_1, SIGNAL(clicked()), this, SLOT(on1()));
    connect(ui->pushButton_2, SIGNAL(clicked()), this, SLOT(on2()));
    connect(ui->pushButton_3, SIGNAL(clicked()), this, SLOT(on3()));
    connect(ui->pushButton_4, SIGNAL(clicked()), this, SLOT(on4()));
    connect(ui->pushButton_5, SIGNAL(clicked()), this, SLOT(on5()));
    connect(ui->pushButton_6, SIGNAL(clicked()), this, SLOT(on6()));
    connect(ui->pushButton_7, SIGNAL(clicked()), this, SLOT(on7()));
    connect(ui->pushButton_8, SIGNAL(clicked()), this, SLOT(on8()));
    connect(ui->pushButton_9, SIGNAL(clicked()), this, SLOT(on9()));

    connect(ui->pushButton_coma, SIGNAL(clicked()), this, SLOT(onComa()));

    connect(ui->pushButton_equal, SIGNAL(clicked()), this, SLOT(onEqual()));
    connect(ui->pushButton_divided, SIGNAL(clicked()), this, SLOT(onDivided()));
    connect(ui->pushButton_plus, SIGNAL(clicked()), this, SLOT(onPlus()));
    connect(ui->pushButton_minus, SIGNAL(clicked()), this, SLOT(onMinus()));
    connect(ui->pushButton_times, SIGNAL(clicked()), this, SLOT(onMultiplicate()));
    connect(ui->pushButton_dollar_euro, SIGNAL(clicked()), this, SLOT(onDollarEuro()));
    connect(ui->pushButton_euro_dollar, SIGNAL(clicked()), this, SLOT(onEuroDollar()));

    // shortcuts
    QShortcut *scDel = new QShortcut(QKeySequence("Del"), this);
    connect(scDel, SIGNAL(activated()), this, SLOT(clearLine()));

    QShortcut *scBackspace = new QShortcut(QKeySequence("Backspace"), this);
    connect(scBackspace, SIGNAL(activated()), this, SLOT(clearLastChar()));

//    QShortcut *scEnter = new QShortcut(QKeySequence("Enter"), this);
//    connect(scEnter, SIGNAL(activated()), this, SLOT(onEqual()));

//    QShortcut *sc0 = new QShortcut(QKeySequence("0"), this);
//    connect(scBackspace, SIGNAL(activated()), this, SLOT(on0()));
}
示例#2
0
void Events::onEventsKey(Uint8 a, SDLKey key)
{
    bool b;
    if( a == SDL_KEYDOWN ) b=true;
        else b=false;
    switch (key)
    {
        case SDLK_RETURN:   if(!altPressed) { onEnter(b); }      onMyEnter(b); break;
        case SDLK_LEFT:     onArrow(LEFT,b);                     break;
        case SDLK_RIGHT:    onArrow(RIGHT,b);                    break;
        case SDLK_UP:       onArrow(UP,b);                       break;
        case SDLK_DOWN:     onArrow(DOWN,b);                     break;
        case SDLK_PLUS:     onPlus(b);                           break;
        case SDLK_MINUS:    onMinus(b);                          break;
        case SDLK_KP_PLUS:  onPlus(b);                           break;
        case SDLK_KP_MINUS: onMinus(b);                          break;
        case SDLK_SPACE:    onSpace(b);                          break;
        case SDLK_f:        onF(b);           onMyF(b);          break;
        case SDLK_s:        onS(b);           onMyS(b);          break;
        case SDLK_ESCAPE:   onEsc(b);                            break;
        case SDLK_RCTRL:    onCtrl(b);                           break;
        case SDLK_LCTRL:    onCtrl(b);                           break;
        case SDLK_RALT:     onAlt(b);         onMyAlt(b);        break;
        case SDLK_LALT:     onAlt(b);         onMyAlt(b);        break;
        default: break;
    }
    onKey(b,key);
    char c=0;
    switch (key)
    {
        case SDLK_a: c='a'; break;
        case SDLK_b: c='b'; break;
        case SDLK_c: c='c'; break;
        case SDLK_d: c='d'; break;
        case SDLK_e: c='e'; break;
        case SDLK_f: c='f'; break;
        case SDLK_g: c='g'; break;
        case SDLK_h: c='h'; break;
        case SDLK_i: c='i'; break;
        case SDLK_j: c='j'; break;
        case SDLK_k: c='k'; break;
        case SDLK_l: c='l'; break;
        case SDLK_m: c='m'; break;
        case SDLK_n: c='n'; break;
        case SDLK_o: c='o'; break;
        case SDLK_p: c='p'; break;
        case SDLK_q: c='q'; break;
        case SDLK_r: c='r'; break;
        case SDLK_s: c='s'; break;
        case SDLK_t: c='t'; break;
        case SDLK_u: c='u'; break;
        case SDLK_w: c='w'; break;
        case SDLK_x: c='x'; break;
        case SDLK_y: c='y'; break;
        case SDLK_v: c='v'; break;
        case SDLK_z: c='z'; break;

        case SDLK_0: c='0'; break;
        case SDLK_1: c='1'; break;
        case SDLK_2: c='2'; break;
        case SDLK_3: c='3'; break;
        case SDLK_4: c='4'; break;
        case SDLK_5: c='5'; break;
        case SDLK_6: c='6'; break;
        case SDLK_7: c='7'; break;
        case SDLK_8: c='8'; break;
        case SDLK_9: c='9'; break;
        default: break;
    };

    if(c) onNamedKey(b,c);
}