|
|
|
@ -236,9 +236,7 @@ UBGraphicsItemDelegate::~UBGraphicsItemDelegate() |
|
|
|
|
|
|
|
|
|
QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) |
|
|
|
|
{ |
|
|
|
|
if(change == QGraphicsItem::ItemChildAddedChange){ |
|
|
|
|
|
|
|
|
|
}else if (change == QGraphicsItem::ItemSelectedHasChanged) { |
|
|
|
|
if (change == QGraphicsItem::ItemSelectedHasChanged) { |
|
|
|
|
bool ok; |
|
|
|
|
bool selected = value.toUInt(&ok); |
|
|
|
|
if (ok) { |
|
|
|
@ -286,6 +284,8 @@ bool UBGraphicsItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
|
{ |
|
|
|
|
mDragStartPosition = event->pos(); |
|
|
|
|
|
|
|
|
|
mMoved = false; |
|
|
|
|
|
|
|
|
|
startUndoStep(); |
|
|
|
|
|
|
|
|
|
if (!delegated()->isSelected()) |
|
|
|
@ -315,6 +315,7 @@ bool UBGraphicsItemDelegate::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
|
} |
|
|
|
|
mDrag->exec(); |
|
|
|
|
mDragPixmap = QPixmap(); |
|
|
|
|
mMoved = true; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
@ -439,22 +440,9 @@ void UBGraphicsItemDelegate::setZOrderButtonsVisible(bool visible) |
|
|
|
|
|
|
|
|
|
void UBGraphicsItemDelegate::remove(bool canUndo) |
|
|
|
|
{ |
|
|
|
|
/*UBGraphicsScene* scene = dynamic_cast<UBGraphicsScene*>(mDelegated->scene());
|
|
|
|
|
if (scene && canUndo) |
|
|
|
|
{ |
|
|
|
|
UBGraphicsItemUndoCommand *uc = new UBGraphicsItemUndoCommand(scene, mDelegated, 0); |
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
} |
|
|
|
|
mDelegated->hide(); */ |
|
|
|
|
|
|
|
|
|
UBGraphicsScene* scene = dynamic_cast<UBGraphicsScene*>(mDelegated->scene()); |
|
|
|
|
if (scene) |
|
|
|
|
{ |
|
|
|
|
// bool shownOnDisplay = mDelegated->data(UBGraphicsItemData::ItemLayerType).toInt() != UBItemLayerType::Control;
|
|
|
|
|
// showHide(shownOnDisplay);
|
|
|
|
|
// updateFrame();
|
|
|
|
|
// updateButtons();
|
|
|
|
|
|
|
|
|
|
if (mFrame && !mFrame->scene() && mDelegated->scene()) |
|
|
|
|
{ |
|
|
|
|
mDelegated->scene()->addItem(mFrame); |
|
|
|
@ -734,7 +722,7 @@ void UBGraphicsItemDelegate::updateButtons(bool showUpdated) |
|
|
|
|
mDelegated->scene()->addItem(mDeleteButton); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (showUpdated /*&& mFrame->isResizing()*/) |
|
|
|
|
if (showUpdated) |
|
|
|
|
mDeleteButton->show(); |
|
|
|
|
|
|
|
|
|
int i = 1, j = 0, k = 0; |
|
|
|
@ -772,7 +760,7 @@ void UBGraphicsItemDelegate::setButtonsVisible(bool visible) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsToolBarItem::UBGraphicsToolBarItem(QGraphicsItem * parent) :
|
|
|
|
|
UBGraphicsToolBarItem::UBGraphicsToolBarItem(QGraphicsItem * parent) : |
|
|
|
|
QGraphicsRectItem(parent), |
|
|
|
|
mShifting(true), |
|
|
|
|
mVisible(false), |
|
|
|
@ -785,7 +773,6 @@ UBGraphicsToolBarItem::UBGraphicsToolBarItem(QGraphicsItem * parent) : |
|
|
|
|
rect.setWidth(parent->boundingRect().width()); |
|
|
|
|
this->setRect(rect); |
|
|
|
|
|
|
|
|
|
// setBrush(QColor(UBSettings::paletteColor));
|
|
|
|
|
setPen(Qt::NoPen); |
|
|
|
|
hide(); |
|
|
|
|
|
|
|
|
@ -815,36 +802,40 @@ void UBGraphicsToolBarItem::paint(QPainter *painter, const QStyleOptionGraphicsI |
|
|
|
|
Q_UNUSED(widget); |
|
|
|
|
|
|
|
|
|
QPainterPath path; |
|
|
|
|
path.addRoundedRect(rect(), 10, 10);
|
|
|
|
|
path.addRoundedRect(rect(), 10, 10); |
|
|
|
|
|
|
|
|
|
setBrush(QBrush(UBSettings::paletteColor)); |
|
|
|
|
|
|
|
|
|
painter->fillPath(path, brush()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
MediaTimer::MediaTimer(QGraphicsItem * parent): QGraphicsRectItem(parent)
|
|
|
|
|
MediaTimer::MediaTimer(QGraphicsItem * parent): QGraphicsRectItem(parent) |
|
|
|
|
{ |
|
|
|
|
val = 0; |
|
|
|
|
smallPoint = false; |
|
|
|
|
setNumDigits(4); |
|
|
|
|
setNumDigits(6); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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, |
|
|
|
|
QBitArray *newPoints, bool newString) |
|
|
|
|
{ |
|
|
|
|
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++) { |
|
|
|
|
pos = QPoint(xOffset + xAdvance*i, yOffset); |
|
|
|
|
if (newString) |
|
|
|
@ -878,11 +869,11 @@ void MediaTimer::drawDigit(const QPoint &pos, QPainter &p, int segLen, |
|
|
|
|
int nUpdates; |
|
|
|
|
const char *segs; |
|
|
|
|
int i,j; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char erase = 0; |
|
|
|
|
const char draw = 1; |
|
|
|
|
const char leaveAlone = 2; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
segs = getSegments(oldCh); |
|
|
|
|
for (nErases=0; segs[nErases] != 99; nErases++) { |
|
|
|
|
updates[nErases][0] = erase; // get segments to erase to
|
|
|
|
@ -910,8 +901,8 @@ void MediaTimer::drawDigit(const QPoint &pos, QPainter &p, int segLen, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
char MediaTimer::segments [][8] =
|
|
|
|
|
{
|
|
|
|
|
char MediaTimer::segments [][8] = |
|
|
|
|
{ |
|
|
|
|
{ 0, 1, 2, 4, 5, 6,99, 0}, // 0 0
|
|
|
|
|
{ 2, 5,99, 0, 0, 0, 0, 0}, // 1 1
|
|
|
|
|
{ 0, 2, 3, 4, 6,99, 0, 0}, // 2 2
|
|
|
|
@ -1090,10 +1081,6 @@ void MediaTimer::paint(QPainter *p, |
|
|
|
|
Q_UNUSED(option); |
|
|
|
|
Q_UNUSED(widget); |
|
|
|
|
|
|
|
|
|
QFont f = p->font(); |
|
|
|
|
f.setPointSizeF(f.pointSizeF()); |
|
|
|
|
p->setFont(f); |
|
|
|
|
|
|
|
|
|
if (smallPoint) |
|
|
|
|
drawString(digitStr, *p, &points, false); |
|
|
|
|
else |
|
|
|
@ -1178,7 +1165,7 @@ void MediaTimer::setNumDigits(int numDigits) |
|
|
|
|
numDigits = 0; |
|
|
|
|
} |
|
|
|
|
if (digitStr.isNull()) { // from constructor
|
|
|
|
|
ndigits = numDigits; |
|
|
|
|
ndigits = numDigits + numDigits/2 - 1; |
|
|
|
|
digitStr.fill(QLatin1Char(' '), ndigits); |
|
|
|
|
points.fill(0, ndigits); |
|
|
|
|
digitStr[ndigits - 1] = QLatin1Char('0'); // "0" is the default number
|
|
|
|
@ -1208,6 +1195,7 @@ void MediaTimer::setNumDigits(int numDigits) |
|
|
|
|
ndigits = numDigits; |
|
|
|
|
update(); |
|
|
|
|
} |
|
|
|
|
positionHandles(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
DelegateMediaControl::DelegateMediaControl(UBGraphicsMediaItem* pDelegated, QGraphicsItem * parent) |
|
|
|
@ -1235,15 +1223,8 @@ void DelegateMediaControl::paint(QPainter *painter, |
|
|
|
|
{ |
|
|
|
|
Q_UNUSED(option); |
|
|
|
|
Q_UNUSED(widget); |
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
QPainterPath path; |
|
|
|
|
|
|
|
|
|
path.addRoundedRect(mSeecArea, mSeecArea.height()/2, mSeecArea.height()/2); |
|
|
|
|
painter->fillPath(path, brush()); |
|
|
|
@ -1274,28 +1255,59 @@ QPainterPath DelegateMediaControl::shape() const |
|
|
|
|
|
|
|
|
|
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()); |
|
|
|
|
|
|
|
|
|
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->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; |
|
|
|
|
mSeecArea.setWidth(rect().width()-mLCDTimerArea.width()-2); |
|
|
|
|
mSeecArea.setHeight(rect().height()-2*mSeecAreaBorderHeight); |
|
|
|
|
mSeecArea.setY(mSeecAreaBorderHeight); |
|
|
|
|
|
|
|
|
|
QRectF selfRect = rect(); |
|
|
|
|
selfRect.setHeight(parentItem()->boundingRect().height()); |
|
|
|
|
setRect(selfRect); |
|
|
|
|
|
|
|
|
|
lcdTimer->setPos(rect().width() - mLCDTimerArea.width(), 0);
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void DelegateMediaControl::update() |
|
|
|
|
{ |
|
|
|
|
QTime t; |
|
|
|
|
t = t.addMSecs(mCurrentTimeInMs < 0 ? 0 : mCurrentTimeInMs); |
|
|
|
|
lcdTimer->display(t.toString("m:ss")); |
|
|
|
|
QTime tCurrent; |
|
|
|
|
tCurrent = tCurrent.addMSecs(mCurrentTimeInMs < 0 ? 0 : mCurrentTimeInMs); |
|
|
|
|
|
|
|
|
|
lcdTimer->display(tCurrent.toString(mDisplayFormat)); |
|
|
|
|
|
|
|
|
|
QGraphicsRectItem::update(); |
|
|
|
|
} |
|
|
|
@ -1309,17 +1321,21 @@ void DelegateMediaControl::updateTicker(qint64 time ) |
|
|
|
|
|
|
|
|
|
void DelegateMediaControl::totalTimeChanged(qint64 newTotalTime) |
|
|
|
|
{ |
|
|
|
|
mTotalTimeInMs = newTotalTime; |
|
|
|
|
update(); |
|
|
|
|
if (mTotalTimeInMs != newTotalTime) |
|
|
|
|
{ |
|
|
|
|
mTotalTimeInMs = newTotalTime; |
|
|
|
|
positionHandles(); |
|
|
|
|
update(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DelegateMediaControl::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
|
{ |
|
|
|
|
qreal frameWidth = mSeecArea.height()/2; |
|
|
|
|
if (boundingRect().contains(event->pos() - QPointF(frameWidth,0))
|
|
|
|
|
if (boundingRect().contains(event->pos() - QPointF(frameWidth,0)) |
|
|
|
|
&& boundingRect().contains(event->pos() + QPointF(frameWidth,0))) |
|
|
|
|
{
|
|
|
|
|
{ |
|
|
|
|
mDisplayCurrentTime = true; |
|
|
|
|
seekToMousePos(event->pos()); |
|
|
|
|
this->update(); |
|
|
|
@ -1331,9 +1347,9 @@ void DelegateMediaControl::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
|
void DelegateMediaControl::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
|
{ |
|
|
|
|
qreal frameWidth = mSeecArea.height() / 2; |
|
|
|
|
if (boundingRect().contains(event->pos() - QPointF(frameWidth,0))
|
|
|
|
|
if (boundingRect().contains(event->pos() - QPointF(frameWidth,0)) |
|
|
|
|
&& boundingRect().contains(event->pos() + QPointF(frameWidth,0))) |
|
|
|
|
{
|
|
|
|
|
{ |
|
|
|
|
seekToMousePos(event->pos()); |
|
|
|
|
this->update(); |
|
|
|
|
event->accept(); |
|
|
|
@ -1347,7 +1363,7 @@ void DelegateMediaControl::seekToMousePos(QPointF mousePos) |
|
|
|
|
qreal frameWidth = rect().height() / 2; |
|
|
|
|
|
|
|
|
|
minX = frameWidth; |
|
|
|
|
length = mSeecArea.width() - lcdTimer->rect().width(); |
|
|
|
|
length = mSeecArea.width() - mSeecArea.height(); |
|
|
|
|
|
|
|
|
|
qreal mouseX = mousePos.x(); |
|
|
|
|
if (mouseX >= (mSeecArea.width() - mSeecArea.height()/2)) |
|
|
|
|