Пример #1
0
GTrans::GTrans() {
    QLayout *mainLayout = new QVBoxLayout;

    // The input section
    QLayout *top = new QHBoxLayout;
    QBoxLayout *tl = new QVBoxLayout;
    QLabel *inLabel = new QLabel(tr("Input:"));
    fromLang = new QComboBox;
    tl->addWidget(inLabel);
    tl->addSpacing(10);
    tl->addWidget(fromLang);
    tl->addStretch();
    top->addItem(tl);
    inputTxt = new QTextEdit;

    top->addWidget(inputTxt);

    // The output section
    QLayout *bottom = new QHBoxLayout;
    QBoxLayout *bl = new QVBoxLayout;
    QLabel *outLabel = new QLabel(tr("Output:"));
    toLang = new QComboBox;
    bl->addWidget(outLabel);
    bl->addSpacing(10);
    bl->addWidget(toLang);
    bl->addStretch();
    bottom->addItem(bl);
    outputTxt = new QTextEdit;
    outputTxt->setReadOnly(true);
    bottom->addWidget(outputTxt);

    mainLayout->addItem(top);
    mainLayout->addItem(bottom);

    // Translate button
    trans_b = new QPushButton(tr("Translate"));
    mainLayout->addWidget(trans_b);

    fillInLanguages();

    setLayout(mainLayout);
    setWindowTitle(tr("Translate"));
    
    trans_b->setDefault(true);
    connect(trans_b, SIGNAL(clicked()), this, SLOT(doTrans()));

    // Setup foxus and tab order.
    inputTxt->setTabChangesFocus(true);
    inputTxt->setFocus(Qt::ActiveWindowFocusReason);
    setTabOrder(inputTxt, toLang);
    setTabOrder(toLang, trans_b);
    setTabOrder(trans_b, fromLang);
    setTabOrder(fromLang, inputTxt);
    outputTxt->setFocusProxy(trans_b);
}
Пример #2
0
float ImageLens::imageInten(int i, int j) const
{
    if (trans_)
        doTrans(i, j);
    if (cut_)
        doCut(i, j);
    float ret = image_.inten2d(i, j);
    const Image& normalizer = gSession->corrset.getNormalizer();
    if (gSession->corrset.isEnabledAndValid())
        ret *= normalizer.inten2d(i, j);
    return ret;
}
Пример #3
0
int atoi(char *str){
    if(str == NULL || *str == '\0'){
        g_invalid_input = 1;
        return -1;
    }

    int minus = 1;
    if(*str == '-'){
        minus = -1;
        str++;
    }
    return doTrans(str, minus);
}
Пример #4
0
GTrans::GTrans() {

    //lzt QTextcode modify for Utf8
    QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
    QTextCodec::setCodecForCStrings( QTextCodec::codecForLocale());

    //Layout
//    QLayout *mainLayout = new QVBoxLayout;
    QLayout *mainLayout = new QStackedLayout;

    // The input section
//    QLayout *top = new QHBoxLayout;
//    QBoxLayout *tl = new QVBoxLayout;
//    QLabel *inLabel = new QLabel(tr("Input:"));
//    mainLayout->addWidget(inLabel);                  //lzt add
//   fromLang = new QComboBox;
//    tl->addWidget(inLabel);
//    tl->addSpacing(10);
//    tl->addWidget(fromLang);
//    tl->addStretch();
//    top->addItem(tl);
//    inputTxt = new QTextEdit;

//    top->addWidget(inputTxt);
//    mainLayout->addWidget(inputTxt);                //lzt add

    // The output section
//    QLayout *bottom = new QHBoxLayout;
//    QBoxLayout *bl = new QVBoxLayout;
//    QLabel *outLabel = new QLabel(tr("Output:"));
//    toLang = new QComboBox;
//    bl->addWidget(outLabel);
//    bl->addSpacing(10);
//    bl->addWidget(toLang);
//    bl->addStretch();
//    bottom->addItem(bl);
//    mainLayout->addWidget(outLabel);                //lzt add
      outputTxt = new QTextEdit;
//    outputTxt->setReadOnly(true);
//    bottom->addWidget(outputTxt);
      mainLayout->addWidget(outputTxt);               //lzt add

//    mainLayout->addItem(top);
//    mainLayout->addItem(bottom);

    // Translate button
//    trans_b = new QPushButton(tr("Translate"));
//    mainLayout->addWidget(trans_b);

    setLayout(mainLayout);
    setWindowTitle(tr("Translate"));


//    trans_b->setDefault(true);
//    connect(trans_b, SIGNAL(clicked()), this, SLOT(doTrans()));

//lzt clip
    QClipboard *clipboard = QApplication::clipboard();
    connect(clipboard, SIGNAL(selectionChanged()), this, SLOT(doTrans()));
//

    // Setup foxus and tab order.
//    inputTxt->setTabChangesFocus(true);
//    inputTxt->setFocus(Qt::ActiveWindowFocusReason);
//    outputTxt->setFocusProxy(trans_b);
}