Pin Tool: fix content margins in Windows
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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 *);
|
||||
|
||||
Reference in New Issue
Block a user