void OrientationWidget::moveCursor(const QPointF &pos) { QPointF centerCircle = this->centerCircle(); qreal sizeX=pos.x() - centerCircle.x(), sizeY=pos.y() - centerCircle.y(); double angle; if(sizeX != 0) { angle = atan2(abs(sizeY), abs(sizeX)) * 57.29577951;// rad2deg } else { angle = 0; } if(sizeX == 0 && sizeY == 0) { return; } else if(sizeX < 0 && sizeY <= 0) { _value = 0 + angle; } else if(sizeX == 0 && sizeY < 0) { _value = 90; } else if(sizeX > 0 && sizeY < 0) { _value = 180 - angle; } else if(sizeX == 0 && sizeY > 0) { _value = 270; } else if(sizeX < 0 && sizeY > 0) { _value = 360 - angle; } else if(sizeX > 0 && sizeY >= 0) { _value = 180 + angle; } quint8 value = degree2byte(); setValue(value); emit valueEdited(value); }
void DAVAFloat32SpinBox::textEditingFinished() { // was modified if(lineEdit()->isUndoAvailable()) { QString newString = lineEdit()->text(); newString.replace(QChar(','), QChar('.')); // current text is different from the originalText if(newString != originalString) { bool convertedNew = false; bool convertedOrig = false; double newValue = newString.toDouble(&convertedNew); double origValue = originalString.toDouble(&convertedOrig); // current double value is different from the original if(convertedNew && convertedOrig && newValue != origValue) { setValue((DAVA::float32) newValue); emit valueEdited(); } } } }
ModificationWidget::ModificationWidget(QWidget* parent) : QWidget(parent) , curScene(NULL) , groupMode(false) , pivotMode(PivotAbsolute) , modifMode(ST_MODIF_OFF) { QHBoxLayout *horizontalLayout; horizontalLayout = new QHBoxLayout(this); horizontalLayout->setSpacing(2); horizontalLayout->setContentsMargins(2, 1, 2, 1); xLabel = new QLabel("X:", this); xLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); horizontalLayout->addWidget(xLabel); xAxisModify = new DAVAFloat32SpinBox(this); xAxisModify->setMinimumSize(QSize(70, 0)); horizontalLayout->addWidget(xAxisModify); yLabel = new QLabel("Y:", this); yLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); horizontalLayout->addWidget(yLabel); yAxisModify = new DAVAFloat32SpinBox(this); yAxisModify->setMinimumSize(QSize(70, 0)); horizontalLayout->addWidget(yAxisModify); zLabel = new QLabel("Z:", this); zLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); horizontalLayout->addWidget(zLabel); zAxisModify = new DAVAFloat32SpinBox(this); zAxisModify->setMinimumSize(QSize(70, 0)); horizontalLayout->addWidget(zAxisModify); QObject::connect(xAxisModify, SIGNAL(valueEdited()), this, SLOT(OnXChanged())); QObject::connect(yAxisModify, SIGNAL(valueEdited()), this, SLOT(OnYChanged())); QObject::connect(zAxisModify, SIGNAL(valueEdited()), this, SLOT(OnZChanged())); QObject::connect(SceneSignals::Instance(), SIGNAL(SelectionChanged(SceneEditor2 *, const EntityGroup *, const EntityGroup *)), this, SLOT(OnSceneSelectionChanged(SceneEditor2 *, const EntityGroup *, const EntityGroup *))); QObject::connect(SceneSignals::Instance(), SIGNAL(Activated(SceneEditor2 *)), this, SLOT(OnSceneActivated(SceneEditor2 *))); QObject::connect(SceneSignals::Instance(), SIGNAL(Deactivated(SceneEditor2 *)), this, SLOT(OnSceneDeactivated(SceneEditor2 *))); QObject::connect(SceneSignals::Instance(), SIGNAL(CommandExecuted(SceneEditor2 *, const Command2* , bool)), this, SLOT(OnSceneCommand(SceneEditor2 *, const Command2* , bool))); }
void DAVAFloat32SpinBox::stepBy(int steps) { textEditingFinished(); setValue(originalValue + (DAVA::float32) steps); selectAll(); emit valueEdited(); }
void SnapSpinBox::stepBy(int steps) { double increaseValue = (steps > 0)?(steps-.5):(steps+.49999); double oldValue = m_originalValue; double newValue = qRound(oldValue + increaseValue); if (newValue < 1) return; setValue(newValue); emit(valueEdited(value())); }
/** Si en cualquier función accedemos al texto, utilizando text(), se pierde la posición del cursor y la edición del número se hace imposible. Por eso, se ha creado una variable interna que almacena el valor numérico, cada vez que el texto cambia. Aquí se almacena ese valor cada vez que se modifca el texto. */ void DBNumberEdit::storeNumber(const QString & texto) { bool ok; if ( !d->m_doingChanges ) { if ( !texto.isNull() && !texto.isEmpty() ) { d->m_numericValue = configuracion.getLocale()->toDouble(texto, &ok); if ( !ok ) { d->m_numericValue = 0; } } else { d->m_numericValue = 0; } } emit valueEdited(QVariant(d->m_numericValue)); }
void SnapSpinBox::handleLineEditTextEdited(const QString &text) { m_originalValue = text.toDouble(); emit(valueEdited(m_originalValue)); }
//------------------------------------------------------------------------------ EstimateDetailsForm::EstimateDetailsForm(EstimateModel* model, QSharedPointer<BudgetingPeriod> period, QUndoStack* stack, QWidget* parent) : QWidget(parent), model(model), period(period), undoStack(stack) { // Setup name field nameField = new LineEdit("", this); nameField->setEnabled(false); connect(nameField, SIGNAL(textEdited(QString)), this, SLOT(updateName(QString))); // Setup description field descriptionField = new LineEdit("", this); descriptionField->setEnabled(false); connect(descriptionField, SIGNAL(textEdited(QString)), this, SLOT(updateDescription(QString))); // Setup type field typeField = new QComboBox(this); typeField->addItem(tr("Expense"), Estimate::Expense); typeField->addItem(tr("Income"), Estimate::Income); typeField->addItem(tr("Transfer"), Estimate::Transfer); typeField->setEnabled(false); connect(typeField, SIGNAL(currentIndexChanged(int)), this, SLOT(updateType(int))); // Setup amount field amountField = new MoneyEdit(this); amountField->setEnabled(false); connect(amountField, SIGNAL(valueEdited(Money)), this, SLOT(updateAmount(Money))); // Setup due date field dueDateField = new QDateEdit(this); dueDateField->installEventFilter(new IgnoreUndoRedo(this, this)); dueDateField->setCalendarPopup(true); dueDateField->setSpecialValueText(tr("None")); dueDateField->setEnabled(false); clearDueDate(); connect(dueDateField, SIGNAL(dateChanged(QDate)), this, SLOT(updateDueDate(QDate))); // Setup clear-due date button clearDueDateButton = new QPushButton(tr("Clear"), this); clearDueDateButton->setEnabled(false); connect(clearDueDateButton, SIGNAL(clicked(bool)), this, SLOT(clearDueDate())); // Make sure we pick up changes to the budgeting period start date // (have to use Qt5 style connect because of namespaced type) connect(period.data(), &BudgetingPeriod::paramsChanged, this, &EstimateDetailsForm::startDateChanged); startDateChanged(); // initial populate // Put due date entry and clear button side-by-side QHBoxLayout* dueDateLayout = new QHBoxLayout; dueDateLayout->addWidget(dueDateField, 1); dueDateLayout->addWidget(clearDueDateButton); // Setup finished field finishedField = new QCheckBox(this); connect(finishedField, SIGNAL(toggled(bool)), this, SLOT(updateFinishedState(bool))); // Setup form layout QFormLayout* form = new QFormLayout; form->addRow(tr("Name"), nameField); form->addRow(tr("Description"), descriptionField); form->addRow(tr("Type"), typeField); form->addRow(tr("Amount"), amountField); form->addRow(tr("Due Date"), dueDateLayout); form->addRow(tr("Finished"), finishedField); // Add to widget setLayout(form); // Get updated data when the estimates change connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(dataChanged(QModelIndex,QModelIndex))); }