Пример #1
0
void ComboBox::onItemActivated(int index)
{
    if (index == count()-1) {
        setCurrentIndex(0);
        emit addItemActivated();
    }
    else {
        emit itemActivated(index);
    }
}
Пример #2
0
void ComboBox::onItemActivated(int index)
{
    if (index == count()-1) {
        setCurrentIndex(0);
        emit addItemActivated();
    }
    else {
        emit itemActivated(index);
    }

    /*if (! mDialog)
        return;

    if (index == count()-1) {
        mDialog->exec();
    }

    setCurrentIndex(0);
    */
}
ObjectEditorWidget::ObjectEditorWidget(QWidget *parent) :
    PropertiesWidget(parent)
{
    QRegExpValidator * validator = new QRegExpValidator(QRegExp("^[0-9]+(%){0,1}$"), this);

    //mChooseObjectComboBox = new QComboBox(this);
    //mChooseObjectComboBox = 0;
    mNameEdit = new QLineEdit(this);
    mVisibleCheckbox = new QCheckBox(this);
    mXSpin = new QSpinBox(this);
    mYSpin = new QSpinBox(this);
    mWidthEditor = new QLineEdit(this);
    mWidthEditor->setValidator(validator);
    mWidthEditor->setObjectName("widthEditor");
    mHeightEditor = new QLineEdit(this);
    mHeightEditor->setValidator(validator);
    mHeightEditor->setObjectName("heightEditor");

    //connect(mChooseObjectComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentWorkingObjectChanged(int)));
    connect(mNameEdit, SIGNAL(textEdited(const QString &)), this, SLOT(onNameChanged(const QString&)));
    connect(mVisibleCheckbox, SIGNAL(toggled(bool)), this, SLOT(onVisibilityChanged(bool)));
    connect(mXSpin, SIGNAL(valueChanged(int)), this, SLOT(onXChanged(int)));
    connect(mYSpin, SIGNAL(valueChanged(int)), this, SLOT(onYChanged(int)));
    connect(mWidthEditor, SIGNAL(textEdited(const QString &)), this, SLOT(onSizeEdited(const QString&)));
    connect(mHeightEditor, SIGNAL(textEdited(const QString &)), this, SLOT(onSizeEdited(const QString&)));

    this->beginGroup(tr("Object"), "Object");
    //this->appendRow(tr("Current"), mChooseObjectComboBox);
    this->appendRow(tr("Name"), mNameEdit);
    this->appendRow(tr("Visible"), mVisibleCheckbox);
    this->appendRow("x", mXSpin);
    this->appendRow("y", mYSpin);
    this->appendRow(tr("Width"), mWidthEditor);
    this->appendRow(tr("Height"), mHeightEditor);
    this->endGroup();

    this->beginGroup(tr("Bounding Rect"));
    mBorderWidthSpinBox = new QSpinBox(this);
    mBorderWidthSpinBox->setMaximum(50);
    mBorderColorButton = new ColorPushButton(this);
    mRoundedRectCheckBox = new QCheckBox(this);
    mXRadiusSpinBox = new QSpinBox(this);
    mYRadiusSpinBox = new QSpinBox(this);
    mXRadiusSpinBox->setDisabled(true);
    mYRadiusSpinBox->setDisabled(true);

    connect(mBorderWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(onBorderWidthChanged(int)));
    connect(mBorderColorButton, SIGNAL(colorChosen(const QColor&)), this, SLOT(onBorderColorChanged(const QColor&)));
    connect(mXRadiusSpinBox, SIGNAL(valueChanged(int)), this, SLOT(onXRadiusValueChanged(int)));
    connect(mYRadiusSpinBox, SIGNAL(valueChanged(int)), this, SLOT(onYRadiusValueChanged(int)));
    connect(mRoundedRectCheckBox, SIGNAL(toggled(bool)), this, SLOT(onRoundedRectToggled(bool)));
    connect(mRoundedRectCheckBox, SIGNAL(toggled(bool)), mXRadiusSpinBox, SLOT(setEnabled(bool)));
    connect(mRoundedRectCheckBox, SIGNAL(toggled(bool)), mYRadiusSpinBox, SLOT(setEnabled(bool)));

    appendRow(tr("Border Width"), mBorderWidthSpinBox);
    appendRow(tr("Border Color"), mBorderColorButton);

    beginSubGroup(tr("Rounded"), mRoundedRectCheckBox);
    appendRow(tr("X Radius"), mXRadiusSpinBox);
    appendRow(tr("Y Radius"), mYRadiusSpinBox);
    endGroup();

    endGroup();

    mImageChooser = new ChooseFileButton(ChooseFileButton::ImageFilter, this);
    mColorButton = new ColorPushButton(this);
    mOpacitySlider = new QSlider(Qt::Horizontal, this);
    mOpacitySlider->setMaximum(255);

    connect(mImageChooser, SIGNAL(fileSelected(const QString&)), this, SLOT(onImageChosen(const QString&)));
    connect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int)));
    connect(mColorButton, SIGNAL(colorChosen(const QColor&)), this, SLOT(onColorChosen(const QColor&)));

    this->beginGroup(tr("Background"));
    this->appendRow(tr("Color"), mColorButton);
    this->appendRow(tr("Image"), mImageChooser);
    this->appendRow(tr("Opacity"), mOpacitySlider);
    this->endGroup();

    this->beginGroup(tr("Events"));
    mMousePressComboBox = new ComboBox(this);
    mMousePressComboBox->setObjectName("MousePressComboBox");
    connect (mMousePressComboBox, SIGNAL(addItemActivated()), this, SLOT(onAddItemActivated()));
    connect (mMousePressComboBox, SIGNAL(itemRemoved(int)), this, SLOT(onEventItemRemoved(int)));
    this->appendRow("OnMousePress", mMousePressComboBox);
    mWidgetToEvent.insert(mMousePressComboBox, Interaction::MousePress);

    mMouseReleaseComboBox = new ComboBox(this);
    mMouseReleaseComboBox->setObjectName("MouseReleaseComboBox");
    connect (mMouseReleaseComboBox, SIGNAL(addItemActivated()), this, SLOT(onAddItemActivated()));
    connect (mMouseReleaseComboBox, SIGNAL(itemRemoved(int)), this, SLOT(onEventItemRemoved(int)));
    this->appendRow("OnMouseRelease", mMouseReleaseComboBox);
    mWidgetToEvent.insert(mMouseReleaseComboBox, Interaction::MouseRelease);
    this->endGroup();

    mMouseMoveComboBox = new ComboBox(this);
    mMouseMoveComboBox->setObjectName("MouseMoveComboBox");
    connect (mMouseMoveComboBox, SIGNAL(addItemActivated()), this, SLOT(onAddItemActivated()));
    connect (mMouseMoveComboBox, SIGNAL(itemRemoved(int)), this, SLOT(onEventItemRemoved(int)));
    this->appendRow("OnMouseMove", mMouseMoveComboBox);
    mWidgetToEvent.insert(mMouseMoveComboBox, Interaction::MouseMove);
    this->endGroup();

    mCurrentObject = 0;

    resizeColumnToContents(0);
}