示例#1
0
文件: gui.cpp 项目: jprid151/roadrace
void GuiManager::generateSquareGrid() {

    std::cout << getUi()->label->text().toStdString() << std::endl;
    Sound::instance().playSoundTrack();

    ui->gameLayout->setContentsMargins(100,100,100,100);
    vector<vector<Square*>> squaresList = Game::instance().getSquares();


    vector<vector<Square*>> squares = Game::instance().getSquares();

    if ( squares.size() == 0) {
        return;
    }


    int border=5;
    int size = ui->gridLayoutWidget->width()/squares.size()/2;

    Square::setSize(size);
    Square::setBorder(border);

    for(size_t index = 0;index<squares.size();index++){
        for (size_t sub_index = 0; sub_index <squares.at(index).size(); sub_index++ ) {

            Square *proc = squares.at(index).at(sub_index);

            SquareLabel *lbl = new SquareLabel(proc,ui->gridLayoutWidget);

            proc->setLabel(lbl);
            QSize size1(size,size);
            QPixmap map = setmap(proc, size1);
            lbl->setPixmap(map);
            lbl->setFixedHeight(size);
            lbl->setFixedWidth(size);
            Player *owner = proc->getOwner();
            std::string color = owner == NULL ? "black" : owner->getColor();
            lbl->setStyleSheet("border:" + QString::fromStdString(to_string(border)) +  "px solid " + QString::fromStdString(color) + ";\n");
            ui->gameLayout->addWidget(lbl,index,sub_index,0);
            lbl->setAlignment(Qt::AlignCenter);
            proc->setX(index);
            proc->setY(sub_index);
            lbl->show();
        }
        //ui->gameLayout->set(index,size);
        //ui->gameLayout->setRowMinimumHeight(index,size);

    }
    ui->gameLayout->setSpacing(0);
}
示例#2
0
    }

    void GuiGrapher::setup() {
        getUi().setupUi(this);
        getUi().grx_term->setVisible(false);
        getUi().grx_lvar->setVisible(false);
        getUi().hsl_value->setEnabled(isInputLVar());
        getUi().hsl_value->setVisible(isInputLVar());
        getUi().led_x->setReadOnly(isOutputLVar());
        getUi().lbl_y->setVisible(isInputLVar());
        getUi().led_y->setVisible(isInputLVar());
        connect();
    }

    void GuiGrapher::connect() {
        QObject::connect(getUi().hsl_value, SIGNAL(valueChanged(int)), this,
                SLOT(onChangeSliderValue(int)));
        QObject::connect(getUi().led_x, SIGNAL(editingFinished()), this,
                SLOT(onEditInputValue()));
        QObject::connect(this, SIGNAL(onChangeInputValue()), this, SLOT(updateUi()));

    }

    void GuiGrapher::disconnect() {
        QObject::disconnect(getUi().hsl_value, SIGNAL(valueChanged(int)), this,
                SLOT(onChangeSliderValue(int)));
        QObject::disconnect(getUi().led_x, SIGNAL(editingFinished()), this,
                SLOT(onEditInputValue()));
        QObject::disconnect(this, SIGNAL(onChangeInputValue()), this, SLOT(updateUi()));
    }
 void GuiLinguisticTerm::setup() {
     getUi().setupUi(this);
     connect();
 }
    GuiLinguisticTerm::~GuiLinguisticTerm() {
        disconnect();
        delete _ui;
    }

    Ui::LinguisticTerm& GuiLinguisticTerm::getUi() const {
        return *this->_ui;
    }

    void GuiLinguisticTerm::setup() {
        getUi().setupUi(this);
        connect();
    }

    void GuiLinguisticTerm::connect() {
        QObject::connect(getUi().dsx_triangular_a, SIGNAL(valueChanged(double)), this,
                SLOT(onChangeTriangularA(double)));
        QObject::connect(getUi().dsx_triangular_b, SIGNAL(valueChanged(double)), this,
                SLOT(onChangeTriangularB(double)));
        QObject::connect(getUi().dsx_triangular_c, SIGNAL(valueChanged(double)), this,
                SLOT(onChangeTriangularC(double)));

        QObject::connect(getUi().dsx_rectangular_min, SIGNAL(valueChanged(double)), this,
                SLOT(onChangeRectangularMin(double)));
        QObject::connect(getUi().dsx_rectangular_max, SIGNAL(valueChanged(double)), this,
                SLOT(onChangeRectangularMax(double)));

        QObject::connect(getUi().dsx_trapezoidal_a, SIGNAL(valueChanged(double)), this,
                SLOT(onChangeTrapezoidalA(double)));
        QObject::connect(getUi().dsx_trapezoidal_b, SIGNAL(valueChanged(double)), this,
                SLOT(onChangeTrapezoidalB(double)));