182 lines
6.1 KiB
C++
182 lines
6.1 KiB
C++
#include "frmalbum.h"
|
|
#include "ui_frmalbum.h"
|
|
#include <QUrl>
|
|
|
|
int FrmAlbum::m_copyType = 0;
|
|
|
|
FrmAlbum::FrmAlbum(QWidget *parent) : QWidget(parent)
|
|
{
|
|
initForm();
|
|
}
|
|
|
|
FrmAlbum::~FrmAlbum()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
// QSet<QString> FrmAlbum::getUrlSet()
|
|
// {
|
|
// return m_selectedImageSet;
|
|
// }
|
|
|
|
int FrmAlbum::getCopyType()
|
|
{
|
|
return m_copyType;
|
|
}
|
|
|
|
void FrmAlbum::slot_updateImage()
|
|
{
|
|
picWidgetList.clear();
|
|
panelWidget->clearWidgets();
|
|
QList<QUrl> urls = ImageManager::instance()->getImageUrls(FileConfigDecode::getInstance()->getAddress(),
|
|
FileConfigDecode::getInstance()->getUserName());
|
|
qDebug() <<urls.size();
|
|
foreach (const QUrl& u, urls) {
|
|
FrmImgShow* widget = new FrmImgShow(this);
|
|
connect(widget, &FrmImgShow::signal_imageSelected, [this](const QString& url){
|
|
m_selectedImageSet.insert(url);
|
|
});
|
|
connect(widget, &FrmImgShow::signal_imageUnselected, [this](const QString& url){
|
|
m_selectedImageSet.remove(url);
|
|
});
|
|
|
|
connect(widget, &FrmImgShow::signal_imageDelete, this, &FrmAlbum::slot_updateImage);
|
|
|
|
widget->loadImage(u);
|
|
picWidgetList.push_back(widget);
|
|
|
|
// panelWidget->setWidget(picWidgetList, 3);
|
|
}
|
|
panelWidget->setWidget(picWidgetList, 4);
|
|
panelWidget->setSpace(15);
|
|
|
|
}
|
|
|
|
void FrmAlbum::initForm()
|
|
{
|
|
|
|
layout = new QVBoxLayout(this);
|
|
setLayout(layout);
|
|
panelWidget = new PanelWidget(this);
|
|
panelWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
panelWidget->setStyleSheet("border:1px solid white;");
|
|
panelWidget->setSpace(5);
|
|
|
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
layout->setSpacing(0);
|
|
|
|
panelWidget->setObjectName("widget");
|
|
panelWidget->setStyleSheet("background-color: rgb(63, 60, 55)");
|
|
// panelWidget->setStyleSheet("background-color: #FFFFFF");
|
|
panelWidget->setAutoHeight(false);
|
|
panelWidget->setAutoWidth(false);
|
|
panelWidget->setAutoHeight(false);
|
|
panelWidget->setAutoWidth(false);
|
|
|
|
btnCopy = new QPushButton;
|
|
btnCopy->setText("复制");
|
|
btnCopy->setCursor(Qt::PointingHandCursor);
|
|
btnCopy->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
btnCopy->setStyleSheet("height:25px;width:70px;background-color:#1B9EF3;color:white;border-style:none;border-radius:8px");
|
|
connect(btnCopy, &QPushButton::clicked, [this](){
|
|
QString clipStr = "";
|
|
foreach (QString s, m_selectedImageSet) {
|
|
switch (cbbCopyType->currentIndex()) {
|
|
case 0:
|
|
{
|
|
QString curStr = QString("").arg(s);
|
|
curStr += "\n";
|
|
clipStr += curStr;
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
QString curStr = QString("%1").arg(s);
|
|
curStr += "\n";
|
|
clipStr += curStr;
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
QString curStr = QString("<img src=\"%1\"/>").arg(s);
|
|
curStr += "\n";
|
|
clipStr += curStr;
|
|
break;
|
|
}
|
|
case 3:
|
|
{
|
|
QString curStr = QString("[IMG]%1[/IMG]").arg(s);
|
|
curStr += "\n";
|
|
clipStr += curStr;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
QClipboard* clipboard = QApplication::clipboard();
|
|
clipboard->setText(clipStr);
|
|
});
|
|
|
|
btnDelete = new QPushButton;
|
|
btnDelete->setText("删除");
|
|
btnDelete->setCursor(Qt::PointingHandCursor);
|
|
btnDelete->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
btnDelete->setStyleSheet("height:25px;width:70px;background-color:#F15140;color:white;border-style:none;border-radius:8px");
|
|
|
|
btnSelectAll = new QPushButton;
|
|
btnSelectAll->setText("全选");
|
|
btnSelectAll->setCursor(Qt::PointingHandCursor);
|
|
btnSelectAll->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
btnSelectAll->setStyleSheet("height:25px;width:70px;background-color:#44B363;color:white;border-style:none;border-radius:8px");
|
|
|
|
cbbCopyType = new QComboBox;
|
|
cbbCopyType->setCursor(Qt::PointingHandCursor);
|
|
cbbCopyType->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
cbbCopyType->setStyleSheet("height:25px;width:300;background-color:white;padding-left:16px;");
|
|
|
|
QList<QString> copyTypeList{"Markdown", "URL", "HTML", "UBB"};
|
|
cbbCopyType->addItems(copyTypeList);
|
|
|
|
connect(cbbCopyType, &QComboBox::currentIndexChanged, [this](int index){
|
|
m_copyType = index;
|
|
});
|
|
|
|
spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
menuLayout = new QHBoxLayout();
|
|
menuLayout->setContentsMargins(0, 0, 0, 0);
|
|
menuLayout->setSpacing(8);
|
|
menuLayout->addWidget(cbbCopyType);
|
|
menuLayout->addWidget(btnCopy);
|
|
menuLayout->addWidget(btnDelete);
|
|
menuLayout->addWidget(btnSelectAll);
|
|
menuLayout->addSpacerItem(spacerItem);
|
|
|
|
layout->addLayout(menuLayout);
|
|
layout->addWidget(panelWidget);
|
|
layout->setSpacing(6);
|
|
// qDebug() << ui->widget;
|
|
|
|
connect(TCHttpService::getInstance(), &TCHttpService::signal_loginSuc, [this](){
|
|
// qDebug() <<"login success";
|
|
QList<QUrl> urls = ImageManager::instance()->getImageUrls(FileConfigDecode::getInstance()->getAddress(),
|
|
FileConfigDecode::getInstance()->getUserName());
|
|
|
|
foreach (const QUrl& u, urls) {
|
|
FrmImgShow* widget = new FrmImgShow(this);
|
|
connect(widget, &FrmImgShow::signal_imageSelected, [this](const QString& url){
|
|
m_selectedImageSet.insert(url);
|
|
});
|
|
connect(widget, &FrmImgShow::signal_imageUnselected, [this](const QString& url){
|
|
m_selectedImageSet.remove(url);
|
|
});
|
|
widget->loadImage(u);
|
|
picWidgetList.push_front(widget);
|
|
|
|
// panelWidget->setWidget(picWidgetList, 3);
|
|
}
|
|
panelWidget->setWidget(picWidgetList, 4);
|
|
panelWidget->setSpace(15);
|
|
});
|
|
}
|