forked from flameshot-org/flameshot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisualseditor.cpp
More file actions
77 lines (67 loc) · 2.42 KB
/
visualseditor.cpp
File metadata and controls
77 lines (67 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2017-2019 Alejandro Sirgo Rica & Contributors
#include "visualseditor.h"
#include "src/config/buttonlistview.h"
#include "src/config/extendedslider.h"
#include "src/config/uicoloreditor.h"
#include "src/utils/confighandler.h"
#include <QHBoxLayout>
#include <QLabel>
VisualsEditor::VisualsEditor(QWidget* parent)
: QWidget(parent)
{
m_layout = new QVBoxLayout();
setLayout(m_layout);
initWidgets();
}
void VisualsEditor::updateComponents()
{
m_buttonList->updateComponents();
m_colorEditor->updateComponents();
int opacity = ConfigHandler().contrastOpacity();
m_opacitySlider->setMapedValue(0, opacity, 255);
}
void VisualsEditor::initOpacitySlider()
{
m_opacitySlider = new ExtendedSlider();
m_opacitySlider->setFocusPolicy(Qt::NoFocus);
m_opacitySlider->setOrientation(Qt::Horizontal);
m_opacitySlider->setRange(0, 100);
QHBoxLayout* localLayout = new QHBoxLayout();
localLayout->addWidget(new QLabel(QStringLiteral("0%")));
localLayout->addWidget(m_opacitySlider);
localLayout->addWidget(new QLabel(QStringLiteral("100%")));
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, opacitySlider](int val) {
label->setText(labelMsg.arg(val));
ConfigHandler().setContrastOpacity(
opacitySlider->mappedValue(0, 255));
});
m_layout->addWidget(label);
m_layout->addLayout(localLayout);
int opacity = ConfigHandler().contrastOpacity();
m_opacitySlider->setMapedValue(0, opacity, 255);
}
void VisualsEditor::initWidgets()
{
m_colorEditor = new UIcolorEditor();
m_layout->addWidget(m_colorEditor);
initOpacitySlider();
auto boxButtons = new QGroupBox();
boxButtons->setTitle(tr("Button Selection"));
auto listLayout = new QVBoxLayout(boxButtons);
m_buttonList = new ButtonListView();
m_layout->addWidget(boxButtons);
listLayout->addWidget(m_buttonList);
QPushButton* setAllButtons = new QPushButton(tr("Select All"));
connect(setAllButtons,
&QPushButton::clicked,
m_buttonList,
&ButtonListView::selectAll);
listLayout->addWidget(setAllButtons);
}