comparison src/uncommitteditem.cpp @ 678:c0b46d0514a7 scale

Incomplete scaling updates. Should do this differently
author Chris Cannam
date Thu, 06 Dec 2018 14:55:45 +0000
parents ae67ea0af696
children
comparison
equal deleted inserted replaced
677:0329bbd4b57c 678:c0b46d0514a7
17 17
18 #include "uncommitteditem.h" 18 #include "uncommitteditem.h"
19 #include "colourset.h" 19 #include "colourset.h"
20 #include "debug.h" 20 #include "debug.h"
21 #include "textabbrev.h" 21 #include "textabbrev.h"
22 #include "common.h"
22 23
23 #include <QPainter> 24 #include <QPainter>
24 #include <QGraphicsScene> 25 #include <QGraphicsScene>
25 #include <QGraphicsSceneMouseEvent> 26 #include <QGraphicsSceneMouseEvent>
26 #include <QMenu> 27 #include <QMenu>
31 UncommittedItem::UncommittedItem() : 32 UncommittedItem::UncommittedItem() :
32 m_showBranch(false), m_isNewBranch(false), m_isMerge(false), 33 m_showBranch(false), m_isNewBranch(false), m_isMerge(false),
33 m_column(0), m_row(0), m_wide(false) 34 m_column(0), m_row(0), m_wide(false)
34 { 35 {
35 m_font = QFont(); 36 m_font = QFont();
36 m_font.setPixelSize(11); 37 m_font.setPixelSize(scalePixelSize(11));
37 m_font.setBold(false); 38 m_font.setBold(false);
38 m_font.setItalic(false); 39 m_font.setItalic(false);
39 setCursor(Qt::ArrowCursor); 40 setCursor(Qt::ArrowCursor);
40 } 41 }
41 42
43 UncommittedItem::boundingRect() const 44 UncommittedItem::boundingRect() const
44 { 45 {
45 //!!! this stuff is gross, refactor with changesetitem and connectionitem 46 //!!! this stuff is gross, refactor with changesetitem and connectionitem
46 int w = 100; 47 int w = 100;
47 if (m_wide) w = 180; 48 if (m_wide) w = 180;
48 return QRectF(-((w-50)/2 - 1), -30, w - 3, 79 + 40); 49 return QRectF(-scalePixelSize((w-50)/2 - 1),
50 -scalePixelSize(30),
51 scalePixelSize(w - 3),
52 scalePixelSize(79 + 40));
49 } 53 }
50 54
51 void 55 void
52 UncommittedItem::mousePressEvent(QGraphicsSceneMouseEvent *e) 56 UncommittedItem::mousePressEvent(QGraphicsSceneMouseEvent *e)
53 { 57 {
142 QFontMetrics fm(f); 146 QFontMetrics fm(f);
143 int fh = fm.height(); 147 int fh = fm.height();
144 148
145 int width = 100; 149 int width = 100;
146 if (m_wide) width = 180; 150 if (m_wide) width = 180;
147 int x0 = -((width - 50) / 2 - 1); 151 int x0 = -scalePixelSize((width - 50) / 2 - 1);
148 152
149 int height = 49; 153 width = scalePixelSize(width);
154 int half = scalePixelSize(50);
155 int height = scalePixelSize(49);
156
150 QRectF r(x0, 0, width - 3, height); 157 QRectF r(x0, 0, width - 3, height);
151 paint->setBrush(Qt::white); 158 paint->setBrush(Qt::white);
152 paint->drawRoundedRect(r, 7, 7); 159 paint->drawRoundedRect(r, 7, 7);
153 160
154 if (m_wide) { 161 if (m_wide) {
155 QString label = tr("Uncommitted changes"); 162 QString label = tr("Uncommitted changes");
156 paint->drawText(-(fm.width(label) - 50)/2, 163 paint->drawText(-(fm.width(label) - half)/2,
157 25 - fm.height()/2 + fm.ascent(), 164 height/2 - fm.height()/2 + fm.ascent(),
158 label); 165 label);
159 } else { 166 } else {
160 QString label = tr("Uncommitted"); 167 QString label = tr("Uncommitted");
161 paint->drawText(-(fm.width(label) - 50)/2, 168 paint->drawText(-(fm.width(label) - half)/2,
162 25 - fm.height() + fm.ascent(), 169 height/2 - fm.height() + fm.ascent(),
163 label); 170 label);
164 label = tr("changes"); 171 label = tr("changes");
165 paint->drawText(-(fm.width(label) - 50)/2, 172 paint->drawText(-(fm.width(label) - half)/2,
166 25 + fm.ascent(), 173 height/2 + fm.ascent(),
167 label); 174 label);
168 } 175 }
169 176
170 if (m_showBranch && m_branch != "") { 177 if (m_showBranch && m_branch != "") {
171 // write branch name 178 // write branch name
208 paint->setFont(f); 215 paint->setFont(f);
209 QFontMetrics fm(f); 216 QFontMetrics fm(f);
210 int fh = fm.height(); 217 int fh = fm.height();
211 218
212 int size = fh * 2; 219 int size = fh * 2;
213 int x0 = -size/2 + 25; 220 int x0 = -size/2 + scalePixelSize(25);
214 221
215 paint->setBrush(Qt::white); 222 paint->setBrush(Qt::white);
216 paint->drawEllipse(QRectF(x0, fh, size, size)); 223 paint->drawEllipse(QRectF(x0, fh, size, size));
217 224
218 if (m_wide) { 225 if (m_wide) {
219 QString label = tr("Uncommitted merge"); 226 QString label = tr("Uncommitted merge");
220 paint->drawText(size/2 + 28, 227 paint->drawText(size/2 + scalePixelSize(28),
221 25 - fm.height()/2 + fm.ascent(), 228 scalePixelSize(25) - fm.height()/2 + fm.ascent(),
222 label); 229 label);
223 } else { 230 } else {
224 QString label = tr("Uncommitted"); 231 QString label = tr("Uncommitted");
225 paint->drawText(size/2 + 28, 232 paint->drawText(size/2 + scalePixelSize(28),
226 25 - fm.height() + fm.ascent(), 233 scalePixelSize(25) - fm.height() + fm.ascent(),
227 label); 234 label);
228 label = tr("merge"); 235 label = tr("merge");
229 paint->drawText(size/2 + 28, 236 paint->drawText(size/2 + scalePixelSize(28),
230 25 + fm.ascent(), 237 scalePixelSize(25) + fm.ascent(),
231 label); 238 label);
232 } 239 }
233 240
234 if (m_showBranch && m_branch != "") { 241 if (m_showBranch && m_branch != "") {
235 // write branch name 242 // write branch name
236 f.setBold(true); 243 f.setBold(true);
237 paint->setFont(f); 244 paint->setFont(f);
238 int wid = size * 3; 245 int wid = size * 3;
239 QString branch = TextAbbrev::abbreviate(m_branch, QFontMetrics(f), wid); 246 QString branch = TextAbbrev::abbreviate(m_branch, QFontMetrics(f), wid);
240 paint->drawText(-wid/2 + 25, fm.ascent() - 4, branch); 247 paint->drawText(-wid/2 + scalePixelSize(25), fm.ascent() - 4, branch);
241 } 248 }
242 249
243 paint->restore(); 250 paint->restore();
244 return; 251 return;
245 } 252 }