fix - Opacity settings resets to default after changing in the configurations if you click on slider (not dragging)

(cherry picked from commit 17a956c03c7245cecd0f7d84bccdc715d6e82bbd)
This commit is contained in:
Yuriy Puchkov
2021-01-28 15:03:56 +02:00
parent 6707f15c31
commit 48d312b8df
2 changed files with 6 additions and 15 deletions

View File

@@ -22,7 +22,6 @@
#include "src/utils/confighandler.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QVBoxLayout>
VisualsEditor::VisualsEditor(QWidget* parent)
: QWidget(parent)
@@ -46,10 +45,6 @@ void VisualsEditor::initOpacitySlider()
m_opacitySlider->setFocusPolicy(Qt::NoFocus);
m_opacitySlider->setOrientation(Qt::Horizontal);
m_opacitySlider->setRange(0, 100);
connect(m_opacitySlider,
&ExtendedSlider::modificationsEnded,
this,
&VisualsEditor::saveOpacity);
QHBoxLayout* localLayout = new QHBoxLayout();
localLayout->addWidget(new QLabel(QStringLiteral("0%")));
localLayout->addWidget(m_opacitySlider);
@@ -57,10 +52,15 @@ void VisualsEditor::initOpacitySlider()
QLabel* label = new QLabel();
QString labelMsg = tr("Opacity of area outside selection:") + " %1%";
ExtendedSlider* opacitySlider = m_opacitySlider;
connect(m_opacitySlider,
&ExtendedSlider::valueChanged,
this,
[labelMsg, label](int val) { label->setText(labelMsg.arg(val)); });
[labelMsg, label, opacitySlider](int val) {
label->setText(labelMsg.arg(val));
ConfigHandler().setContrastOpacity(
opacitySlider->mappedValue(0, 255));
});
m_layout->addWidget(label);
m_layout->addLayout(localLayout);
@@ -68,12 +68,6 @@ void VisualsEditor::initOpacitySlider()
m_opacitySlider->setMapedValue(0, opacity, 255);
}
void VisualsEditor::saveOpacity()
{
int value = m_opacitySlider->mappedValue(0, 255);
ConfigHandler().setContrastOpacity(value);
}
void VisualsEditor::initWidgets()
{
m_colorEditor = new UIcolorEditor();

View File

@@ -33,9 +33,6 @@ public:
public slots:
void updateComponents();
private slots:
void saveOpacity();
private:
QVBoxLayout* m_layout;
ButtonListView* m_buttonList;