-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.Adjust crop button position to left side toolbar 2.When the crop button is clicked, the view window fills the entire scene 3.Can adjust the size of the cropping box through four edges 4.When cropping, the unselected parts of the drawing board need to be masked with gray 5.Display the correct cursor style when resizing Log: [UI] Add some new features
- Loading branch information
Showing
14 changed files
with
310 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include "maskitem.h" | ||
#include "pagescene.h" | ||
#include "pageitem_p.h" | ||
#include <QPainter> | ||
REGISTITEMCLASS(MaskItem, MaskItemType) | ||
|
||
MaskItem::MaskItem(PageScene *scene): | ||
PageItem(nullptr) | ||
{ | ||
setZValue(10000); | ||
if (scene != nullptr) { | ||
setRect(scene->sceneRect()); | ||
} else { | ||
setRect(QRectF(0, 0, 1920, 1080)); | ||
} | ||
} | ||
|
||
int MaskItem::type() const | ||
{ | ||
return MaskItemType; | ||
} | ||
|
||
QRectF MaskItem::itemRect() const | ||
{ | ||
return rect(); | ||
} | ||
|
||
void MaskItem::setRect(const QRectF &rect) | ||
{ | ||
prepareGeometryChange(); | ||
m_rect = rect; | ||
updateShape(); | ||
} | ||
|
||
QRectF MaskItem::rect() const | ||
{ | ||
return m_rect; | ||
} | ||
|
||
bool MaskItem::contains(const QPointF &point) const | ||
{ | ||
return false; | ||
} | ||
|
||
bool MaskItem::isPosPenetrable(const QPointF &posLocal) | ||
{ | ||
return true; | ||
} | ||
|
||
bool MaskItem::isRectPenetrable(const QRectF &rectLocal) | ||
{ | ||
return true; | ||
} | ||
|
||
void MaskItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | ||
{ | ||
painter->setBrush(Qt::transparent); | ||
painter->setPen(Qt::NoPen); | ||
painter->drawRect(orgRect()); | ||
PageItem::paint(painter, option, widget); | ||
|
||
if (pageScene()->page()->currentTool() == cut) { | ||
PageItem* cutItem = nullptr; | ||
QList<PageItem *> pageItems = pageScene()->allPageItems(); | ||
foreach (auto item, pageItems) { | ||
if (item && item->type() == CutType) { | ||
cutItem = item; | ||
break; | ||
} | ||
} | ||
|
||
if (cutItem && cutItem->isVisible()) { | ||
painter->save(); | ||
QRectF layerRct = mapToScene(itemRect()).boundingRect(); | ||
QRectF cutRct = cutItem->mapToScene(cutItem->itemRect()).boundingRect(); | ||
QRegion r1(cutRct.toRect()); | ||
QRegion r2(layerRct.toRect()); | ||
QRegion r3 = r2.subtracted(r1); | ||
QPainterPath path; | ||
path.addRegion(r3); | ||
|
||
QColor background(0, 0, 0, 51); | ||
painter->setPen(Qt::NoPen); | ||
painter->setBrush(background); | ||
painter->drawPath(path); | ||
painter->restore(); | ||
} | ||
} | ||
} | ||
|
||
void MaskItem::updateShape() | ||
{ | ||
// QRectF rct; | ||
// if (scene() != nullptr) { | ||
// rct = scene()->sceneRect(); | ||
// } | ||
// setRect(rct); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#ifndef MASKITEM_H | ||
#define MASKITEM_H | ||
#include "pageitem.h" | ||
|
||
class PageScene; | ||
class MaskItem: public PageItem | ||
{ | ||
public: | ||
MaskItem(PageScene *scene = nullptr); | ||
|
||
int type() const override; | ||
|
||
/** | ||
* @brief type 图元的包裹矩形 | ||
*/ | ||
QRectF itemRect() const override; | ||
|
||
/** | ||
* @brief setRect 设置蒙板矩形 | ||
*/ | ||
void setRect(const QRectF &rect); | ||
|
||
/** | ||
* @brief rect 蒙板矩形 | ||
*/ | ||
QRectF rect() const; | ||
|
||
private: | ||
|
||
bool contains(const QPointF &point) const override; | ||
bool isPosPenetrable(const QPointF &posLocal) override; | ||
bool isRectPenetrable(const QRectF &rectLocal) override; | ||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, | ||
QWidget *widget) override; | ||
void updateShape() override; | ||
|
||
QRectF m_rect; | ||
}; | ||
Q_DECLARE_METATYPE(MaskItem *) | ||
|
||
#endif // MASKITEM_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/drawboard/drawboard/res/toolIconsNew/crop_highlight_20px.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.