按钮级别设置优化

This commit is contained in:
zhaominyong 2022-04-19 09:56:06 +08:00
parent 5b31573152
commit 8c4af073c5
3 changed files with 20 additions and 7 deletions

View File

@ -3,7 +3,6 @@
#include <QTextCodec>
#include <unistd.h>
#include "component/mylabel.h"
#include "component/mypushbutton.h"
#include "../../common/utils.h"
#include "../globalbackupinfo.h"
#include "../deletebackupdialog.h"
@ -30,15 +29,20 @@ ManageBackupPointList::ManageBackupPointList(QWidget *parent, BackupPointType ba
labelTips->setMinimumWidth(600);
labelTips->setDeplayText(tr("You can delete the backup that does not need, refer operation logs for more details"));
MyPushButton * buttonDelete = new MyPushButton;
buttonDelete->setText(tr("Delete"));
buttonDelete->setProperty("isImportant", true);
m_buttonDelete = new MyPushButton;
m_buttonDelete->setText(tr("Delete"));
m_buttonDelete->setProperty("isImportant", true);
m_buttonDelete->setEnabled(false);
m_bottomLayout->addWidget(labelTips);
m_bottomLayout->addStretch();
m_bottomLayout->addWidget(buttonDelete);
m_bottomLayout->addWidget(m_buttonDelete);
connect(buttonDelete, &MyPushButton::clicked, this, [=](){
connect(m_tableWidget, &QTableWidget::clicked, this, [=]() {
this->m_buttonDelete->setEnabled(true);
});
connect(m_buttonDelete, &MyPushButton::clicked, this, [=](){
// 判断是否已经选中备份点
QList<QTableWidgetItem *> selectList = this->m_tableWidget->selectedItems();
if (selectList.isEmpty()) {
@ -174,10 +178,11 @@ void ManageBackupPointList::deleteBackupPoint(ParseBackupList::BackupPoint backu
if (result)
this->m_tableWidget->removeRow(m_deleteRow);
m_deleteRow = -1;
if (this->m_tableWidget->rowCount() ==0) {
if (this->m_tableWidget->rowCount() == 0) {
m_labelEmpty->setVisible(true);
m_labelEmptyText->setVisible(true);
m_tableWidget->horizontalHeader()->setVisible(false);
this->m_buttonDelete->setEnabled(false);
}
});
deleteDialog->exec();

View File

@ -2,6 +2,7 @@
#define MANAGEBACKUPPOINTLIST_H
#include "../backuppointlistdialog.h"
#include "component/mypushbutton.h"
class ManageBackupPointList : public BackupPointListDialog
{
@ -27,6 +28,8 @@ private:
BackupPointType m_backupType;
// 删除的行索引
int m_deleteRow = -1;
// 删除按钮
MyPushButton * m_buttonDelete;
};
#endif // MANAGEBACKUPPOINTLIST_H

View File

@ -28,12 +28,17 @@ SelectRestorePoint::SelectRestorePoint(QWidget *parent, BackupPointType backupTy
MyPushButton * buttonOk = new MyPushButton;
buttonOk->setText(tr("Ok"));
this->setResult(QDialog::Rejected);
buttonOk->setProperty("isImportant", true);
buttonOk->setEnabled(false);
m_bottomLayout->addStretch();
// m_bottomLayout->addWidget(buttonRefresh);
m_bottomLayout->addSpacing(10);
m_bottomLayout->addWidget(buttonOk);
connect(m_tableWidget, &QTableWidget::clicked, this, [=]() {
buttonOk->setEnabled(true);
});
// connect(buttonRefresh, &MyPushButton::clicked, this, &SelectRestorePoint::initTableWidget);
connect(this, &SelectRestorePoint::udiskChange, this, &SelectRestorePoint::initTableWidget);