|
28 | 28 | #include "board/UBDrawingController.h" |
29 | 29 | #include "document/UBDocument.h" |
30 | 30 | #include "domain/UBGraphicsScene.h" |
| 31 | +#include "gui/UBBoardThumbnailsView.h" |
31 | 32 | #include "gui/UBDocumentThumbnailsView.h" |
32 | 33 | #include "gui/UBThumbnailScene.h" |
33 | 34 |
|
@@ -247,7 +248,24 @@ QVariant UBThumbnail::itemChange(GraphicsItemChange change, const QVariant& valu |
247 | 248 |
|
248 | 249 | void UBThumbnail::hoverEnterEvent(QGraphicsSceneHoverEvent* event) |
249 | 250 | { |
250 | | - mEditable = true; |
| 251 | + auto thumbnailScene = dynamic_cast<UBThumbnailScene*>(scene()); |
| 252 | + |
| 253 | + if (thumbnailScene) |
| 254 | + { |
| 255 | + for (const auto view : thumbnailScene->views()) |
| 256 | + { |
| 257 | + if (view->isVisible()) |
| 258 | + { |
| 259 | + bool isBoardThumbnailsView = dynamic_cast<UBBoardThumbnailsView*>(view) != nullptr; |
| 260 | + |
| 261 | + if (isBoardThumbnailsView) |
| 262 | + { |
| 263 | + mEditable = true; |
| 264 | + break; |
| 265 | + } |
| 266 | + } |
| 267 | + } |
| 268 | + } |
251 | 269 | QGraphicsRectItem::hoverEnterEvent(event); |
252 | 270 | } |
253 | 271 |
|
@@ -296,8 +314,11 @@ void UBThumbnail::paint(QPainter* painter, const QStyleOptionGraphicsItem* optio |
296 | 314 | // paint the buttons |
297 | 315 | if (mEditable) |
298 | 316 | { |
299 | | - UBThumbnailUI::draw(painter, *UBThumbnailUI::getIcon(mDeletable ? "close" : "closeDisabled")); |
300 | | - UBThumbnailUI::draw(painter, *UBThumbnailUI::getIcon("duplicate")); |
| 317 | + using namespace UBThumbnailUI; //should be reworked so icons' scale adapts to what's needed |
| 318 | + const UBThumbnailUIIcon& closeThumbnailIcon = *UBThumbnailUI::getIcon(mDeletable ? "close" : "closeDisabled"); |
| 319 | + const UBThumbnailUIIcon& duplicateThumbnailIcon = *UBThumbnailUI::getIcon("duplicate"); |
| 320 | + painter->drawPixmap(mPixmapItem->x() + (closeThumbnailIcon.pos() * (ICONSIZE + ICONSPACING)), 0, ICONSIZE, ICONSIZE, closeThumbnailIcon); |
| 321 | + painter->drawPixmap(mPixmapItem->x() + (duplicateThumbnailIcon.pos() * (ICONSIZE + ICONSPACING)), 0, ICONSIZE, ICONSIZE, duplicateThumbnailIcon); |
301 | 322 | } |
302 | 323 |
|
303 | 324 | // do not call superclass - do not paint the rectangle itself or the default dashed selection rectangle |
|
0 commit comments