1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtGui>
#include <QtSvg>
#include <QDrag>
#include "UBGraphicsItemDelegate.h"
#include "UBGraphicsDelegateFrame.h"
#include "UBGraphicsScene.h"
#include "UBGraphicsItemUndoCommand.h"
#include "UBGraphicsItemTransformUndoCommand.h"
#include "board/UBBoardController.h" // TODO UB 4.x clean that dependency
#include "board/UBBoardView.h" // TODO UB 4.x clean that dependency
#include "core/UBApplication.h"
#include "core/UBApplicationController.h"
#include "core/UBDisplayManager.h"
#include "core/UBSettings.h"
#include "core/UBPersistenceManager.h"
#include "document/UBDocumentProxy.h"
#include "UBGraphicsWidgetItem.h"
#include "domain/UBAbstractWidget.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsVideoItem.h"
#include "web/UBWebController.h"
#include "frameworks/UBFileSystemUtils.h"
#include "board/UBDrawingController.h"
#include "core/memcheck.h"
class UBGraphicsParaschoolEditorWidgetItem;
DelegateButton::DelegateButton(const QString & fileName, QGraphicsItem* pDelegated, QGraphicsItem * parent, Qt::WindowFrameSection section)
: QGraphicsSvgItem(fileName, parent)
, mDelegated(pDelegated)
, mIsTransparentToMouseEvent(false)
, mButtonAlignmentSection(section)
{
setAcceptedMouseButtons(Qt::LeftButton);
setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
}
DelegateButton::~DelegateButton()
{
// NOOP
}
void DelegateButton::setFileName(const QString & fileName)
{
QGraphicsSvgItem::setSharedRenderer(new QSvgRenderer (fileName, this));
}
void DelegateButton::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
// make sure delegate is selected, to avoid control being hidden
mPressedTime = QTime::currentTime();
// mDelegated->setSelected(true);
event->setAccepted(!mIsTransparentToMouseEvent);
}
void DelegateButton::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
int timeto = qAbs(QTime::currentTime().msecsTo(mPressedTime));
if (timeto < UBSettings::longClickInterval) {
emit clicked();
} else {
emit longClicked();
}
event->setAccepted(!mIsTransparentToMouseEvent);
}
UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObject * parent, bool respectRatio, bool canRotate)
: QObject(parent)
, mDelegated(pDelegated)
, mDeleteButton(NULL)
, mDuplicateButton(NULL)
, mMenuButton(NULL)
, mMenu(0)
, mLockAction(0)
, mShowOnDisplayAction(0)
, mGotoContentSourceAction(0)
, mFrame(0)
, mFrameWidth(UBSettings::settings()->objectFrameWidth)
, mAntiScaleRatio(1.0)
, mCanRotate(canRotate)
, mCanDuplicate(true)
, mRespectRatio(respectRatio)
, mMimeData(NULL)
, mFlippable(false)
{
// NOOP
}
void UBGraphicsItemDelegate::init()
{
mToolBarItem = new UBGraphicsToolBarItem(delegated());
mFrame = new UBGraphicsDelegateFrame(this, QRectF(0, 0, 0, 0), mFrameWidth, mRespectRatio);
mFrame->hide();
mFrame->setFlag(QGraphicsItem::ItemIsSelectable, true);
mDeleteButton = new DelegateButton(":/images/close.svg", mDelegated, mFrame, Qt::TopLeftSection);
mButtons << mDeleteButton;
connect(mDeleteButton, SIGNAL(clicked()), this, SLOT(remove()));
if (canDuplicate()){
mDuplicateButton = new DelegateButton(":/images/duplicate.svg", mDelegated, mFrame, Qt::TopLeftSection);
connect(mDuplicateButton, SIGNAL(clicked(bool)), this, SLOT(duplicate()));
mButtons << mDuplicateButton;
}
mMenuButton = new DelegateButton(":/images/menu.svg", mDelegated, mFrame, Qt::TopLeftSection);
connect(mMenuButton, SIGNAL(clicked()), this, SLOT(showMenu()));
mButtons << mMenuButton;
mZOrderUpButton = new DelegateButton(":/images/plus.svg", mDelegated, mFrame, Qt::BottomLeftSection);
connect(mZOrderUpButton, SIGNAL(clicked()), this, SLOT(increaseZLevelUp()));
connect(mZOrderUpButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelTop()));
mButtons << mZOrderUpButton;
mZOrderDownButton = new DelegateButton(":/images/minus.svg", mDelegated, mFrame, Qt::BottomLeftSection);
connect(mZOrderDownButton, SIGNAL(clicked()), this, SLOT(increaseZLevelDown()));
connect(mZOrderDownButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelBottom()));
mButtons << mZOrderDownButton;
buildButtons();
foreach(DelegateButton* button, mButtons)
{
if (button->getSection() != Qt::TitleBarArea)
{
button->hide();
button->setFlag(QGraphicsItem::ItemIsSelectable, true);
}
}
}
UBGraphicsItemDelegate::~UBGraphicsItemDelegate()
{
qDeleteAll(mButtons);
// do not release mMimeData.
// the mMimeData is owned by QDrag since the setMimeData call as specified in the documentation
}
QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedHasChanged) {
bool ok;
bool selected = value.toUInt(&ok);
if (ok) {
UBGraphicsScene *ubScene = castUBGraphicsScene();
if (ubScene) {
if (selected) {
ubScene->setSelectedZLevel(delegated());
} else {
ubScene->setOwnZlevel(delegated());
}
}
}
}
if ((change == QGraphicsItem::ItemSelectedHasChanged
|| change == QGraphicsItem::ItemPositionHasChanged
|| change == QGraphicsItem::ItemTransformHasChanged)
&& mDelegated->scene())
{
mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom());
positionHandles();
}
if (change == QGraphicsItem::ItemPositionHasChanged
|| change == QGraphicsItem::ItemTransformHasChanged
|| change == QGraphicsItem::ItemZValueHasChanged)
{
UBGraphicsScene* ubScene = qobject_cast<UBGraphicsScene*>(mDelegated->scene());
if(ubScene)
ubScene->setModified(true);
}
return value;
}
UBGraphicsScene *UBGraphicsItemDelegate::castUBGraphicsScene()
{
UBGraphicsScene *castScene = dynamic_cast<UBGraphicsScene*>(delegated()->scene());
return castScene;
}
bool UBGraphicsItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
mDragStartPosition = event->pos();
startUndoStep();
if (!mDelegated->isSelected())
{
mDelegated->setSelected(true);
positionHandles();
return true;
}
else
{
return false;
}
}
void UBGraphicsItemDelegate::setMimeData(QMimeData *mimeData)
{
mMimeData = mimeData;
}
bool UBGraphicsItemDelegate::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if(NULL != mMimeData)
{
QDrag* mDrag = new QDrag(event->widget());
mDrag->setMimeData(mMimeData);
if (!mDragPixmap.isNull()) {
mDrag->setPixmap(mDragPixmap);
mDrag->setHotSpot(mDragPixmap.rect().center());
}
mDrag->exec();
mDragPixmap = QPixmap();
return true;
}
if(isLocked())
{
event->accept();
return true;
}
else
return false;
}
bool UBGraphicsItemDelegate::weelEvent(QGraphicsSceneWheelEvent *event)
{
Q_UNUSED(event);
if( mDelegated->isSelected() )
{
// event->accept();
return true;
}
else
{
// event->ignore();
return false;
}
}
bool UBGraphicsItemDelegate::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event);
//Deselect all the rest selected items if no ctrl key modifier
if (delegated()->scene()
&& delegated()->scene()->selectedItems().count()
&& event->modifiers() != Qt::ControlModifier) {
foreach (QGraphicsItem *item, delegated()->scene()->selectedItems()) {
if (item != delegated()) {
item->setSelected(false);
}
}
}
commitUndoStep();
return true;
}
void UBGraphicsItemDelegate::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
// if (!mDelegated->isSelected()) {
// setZOrderButtonsVisible(true);
// }
}
void UBGraphicsItemDelegate::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
// if (!mDelegated->isSelected()) {
// setZOrderButtonsVisible(false);
// }
}
void UBGraphicsItemDelegate::positionHandles()
{
if (mDelegated->isSelected()) {
bool shownOnDisplay = mDelegated->data(UBGraphicsItemData::ItemLayerType).toInt() != UBItemLayerType::Control;
showHide(shownOnDisplay);
lock(isLocked());
updateFrame();
mFrame->show();
updateButtons(true);
if (mToolBarItem->isVisibleOnBoard())
{
updateToolBar();
mToolBarItem->show();
}
} else {
foreach(DelegateButton* button, mButtons)
button->hide();
mFrame->hide();
mToolBarItem->hide();
}
}
void UBGraphicsItemDelegate::setZOrderButtonsVisible(bool visible)
{
if (visible) {
updateFrame();
updateButtons();
QPointF newUpPoint = mFrame->mapToItem(mDelegated, mZOrderUpButton->pos());
QPointF newDownPoint = mFrame->mapToItem(mDelegated, mZOrderDownButton->pos());
mZOrderUpButton->setParentItem(mDelegated);
mZOrderDownButton->setParentItem(mDelegated);
mZOrderUpButton->setPos(newUpPoint + QPointF(0,0));
mZOrderDownButton->setPos(newDownPoint + QPointF(0,0));
mZOrderUpButton->show();
mZOrderDownButton->show();
} else {
mZOrderUpButton->hide();
mZOrderDownButton->hide();
}
}
void UBGraphicsItemDelegate::remove(bool canUndo)
{
// QGraphicsScene* scene = mDelegated->scene();
UBGraphicsScene* scene = (UBGraphicsScene*)(mDelegated->scene());
if (scene)
{
foreach(DelegateButton* button, mButtons)
scene->removeItem(button);
scene->removeItem(mFrame);
scene->removeItem(mDelegated);
scene->removeItem(mToolBarItem);
if (canUndo)
{
UBGraphicsItemUndoCommand *uc = new UBGraphicsItemUndoCommand((UBGraphicsScene*) scene, mDelegated, 0);
UBApplication::undoStack->push(uc);
}
}
}
bool UBGraphicsItemDelegate::isLocked()
{
return mDelegated->data(UBGraphicsItemData::ItemLocked).toBool();
}
void UBGraphicsItemDelegate::duplicate()
{
// TODO UB 4.x .. rewrite .. .this is absurde ... we know what we are duplicating
UBApplication::boardController->copy();
UBApplication::boardController->paste();
}
void UBGraphicsItemDelegate::increaseZLevelUp()
{
UBGraphicsScene *curScene = castUBGraphicsScene();
if (curScene) {
curScene->changeZLevelTo(delegated(), UBZLayerController::up);
}
}
void UBGraphicsItemDelegate::increaseZlevelTop()
{
UBGraphicsScene *curScene = castUBGraphicsScene();
if (curScene) {
curScene->changeZLevelTo(delegated(), UBZLayerController::top);
}
}
void UBGraphicsItemDelegate::increaseZLevelDown()
{
UBGraphicsScene *curScene = castUBGraphicsScene();
if (curScene) {
curScene->changeZLevelTo(delegated(), UBZLayerController::down);
}
}
void UBGraphicsItemDelegate::increaseZlevelBottom()
{
UBGraphicsScene *curScene = castUBGraphicsScene();
if (curScene) {
curScene->changeZLevelTo(delegated(), UBZLayerController::bottom);
}
}
void UBGraphicsItemDelegate::lock(bool locked)
{
if (locked)
{
mDelegated->setData(UBGraphicsItemData::ItemLocked, QVariant(true));
}
else
{
mDelegated->setData(UBGraphicsItemData::ItemLocked, QVariant(false));
}
mDelegated->update();
mFrame->positionHandles();
}
void UBGraphicsItemDelegate::showHide(bool show)
{
if (show)
{
mDelegated->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Object));
}
else
{
mDelegated->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
}
mDelegated->update();
emit showOnDisplayChanged(show);
}
void UBGraphicsItemDelegate::gotoContentSource(bool checked)
{
Q_UNUSED(checked)
UBItem* item = dynamic_cast<UBItem*>(mDelegated);
if(item && !item->sourceUrl().isEmpty())
{
UBApplication::applicationController->showInternet();
UBApplication::webController->loadUrl(item->sourceUrl());
}
}
void UBGraphicsItemDelegate::startUndoStep()
{
mPreviousPosition = mDelegated->pos();
mPreviousTransform = mDelegated->transform();
mPreviousZValue = mDelegated->zValue();
UBResizableGraphicsItem* resizableItem = dynamic_cast<UBResizableGraphicsItem*>(mDelegated);
if (resizableItem)
mPreviousSize = resizableItem->size();
else
mPreviousSize = QSizeF();
}
void UBGraphicsItemDelegate::commitUndoStep()
{
UBResizableGraphicsItem* resizableItem = dynamic_cast<UBResizableGraphicsItem*>(mDelegated);
if (mDelegated->pos() != mPreviousPosition
|| mDelegated->transform() != mPreviousTransform
|| mDelegated->zValue() != mPreviousZValue
|| (resizableItem && resizableItem->size() != mPreviousSize))
{
UBGraphicsItemTransformUndoCommand *uc =
new UBGraphicsItemTransformUndoCommand(mDelegated,
mPreviousPosition,
mPreviousTransform,
mPreviousZValue,
mPreviousSize);
UBApplication::undoStack->push(uc);
}
}
void UBGraphicsItemDelegate::decorateMenu(QMenu* menu)
{
mLockAction = menu->addAction(tr("Locked"), this, SLOT(lock(bool)));
QIcon lockIcon;
lockIcon.addPixmap(QPixmap(":/images/locked.svg"), QIcon::Normal, QIcon::On);
lockIcon.addPixmap(QPixmap(":/images/unlocked.svg"), QIcon::Normal, QIcon::Off);
mLockAction->setIcon(lockIcon);
mLockAction->setCheckable(true);
mShowOnDisplayAction = mMenu->addAction(tr("Visible on Extended Screen"), this, SLOT(showHide(bool)));
mShowOnDisplayAction->setCheckable(true);
QIcon showIcon;
showIcon.addPixmap(QPixmap(":/images/eyeOpened.svg"), QIcon::Normal, QIcon::On);
showIcon.addPixmap(QPixmap(":/images/eyeClosed.svg"), QIcon::Normal, QIcon::Off);
mShowOnDisplayAction->setIcon(showIcon);
mGotoContentSourceAction = menu->addAction(tr("Go to Content Source"), this, SLOT(gotoContentSource(bool)));
QIcon sourceIcon;
sourceIcon.addPixmap(QPixmap(":/images/toolbar/internet.png"), QIcon::Normal, QIcon::On);
mGotoContentSourceAction->setIcon(sourceIcon);
}
void UBGraphicsItemDelegate::updateMenuActionState()
{
if (mLockAction)
mLockAction->setChecked(isLocked());
if (mShowOnDisplayAction)
{
bool isControl = mDelegated->data(UBGraphicsItemData::ItemLayerType) == UBItemLayerType::Control;
mShowOnDisplayAction->setChecked(!isControl);
}
if (mGotoContentSourceAction)
{
UBItem* item = dynamic_cast<UBItem*>(mDelegated);
mGotoContentSourceAction->setEnabled(item && !item->sourceUrl().isEmpty());
}
}
void UBGraphicsItemDelegate::showMenu()
{
if (!mMenu)
{
mMenu = new QMenu(UBApplication::boardController->controlView());
decorateMenu(mMenu);
}
updateMenuActionState();
UBBoardView* cv = UBApplication::boardController->controlView();
QRect pinPos = cv->mapFromScene(mMenuButton->sceneBoundingRect()).boundingRect();
mMenu->exec(cv->mapToGlobal(pinPos.bottomRight()));
}
void UBGraphicsItemDelegate::setFlippable(bool flippable)
{
mFlippable = flippable;
}
bool UBGraphicsItemDelegate::isFlippable()
{
return mFlippable;
}
void UBGraphicsItemDelegate::updateFrame()
{
if (mFrame && !mFrame->scene() && mDelegated->scene())
{
mDelegated->scene()->addItem(mFrame);
}
mFrame->setAntiScale(mAntiScaleRatio);
mFrame->positionHandles();
}
void UBGraphicsItemDelegate::updateButtons(bool showUpdated)
{
QTransform tr;
tr.scale(mAntiScaleRatio, mAntiScaleRatio);
mDeleteButton->setParentItem(mFrame);
mDeleteButton->setTransform(tr);
qreal topX = mFrame->rect().left() - mDeleteButton->renderer()->viewBox().width() * mAntiScaleRatio / 2;
qreal topY = mFrame->rect().top() - mDeleteButton->renderer()->viewBox().height() * mAntiScaleRatio / 2;
qreal bottomX = mFrame->rect().left() - mDeleteButton->renderer()->viewBox().width() * mAntiScaleRatio / 2;
qreal bottomY = mFrame->rect().bottom() - mDeleteButton->renderer()->viewBox().height() * mAntiScaleRatio / 2;
mDeleteButton->setPos(topX, topY);
if (!mDeleteButton->scene())
{
if (mDelegated->scene())
mDelegated->scene()->addItem(mDeleteButton);
}
if (showUpdated /*&& mFrame->isResizing()*/)
mDeleteButton->show();
int i = 1, j = 0, k = 0;
while ((i + j + k) < mButtons.size()) {
DelegateButton* button = mButtons[i + j];
if (button->getSection() == Qt::TopLeftSection) {
button->setParentItem(mFrame);
button->setPos(topX + (i++ * 1.6 * mFrameWidth * mAntiScaleRatio), topY);
button->setTransform(tr);
} else if (button->getSection() == Qt::BottomLeftSection) {
button->setParentItem(mFrame);
button->setPos(bottomX + (++j * 1.6 * mFrameWidth * mAntiScaleRatio), bottomY);
button->setTransform(tr);
} else if (button->getSection() == Qt::TitleBarArea || button->getSection() == Qt::NoSection){
++k;
}
if (!button->scene())
{
if (mDelegated->scene())
mDelegated->scene()->addItem(button);
}
if (showUpdated) {
button->show();
button->setZValue(delegated()->zValue());
}
}
}
void UBGraphicsItemDelegate::updateToolBar()
{
QTransform transformForToolbarButtons;
transformForToolbarButtons.scale(mAntiScaleRatio, 1);
QRectF toolBarRect = mToolBarItem->rect();
toolBarRect.setWidth(delegated()->boundingRect().width() - 10);
mToolBarItem->setRect(toolBarRect);
if (mToolBarItem->isShifting())
mToolBarItem->setPos(delegated()->boundingRect().bottomLeft() + QPointF(5 * mAntiScaleRatio, 0));
else mToolBarItem->setPos(delegated()->boundingRect().bottomLeft() - QPointF(-5 * mAntiScaleRatio, mToolBarItem->rect().height() * 1.1 * mAntiScaleRatio));
int offsetOnToolBar = 5 * mAntiScaleRatio;
QList<QGraphicsItem*> itemList = mToolBarItem->itemsOnToolBar();
foreach (QGraphicsItem* item, itemList)
{
item->setPos(offsetOnToolBar, 0);
offsetOnToolBar += (item->boundingRect().width() + 5) * mAntiScaleRatio;
item->setTransform(transformForToolbarButtons);
item->show();
}
mToolBarItem->setOffsetOnToolBar(offsetOnToolBar);
QTransform tr;
tr.scale(1, mAntiScaleRatio);
mToolBarItem->setTransform(tr);
}
void UBGraphicsItemDelegate::setButtonsVisible(bool visible)
{
foreach(DelegateButton* pButton, mButtons){
pButton->setVisible(visible);
}
}
UBGraphicsToolBarItem::UBGraphicsToolBarItem(QGraphicsItem * parent) :
QGraphicsRectItem(parent),
mShifting(true),
mVisible(false),
mMinWidth(200)
{
QRectF rect = this->rect();
rect.setHeight(26);
this->setRect(rect);
setBrush(QColor(UBSettings::paletteColor));
setPen(Qt::NoPen);
hide();
}
void UBGraphicsToolBarItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
QPainterPath path;
path.addRoundedRect(rect(), 10, 10);
painter->fillPath(path, brush());
}