summaryrefslogtreecommitdiff
path: root/media-sound/flacon/files/flacon-1.2.0-fix-qpainter-error.patch
blob: cc7398730edade1bfbd3941ed5cb139ae88f0fcf (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
From 8ffd4d83e19e8f1e28841f37248e99fae0796b10 Mon Sep 17 00:00:00 2001
From: "sokoloff (Alexander)" <sokoloff.a@gmail.com>
Date: Fri, 18 Sep 2015 20:14:31 +0300
Subject: [PATCH] Fix QPainter::font: Painter not active error

---
 gui/trackviewdelegate.cpp | 20 +++++++++-----------
 gui/trackviewdelegate.h   |  4 ++--
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/gui/trackviewdelegate.cpp b/gui/trackviewdelegate.cpp
index ab05833..02b6137 100644
--- a/gui/trackviewdelegate.cpp
+++ b/gui/trackviewdelegate.cpp
@@ -261,8 +261,8 @@ void TrackViewDelegate::paintDisk(QPainter *painter, const QStyleOptionViewItem
     //cache = self.cache(index)
     painter->save();
     painter->setClipRect(option.rect);
-    QFont titleFont = this->titleFont(painter);
-    QFont filesFont = this->filesFont(painter);
+    QFont titleFont = this->titleFont(painter->font());
+    QFont filesFont = this->filesFont(painter->font());
 
 
     int topPadding = index.row() ? TOP_PADDING : 0;
@@ -408,19 +408,17 @@ QSize TrackViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QMod
 
     if (!index.parent().isValid())
     {
-
         if (!mDiskHeightHint)
         {
             int h = 8;
-            QPainter painter(mTrackView);
-            QFont titleFont = this->titleFont(&painter);
-            QFont filesFont = this->filesFont(&painter);
+
+            QFont titleFont = this->titleFont(option.font);
+            QFont filesFont = this->filesFont(option.font);
             h += QFontMetrics(titleFont).height();
             h += QFontMetrics(filesFont).height() * 2;
             mDiskHeightHint = qMax(IMG_HEIGHT, h) + 2 * MARGIN + BOTTOM_PADDING; //For Line
         }
 
-
         res.rheight() = mDiskHeightHint;
         if (index.row())
             res.rheight() += TOP_PADDING;
@@ -533,9 +531,9 @@ void TrackViewDelegate::downloadingFinished(DataProvider *provider)
 /************************************************
 
  ************************************************/
-QFont TrackViewDelegate::titleFont(const QPainter *painter) const
+QFont TrackViewDelegate::titleFont(const QFont &font) const
 {
-    QFont res = painter->font();
+    QFont res = font;
     res.setPointSize(res.pointSize() + 1);
     res.setBold(true);
     return res;
@@ -545,9 +543,9 @@ QFont TrackViewDelegate::titleFont(const QPainter *painter) const
 /************************************************
 
  ************************************************/
-QFont TrackViewDelegate::filesFont(const QPainter *painter) const
+QFont TrackViewDelegate::filesFont(const QFont &font) const
 {
-    QFont res = painter->font();
+    QFont res = font;
     return res;
 }
 
diff --git a/gui/trackviewdelegate.h b/gui/trackviewdelegate.h
index 3a6aa09..492e514 100644
--- a/gui/trackviewdelegate.h
+++ b/gui/trackviewdelegate.h
@@ -76,8 +76,8 @@ private slots:
     QMovie mDownloadMovie;
     mutable int mDiskHeightHint;
 
-    QFont titleFont(const QPainter *painter) const;
-    QFont filesFont(const QPainter *painter) const;
+    QFont titleFont(const QFont &font) const;
+    QFont filesFont(const QFont &font) const;
     void paintTrack(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index, const Track *track) const;
     void paintDisk(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index, const Disk *disk) const;
     QRect drawLabel(const QString &text, QRect rect, QPainter *painter) const;