Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting pin border width (or removing it) #622

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions data/translations/Internationalization_ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1167,17 +1167,22 @@ You may need to escape the &apos;#&apos; sign as in &apos;\#FFF&apos;</source>
<context>
<name>VisualsEditor</name>
<message>
<location filename="../../src/config/visualseditor.cpp" line="61"/>
<location filename="../../src/config/visualseditor.cpp" line="62"/>
<source>Opacity of area outside selection:</source>
<translation>Затемнение невыделенной области:</translation>
</message>
<message>
<location filename="../../src/config/visualseditor.cpp" line="89"/>
<location filename="../../src/config/visualseditor.cpp" line="77"/>
<source>Pin border width:</source>
<translation>Размер рамки прикрепленного изображения:</translation>
</message>
<message>
<location filename="../../src/config/visualseditor.cpp" line="116"/>
<source>Button Selection</source>
<translation>Выбор кнопок</translation>
</message>
<message>
<location filename="../../src/config/visualseditor.cpp" line="95"/>
<location filename="../../src/config/visualseditor.cpp" line="122"/>
<source>Select All</source>
<translation>Выбрать все</translation>
</message>
Expand Down
27 changes: 27 additions & 0 deletions src/config/visualseditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "src/utils/confighandler.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QSpinBox>
#include <QVBoxLayout>

VisualsEditor::VisualsEditor(QWidget* parent)
Expand Down Expand Up @@ -70,6 +71,30 @@ VisualsEditor::initOpacitySlider()
m_opacitySlider->setMapedValue(0, opacity, 255);
}

void
VisualsEditor::initPinBorderEditor()
{
QLabel* label = new QLabel(tr("Pin border width:"));
label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

m_pinBorderWidthSpinBox = new QSpinBox();
m_pinBorderWidthSpinBox->setRange(0, 20);
m_pinBorderWidthSpinBox->setSizePolicy(QSizePolicy::Fixed,
QSizePolicy::Fixed);
m_pinBorderWidthSpinBox->setValue(ConfigHandler().pinBorderWidthValue());
connect(m_pinBorderWidthSpinBox,
QOverload<int>::of(&QSpinBox::valueChanged),
this,
[](int val) { ConfigHandler().setPinBorderWidth(val); });

QHBoxLayout* localLayout = new QHBoxLayout();
localLayout->addWidget(label);
localLayout->addWidget(m_pinBorderWidthSpinBox);
localLayout->addItem(
new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
m_layout->addLayout(localLayout);
}

void
VisualsEditor::saveOpacity()
{
Expand All @@ -85,6 +110,8 @@ VisualsEditor::initWidgets()

initOpacitySlider();

initPinBorderEditor();

auto boxButtons = new QGroupBox();
boxButtons->setTitle(tr("Button Selection"));
auto listLayout = new QVBoxLayout(boxButtons);
Expand Down
3 changes: 3 additions & 0 deletions src/config/visualseditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <QWidget>

class QSpinBox;
class ExtendedSlider;
class QVBoxLayout;
class ButtonListView;
Expand All @@ -41,7 +42,9 @@ private slots:
ButtonListView* m_buttonList;
UIcolorEditor* m_colorEditor;
ExtendedSlider* m_opacitySlider;
QSpinBox* m_pinBorderWidthSpinBox;

void initWidgets();
void initOpacitySlider();
void initPinBorderEditor();
};
7 changes: 3 additions & 4 deletions src/tools/pin/pinwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ PinWidget::PinWidget(const QPixmap& pixmap, QWidget* parent)
// set the bottom widget background transparent
setAttribute(Qt::WA_TranslucentBackground);

ConfigHandler conf;
m_baseColor = conf.uiMainColorValue();
m_hoverColor = conf.uiContrastColorValue();
m_baseColor = m_config.uiMainColorValue();
m_hoverColor = m_config.uiContrastColorValue();

m_layout = new QVBoxLayout(this);
const int margin = this->margin();
Expand All @@ -56,7 +55,7 @@ PinWidget::PinWidget(const QPixmap& pixmap, QWidget* parent)
int
PinWidget::margin() const
{
return 7;
return m_config.pinBorderWidthValue();
}

void
Expand Down
3 changes: 3 additions & 0 deletions src/tools/pin/pinwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <QGraphicsDropShadowEffect>
#include <QWidget>

#include <src/utils/confighandler.h>

class QVBoxLayout;
class QLabel;

Expand Down Expand Up @@ -49,4 +51,5 @@ class PinWidget : public QWidget
qreal m_offsetX, m_offsetY;
QGraphicsDropShadowEffect* m_shadowEffect;
QColor m_baseColor, m_hoverColor;
ConfigHandler m_config;
};
12 changes: 12 additions & 0 deletions src/utils/confighandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,18 @@ ConfigHandler::setdrawThickness(const int thickness)
m_settings.setValue(QStringLiteral("drawThickness"), thickness);
}

int
ConfigHandler::pinBorderWidthValue() const
{
return m_settings.value(QStringLiteral("pinBorderWidth"), 7).toInt();
}

void
ConfigHandler::setPinBorderWidth(const int value)
{
m_settings.setValue(QStringLiteral("pinBorderWidth"), value);
}

bool
ConfigHandler::keepOpenAppLauncherValue()
{
Expand Down
3 changes: 3 additions & 0 deletions src/utils/confighandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ class ConfigHandler
int drawThicknessValue();
void setdrawThickness(const int);

int pinBorderWidthValue() const;
void setPinBorderWidth(const int);

bool keepOpenAppLauncherValue();
void setKeepOpenAppLauncher(const bool);

Expand Down