Skip to content

Commit

Permalink
Add highlight bounding rectangle on hover to PageAttributePixmap item #…
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorsandy committed Sep 20, 2020
1 parent 6bbfed6 commit 8673e63
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 13 deletions.
2 changes: 1 addition & 1 deletion builds/linux/obs/alldeps/PKGBUILD
Expand Up @@ -2,7 +2,7 @@
# Last Update: July 23, 2019
# Copyright (c) 2017 - 2019 by Trevor SANDY
pkgname=lpub3d
pkgver=2.4.0.1700
pkgver=2.4.0.1701
pkgrel=1
pkgdesc="An LDraw Building Instruction Editor"
url="https://github.com/trevorsandy/lpub3d.git"
Expand Down
6 changes: 3 additions & 3 deletions builds/linux/obs/alldeps/debian/changelog
@@ -1,5 +1,5 @@
lpub3d (2.4.0.1700) debian; urgency=medium
lpub3d (2.4.0.1701) debian; urgency=medium

* LPub3D version 2.4.0.1.1700_20200920 for Linux
* LPub3D version 2.4.0.1.1701_20200920 for Linux

-- Trevor SANDY <trevor.sandy@gmail.com> Sun, 20 Sep 2020 09:29:20 +0200
-- Trevor SANDY <trevor.sandy@gmail.com> Sun, 20 Sep 2020 09:29:58 +0200
2 changes: 1 addition & 1 deletion builds/linux/obs/alldeps/debian/lpub3d.dsc
Expand Up @@ -2,7 +2,7 @@ Format: 1.0
Source: lpub3d
Binary: lpub3d
Architecture: any
Version: 2.4.0.1700
Version: 2.4.0.1701
Maintainer: Trevor SANDY <trevor.sandy@gmail.com>
Homepage: https://trevorsandy.github.io/lpub3d/
Standards-Version: 3.9.7
Expand Down
4 changes: 2 additions & 2 deletions builds/linux/obs/alldeps/lpub3d.spec
Expand Up @@ -116,7 +116,7 @@ BuildRequires: fdupes
Summary: An LDraw Building Instruction Editor
Name: lpub3d
Icon: lpub3d.xpm
Version: 2.4.0.1700
Version: 2.4.0.1701
Release: <B_CNT>%{?dist}
URL: https://trevorsandy.github.io/lpub3d
Vendor: Trevor SANDY
Expand Down Expand Up @@ -728,5 +728,5 @@ update-mime-database /usr/share/mime >/dev/null || true
update-desktop-database || true
%endif

* Sun Sep 20 2020 - trevor.dot.sandy.at.gmail.dot.com 2.4.0.1700
* Sun Sep 20 2020 - trevor.dot.sandy.at.gmail.dot.com 2.4.0.1701
- LPub3D Linux package (rpm) release
Binary file modified builds/utilities/ci/secure/.secrets.tar.enc
Binary file not shown.
2 changes: 1 addition & 1 deletion builds/utilities/version.info
@@ -1 +1 @@
2 4 0 1 1700 ecf34ce
2 4 0 1 1701 6bbfed6
2 changes: 1 addition & 1 deletion mainApp/docs/README.txt
@@ -1,4 +1,4 @@
LPub3D 2.4.0.1.1700 (20 09 2020 09:29:20)
LPub3D 2.4.0.1.1701 (20 09 2020 09:29:58)

Features, enhancements, fixes and changes
------------
Expand Down
2 changes: 1 addition & 1 deletion mainApp/docs/RELEASE_NOTES.html
Expand Up @@ -9,7 +9,7 @@
<table class="tg">
<tr>
<th class="tg-0pky">
<h4><a id="LPub3D_0"></a>LPub3D 2.4.0.1.1700 (20 09 2020 09:29:20)</h4>
<h4><a id="LPub3D_0"></a>LPub3D 2.4.0.1.1701 (20 09 2020 09:29:58)</h4>
<hr>
<p>
LPub3D Continuous release.<br>
Expand Down
2 changes: 1 addition & 1 deletion mainApp/org.trevorsandy.lpub3d.appdata.xml
Expand Up @@ -68,7 +68,7 @@
<binary>lpub3d24</binary>
​</provides>
<releases>
<release version="2.4.0.1700" date="2020-09-20">
<release version="2.4.0.1701" date="2020-09-20">
<description>
<p>LPub3D Linux AppImage package</p>
</description>
Expand Down
40 changes: 38 additions & 2 deletions mainApp/pageattributepixmapitem.cpp
Expand Up @@ -27,8 +27,9 @@ PageAttributePixmapItem::PageAttributePixmapItem(
Page *_page,
QPixmap &pixmap,
PageAttributePictureMeta &pageAttributePictureMeta,
QGraphicsItem *parent)

QGraphicsItem *parent):
isHovered(false),
mouseIsDown(false)
{
page = _page;
placement = pageAttributePictureMeta.placement;
Expand Down Expand Up @@ -163,6 +164,8 @@ PageAttributePixmapItem::PageAttributePixmapItem(

setParentItem(parent);
setPixmap(pixmap);
setAcceptHoverEvents(true);
setFlag(QGraphicsItem::ItemIsFocusable,true);
setFlag(QGraphicsItem::ItemIsSelectable,movable);
setFlag(QGraphicsItem::ItemIsMovable,movable);
setData(ObjectId, PageAttributePixmapObj);
Expand Down Expand Up @@ -260,6 +263,7 @@ void PageAttributePixmapItem::change()

void PageAttributePixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
mouseIsDown = true;
position = pos();
positionChanged = false;
if (fillMode == Aspect) {
Expand Down Expand Up @@ -397,3 +401,35 @@ void PageAttributePixmapItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *e
deleteMeta(page->meta.LPub.page.coverImage.file.here());
}
}

/* Highlight bounding rectangle on hover */

void PageAttributePixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
mouseIsDown = false;
QGraphicsItem::mouseReleaseEvent(event);
}

void PageAttributePixmapItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
isHovered = !this->isSelected() && !mouseIsDown;
QGraphicsItem::hoverEnterEvent(event);
}

void PageAttributePixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
isHovered = false;
QGraphicsItem::hoverLeaveEvent(event);
}

void PageAttributePixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QPen pen;
pen.setColor(isHovered ? QColor(Preferences::sceneGuideColor) : Qt::black);
pen.setWidth(0/*cosmetic*/);
pen.setStyle(isHovered ? Qt::PenStyle(Preferences::sceneGuidesLine) : Qt::NoPen);
painter->setPen(pen);
painter->setBrush(Qt::transparent);
painter->drawRect(this->boundingRect());
QGraphicsPixmapItem::paint(painter,option,widget);
}
7 changes: 7 additions & 0 deletions mainApp/pageattributepixmapitem.h
Expand Up @@ -40,6 +40,13 @@ class PageAttributePixmapItem : public ResizePixmapItem
protected:
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
/* Highlight bounding rectangle on hover */
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
bool isHovered;
bool mouseIsDown;
};

#endif // PAGEATTRIBUTEPIXMAPITEM_H

0 comments on commit 8673e63

Please sign in to comment.