some cosmetics

preferencesAboutTextFull
Claudio Valerio 12 years ago
parent c1423f9b94
commit 59725062a9
  1. 93
      src/domain/UBGraphicsItemDelegate.cpp

@ -718,7 +718,7 @@ void UBGraphicsItemDelegate::updateButtons(bool showUpdated)
mDelegated->scene()->addItem(mDeleteButton); mDelegated->scene()->addItem(mDeleteButton);
} }
if (showUpdated /*&& mFrame->isResizing()*/) if (showUpdated)
mDeleteButton->show(); mDeleteButton->show();
int i = 1, j = 0, k = 0; int i = 1, j = 0, k = 0;
@ -810,25 +810,29 @@ MediaTimer::MediaTimer(QGraphicsItem * parent): QGraphicsRectItem(parent)
{ {
val = 0; val = 0;
smallPoint = false; smallPoint = false;
setNumDigits(4); setNumDigits(6);
} }
MediaTimer::~MediaTimer() MediaTimer::~MediaTimer()
{} {}
void MediaTimer::positionHandles()
{
digitSpace = smallPoint ? 2 : 1;
ySegLen = rect().height()*5/12;
xSegLen = ySegLen*2/3;
segLen = xSegLen;
xAdvance = segLen*(5 + digitSpace)/5;
xOffset = (rect().width() - ndigits*xAdvance + segLen/5)/2;
yOffset = rect().height() - ySegLen*2;
setRect(rect().x(), rect().y(), xOffset + xAdvance*ndigits, rect().height());
}
void MediaTimer::drawString(const QString &s, QPainter &p, void MediaTimer::drawString(const QString &s, QPainter &p,
QBitArray *newPoints, bool newString) QBitArray *newPoints, bool newString)
{ {
QPoint pos; QPoint pos;
int digitSpace = smallPoint ? 2 : 1;
int xSegLen = (rect().width()/1)*5/(ndigits*(5 + digitSpace) + digitSpace);
int ySegLen = rect().height()*5/12;
int segLen = ySegLen > xSegLen ? xSegLen : ySegLen;
int xAdvance = segLen*(5 + digitSpace)/5;
int xOffset = rect().x() + (rect().width()/1 - ndigits*xAdvance + segLen/5)/2;
int yOffset = (rect().height() - segLen*2)/2;
for (int i=0; i<ndigits; i++) { for (int i=0; i<ndigits; i++) {
pos = QPoint(xOffset + xAdvance*i, yOffset); pos = QPoint(xOffset + xAdvance*i, yOffset);
if (newString) if (newString)
@ -1074,10 +1078,6 @@ void MediaTimer::paint(QPainter *p,
Q_UNUSED(option); Q_UNUSED(option);
Q_UNUSED(widget); Q_UNUSED(widget);
QFont f = p->font();
f.setPointSizeF(f.pointSizeF());
p->setFont(f);
if (smallPoint) if (smallPoint)
drawString(digitStr, *p, &points, false); drawString(digitStr, *p, &points, false);
else else
@ -1162,7 +1162,7 @@ void MediaTimer::setNumDigits(int numDigits)
numDigits = 0; numDigits = 0;
} }
if (digitStr.isNull()) { // from constructor if (digitStr.isNull()) { // from constructor
ndigits = numDigits; ndigits = numDigits + numDigits/2 - 1;
digitStr.fill(QLatin1Char(' '), ndigits); digitStr.fill(QLatin1Char(' '), ndigits);
points.fill(0, ndigits); points.fill(0, ndigits);
digitStr[ndigits - 1] = QLatin1Char('0'); // "0" is the default number digitStr[ndigits - 1] = QLatin1Char('0'); // "0" is the default number
@ -1192,6 +1192,7 @@ void MediaTimer::setNumDigits(int numDigits)
ndigits = numDigits; ndigits = numDigits;
update(); update();
} }
positionHandles();
} }
DelegateMediaControl::DelegateMediaControl(UBGraphicsMediaItem* pDelegated, QGraphicsItem * parent) DelegateMediaControl::DelegateMediaControl(UBGraphicsMediaItem* pDelegated, QGraphicsItem * parent)
@ -1222,13 +1223,6 @@ void DelegateMediaControl::paint(QPainter *painter,
QPainterPath path; QPainterPath path;
mLCDTimerArea.setHeight(rect().height());
mLCDTimerArea.setWidth(rect().height());
mSeecArea.setWidth(rect().width()-mLCDTimerArea.width()-2);
mSeecArea.setHeight(rect().height()-2*mSeecAreaBorderHeight);
mSeecArea.setY(mSeecAreaBorderHeight);
path.addRoundedRect(mSeecArea, mSeecArea.height()/2, mSeecArea.height()/2); path.addRoundedRect(mSeecArea, mSeecArea.height()/2, mSeecArea.height()/2);
painter->fillPath(path, brush()); painter->fillPath(path, brush());
@ -1258,28 +1252,55 @@ QPainterPath DelegateMediaControl::shape() const
void DelegateMediaControl::positionHandles() void DelegateMediaControl::positionHandles()
{ {
mLCDTimerArea.setWidth(parentItem()->boundingRect().height()); QRectF selfRect = rect();
selfRect.setHeight(parentItem()->boundingRect().height());
setRect(selfRect);
QTime tTotal;
tTotal = tTotal.addMSecs(mTotalTimeInMs);
mLCDTimerArea.setHeight(parentItem()->boundingRect().height()); mLCDTimerArea.setHeight(parentItem()->boundingRect().height());
int digitsCount = 2;
int timerWidth = mLCDTimerArea.height();
mDisplayFormat = "ss";
if (tTotal.minute() > 0)
{
mDisplayFormat = "mm:" + mDisplayFormat;
digitsCount += 3;
timerWidth += mLCDTimerArea.height()*0.5;
}
if (tTotal.hour() > 0)
{
mDisplayFormat = "hh:" + mDisplayFormat;
digitsCount += 3;
timerWidth += mLCDTimerArea.height();
}
lcdTimer->setNumDigits(digitsCount);
mLCDTimerArea.setWidth(timerWidth);
lcdTimer->setRect(mLCDTimerArea); lcdTimer->setRect(mLCDTimerArea);
lcdTimer->setPos(mSeecArea.width()-mLCDTimerArea.width(),0); // not the best solution, but it works.
lcdTimer->positionHandles();
mLCDTimerArea = lcdTimer->rect();
// -------------------------------------
lcdTimer->setPos(rect().width() - mLCDTimerArea.width(), 0);
mSeecAreaBorderHeight = rect().height()/20; mSeecAreaBorderHeight = rect().height()/20;
mSeecArea.setWidth(rect().width()-mLCDTimerArea.width()-2); mSeecArea.setWidth(rect().width()-mLCDTimerArea.width()-2);
mSeecArea.setHeight(rect().height()-2*mSeecAreaBorderHeight); mSeecArea.setHeight(rect().height()-2*mSeecAreaBorderHeight);
mSeecArea.setY(mSeecAreaBorderHeight); mSeecArea.setY(mSeecAreaBorderHeight);
QRectF selfRect = rect();
selfRect.setHeight(parentItem()->boundingRect().height());
setRect(selfRect);
lcdTimer->setPos(rect().width() - mLCDTimerArea.width(), 0);
} }
void DelegateMediaControl::update() void DelegateMediaControl::update()
{ {
QTime t; QTime tCurrent;
t = t.addMSecs(mCurrentTimeInMs < 0 ? 0 : mCurrentTimeInMs); tCurrent = tCurrent.addMSecs(mCurrentTimeInMs < 0 ? 0 : mCurrentTimeInMs);
lcdTimer->display(t.toString("m:ss"));
lcdTimer->display(tCurrent.toString(mDisplayFormat));
QGraphicsRectItem::update(); QGraphicsRectItem::update();
} }
@ -1292,10 +1313,14 @@ void DelegateMediaControl::updateTicker(qint64 time )
void DelegateMediaControl::totalTimeChanged(qint64 newTotalTime) void DelegateMediaControl::totalTimeChanged(qint64 newTotalTime)
{
if (mTotalTimeInMs != newTotalTime)
{ {
mTotalTimeInMs = newTotalTime; mTotalTimeInMs = newTotalTime;
positionHandles();
update(); update();
} }
}
void DelegateMediaControl::mousePressEvent(QGraphicsSceneMouseEvent *event) void DelegateMediaControl::mousePressEvent(QGraphicsSceneMouseEvent *event)
@ -1331,7 +1356,7 @@ void DelegateMediaControl::seekToMousePos(QPointF mousePos)
qreal frameWidth = rect().height() / 2; qreal frameWidth = rect().height() / 2;
minX = frameWidth; minX = frameWidth;
length = mSeecArea.width() - lcdTimer->rect().width(); length = mSeecArea.width() - mSeecArea.height();
qreal mouseX = mousePos.x(); qreal mouseX = mousePos.x();
if (mouseX >= (mSeecArea.width() - mSeecArea.height()/2)) if (mouseX >= (mSeecArea.width() - mSeecArea.height()/2))

Loading…
Cancel
Save