bug/loadimage-dump
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
#include "frmimgshow.h"
|
||||
#include "frmalbum.h"
|
||||
|
||||
FrmImgShow::FrmImgShow(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
initForm();
|
||||
initSignalSlot();
|
||||
connect(TCHttpService::getInstance(), &TCHttpService::signal_imageDownloaded,
|
||||
this, [this](const QString& requestId, const QPixmap& pixmap){
|
||||
if (requestId == m_requestId) {
|
||||
setLoadingState(false);
|
||||
// setLoadingState(false);
|
||||
qDebug() << "load success";
|
||||
setImage(pixmap);
|
||||
}
|
||||
});
|
||||
@@ -14,7 +17,7 @@ FrmImgShow::FrmImgShow(QWidget *parent) : QWidget(parent)
|
||||
connect(TCHttpService::getInstance(), &TCHttpService::signal_downloadFailed,
|
||||
this, [this](const QString& requestId, const QString& error){
|
||||
if (requestId == m_requestId) {
|
||||
setLoadingState(true);
|
||||
qDebug() << "load failed";
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -24,14 +27,11 @@ void FrmImgShow::loadImage(const QUrl &imageUrl)
|
||||
qDebug() << "loadImage";
|
||||
m_currentUrl = imageUrl;
|
||||
m_requestId = QUuid::createUuid().toString();
|
||||
setLoadingState(true);
|
||||
qDebug() << "downlaodImage";
|
||||
TCHttpService::getInstance()->downloadImage(m_requestId, imageUrl);
|
||||
}
|
||||
|
||||
void FrmImgShow::setImage(const QPixmap &pixmap)
|
||||
{
|
||||
qDebug() << "setImage";
|
||||
// int h = pixmap.height();
|
||||
// int w = pixmap.width();
|
||||
// int sh, sw;
|
||||
@@ -51,6 +51,52 @@ void FrmImgShow::setLoadingState(bool loading)
|
||||
|
||||
}
|
||||
|
||||
void FrmImgShow::initSignalSlot()
|
||||
{
|
||||
connect(btnCopy, &QPushButton::clicked, [this](){
|
||||
switch(FrmAlbum::getCopyType()) {
|
||||
case 0:
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
QString mdStr = QString("").arg(m_currentUrl.toString());
|
||||
clipboard->setText(mdStr);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
QString urlStr = m_currentUrl.toString();
|
||||
clipboard->setText(urlStr);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
QString htmlStr = QString("<img src=\"%1\"/>").arg(m_currentUrl.toString());
|
||||
clipboard->setText(htmlStr);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
QString ubbStr = QString("[IMG]%1[/IMG]").arg(m_currentUrl.toString());
|
||||
clipboard->setText(ubbStr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
connect(ckbSelect, &QCheckBox::checkStateChanged, [this](Qt::CheckState state){
|
||||
if (state == Qt::Unchecked) {
|
||||
emit signal_imageUnselected(m_currentUrl.toString());
|
||||
}
|
||||
|
||||
if (state == Qt::Checked) {
|
||||
emit signal_imageSelected(m_currentUrl.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
QSize FrmImgShow::sizeHint()
|
||||
{
|
||||
@@ -113,6 +159,7 @@ void FrmImgShow::initForm()
|
||||
btnCopy->setMinimumSize(22, 22);
|
||||
btnCopy->setFlat(true);
|
||||
btnCopy->setIcon(QIcon(":/qrc/image/copy_white.png"));
|
||||
btnCopy->setCursor(Qt::PointingHandCursor);
|
||||
|
||||
btnCopy->installEventFilter(this);
|
||||
|
||||
@@ -121,14 +168,17 @@ void FrmImgShow::initForm()
|
||||
btnDelete->setFlat(true);
|
||||
btnDelete->setIcon(QIcon(":/qrc/image/delete_white.png"));
|
||||
btnDelete->installEventFilter(this);
|
||||
btnDelete->setCursor(Qt::PointingHandCursor);
|
||||
|
||||
horizenSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
hLayout = new QHBoxLayout();
|
||||
|
||||
ckbSelect = new QCheckBox();
|
||||
// ckbSelect->setMinimumSize(20, 20);
|
||||
ckbSelect->setText("");
|
||||
ckbSelect->setMinimumSize(20, 20);
|
||||
ckbSelect->setCursor(Qt::PointingHandCursor);
|
||||
// ckbSelect->setStyleSheet("border:1px solid white;border-radius:5px");
|
||||
ckbSelect->setStyleSheet("border-style:none;");
|
||||
// ckbSelect->setStyleSheet("border-style:none;background-color:green;spacing:0px;");
|
||||
|
||||
hLayout->addWidget(btnCopy);
|
||||
hLayout->addWidget(btnDelete);
|
||||
@@ -143,12 +193,13 @@ void FrmImgShow::initForm()
|
||||
|
||||
|
||||
|
||||
|
||||
// btnCopy->setIcon(QIcon(QPixmap(":/qrc/image/copy_white.png")));
|
||||
// btnDelete->setIcon(QIcon(QPixmap(":/qrc/image/delete_white.png")));
|
||||
// btnCopy->setFixedSize(32, 32);
|
||||
// btnCopy->setCursor(Qt::PointingHandCursor);
|
||||
|
||||
// setStyleSheet("background-color: #FF0000;border: 1px solid white");
|
||||
setStyleSheet("background-color: #FF0000");
|
||||
|
||||
setFixedSize(134, 160);
|
||||
|
||||
@@ -158,6 +209,6 @@ void FrmImgShow::initForm()
|
||||
|
||||
void FrmImgShow::initWidget()
|
||||
{
|
||||
// btnCopy->installEventFilter(this);
|
||||
// btnDelete->installEventFilter(this);
|
||||
btnCopy->installEventFilter(this);
|
||||
btnDelete->installEventFilter(this);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <QSpacerItem>
|
||||
#include <QUrl>
|
||||
#include <QCheckBox>
|
||||
#include <QClipboard>
|
||||
#include <QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include "tchttpservice.h"
|
||||
|
||||
@@ -23,7 +25,9 @@ public:
|
||||
void setImage(const QPixmap& pixmap);
|
||||
void setLoadingState(bool loading);
|
||||
|
||||
QSize sizeHint();
|
||||
void initSignalSlot();
|
||||
|
||||
virtual QSize sizeHint();
|
||||
private:
|
||||
QLabel* labImg;
|
||||
// QLabel* labLoading;
|
||||
@@ -48,6 +52,10 @@ private:
|
||||
|
||||
QString m_requestId;
|
||||
QUrl m_currentUrl;
|
||||
|
||||
signals:
|
||||
void signal_imageSelected(QString);
|
||||
void signal_imageUnselected(QString);
|
||||
};
|
||||
|
||||
#endif // FRMIMGSHOW_H
|
||||
|
||||
Reference in New Issue
Block a user