-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ImageCarousel 功能重构]: 图片轮播组件功能升级与界面调整
- 图片轮播组件 `ImageCarousel` 进行了功能重构,引入了新的 `ImageViewer` 类,提供了更加丰富的图片展示和交互方式。 - 移除了原有的 `ImageCarousel` 类定义和实现文件,包括 `imagecarousel.cc` 和 `imagecarousel.hpp`,以及相关的图片轮播控件 `ImageCarouselWidget` 的定义和实现文件。 - 新增 `graphicspixmapitem.cc` 和 `graphicspixmapitem.hpp` 文件,定义了一个扩展自 `QGraphicsPixmapItem` 的 `GraphicsPixmapItem` 类,增加了点击信号和自定义的图片尺寸调整功能。 - 新增 `imageviewer.cc` 和 `imageviewer.hpp` 文件,定义了 `ImageViewer` 类,该类支持图片的左右切换、点击响应以及动画效果展示。 - 对 `main.cc` 和 `mainwindow.cc` 进行了修改,以适应新的 `ImageViewer` 组件,移除了与旧 `ImageCarouselWidget` 相关的代码,并简化了主窗口的 UI 设计。 - 更新了 `README.md` 文件,调整了图片轮播组件的描述和展示图片。
- Loading branch information
Showing
15 changed files
with
302 additions
and
437 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
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,29 @@ | ||
#include "graphicspixmapitem.hpp" | ||
|
||
#include <QGraphicsSceneMouseEvent> | ||
|
||
void GraphicsPixmapItem::setCustomPixmap(const QPixmap &pixmap) | ||
{ | ||
m_pixmap = pixmap; | ||
} | ||
|
||
QPixmap GraphicsPixmapItem::customPixmap() const | ||
{ | ||
return m_pixmap; | ||
} | ||
|
||
void GraphicsPixmapItem::setSize(const QSize &size) | ||
{ | ||
setPixmap(m_pixmap.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation)); | ||
} | ||
|
||
QSize GraphicsPixmapItem::size() const | ||
{ | ||
return pixmap().size(); | ||
} | ||
|
||
void GraphicsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) | ||
{ | ||
// QGraphicsPixmapItem::mousePressEvent(event); | ||
emit clicked(); | ||
} |
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,25 @@ | ||
#pragma once | ||
|
||
#include <QGraphicsPixmapItem> | ||
|
||
class GraphicsPixmapItem : public QObject, public QGraphicsPixmapItem | ||
{ | ||
Q_OBJECT | ||
Q_PROPERTY(QPointF pos READ pos WRITE setPos) | ||
Q_PROPERTY(QSize size READ size WRITE setSize) | ||
public: | ||
void setCustomPixmap(const QPixmap &pixmap); | ||
QPixmap customPixmap() const; | ||
|
||
void setSize(const QSize &size); | ||
QSize size() const; | ||
|
||
signals: | ||
void clicked(); | ||
|
||
protected: | ||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override; | ||
|
||
private: | ||
QPixmap m_pixmap; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.