From e2de64d6f1beb9e492daf5b886e19933c1fa41dd Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- juk/deletedialog.cpp | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 juk/deletedialog.cpp (limited to 'juk/deletedialog.cpp') diff --git a/juk/deletedialog.cpp b/juk/deletedialog.cpp new file mode 100644 index 00000000..cafd7849 --- /dev/null +++ b/juk/deletedialog.cpp @@ -0,0 +1,121 @@ +/*************************************************************************** + begin : Tue Aug 31 21:59:58 EST 2004 + copyright : (C) 2004 by Michael Pyne + email : michael.pyne@kdemail.net +***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "deletedialog.h" + +////////////////////////////////////////////////////////////////////////////// +// DeleteWidget implementation +////////////////////////////////////////////////////////////////////////////// + +DeleteWidget::DeleteWidget(QWidget *parent, const char *name) + : DeleteDialogBase(parent, name) +{ + KConfigGroup messageGroup(KGlobal::config(), "FileRemover"); + + bool deleteInstead = messageGroup.readBoolEntry("deleteInsteadOfTrash", false); + slotShouldDelete(deleteInstead); + ddShouldDelete->setChecked(deleteInstead); +} + +void DeleteWidget::setFiles(const QStringList &files) +{ + ddFileList->clear(); + ddFileList->insertStringList(files); + ddNumFiles->setText(i18n("1 file selected.", "%n files selected.", files.count())); +} + +void DeleteWidget::slotShouldDelete(bool shouldDelete) +{ + if(shouldDelete) { + ddDeleteText->setText(i18n("These items will be permanently " + "deleted from your hard disk.")); + ddWarningIcon->setPixmap(KGlobal::iconLoader()->loadIcon("messagebox_warning", + KIcon::Desktop, KIcon::SizeLarge)); + } + else { + ddDeleteText->setText(i18n("These items will be moved to the Trash Bin.")); + ddWarningIcon->setPixmap(KGlobal::iconLoader()->loadIcon("trashcan_full", + KIcon::Desktop, KIcon::SizeLarge)); + } +} + +////////////////////////////////////////////////////////////////////////////// +// DeleteDialog implementation +////////////////////////////////////////////////////////////////////////////// + +DeleteDialog::DeleteDialog(QWidget *parent, const char *name) : + KDialogBase(Swallow, WStyle_DialogBorder, parent, name, + true /* modal */, i18n("About to delete selected files"), + Ok | Cancel, Cancel /* Default */, true /* separator */), + m_trashGuiItem(i18n("&Send to Trash"), "trashcan_full") +{ + m_widget = new DeleteWidget(this, "delete_dialog_widget"); + setMainWidget(m_widget); + + m_widget->setMinimumSize(400, 300); + setMinimumSize(410, 326); + adjustSize(); + + slotShouldDelete(shouldDelete()); + + connect(m_widget->ddShouldDelete, SIGNAL(toggled(bool)), SLOT(slotShouldDelete(bool))); +} + +bool DeleteDialog::confirmDeleteList(const QStringList &condemnedFiles) +{ + m_widget->setFiles(condemnedFiles); + + return exec() == QDialog::Accepted; +} + +void DeleteDialog::setFiles(const QStringList &files) +{ + m_widget->setFiles(files); +} + +void DeleteDialog::accept() +{ + KConfigGroup messageGroup(KGlobal::config(), "FileRemover"); + + // Save user's preference + + messageGroup.writeEntry("deleteInsteadOfTrash", shouldDelete()); + messageGroup.sync(); + + KDialogBase::accept(); +} + +void DeleteDialog::slotShouldDelete(bool shouldDelete) +{ + setButtonGuiItem(Ok, shouldDelete ? KStdGuiItem::del() : m_trashGuiItem); +} + +#include "deletedialog.moc" + +// vim: set et ts=4 sw=4: -- cgit v1.2.1