Skip to content

Commit 038f13e

Browse files
committed
Hide resize handles of all selected items while moving items. #12
1 parent 716e2fc commit 038f13e

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

src/annotations/modifiers/AnnotationItemModifier.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,68 +40,69 @@ AnnotationItemModifier::~AnnotationItemModifier()
4040
delete mItemMover;
4141
}
4242

43-
void AnnotationItemModifier::handleMousePress(const QPointF& pos, QList<AbstractAnnotationItem*>* items, bool isCtrlPressed)
43+
void AnnotationItemModifier::handleMousePress(const QPointF &pos, QList<AbstractAnnotationItem *> *items, bool isCtrlPressed)
4444
{
4545
mItemResizer->grabHandle(pos);
46-
if(mItemResizer->isResizing()) {
46+
if (mItemResizer->isResizing()) {
4747
return;
4848
}
4949

5050
mItemSelector->handleSelectionAt(pos, items, isCtrlPressed);
51-
if(mItemSelector->isSelecting()) {
51+
if (mItemSelector->isSelecting()) {
5252
mItemResizer->detach();
5353
return;
5454
}
5555

5656
auto selectedItems = mItemSelector->selectedItems();
5757
mItemMover->setOffset(pos, selectedItems);
58+
mItemResizer->hide();
5859

5960
handleSelection();
6061
updateCursor(mItemMover->cursor());
6162
}
6263

63-
void AnnotationItemModifier::handleMouseMove(const QPointF& pos)
64+
void AnnotationItemModifier::handleMouseMove(const QPointF &pos)
6465
{
65-
if(mItemResizer->isResizing()) {
66+
if (mItemResizer->isResizing()) {
6667
mItemResizer->moveHandle(pos);
6768
updateCursor(mItemResizer->cursorForCurrentHandle());
68-
} else if(mItemSelector->isSelecting()) {
69+
} else if (mItemSelector->isSelecting()) {
6970
mItemSelector->extendSelectionRectWhenShown(pos);
7071
} else {
7172
mItemMover->moveItems(pos);
72-
mItemResizer->refresh();
7373
mItemSelector->refresh();
7474
}
7575
}
7676

77-
void AnnotationItemModifier::handleMouseRelease(QList<AbstractAnnotationItem*>* items)
77+
void AnnotationItemModifier::handleMouseRelease(QList<AbstractAnnotationItem *> *items)
7878
{
79-
if(mItemResizer->isResizing()) {
79+
if (mItemResizer->isResizing()) {
8080
mItemResizer->releaseHandle();
81-
} else if(mItemSelector->isSelecting()) {
81+
} else if (mItemSelector->isSelecting()) {
8282
mItemSelector->finishSelectionRectWhenShown(items);
8383
} else {
8484
mItemMover->clearOffset();
85+
mItemResizer->show();
8586
updateCursor(mItemMover->cursor());
8687
}
8788

8889
handleSelection();
8990
}
9091

91-
void AnnotationItemModifier::handleSelectionAt(const QPointF& pos, QList<AbstractAnnotationItem *>* items, bool isCtrlPressed)
92+
void AnnotationItemModifier::handleSelectionAt(const QPointF &pos, QList<AbstractAnnotationItem *> *items, bool isCtrlPressed)
9293
{
9394
mItemSelector->handleSelectionAt(pos, items, isCtrlPressed);
9495
handleSelection();
9596
}
9697

97-
QList<AbstractAnnotationItem*> AnnotationItemModifier::selectedItems() const
98+
QList<AbstractAnnotationItem *> AnnotationItemModifier::selectedItems() const
9899
{
99100
return mItemSelector->selectedItems();
100101
}
101102

102103
QRectF AnnotationItemModifier::boundingRect() const
103104
{
104-
if(mItemResizer->hasItemsAttached()) {
105+
if (mItemResizer->hasItemsAttached()) {
105106
return mItemResizer->boundingRect();
106107
}
107108
return mItemSelector->boundingRect();
@@ -120,15 +121,15 @@ void AnnotationItemModifier::updateSelection()
120121
mItemResizer->refresh();
121122
}
122123

123-
void AnnotationItemModifier::mousePressEvent(QGraphicsSceneMouseEvent* event)
124+
void AnnotationItemModifier::mousePressEvent(QGraphicsSceneMouseEvent *event)
124125
{
125126
Q_UNUSED(event)
126127
// Move Cursor disappears when we let this event propagate
127128
}
128129

129-
void AnnotationItemModifier::hoverMoveEvent(QGraphicsSceneHoverEvent* event)
130+
void AnnotationItemModifier::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
130131
{
131-
if(mItemMover->isMoving()) {
132+
if (mItemMover->isMoving()) {
132133
return;
133134
}
134135

@@ -139,7 +140,7 @@ void AnnotationItemModifier::handleSelection()
139140
{
140141
auto selectedItems = mItemSelector->selectedItems();
141142
auto count = selectedItems.count();
142-
if(count == 0) {
143+
if (count == 0) {
143144
clearSelection();
144145
} else {
145146
mItemResizer->attachTo(selectedItems);
@@ -148,7 +149,7 @@ void AnnotationItemModifier::handleSelection()
148149

149150
void AnnotationItemModifier::updateCursor(Qt::CursorShape cursor)
150151
{
151-
if(cursor == CursorHelper::defaultCursor()) {
152+
if (cursor == CursorHelper::defaultCursor()) {
152153
unsetCursor();
153154
} else {
154155
setCursor(cursor);

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int main(int argc, char **argv)
2525
{
2626
QApplication app(argc, argv);
2727
QPixmap pixmap(QSize(500, 500));
28-
pixmap.fill(QColor(Qt::green));
28+
pixmap.fill(QColor(Qt::darkGreen));
2929
auto kImageAnnotator = new KImageAnnotator(pixmap);
3030
kImageAnnotator->show();
3131

0 commit comments

Comments
 (0)