Skip to content

Commit

Permalink
[重构图形库以引入圆角矩形绘制功能]: 引入了新的GraphicsRoundedRectItem类以支持圆角矩形的绘制,并重构了相关类…
Browse files Browse the repository at this point in the history
…以适应这一新功能。

- 将文档目录从`doc`更名为`docs`,并更新了所有相关的文件引用路径。
- 删除了旧的圆角编辑窗口图片,并新增了`RoundEdit.jpg`图片。
- 更新了`README.md`中的图片引用路径,并修正了图片显示问题。
- 在`Qt-Graphics.pro`中增加了对新文件`docs/**`的包含。
- 重命名和移动了图片文件,从`doc/`到`docs/`,并新增了`RoundEdit.jpg`。
- 在`drawwidget.cpp`中增加了对圆角矩形和旋转矩形的支持。
- 在`maskdialog.cpp`中进行了一些代码改进,使用`auto`关键字简化类型声明。
- 重构了`rounddialog.cc`和`rounddialog.hpp`,使用新的`GraphicsRoundedRectItem`代替了旧的`GraphicsRectItem`,并增加了预览和遮罩功能。
- 更新了`subtitlsplicingwidget.cc`,将图片格式从`ARGB32`改为`RGBA8888_Premultiplied`以保持一致性。
- 在`CMakeLists.txt`中添加了对新组件`graphicsroundedrectitem`的编译指令。
- 在`basicgraphicsitem.cpp`和`basicgraphicsitem.h`中增加了显示边框的选项,并在各类图形项中实现了边框绘制。
- 更新了`graphics.pro`,增加了对新头文件和源文件的包含。
- 在`graphicsarcitem.cpp`、`graphicscircleitem.cpp`、`graphicslineitem.cpp`、`graphicspixmapitem.cpp`、`graphicspolygonitem.cpp`、`graphicsringitem.cpp`和`graphicsrotatedrectitem.cpp`中增加了边框绘制功能。
- 重构了`graphicsrectitem.cpp`和`graphicsrectitem.h`,现在`GraphicsRectItem`继承自`GraphicsRoundedRectItem`,并使用新的圆角矩形实现。
- 新增了`graphicsroundedrectitem.cc`和`graphicsroundedrectitem.hpp`,提供了圆角矩形的实现。
  • Loading branch information
RealChuan committed Aug 28, 2024
1 parent 0d97583 commit 81e8652
Show file tree
Hide file tree
Showing 33 changed files with 554 additions and 415 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name: CMake Build
on:
push:
paths-ignore:
- 'doc/**'
- 'docs/**'
- '.clang-format'
- '.gitignore'
- 'LICENSE'
- 'README*'
pull_request:
paths-ignore:
- 'doc/**'
- 'docs/**'
- '.clang-format'
- '.gitignore'
- 'LICENSE'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/qmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name: QMake Build
on:
push:
paths-ignore:
- 'doc/**'
- 'docs/**'
- '.clang-format'
- '.gitignore'
- 'LICENSE'
- 'README*'
pull_request:
paths-ignore:
- 'doc/**'
- 'docs/**'
- '.clang-format'
- '.gitignore'
- 'LICENSE'
Expand Down
2 changes: 1 addition & 1 deletion Qt-Graphics.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SUBDIRS += \
examples

