Pin tool cleanup

This commit is contained in:
lupoDharkael
2018-05-03 18:53:13 +02:00
parent fe8a43a02a
commit c68179f64c
3 changed files with 11 additions and 15 deletions

View File

@@ -44,10 +44,7 @@ QString PinTool::description() const {
QWidget* PinTool::widget() {
PinWidget *w = new PinWidget(m_pixmap);
QRect adjusted_pos = QRect (m_geometry.left() - LAYOUT_MARGIN,
m_geometry.top() - LAYOUT_MARGIN,
m_geometry.width() + 2 * LAYOUT_MARGIN,
m_geometry.height() + 2 * LAYOUT_MARGIN);
QRect adjusted_pos = m_geometry + w->contentsMargins();
w->setGeometry(adjusted_pos);
return w;
}

View File

@@ -26,19 +26,20 @@ PinWidget::PinWidget(const QPixmap &pixmap, QWidget *parent) :
QWidget(parent), m_pixmap(pixmap)
{
setWindowFlags(Qt::WindowStaysOnTopHint
| Qt::FramelessWindowHint
| Qt::Tool
| Qt::X11BypassWindowManagerHint);
| Qt::FramelessWindowHint);
//set the bottom widget background transparent
setAttribute(Qt::WA_TranslucentBackground);
m_shadowEffect->setColor(Qt::lightGray);
m_shadowEffect->setBlurRadius(2 * LAYOUT_MARGIN);
m_shadowEffect->setOffset(0, 0);
setGraphicsEffect(m_shadowEffect);
m_layout = new QVBoxLayout(this);
m_layout->setContentsMargins(LAYOUT_MARGIN, LAYOUT_MARGIN, LAYOUT_MARGIN, LAYOUT_MARGIN);
const int margin = 7;
m_layout->setContentsMargins(margin, margin, margin, margin);
m_shadowEffect = new QGraphicsDropShadowEffect(this);
m_shadowEffect->setColor(Qt::lightGray);
m_shadowEffect->setBlurRadius(2 * margin);
m_shadowEffect->setOffset(0, 0);
setGraphicsEffect(m_shadowEffect);
m_label = new QLabel();
m_label->setPixmap(m_pixmap);

View File

@@ -20,8 +20,6 @@
#include <QWidget>
#include <QGraphicsDropShadowEffect>
#define LAYOUT_MARGIN 7
class QVBoxLayout;
class QLabel;
@@ -46,5 +44,5 @@ private:
QLabel *m_label;
QPoint m_dragStart;
qreal m_offsetX, m_offsetY;
QGraphicsDropShadowEffect *m_shadowEffect = new QGraphicsDropShadowEffect(this);
QGraphicsDropShadowEffect *m_shadowEffect;
};