20
20
#include < QAbstractItemDelegate>
21
21
#include < QPainter>
22
22
23
- #define DECORATION_SIZE 64
23
+ #define DECORATION_SIZE 48
24
24
25
25
class TxViewDelegate : public QAbstractItemDelegate
26
26
{
27
27
Q_OBJECT
28
28
public:
29
- TxViewDelegate (QObject *parent=nullptr ): QAbstractItemDelegate(parent), unit(BitcoinUnits::BTC)
29
+ TxViewDelegate (QObject *parent=nullptr , int scaledDecorationSize = DECORATION_SIZE):
30
+ QAbstractItemDelegate (parent), unit(BitcoinUnits::BTC), scaledDecorationSize(scaledDecorationSize)
30
31
{
31
32
32
33
}
@@ -38,8 +39,8 @@ class TxViewDelegate : public QAbstractItemDelegate
38
39
39
40
QIcon icon = qvariant_cast<QIcon>(index.data (Qt::DecorationRole));
40
41
QRect mainRect = option.rect ;
41
- QRect decorationRect (mainRect.topLeft (), QSize (DECORATION_SIZE, DECORATION_SIZE ));
42
- int xspace = DECORATION_SIZE + 8 ;
42
+ QRect decorationRect (mainRect.topLeft (), QSize (scaledDecorationSize, scaledDecorationSize ));
43
+ int xspace = scaledDecorationSize + 8 ;
43
44
int ypad = 6 ;
44
45
int halfheight = (mainRect.height () - 2 *ypad)/2 ;
45
46
QRect amountRect (mainRect.left () + xspace, mainRect.top ()+ypad, mainRect.width () - xspace, halfheight);
@@ -89,11 +90,15 @@ class TxViewDelegate : public QAbstractItemDelegate
89
90
90
91
inline QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const
91
92
{
92
- return QSize (DECORATION_SIZE, DECORATION_SIZE );
93
+ return QSize (scaledDecorationSize, scaledDecorationSize );
93
94
}
94
95
95
96
int unit;
96
97
98
+ private:
99
+
100
+ int scaledDecorationSize;
101
+
97
102
};
98
103
#include " overviewpage.moc"
99
104
@@ -105,14 +110,29 @@ OverviewPage::OverviewPage(QWidget *parent) :
105
110
currentBalance(-1 ),
106
111
currentStake(0 ),
107
112
currentUnconfirmedBalance(-1 ),
108
- currentImmatureBalance(-1 ),
109
- txdelegate(new TxViewDelegate(this ))
113
+ currentImmatureBalance(-1 )
110
114
{
115
+ scaledDecorationSize = DECORATION_SIZE * this ->logicalDpiX () / 96 ;
116
+
117
+ txdelegate = new TxViewDelegate (this , scaledDecorationSize);
118
+
111
119
ui->setupUi (this );
112
120
121
+ // Override .ui default spacing to deal with various dpi displays.
122
+ int verticalSpacing = 7 * this ->logicalDpiY () / 96 ;
123
+ ui->verticalLayout_10 ->setMargin (verticalSpacing);
124
+ ui->formLayout ->setVerticalSpacing (verticalSpacing);
125
+ ui->formLayout_2 ->setVerticalSpacing (verticalSpacing);
126
+ ui->researcherFormLayout ->setVerticalSpacing (verticalSpacing);
127
+
128
+ QRect verticalSpacerSpacing (0 , 0 , 20 , 20 * this ->logicalDpiY () / 96 );
129
+ ui->verticalSpacer ->setGeometry (verticalSpacerSpacing);
130
+ ui->researcherSectionVerticalSpacer ->setGeometry (verticalSpacerSpacing);
131
+ ui->verticalSpacer_2 ->setGeometry (verticalSpacerSpacing);
132
+
113
133
// Recent transactions
114
134
ui->listTransactions ->setItemDelegate (txdelegate);
115
- ui->listTransactions ->setIconSize (QSize (DECORATION_SIZE, DECORATION_SIZE ));
135
+ ui->listTransactions ->setIconSize (QSize (scaledDecorationSize, scaledDecorationSize ));
116
136
ui->listTransactions ->setAttribute (Qt::WA_MacShowFocusRect, false );
117
137
updateTransactions ();
118
138
@@ -158,7 +178,7 @@ int OverviewPage::getNumTransactionsForView()
158
178
{
159
179
// Compute the maximum number of transactions the transaction list widget
160
180
// can hold without overflowing.
161
- const size_t itemHeight = DECORATION_SIZE + ui->listTransactions ->spacing ();
181
+ const size_t itemHeight = scaledDecorationSize + ui->listTransactions ->spacing ();
162
182
const size_t contentsHeight = ui->listTransactions ->height ();
163
183
const int numItems = contentsHeight / itemHeight;
164
184
0 commit comments