DISTFILES += \
doc/** \
docs/** \
.clang* \
LICENSE \
README*
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
## 看图界面

<div align=center>
<img src="doc/ImageView.png" width="90%" height="90%">
<img src="docs/ImageView.png" width="90%" height="90%">
</div>

## Opengl看图界面
Expand All @@ -45,23 +45,21 @@
## 马赛克绘制界面(橡皮擦效果)

<div align=center>
<img src="doc/MaskEdit.png" width="90%" height="90%">
<img src="docs/MaskEdit.png" width="90%" height="90%">
</div>

## 圆角编辑窗口(也可编辑成圆形图标)

1. 一定要保存为PNG,不然圆角处会变成黑色;

<div align=center>
<img src="doc/RoundEdit_1.png" width="90%" height="90%">
<img src="doc/RoundEdit_2.png" width="90%" height="90%">
<img src="doc/RoundEdit_3.png" width="90%" height="90%">
<img src="docs/RoundEdit.jpg" width="90%" height="90%">
</div>

## 简单图形绘制界面

<div align=center>
<img src="doc/DrawScene.png" width="90%" height="90%">
<img src="docs/DrawScene.png" width="90%" height="90%">
</div>

## 电影字幕拼接界面
Expand All @@ -71,7 +69,7 @@
3. 虽然第一眼看起来模糊,但是实际生成的时候都是重新载入左侧原图剪切生成,保存后可用其他图片查看工具验证,或者按照上一点(2)查看;

<div align=center>
<img src="doc/FilmSubTiltleSplicing.png" width="90%" height="90%">
<img src="docs/FilmSubTiltleSplicing.png" width="90%" height="90%">
</div>

## GIF录制(egif和gif-h库)和截图功能
Expand All @@ -80,5 +78,5 @@
2. 截屏之后可以使用(4)绘制图形;

<div align=center>
<img src="doc/Record_Screenshot.gif" width="90%" height="90%">
<img src="docs/Record_Screenshot.gif" width="90%" height="90%">
</div>
Binary file removed doc/RoundEdit_1.png
Binary file not shown.
Binary file removed doc/RoundEdit_2.png
Binary file not shown.
Binary file removed doc/RoundEdit_3.png
Binary file not shown.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added docs/RoundEdit.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion examples/graphics/drawwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <graphics/graphicsrectitem.h>
#include <graphics/graphicsringitem.h>
#include <graphics/graphicsrotatedrectitem.h>
#include <graphics/graphicsroundedrectitem.hpp>
#include <graphics/graphicstextitem.hpp>
#include <graphics/imageview.h>
#include <utils/validator.hpp>
Expand Down Expand Up @@ -100,11 +101,12 @@ void DrawWidget::onAddShape(QListWidgetItem *item)
switch (type) {
case BasicGraphicsItem::LINE: shape = new GraphicsLineItem; break;
case BasicGraphicsItem::RECT: shape = new GraphicsRectItem; break;
case BasicGraphicsItem::ROUNDEDRECT: shape = new GraphicsRoundedRectItem; break;
case BasicGraphicsItem::ROTATEDRECT: shape = new GraphicsRotatedRectItem; break;
case BasicGraphicsItem::CIRCLE: shape = new GraphicsCircleItem; break;
case BasicGraphicsItem::POLYGON: shape = new GraphicsPolygonItem; break;
case BasicGraphicsItem::RING: shape = new GraphicsRingItem; break;
case BasicGraphicsItem::ARC: shape = new GraphicsArcItem; break;
case BasicGraphicsItem::ROTATEDRECT: shape = new GraphicsRotatedRectItem; break;
default: break;
}
if (shape) {
Expand Down
14 changes: 7 additions & 7 deletions examples/graphics/maskdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,24 +166,24 @@ void MaskDialog::onSave()

auto newFlatBlueButton(const QString &text, QWidget *parent) -> QPushButton *
{
QPushButton *button = new QPushButton(text, parent);
auto *button = new QPushButton(text, parent);
return button;
}

void MaskDialog::setupUI()
{
QPushButton *button1 = newFlatBlueButton(tr("Mask"), this);
QPushButton *button2 = newFlatBlueButton(tr("Erase"), this);
QPushButton *button3 = new QPushButton(tr("Clear"), this);
auto *button1 = newFlatBlueButton(tr("Mask"), this);
auto *button2 = newFlatBlueButton(tr("Erase"), this);
auto *button3 = new QPushButton(tr("Clear"), this);
d_ptr->buttonGroup->addButton(button1, 1);
d_ptr->buttonGroup->addButton(button2, 2);
d_ptr->buttonGroup->addButton(button3, 3);
d_ptr->buttonGroup->button(1)->setChecked(true);

QPushButton *saveButton = newFlatBlueButton(tr("Save"), this);
auto *saveButton = newFlatBlueButton(tr("Save"), this);
connect(saveButton, &QPushButton::clicked, this, &MaskDialog::onSave);

QHBoxLayout *editLayout = new QHBoxLayout;
auto *editLayout = new QHBoxLayout;
editLayout->addStretch();
editLayout->addWidget(new QLabel(tr("Pen Size: "), this));
editLayout->addWidget(d_ptr->penSizeSpinBox);
Expand All @@ -195,7 +195,7 @@ void MaskDialog::setupUI()
editLayout->addWidget(saveButton);
editLayout->addStretch();

QVBoxLayout *layout = new QVBoxLayout(this);
auto *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 10);
layout->addWidget(d_ptr->imageView);
layout->addLayout(editLayout);
Expand Down
Loading

0 comments on commit 81e8652

Please sign in to comment.