comparison src/changesetitem.cpp @ 678:c0b46d0514a7 scale

Incomplete scaling updates. Should do this differently
author Chris Cannam
date Thu, 06 Dec 2018 14:55:45 +0000
parents ce29dc775650
children
comparison
equal deleted inserted replaced
677:0329bbd4b57c 678:c0b46d0514a7
20 #include "changesetdetailitem.h" 20 #include "changesetdetailitem.h"
21 #include "changeset.h" 21 #include "changeset.h"
22 #include "textabbrev.h" 22 #include "textabbrev.h"
23 #include "colourset.h" 23 #include "colourset.h"
24 #include "debug.h" 24 #include "debug.h"
25 #include "common.h"
25 26
26 #include <QPainter> 27 #include <QPainter>
27 #include <QGraphicsScene> 28 #include <QGraphicsScene>
28 #include <QGraphicsSceneMouseEvent> 29 #include <QGraphicsSceneMouseEvent>
29 #include <QMenu> 30 #include <QMenu>
39 m_changeset(cs), m_detail(0), m_detailVisible(false), 40 m_changeset(cs), m_detail(0), m_detailVisible(false),
40 m_showBranch(false), m_column(0), m_row(0), m_wide(false), 41 m_showBranch(false), m_column(0), m_row(0), m_wide(false),
41 m_current(false), m_closing(false), m_new(false), m_searchMatches(false) 42 m_current(false), m_closing(false), m_new(false), m_searchMatches(false)
42 { 43 {
43 m_font = QFont(); 44 m_font = QFont();
44 m_font.setPixelSize(11); 45 m_font.setPixelSize(scalePixelSize(11));
45 m_font.setBold(false); 46 m_font.setBold(false);
46 m_font.setItalic(false); 47 m_font.setItalic(false);
47 setCursor(Qt::ArrowCursor); 48 setCursor(Qt::ArrowCursor);
48 49
49 if (!m_star) m_star = new QImage(":images/star.png"); 50 if (!m_star) m_star = new QImage(":images/star.png");
63 QRectF 64 QRectF
64 ChangesetItem::boundingRect() const 65 ChangesetItem::boundingRect() const
65 { 66 {
66 int w = 100; 67 int w = 100;
67 if (m_wide) w = 180; 68 if (m_wide) w = 180;
68 return QRectF(-((w-50)/2 - 1), -30, w - 3, 90); 69 return QRectF(-scalePixelSize((w-50)/2 - 1),
70 -scalePixelSize(30),
71 scalePixelSize(w - 3),
72 scalePixelSize(90));
69 } 73 }
70 74
71 void 75 void
72 ChangesetItem::showDetail() 76 ChangesetItem::showDetail()
73 { 77 {
79 scene()->addItem(m_detail); 83 scene()->addItem(m_detail);
80 int w = 100; 84 int w = 100;
81 if (m_wide) w = 180; 85 if (m_wide) w = 180;
82 if (isMerge() || isClosingCommit()) w = 60; 86 if (isMerge() || isClosingCommit()) w = 60;
83 int h = 80; 87 int h = 80;
84 m_detail->setPos(x() + (w + 50) / 2 + 10 + 0.5, 88 m_detail->setPos(x() + scalePixelSize((w + 50) / 2 + 10 + 0.5),
85 y() - (m_detail->boundingRect().height() - h) / 3 + 0.5); 89 y() - (m_detail->boundingRect().height() -
90 scalePixelSize(h)) / 3 + 0.5);
86 m_detailVisible = true; 91 m_detailVisible = true;
87 emit detailShown(); 92 emit detailShown();
88 } 93 }
89 94
90 void 95 void
333 QFontMetrics fm(f); 338 QFontMetrics fm(f);
334 int fh = fm.height(); 339 int fh = fm.height();
335 340
336 int width = 100; 341 int width = 100;
337 if (m_wide) width = 180; 342 if (m_wide) width = 180;
338 int x0 = -((width - 50) / 2 - 1); 343 int x0 = -scalePixelSize((width - 50) / 2 - 1);
339 344
340 int textwid = width - 7; 345 int textwid = scalePixelSize(width - 7);
341 346
342 QString comment; 347 QString comment;
343 QStringList lines; 348 QStringList lines;
344 int lineCount = 3; 349 int lineCount = 3;
345 350
346 if (showText) { 351 if (showText) {
352 comment = comment.replace("\\\"", "\""); 357 comment = comment.replace("\\\"", "\"");
353 358
354 comment = TextAbbrev::abbreviate(comment, fm, textwid, 359 comment = TextAbbrev::abbreviate(comment, fm, textwid,
355 TextAbbrev::ElideEnd, "...", 3); 360 TextAbbrev::ElideEnd, "...", 3);
356 // abbreviate() changes this (ouch!), restore it 361 // abbreviate() changes this (ouch!), restore it
357 textwid = width - 5; 362 textwid = scalePixelSize(width - 7);
358 363
359 lines = comment.split('\n'); 364 lines = comment.split('\n');
360 lineCount = lines.size(); 365 lineCount = lines.size();
361 366
362 if (lineCount < 2) lineCount = 2; 367 if (lineCount < 2) lineCount = 2;
363 } 368 }
364 369
365 int height = (lineCount + 1) * fh + 2; 370 width = scalePixelSize(width);
371 int height = (lineCount + 1) * fh + scalePixelSize(2);
366 QRectF r(x0, 0, width - 3, height); 372 QRectF r(x0, 0, width - 3, height);
367 373
368 QColor textColour = Qt::black; 374 QColor textColour = Qt::black;
369 textColour.setAlpha(alpha); 375 textColour.setAlpha(alpha);
370 376