123980 【UKUI 3.1.4 走查】【设计】【备份还原】数据备份 添加路径列表增加间距
This commit is contained in:
parent
61e40267e8
commit
e90cf2a31a
|
@ -11,6 +11,7 @@
|
||||||
#include "component/imageutil.h"
|
#include "component/imageutil.h"
|
||||||
|
|
||||||
#define WIDTH_ITEM 36
|
#define WIDTH_ITEM 36
|
||||||
|
#define MERGE_IN 8
|
||||||
|
|
||||||
MyItemWidget::MyItemWidget(QWidget* parent) :
|
MyItemWidget::MyItemWidget(QWidget* parent) :
|
||||||
QWidget(parent)
|
QWidget(parent)
|
||||||
|
@ -33,13 +34,22 @@ MyItemWidget::MyItemWidget(QWidget* parent) :
|
||||||
|
|
||||||
hlayout->addWidget(m_label);
|
hlayout->addWidget(m_label);
|
||||||
hlayout->addWidget(m_buttonDelete);
|
hlayout->addWidget(m_buttonDelete);
|
||||||
hlayout->setAlignment(Qt::AlignLeft);
|
// hlayout->setAlignment(Qt::AlignLeft);
|
||||||
|
|
||||||
connect(this, &MyItemWidget::setScrollWidth, this, [=](int width) {
|
connect(this, &MyItemWidget::setScrollWidth, this, [=](int width) {
|
||||||
this->m_scrollWidth = width;
|
|
||||||
int labelWidth = this->m_label->width();
|
int labelWidth = this->m_label->width();
|
||||||
this->m_label->setFixedWidth(labelWidth + (this->m_scrollWidth - width));
|
this->m_extWidth = 0;
|
||||||
|
// 隐藏滚动条时会增加右侧边距
|
||||||
|
if (this->m_scrollWidth > 0 && width == 0)
|
||||||
|
this->m_extWidth = -1 * MERGE_IN;
|
||||||
|
// 显示滚动条时去掉右侧边距
|
||||||
|
else if (this->m_scrollWidth == 0 && width > 0)
|
||||||
|
this->m_extWidth = MERGE_IN;
|
||||||
|
this->m_label->setFixedWidth(labelWidth + (this->m_scrollWidth - width) + this->m_extWidth);
|
||||||
|
|
||||||
this->m_label->setElidedText(this->m_text, Qt::ElideLeft);
|
this->m_label->setElidedText(this->m_text, Qt::ElideLeft);
|
||||||
|
this->m_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
|
this->m_scrollWidth = width;
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::fontChanged, this, [=](int fontSize) {
|
connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::fontChanged, this, [=](int fontSize) {
|
||||||
|
@ -51,16 +61,24 @@ MyItemWidget::MyItemWidget(QWidget* parent) :
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(this, &MyItemWidget::selected, this, [=](bool checked) {
|
connect(this, &MyItemWidget::selected, this, [=](bool checked) {
|
||||||
|
int labelWidth = this->m_label->width();
|
||||||
if (checked) {
|
if (checked) {
|
||||||
this->m_buttonDelete->setVisible(true);
|
this->m_buttonDelete->setVisible(true);
|
||||||
this->m_label->setFixedWidth(this->width() - 12 - 20 - this->m_scrollWidth);
|
this->m_label->setFixedWidth(labelWidth - 5 - m_buttonDelete->width());
|
||||||
this->m_label->setElidedText(this->m_text, Qt::ElideLeft);
|
this->m_label->setElidedText(this->m_text, Qt::ElideLeft);
|
||||||
this->m_label->setStyleSheet("color:white");
|
this->m_label->setFontColor(Qt::white);
|
||||||
|
this->m_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
|
this->m_label->setStyleSheet("QLabel {color:white}"
|
||||||
|
"QToolTip {color:palette(windowText)}");
|
||||||
|
this->m_checked = true;
|
||||||
} else {
|
} else {
|
||||||
this->m_buttonDelete->setVisible(false);
|
this->m_buttonDelete->setVisible(false);
|
||||||
this->m_label->setFixedWidth(this->width() - 7 - this->m_scrollWidth);
|
this->m_label->setFixedWidth(labelWidth + 5 + m_buttonDelete->width());
|
||||||
this->m_label->setElidedText(this->m_text, Qt::ElideLeft);
|
this->m_label->setElidedText(this->m_text, Qt::ElideLeft);
|
||||||
this->m_label->setStyleSheet("color:palette(windowText)");
|
this->m_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
|
this->m_label->setStyleSheet("QLabel {color:palette(windowText)}"
|
||||||
|
"QToolTip {color:palette(windowText)}");
|
||||||
|
this->m_checked = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -72,7 +90,7 @@ MyItemWidget::MyItemWidget(QWidget* parent) :
|
||||||
void MyItemWidget::setText(const QString& text)
|
void MyItemWidget::setText(const QString& text)
|
||||||
{
|
{
|
||||||
m_text = text;
|
m_text = text;
|
||||||
m_label->setFixedWidth(this->width() - 7 - this->m_scrollWidth);
|
// m_label->setFixedWidth(this->width() - 7 - this->m_scrollWidth);
|
||||||
m_label->setElidedText(m_text, Qt::ElideLeft);
|
m_label->setElidedText(m_text, Qt::ElideLeft);
|
||||||
m_label->setToolTip(m_text);
|
m_label->setToolTip(m_text);
|
||||||
}
|
}
|
||||||
|
@ -81,8 +99,9 @@ MyItemWidget::~MyItemWidget()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BackupListWidget::BackupListWidget(QWidget *parent /*= nullptr*/) :
|
BackupListWidget::BackupListWidget(QWidget *parent /*= nullptr*/, QHBoxLayout *parentLayout /*= nullptr*/) :
|
||||||
QListWidget(parent)
|
QListWidget(parent),
|
||||||
|
m_parentLayout(parentLayout)
|
||||||
{
|
{
|
||||||
setSortingEnabled(false);
|
setSortingEnabled(false);
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
@ -90,7 +109,12 @@ BackupListWidget::BackupListWidget(QWidget *parent /*= nullptr*/) :
|
||||||
// setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
// setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
// 设置为无边框,默认时为StyledPanel
|
// 设置为无边框,默认时为StyledPanel
|
||||||
// setFrameShape(QListWidget::NoFrame);
|
setFrameShape(QListWidget::NoFrame);
|
||||||
|
if (parentLayout != nullptr) {
|
||||||
|
parentLayout->setContentsMargins(MERGE_IN, MERGE_IN, MERGE_IN, MERGE_IN);
|
||||||
|
setGridSize(QSize(this->width(), 40 + MERGE_IN / 2));
|
||||||
|
} else
|
||||||
|
setGridSize(QSize(this->width(), 40));
|
||||||
|
|
||||||
// 列表为空时,展示一个“+”号图标和拖拽文件提示
|
// 列表为空时,展示一个“+”号图标和拖拽文件提示
|
||||||
m_plusLogo = new QLabel;
|
m_plusLogo = new QLabel;
|
||||||
|
@ -163,11 +187,15 @@ bool BackupListWidget::appendItem(const QString &text)
|
||||||
connect(this, &BackupListWidget::setScrollWidth, widget, &MyItemWidget::setScrollWidth);
|
connect(this, &BackupListWidget::setScrollWidth, widget, &MyItemWidget::setScrollWidth);
|
||||||
// 滚动条是否展示
|
// 滚动条是否展示
|
||||||
QScrollBar *vertScroll = verticalScrollBar();
|
QScrollBar *vertScroll = verticalScrollBar();
|
||||||
if (vertScroll->isVisible())
|
int scrollWidth = 0;
|
||||||
emit this->setScrollWidth(vertScroll->size().width());
|
if (vertScroll->isVisible()) {
|
||||||
|
if (m_parentLayout != nullptr)
|
||||||
|
m_parentLayout->setContentsMargins(MERGE_IN, MERGE_IN, 0, MERGE_IN);
|
||||||
|
scrollWidth = vertScroll->size().width();
|
||||||
|
item->setSizeHint(QSize(this->width() - 5 - scrollWidth, WIDTH_ITEM));
|
||||||
|
emit this->setScrollWidth(scrollWidth);
|
||||||
|
}
|
||||||
|
|
||||||
QRect rect = this->visualItemRect(item);
|
|
||||||
widget->setBaseSize(rect.width(), rect.height());
|
|
||||||
widget->setText(text);
|
widget->setText(text);
|
||||||
m_List << text;
|
m_List << text;
|
||||||
|
|
||||||
|
@ -184,9 +212,12 @@ bool BackupListWidget::appendItem(const QString &text)
|
||||||
emit this->deleteEmpty();
|
emit this->deleteEmpty();
|
||||||
} else {
|
} else {
|
||||||
QScrollBar *vertScrollBar = verticalScrollBar();
|
QScrollBar *vertScrollBar = verticalScrollBar();
|
||||||
if (!vertScrollBar->isVisible())
|
if (!vertScrollBar->isVisible()) {
|
||||||
|
if (m_parentLayout != nullptr)
|
||||||
|
m_parentLayout->setContentsMargins(MERGE_IN, MERGE_IN, MERGE_IN, MERGE_IN);
|
||||||
emit this->setScrollWidth(0);
|
emit this->setScrollWidth(0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
m_plusLogo->setVisible(false);
|
m_plusLogo->setVisible(false);
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <QDropEvent>
|
#include <QDropEvent>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QHBoxLayout>
|
||||||
#include "mylabel.h"
|
#include "mylabel.h"
|
||||||
|
|
||||||
class MyItemWidget : public QWidget
|
class MyItemWidget : public QWidget
|
||||||
|
@ -32,14 +33,16 @@ private:
|
||||||
QString m_text;
|
QString m_text;
|
||||||
MyLabel *m_label;
|
MyLabel *m_label;
|
||||||
QPushButton *m_buttonDelete;
|
QPushButton *m_buttonDelete;
|
||||||
int m_scrollWidth = 0;
|
int m_scrollWidth = 0; //父窗口QListWidget的滚动条宽度
|
||||||
|
int m_extWidth = 0; //去掉父窗口QListWidget的父窗口QFrame的右侧边距时扩展的宽度
|
||||||
|
bool m_checked = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BackupListWidget : public QListWidget
|
class BackupListWidget : public QListWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit BackupListWidget(QWidget *parent = nullptr);
|
explicit BackupListWidget(QWidget *parent = nullptr, QHBoxLayout *parentLayout = nullptr);
|
||||||
virtual ~BackupListWidget();
|
virtual ~BackupListWidget();
|
||||||
|
|
||||||
// 添加列表项,注意使用本类的功能不能用addItem等基类添加项的方法
|
// 添加列表项,注意使用本类的功能不能用addItem等基类添加项的方法
|
||||||
|
@ -78,6 +81,8 @@ private:
|
||||||
int m_type = QListWidgetItem::ItemType::UserType + 1;
|
int m_type = QListWidgetItem::ItemType::UserType + 1;
|
||||||
QStringList m_List;
|
QStringList m_List;
|
||||||
QStringList m_pathLimit;
|
QStringList m_pathLimit;
|
||||||
|
|
||||||
|
QHBoxLayout *m_parentLayout;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // REMOVABLELISTWIDGET_H
|
#endif // REMOVABLELISTWIDGET_H
|
||||||
|
|
|
@ -370,10 +370,16 @@ void DataBackup::initSecondWidget()
|
||||||
getPathsLimit(pathLimits, siderUrls);
|
getPathsLimit(pathLimits, siderUrls);
|
||||||
|
|
||||||
// 备份列表
|
// 备份列表
|
||||||
BackupListWidget *listWidget = new BackupListWidget;
|
QFrame *listFrame = new QFrame;
|
||||||
|
listFrame->setFrameShape(QFrame::StyledPanel);
|
||||||
|
listFrame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
QHBoxLayout * hlayoutFrame = new QHBoxLayout;
|
||||||
|
listFrame->setLayout(hlayoutFrame);
|
||||||
|
BackupListWidget *listWidget = new BackupListWidget(listFrame, hlayoutFrame);
|
||||||
listWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
listWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
listWidget->setPathLimit(pathLimits);
|
listWidget->setPathLimit(pathLimits);
|
||||||
hlayoutLine5->addWidget(listWidget);
|
hlayoutFrame->addWidget(listWidget);
|
||||||
|
hlayoutLine5->addWidget(listFrame);
|
||||||
hlayoutLine5->addSpacing(40);
|
hlayoutLine5->addSpacing(40);
|
||||||
vlayout->addLayout(hlayoutLine5);
|
vlayout->addLayout(hlayoutLine5);
|
||||||
|
|
||||||
|
@ -687,10 +693,16 @@ void DataBackup::initSecondWidget_inc()
|
||||||
QList<QUrl> siderUrls;
|
QList<QUrl> siderUrls;
|
||||||
getPathsLimit(pathLimits, siderUrls);
|
getPathsLimit(pathLimits, siderUrls);
|
||||||
// 备份列表
|
// 备份列表
|
||||||
BackupListWidget *listWidget = new BackupListWidget;
|
QFrame *listFrame = new QFrame;
|
||||||
|
listFrame->setFrameShape(QFrame::StyledPanel);
|
||||||
|
listFrame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
QHBoxLayout * hlayoutFrame = new QHBoxLayout;
|
||||||
|
listFrame->setLayout(hlayoutFrame);
|
||||||
|
BackupListWidget *listWidget = new BackupListWidget(listFrame, hlayoutFrame);
|
||||||
listWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
listWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
listWidget->setPathLimit(pathLimits);
|
listWidget->setPathLimit(pathLimits);
|
||||||
hlayoutLine5->addWidget(listWidget);
|
hlayoutFrame->addWidget(listWidget);
|
||||||
|
hlayoutLine5->addWidget(listFrame);
|
||||||
hlayoutLine5->addSpacing(40);
|
hlayoutLine5->addSpacing(40);
|
||||||
vlayout->addLayout(hlayoutLine5);
|
vlayout->addLayout(hlayoutLine5);
|
||||||
|
|
||||||
|
@ -1282,6 +1294,8 @@ void DataBackup::initForthWidget()
|
||||||
// vlayout->addLayout(hlayoutCenterLine2);
|
// vlayout->addLayout(hlayoutCenterLine2);
|
||||||
|
|
||||||
connect(validator, &InputValidator::checked, this, [=](bool valid, QString in, int pos, QChar c) {
|
connect(validator, &InputValidator::checked, this, [=](bool valid, QString in, int pos, QChar c) {
|
||||||
|
if (in.isEmpty())
|
||||||
|
return;
|
||||||
QString text = editBackupName->text();
|
QString text = editBackupName->text();
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if (pos >= MAX_LEN_BACKUPNAME) {
|
if (pos >= MAX_LEN_BACKUPNAME) {
|
||||||
|
|
|
@ -77,6 +77,7 @@ void OperationLog::initFirstWidget()
|
||||||
m_tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
m_tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
m_tableWidget->setShowGrid(false);
|
m_tableWidget->setShowGrid(false);
|
||||||
m_tableWidget->hideColumn(1); // 隐藏uuid
|
m_tableWidget->hideColumn(1); // 隐藏uuid
|
||||||
|
m_tableWidget->setFrameShape(QTableWidget::NoFrame);
|
||||||
hlayoutLine3->addWidget(m_tableWidget);
|
hlayoutLine3->addWidget(m_tableWidget);
|
||||||
vlayout->addLayout(hlayoutLine3);
|
vlayout->addLayout(hlayoutLine3);
|
||||||
|
|
||||||
|
|
|
@ -814,6 +814,8 @@ void SystemBackup::initForthWidget()
|
||||||
labelError->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
labelError->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
|
|
||||||
connect(validator, &InputValidator::checked, this, [=](bool valid, QString in, int pos, QChar c) {
|
connect(validator, &InputValidator::checked, this, [=](bool valid, QString in, int pos, QChar c) {
|
||||||
|
if (in.isEmpty())
|
||||||
|
return;
|
||||||
QString text = editBackupName->text();
|
QString text = editBackupName->text();
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if (pos >= MAX_LEN_BACKUPNAME) {
|
if (pos >= MAX_LEN_BACKUPNAME) {
|
||||||
|
|
Loading…
Reference in New Issue