Pin Tool: fix content margins in Windows

This commit is contained in:
lupoDharkael
2018-05-04 11:21:20 +02:00
parent c68179f64c
commit 2fd8bd209b
3 changed files with 9 additions and 2 deletions

View File

@@ -44,7 +44,8 @@ QString PinTool::description() const {
QWidget* PinTool::widget() {
PinWidget *w = new PinWidget(m_pixmap);
QRect adjusted_pos = m_geometry + w->contentsMargins();
const int &&m = w->margin();
QRect adjusted_pos = m_geometry + QMargins(m,m,m,m);
w->setGeometry(adjusted_pos);
return w;
}

View File

@@ -32,7 +32,7 @@ PinWidget::PinWidget(const QPixmap &pixmap, QWidget *parent) :
m_layout = new QVBoxLayout(this);
const int margin = 7;
const int margin = this->margin();
m_layout->setContentsMargins(margin, margin, margin, margin);
m_shadowEffect = new QGraphicsDropShadowEffect(this);
@@ -49,6 +49,10 @@ PinWidget::PinWidget(const QPixmap &pixmap, QWidget *parent) :
new QShortcut(Qt::Key_Escape, this, SLOT(close()));
}
int PinWidget::margin() const {
return 7;
}
void PinWidget::wheelEvent(QWheelEvent *e) {
int val = e->delta() > 0 ? 5 : -5;
int newWidth = qBound(50, m_label->width() + val, maximumWidth());

View File

@@ -28,6 +28,8 @@ class PinWidget : public QWidget {
public:
explicit PinWidget(const QPixmap &pixmap, QWidget *parent = nullptr);
int margin() const;
protected:
void wheelEvent(QWheelEvent *e);
void mouseDoubleClickEvent(QMouseEvent *);