| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #include "lc_actionoptionswidget.h" |
| |
|
| | #include <QLineEdit> |
| | #include <QToolButton> |
| |
|
| | #include "lc_actioncontext.h" |
| | #include "lc_convert.h" |
| | #include "lc_linemath.h" |
| | #include "rs_actioninterface.h" |
| | #include "rs_debug.h" |
| | #include "rs_math.h" |
| | #include "rs_settings.h" |
| |
|
| | class LC_LateCompletionRequestor; |
| |
|
| | LC_ActionOptionsWidget::LC_ActionOptionsWidget(QWidget *parent, Qt::WindowFlags fl) : |
| | QWidget(parent, fl) { |
| | m_interactiveInputControlsAutoRaise = LC_GET_ONE_BOOL("Widgets", "PickValueButtonsFlatIcons", true); |
| | m_interactiveInputControlsVisible = LC_GET_ONE_BOOL("Defaults", "InteractiveInputEnabled", true); |
| | } |
| |
|
| | LC_ActionOptionsWidget::~LC_ActionOptionsWidget() = default; |
| |
|
| | |
| | |
| | |
| | |
| | void LC_ActionOptionsWidget::hideOptions(){ |
| | hide(); |
| | saveSettings(); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | void LC_ActionOptionsWidget::setAction(RS_ActionInterface *a, bool update){ |
| | if (a != nullptr){ |
| | RS2::ActionType actionType = a->rtti(); |
| | if (checkActionRttiValid(actionType)){ |
| | |
| | LC_GROUP(getSettingsGroupName()); |
| | m_actionContext = a->getActionContext(); |
| | m_laterCompletionRequestor = dynamic_cast<LC_LateCompletionRequestor*>(a); |
| | doSetAction(a, update); |
| | LC_GROUP_END(); |
| | } |
| | else{ |
| | RS_DEBUG->print(RS_Debug::D_ERROR, typeid(*this).name(), "::setAction: wrong action type"); |
| | } |
| | } |
| | else { |
| | m_laterCompletionRequestor = nullptr; |
| | m_actionContext = nullptr; |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | bool LC_ActionOptionsWidget::checkActionRttiValid([[maybe_unused]]RS2::ActionType actionType){ |
| | return false; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | void LC_ActionOptionsWidget::saveSettings(){ |
| | LC_GROUP(getSettingsGroupName()); |
| | doSaveSettings(); |
| | LC_GROUP_END(); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | bool LC_ActionOptionsWidget::toDouble(const QString& strValue, double &res, double notMeaningful, bool positiveOnly){ |
| | bool ok = false; |
| | double x = RS_Math::eval(strValue, &ok); |
| | if(ok){ |
| | res = LC_LineMath::getMeaningful(x, notMeaningful); |
| | if (positiveOnly){ |
| | res = std::abs(res); |
| | } |
| | } |
| | return ok; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | bool LC_ActionOptionsWidget::toDoubleAngleDegrees(const QString& strValue, double &res, double notMeaningful, bool positiveOnly){ |
| | bool ok = LC_Convert::parseToToDoubleAngleDegrees(strValue, res, notMeaningful, positiveOnly); |
| | return ok; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | QString LC_ActionOptionsWidget::fromDouble(double value){ |
| | |
| | if (LC_LineMath::isNotMeaningful(value)){ |
| | value = 0.0; |
| | } |
| | return QString::number(value, 'g', 6); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | QString LC_ActionOptionsWidget::load(QString name, QString defaultValue){ |
| | QString key = getSettingsOptionNamePrefix() + name; |
| | return LC_GET_STR(key, defaultValue); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | int LC_ActionOptionsWidget::loadInt(QString name, int defaultValue){ |
| | QString key = getSettingsOptionNamePrefix() + name; |
| | return LC_GET_INT(key, defaultValue); |
| | } |
| |
|
| | bool LC_ActionOptionsWidget::loadBool(QString name, bool defaultValue){ |
| | QString key = getSettingsOptionNamePrefix() + name; |
| | return LC_GET_INT(key, defaultValue ? 1 : 0) == 1; |
| | } |
| |
|
| | void LC_ActionOptionsWidget::save(QString name, QString value){ |
| | QString key = getSettingsOptionNamePrefix() + name; |
| | LC_SET(key, value); |
| | } |
| |
|
| | void LC_ActionOptionsWidget::save(QString name, int value){ |
| | QString key = getSettingsOptionNamePrefix() + name; |
| | LC_SET(key, value); |
| | } |
| |
|
| | void LC_ActionOptionsWidget::save(QString name, bool value){ |
| | QString key = getSettingsOptionNamePrefix() + name; |
| | LC_SET(key, value ? 1 : 0); |
| | } |
| |
|
| | void LC_ActionOptionsWidget::connectInteractiveInputButton(QToolButton* button, |
| | LC_ActionContext::InteractiveInputInfo::InputType |
| | inputType, QString tag) { |
| | if (m_interactiveInputControlsVisible) { |
| | button->setVisible(true); |
| | button->setProperty("_interactiveInputButton", inputType); |
| | button->setProperty("_interactiveInputTag", tag); |
| | button->connect(button, &QToolButton::clicked, this, &LC_ActionOptionsWidget::onInteractiveInputButtonClicked); |
| | button->setAutoRaise(m_interactiveInputControlsAutoRaise); |
| | } |
| | else { |
| | button->setVisible(false); |
| | } |
| | } |
| |
|
| | void LC_ActionOptionsWidget::requestFocusForTag(const QString& tag) { |
| | auto widgets = findChildren<QWidget*>(); |
| | for (auto le:widgets) { |
| | auto tagProperty = le->property("_tagHolder"); |
| | if (tagProperty.isValid() && !tagProperty.isNull()) { |
| | QString editTag = tagProperty.toString(); |
| | if (tag == editTag) { |
| | le->setFocus(); |
| | break; |
| | } |
| | } |
| | } |
| | } |
| |
|
| | void LC_ActionOptionsWidget::pickDistanceSetup(QString tag, QToolButton* button, QLineEdit* lineedit) { |
| | connectInteractiveInputButton(button, LC_ActionContext::InteractiveInputInfo::DISTANCE, tag); |
| | lineedit->setProperty("_tagHolder", tag); |
| | } |
| |
|
| | void LC_ActionOptionsWidget::pickAngleSetup(QString tag, QToolButton* button, QLineEdit* lineedit) { |
| | connectInteractiveInputButton(button, LC_ActionContext::InteractiveInputInfo::ANGLE, tag); |
| | lineedit->setProperty("_tagHolder", tag); |
| | } |
| |
|
| | void LC_ActionOptionsWidget::onInteractiveInputButtonClicked([[maybe_unused]]bool checked) { |
| | auto senderButton = dynamic_cast<QToolButton*>(sender()); |
| | if (senderButton != nullptr) { |
| | auto property = senderButton->property ("_interactiveInputButton"); |
| | if (property.isValid()) { |
| | auto inputType = static_cast<LC_ActionContext::InteractiveInputInfo::InputType>(property.toInt()); |
| | auto tagProperty = senderButton->property ("_interactiveInputTag"); |
| | QString tag = tagProperty.toString(); |
| | switch (inputType) { |
| | case LC_ActionContext::InteractiveInputInfo::DISTANCE: |
| | case LC_ActionContext::InteractiveInputInfo::ANGLE: { |
| | m_actionContext->interactiveInputStart(inputType, m_laterCompletionRequestor, tag); |
| | break; |
| | } |
| | case LC_ActionContext::InteractiveInputInfo::POINT: { |
| | |
| | break; |
| | } |
| | default: |
| | break; |
| | } |
| | } |
| | } |
| | } |
| |
|