mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
Merge "modify trash empty confirm dialog ui"
This commit is contained in:
commit
0037943366
@ -17,7 +17,7 @@ PopupControlWidget::PopupControlWidget(QWidget *parent)
|
||||
m_empty(false),
|
||||
|
||||
m_openBtn(new DLinkButton(tr("Run"), this)),
|
||||
m_clearBtn(new DLinkButton(tr("Empty"), this)),
|
||||
m_clearBtn(new DLinkButton(tr("Empty Trash"), this)),
|
||||
|
||||
m_fsWatcher(new QFileSystemWatcher(this))
|
||||
{
|
||||
@ -66,16 +66,20 @@ void PopupControlWidget::clearTrashFloder()
|
||||
{
|
||||
// show confrim dialog
|
||||
bool accept = false;
|
||||
const QStringList btns = {tr("Confrim"), tr("Cancel")};
|
||||
const int itemCount = trashItemCount();
|
||||
const QStringList btns = {tr("Cancel"), tr("Empty")};
|
||||
|
||||
DDialog *dialog = new DDialog(nullptr);
|
||||
dialog->addButtons(btns);
|
||||
dialog->setIconPixmap(QIcon::fromTheme("user-trash-full").pixmap(48, 48));
|
||||
dialog->setTitle(tr("Are you sure to empty trash ?"));
|
||||
dialog->setMessage(tr("This action cannot be restored"));
|
||||
if (itemCount == 1)
|
||||
dialog->setTitle(tr("Are you sure to empty 1 item ?"));
|
||||
else
|
||||
dialog->setTitle(tr("Are you sure to empty %1 items ?").arg(itemCount));
|
||||
|
||||
connect(dialog, &DDialog::buttonClicked, [&] (const int index) {
|
||||
accept = !index;
|
||||
accept = index;
|
||||
});
|
||||
dialog->exec();
|
||||
dialog->deleteLater();
|
||||
@ -95,6 +99,11 @@ void PopupControlWidget::clearTrashFloder()
|
||||
}
|
||||
}
|
||||
|
||||
int PopupControlWidget::trashItemCount() const
|
||||
{
|
||||
return QDir(TrashDir + "/files").entryInfoList().count() - 2;
|
||||
}
|
||||
|
||||
void PopupControlWidget::trashStatusChanged()
|
||||
{
|
||||
const bool empty = QDir(TrashDir).entryList().count() == 2;
|
||||
|
@ -24,6 +24,9 @@ public slots:
|
||||
signals:
|
||||
void emptyChanged(const bool empty) const;
|
||||
|
||||
private:
|
||||
int trashItemCount() const;
|
||||
|
||||
private slots:
|
||||
void trashStatusChanged();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user