1 |
commit: 3490a8cb8b1f58dadaf25feedd2cf108ec1a9dd0 |
2 |
Author: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Jun 30 21:42:13 2020 +0000 |
4 |
Commit: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Jun 30 21:44:04 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3490a8cb |
7 |
|
8 |
kde-misc/kdiff3: Fix HiDPI support |
9 |
|
10 |
Closes: https://bugs.gentoo.org/723436 |
11 |
Package-Manager: Portage-2.3.103, Repoman-2.3.23 |
12 |
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org> |
13 |
|
14 |
kde-misc/kdiff3/files/kdiff3-1.8.3-hidpi.patch | 112 +++++++++++++++++++++++++ |
15 |
kde-misc/kdiff3/kdiff3-1.8.3-r1.ebuild | 41 +++++++++ |
16 |
2 files changed, 153 insertions(+) |
17 |
|
18 |
diff --git a/kde-misc/kdiff3/files/kdiff3-1.8.3-hidpi.patch b/kde-misc/kdiff3/files/kdiff3-1.8.3-hidpi.patch |
19 |
new file mode 100644 |
20 |
index 00000000000..180009afe0e |
21 |
--- /dev/null |
22 |
+++ b/kde-misc/kdiff3/files/kdiff3-1.8.3-hidpi.patch |
23 |
@@ -0,0 +1,112 @@ |
24 |
+From 5dcc0673c61cc75122bf5f812a45bbb15b778218 Mon Sep 17 00:00:00 2001 |
25 |
+From: Alexander Volkov <avolkov@××××××××××.ru> |
26 |
+Date: Mon, 27 Apr 2020 15:52:18 +0300 |
27 |
+Subject: [PATCH] Add HiDPI support |
28 |
+ |
29 |
+* Backported to 1.8 branch |
30 |
+--- |
31 |
+ src/Overview.cpp | 6 ++++-- |
32 |
+ src/directorymergewindow.cpp | 15 +++++++++------ |
33 |
+ src/main.cpp | 1 + |
34 |
+ src/mergeresultwindow.cpp | 7 +++++-- |
35 |
+ 4 files changed, 19 insertions(+), 10 deletions(-) |
36 |
+ |
37 |
+diff --git a/src/Overview.cpp b/src/Overview.cpp |
38 |
+index ee1d73f..ac35e7e 100644 |
39 |
+--- a/src/Overview.cpp |
40 |
++++ b/src/Overview.cpp |
41 |
+@@ -271,7 +271,8 @@ void Overview::paintEvent(QPaintEvent*) |
42 |
+ int h = height() - 1; |
43 |
+ int w = width(); |
44 |
+ |
45 |
+- if(m_pixmap.size() != size()) |
46 |
++ const auto dpr = devicePixelRatioF(); |
47 |
++ if(m_pixmap.size() != size() * dpr) |
48 |
+ { |
49 |
+ if(m_pOptions->m_bWordWrap) |
50 |
+ { |
51 |
+@@ -287,7 +288,8 @@ void Overview::paintEvent(QPaintEvent*) |
52 |
+ m_nofLines = m_pDiff3LineList->size(); |
53 |
+ } |
54 |
+ |
55 |
+- m_pixmap = QPixmap(size()); |
56 |
++ m_pixmap = QPixmap(size() * dpr); |
57 |
++ m_pixmap.setDevicePixelRatio(dpr); |
58 |
+ |
59 |
+ QPainter p(&m_pixmap); |
60 |
+ p.fillRect(rect(), m_pOptions->m_bgColor); |
61 |
+diff --git a/src/directorymergewindow.cpp b/src/directorymergewindow.cpp |
62 |
+index 31dbcaf..1cc62b4 100644 |
63 |
+--- a/src/directorymergewindow.cpp |
64 |
++++ b/src/directorymergewindow.cpp |
65 |
+@@ -584,7 +584,10 @@ class DirectoryMergeWindow::DirMergeItemDelegate : public QStyledItemDelegate |
66 |
+ //QPixmap icon = value.value<QPixmap>(); //pixmap(column); |
67 |
+ if(!icon.isNull()) |
68 |
+ { |
69 |
+- int yOffset = (sizeHint(option, index).height() - icon.height()) / 2; |
70 |
++ const auto dpr = thePainter->device()->devicePixelRatioF(); |
71 |
++ const int w = qRound(icon.width() / dpr); |
72 |
++ const int h = qRound(icon.height() / dpr); |
73 |
++ int yOffset = (sizeHint(option, index).height() - h) / 2; |
74 |
+ thePainter->drawPixmap(x + 2, y + yOffset, icon); |
75 |
+ |
76 |
+ int i = index == d->m_selection1Index ? 1 : index == d->m_selection2Index ? 2 : index == d->m_selection3Index ? 3 : 0; |
77 |
+@@ -593,20 +596,20 @@ class DirectoryMergeWindow::DirMergeItemDelegate : public QStyledItemDelegate |
78 |
+ Options* pOpts = d->m_pOptions; |
79 |
+ QColor c(i == 1 ? pOpts->m_colorA : i == 2 ? pOpts->m_colorB : pOpts->m_colorC); |
80 |
+ thePainter->setPen(c); // highlight() ); |
81 |
+- thePainter->drawRect(x + 2, y + yOffset, icon.width(), icon.height()); |
82 |
++ thePainter->drawRect(x + 2, y + yOffset, w, h); |
83 |
+ thePainter->setPen(QPen(c, 0, Qt::DotLine)); |
84 |
+- thePainter->drawRect(x + 1, y + yOffset - 1, icon.width() + 2, icon.height() + 2); |
85 |
++ thePainter->drawRect(x + 1, y + yOffset - 1, w + 2, h + 2); |
86 |
+ thePainter->setPen(Qt::white); |
87 |
+ QString s(QChar('A' + i - 1)); |
88 |
+ |
89 |
+- thePainter->drawText(x + 2 + (icon.width() - Utils::getHorizontalAdvance(thePainter->fontMetrics(), s)) / 2, |
90 |
+- y + yOffset + (icon.height() + thePainter->fontMetrics().ascent()) / 2 - 1, |
91 |
++ thePainter->drawText(x + 2 + (w - Utils::getHorizontalAdvance(thePainter->fontMetrics(), s)) / 2, |
92 |
++ y + yOffset + (h + thePainter->fontMetrics().ascent()) / 2 - 1, |
93 |
+ s); |
94 |
+ } |
95 |
+ else |
96 |
+ { |
97 |
+ thePainter->setPen(m_pDMW->palette().window().color()); |
98 |
+- thePainter->drawRect(x + 1, y + yOffset - 1, icon.width() + 2, icon.height() + 2); |
99 |
++ thePainter->drawRect(x + 1, y + yOffset - 1, w + 2, h + 2); |
100 |
+ } |
101 |
+ return; |
102 |
+ } |
103 |
+diff --git a/src/main.cpp b/src/main.cpp |
104 |
+index df06eab..c62aee3 100644 |
105 |
+--- a/src/main.cpp |
106 |
++++ b/src/main.cpp |
107 |
+@@ -81,6 +81,7 @@ int main(int argc, char* argv[]) |
108 |
+ { |
109 |
+ const QLatin1String appName("kdiff3"); |
110 |
+ |
111 |
++ QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); |
112 |
+ QApplication app(argc, argv); // KAboutData and QCommandLineParser depend on this being setup. |
113 |
+ KLocalizedString::setApplicationDomain(appName.data()); |
114 |
+ |
115 |
+diff --git a/src/mergeresultwindow.cpp b/src/mergeresultwindow.cpp |
116 |
+index 894bc44..29d16ae 100644 |
117 |
+--- a/src/mergeresultwindow.cpp |
118 |
++++ b/src/mergeresultwindow.cpp |
119 |
+@@ -1970,8 +1970,11 @@ void MergeResultWindow::paintEvent(QPaintEvent*) |
120 |
+ if(!m_bCursorUpdate) // Don't redraw everything for blinking cursor? |
121 |
+ { |
122 |
+ m_selection.bSelectionContainsData = false; |
123 |
+- if(size() != m_pixmap.size()) |
124 |
+- m_pixmap = QPixmap(size()); |
125 |
++ const auto dpr = devicePixelRatioF(); |
126 |
++ if(size() * dpr != m_pixmap.size()) { |
127 |
++ m_pixmap = QPixmap(size() * dpr); |
128 |
++ m_pixmap.setDevicePixelRatio(dpr); |
129 |
++ } |
130 |
+ |
131 |
+ RLPainter p(&m_pixmap, m_pOptions->m_bRightToLeftLanguage, width(), fontWidth); |
132 |
+ p.setFont(font()); |
133 |
+-- |
134 |
+2.27.0 |
135 |
+ |
136 |
|
137 |
diff --git a/kde-misc/kdiff3/kdiff3-1.8.3-r1.ebuild b/kde-misc/kdiff3/kdiff3-1.8.3-r1.ebuild |
138 |
new file mode 100644 |
139 |
index 00000000000..9611b4dd913 |
140 |
--- /dev/null |
141 |
+++ b/kde-misc/kdiff3/kdiff3-1.8.3-r1.ebuild |
142 |
@@ -0,0 +1,41 @@ |
143 |
+# Copyright 1999-2020 Gentoo Authors |
144 |
+# Distributed under the terms of the GNU General Public License v2 |
145 |
+ |
146 |
+EAPI=7 |
147 |
+ |
148 |
+ECM_HANDBOOK="forceoptional" |
149 |
+KFMIN=5.60.0 |
150 |
+QTMIN=5.12.3 |
151 |
+inherit ecm kde.org |
152 |
+ |
153 |
+DESCRIPTION="Frontend to diff3 based on KDE Frameworks" |
154 |
+HOMEPAGE="https://kde.org/applications/development/org.kde.kdiff3 |
155 |
+https://userbase.kde.org/KDiff3" |
156 |
+SRC_URI="mirror://kde/stable/${PN}/${P}.tar.xz" |
157 |
+ |
158 |
+LICENSE="GPL-2" |
159 |
+SLOT="5" |
160 |
+KEYWORDS="~amd64 ~arm64 ~ppc64 ~x86" |
161 |
+IUSE="" |
162 |
+ |
163 |
+DEPEND=" |
164 |
+ >=dev-qt/qtgui-${QTMIN}:5 |
165 |
+ >=dev-qt/qtprintsupport-${QTMIN}:5 |
166 |
+ >=dev-qt/qtwidgets-${QTMIN}:5 |
167 |
+ >=kde-frameworks/kconfig-${KFMIN}:5 |
168 |
+ >=kde-frameworks/kconfigwidgets-${KFMIN}:5 |
169 |
+ >=kde-frameworks/kcoreaddons-${KFMIN}:5 |
170 |
+ >=kde-frameworks/kcrash-${KFMIN}:5 |
171 |
+ >=kde-frameworks/ki18n-${KFMIN}:5 |
172 |
+ >=kde-frameworks/kiconthemes-${KFMIN}:5 |
173 |
+ >=kde-frameworks/kio-${KFMIN}:5 |
174 |
+ >=kde-frameworks/kparts-${KFMIN}:5 |
175 |
+ >=kde-frameworks/ktextwidgets-${KFMIN}:5 |
176 |
+ >=kde-frameworks/kwidgetsaddons-${KFMIN}:5 |
177 |
+ >=kde-frameworks/kxmlgui-${KFMIN}:5 |
178 |
+" |
179 |
+RDEPEND="${DEPEND} |
180 |
+ sys-apps/diffutils |
181 |
+" |
182 |
+ |
183 |
+PATCHES=( "${FILESDIR}/${P}-hidpi.patch" ) |