:gif:
This commit is contained in:
parent
d106d9beee
commit
89c21bc90b
|
@ -21,6 +21,7 @@ BottomButtonGroup::BottomButtonGroup(QWidget *parent)
|
|||
"QPushButton {"
|
||||
"background-color:rgba(225,255,255,0);"
|
||||
"color: white;"
|
||||
"border-style: none;"
|
||||
"}");
|
||||
|
||||
auto newBtn = [](QString text) -> QPushButton * {
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#include <QGraphicsItem>
|
||||
#include <QUrl>
|
||||
#include <QGraphicsSvgItem>
|
||||
#include <QMovie>
|
||||
#include <QLabel>
|
||||
|
||||
GraphicsScene::GraphicsScene(QObject *parent)
|
||||
: QGraphicsScene(parent)
|
||||
|
@ -42,3 +44,16 @@ void GraphicsScene::showSvg(const QString &filepath)
|
|||
m_theThing = svgItem;
|
||||
this->setSceneRect(m_theThing->boundingRect());
|
||||
}
|
||||
|
||||
void GraphicsScene::showGif(const QString &filepath)
|
||||
{
|
||||
this->clear();
|
||||
QMovie * movie = new QMovie(filepath);
|
||||
QLabel * label = new QLabel;
|
||||
label->setStyleSheet("background-color:white;");
|
||||
label->setMovie(movie);
|
||||
this->addWidget(label);
|
||||
movie->start();
|
||||
m_theThing = this->addRect(QRect(QPoint(0, 0), movie->scaledSize()));
|
||||
this->setSceneRect(m_theThing->boundingRect());
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ public:
|
|||
void showImage(const QPixmap &pixmap);
|
||||
void showText(const QString &text);
|
||||
void showSvg(const QString &filepath);
|
||||
void showGif(const QString &filepath);
|
||||
|
||||
private:
|
||||
QGraphicsItem * m_theThing;
|
||||
|
|
|
@ -40,6 +40,11 @@ void GraphicsView::showSvg(const QString &filepath)
|
|||
scene()->showSvg(filepath);
|
||||
}
|
||||
|
||||
void GraphicsView::showGif(const QString &filepath)
|
||||
{
|
||||
scene()->showGif(filepath);
|
||||
}
|
||||
|
||||
GraphicsScene *GraphicsView::scene() const
|
||||
{
|
||||
return qobject_cast<GraphicsScene*>(QGraphicsView::scene());
|
||||
|
@ -138,6 +143,8 @@ void GraphicsView::dropEvent(QDropEvent *event)
|
|||
|
||||
if (filePath.endsWith(".svg")) {
|
||||
showSvg(filePath);
|
||||
} else if (filePath.endsWith(".gif")) {
|
||||
showGif(filePath);
|
||||
} else {
|
||||
QImageReader imageReader(filePath);
|
||||
QImage::Format imageFormat = imageReader.imageFormat();
|
||||
|
|
|
@ -12,6 +12,7 @@ public:
|
|||
void showImage(const QPixmap &pixmap);
|
||||
void showText(const QString &text);
|
||||
void showSvg(const QString &filepath);
|
||||
void showGif(const QString &filepath);
|
||||
|
||||
GraphicsScene * scene() const;
|
||||
void setScene(GraphicsScene *scene);
|
||||
|
|
Loading…
Reference in New Issue
Block a user