#include "frmalbum.h" #include "ui_frmalbum.h" #include int FrmAlbum::m_copyType = 0; FrmAlbum::FrmAlbum(QWidget *parent) : QWidget(parent) { initForm(); } FrmAlbum::~FrmAlbum() { delete ui; } // QSet FrmAlbum::getUrlSet() // { // return m_selectedImageSet; // } int FrmAlbum::getCopyType() { return m_copyType; } void FrmAlbum::slot_updateImage() { qDebug() <<"slot_updateImage"; // QList urls = ImageManager::instance()->getImageUrls(FileConfigDecode::getInstance()->getAddress(), // FileConfigDecode::getInstance()->getUserName()); // foreach (const QUrl& u, urls) { // qDebug() << "image url:" <loadImage(u); // picWidgetList.push_front(widget); // panelWidget->setWidget(picWidgetList, 3); // } } void FrmAlbum::initForm() { layout = new QVBoxLayout(); setLayout(layout); panelWidget = new PanelWidget(); 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](){ qDebug() <<"btnCopy"; QString clipStr = ""; foreach (QString s, m_selectedImageSet) { switch (cbbCopyType->currentIndex()) { case 0: { QString curStr = QString("![](%1)").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("").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 copyTypeList{"Markdown", "URL", "HTML", "UBB"}; cbbCopyType->addItems(copyTypeList); connect(cbbCopyType, &QComboBox::currentIndexChanged, [this](int index){ m_copyType = index; qDebug() << m_copyType; }); 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 urls = ImageManager::instance()->getImageUrls(FileConfigDecode::getInstance()->getAddress(), FileConfigDecode::getInstance()->getUserName()); foreach (const QUrl& u, urls) { qDebug() << "image url:" <loadImage(u); picWidgetList.push_front(widget); panelWidget->setWidget(picWidgetList, 3); } }); panelWidget->setWidget(picWidgetList, 4); panelWidget->setSpace(15); }