-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAppStyle.cpp
36 lines (31 loc) · 1019 Bytes
/
AppStyle.cpp
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
#include "AppStyle.h"
AppStyle::AppStyle(QObject *parent)
: QObject(parent)
, selectedItemPenWidthPt_(1)
, activeItemPenWidthPt_(1)
{
// Warning: selectionPen's width is in pixels (not in points)
// because it's cosmetic. As devicePixelRation is not known at this
// step, the width can't be set right now.
selectedItemPen_.setColor(Qt::black);
selectedItemPen_.setStyle(Qt::DashLine);
selectedItemPen_.setCosmetic(true);
activeItemPen_.setColor(Qt::black);
activeItemPen_.setStyle(Qt::DotLine);
activeItemPen_.setCosmetic(true);
}
AppStyle *AppStyle::sharedInstance()
{
static AppStyle *instance = new AppStyle;
return instance;
}
QPen AppStyle::selectedItemPen(int devicePixelRatio) const
{
selectedItemPen_.setWidth(selectedItemPenWidthPt_ * devicePixelRatio);
return selectedItemPen_;
}
QPen AppStyle::activeItemPen(int devicePixelRatio) const
{
activeItemPen_.setWidth(activeItemPenWidthPt_ * devicePixelRatio);
return activeItemPen_;
}