Commit 8655625b authored by Michael Pyne's avatar Michael Pyne
Browse files

Some delete dialog code cleanups (what I really should be doing is porting...

Some delete dialog code cleanups (what I really should be doing is porting CollectionList{,Item} instead of rarely used dialogs :( )

svn path=/trunk/KDE/kdemultimedia/juk/; revision=807147
parent 0551ea2c
/***************************************************************************
begin : Tue Aug 31 21:59:58 EST 2004
copyright : (C) 2004 by Michael Pyne
copyright : (C) 2004, 2008 by Michael Pyne
email : michael.pyne@kdemail.net
***************************************************************************/
......@@ -14,8 +14,8 @@
***************************************************************************/
#include "deletedialog.h"
#include "ui_deletedialogbase.h"
#include <kdialog.h>
#include <KApplication>
#include <KStandardGuiItem>
#include <klocale.h>
......@@ -30,38 +30,46 @@
// DeleteWidget implementation
//////////////////////////////////////////////////////////////////////////////
DeleteWidget::DeleteWidget(QWidget *parent, const char *name)
: QWidget(parent)
DeleteWidget::DeleteWidget(QWidget *parent)
: QWidget(parent), m_ui(new Ui::DeleteDialogBase)
{
setupUi(this);
m_ui->setupUi(this);
setObjectName(name);
setObjectName("delete_dialog_widget");
KConfigGroup messageGroup(KGlobal::config(), "FileRemover");
KConfigGroup messageGroup(KGlobal::config()->group("FileRemover"));
bool deleteInstead = messageGroup.readEntry("deleteInsteadOfTrash", false);
slotShouldDelete(deleteInstead);
ddShouldDelete->setChecked(deleteInstead);
m_ui->ddShouldDelete->setChecked(deleteInstead);
// Forward on this signal.
connect(m_ui->ddShouldDelete, SIGNAL(toggled(bool)), SIGNAL(signalShouldDelete(bool)));
}
void DeleteWidget::setFiles(const QStringList &files)
{
ddFileList->clear();
ddFileList->insertStringList(files);
ddNumFiles->setText(i18np("<b>1</b> file selected.", "<b>%1</b> files selected.", files.count()));
m_ui->ddFileList->clear();
m_ui->ddFileList->insertStringList(files);
m_ui->ddNumFiles->setText(i18np("<b>1</b> file selected.", "<b>%1</b> files selected.", files.count()));
}
bool DeleteWidget::shouldDelete() const
{
return m_ui->ddShouldDelete->isChecked();
}
void DeleteWidget::slotShouldDelete(bool shouldDelete)
{
if(shouldDelete) {
ddDeleteText->setText(i18n("<qt>These items will be <b>permanently "
m_ui->ddDeleteText->setText(i18n("<qt>These items will be <b>permanently "
"deleted</b> from your hard disk.</qt>"));
ddWarningIcon->setPixmap(KIconLoader::global()->loadIcon("dialog-warning",
m_ui->ddWarningIcon->setPixmap(KIconLoader::global()->loadIcon("dialog-warning",
KIconLoader::Desktop, KIconLoader::SizeLarge));
}
else {
ddDeleteText->setText(i18n("<qt>These items will be moved to the Trash Bin.</qt>"));
ddWarningIcon->setPixmap(KIconLoader::global()->loadIcon("user-trash-full",
m_ui->ddDeleteText->setText(i18n("<qt>These items will be moved to the Trash Bin.</qt>"));
m_ui->ddWarningIcon->setPixmap(KIconLoader::global()->loadIcon("user-trash-full",
KIconLoader::Desktop, KIconLoader::SizeLarge));
}
}
......@@ -70,27 +78,30 @@ void DeleteWidget::slotShouldDelete(bool shouldDelete)
// DeleteDialog implementation
//////////////////////////////////////////////////////////////////////////////
DeleteDialog::DeleteDialog(QWidget *parent, const char *name) :
DeleteDialog::DeleteDialog(QWidget *parent) :
KDialog(parent, Qt::WStyle_DialogBorder),
m_trashGuiItem(i18n("&Send to Trash"), "user-trash-full")
{
setObjectName(name);
setObjectName("delete_dialog");
setModal(true);
setCaption(i18n("About to delete selected files"));
setButtons(Ok | Cancel);
setDefaultButton(Cancel);
showButtonSeparator(true);
m_widget = new DeleteWidget(this, "delete_dialog_widget");
m_widget = new DeleteWidget(this);
setMainWidget(m_widget);
m_widget->setMinimumSize(400, 300);
// Trying to adjust for Qt bug with rich text where the layout is ignored
// (something about not being able to get height-for-width on X11?)
setMinimumSize(410, 326);
adjustSize();
slotShouldDelete(shouldDelete());
connect(m_widget->ddShouldDelete, SIGNAL(toggled(bool)), SLOT(slotShouldDelete(bool)));
connect(m_widget, SIGNAL(signalShouldDelete(bool)), SLOT(slotShouldDelete(bool)));
}
bool DeleteDialog::confirmDeleteList(const QStringList &condemnedFiles)
......@@ -107,7 +118,7 @@ void DeleteDialog::setFiles(const QStringList &files)
void DeleteDialog::accept()
{
KConfigGroup messageGroup(KGlobal::config(), "FileRemover");
KConfigGroup messageGroup(KGlobal::config()->group("FileRemover"));
// Save user's preference
......
/***************************************************************************
begin : Tue Aug 31 21:54:20 EST 2004
copyright : (C) 2004 by Michael Pyne
copyright : (C) 2004, 2008 by Michael Pyne
email : michael.pyne@kdemail.net
***************************************************************************/
......@@ -16,26 +16,35 @@
#ifndef DELETEDIALOG_H
#define DELETEDIALOG_H
#include <QCheckBox>
//Added by qt3to4:
#include <QLabel>
class QStringList;
#include "ui_deletedialogbase.h"
#include <QWidget>
class QStringList;
class QLabel;
#include <KDialog>
namespace Ui
{
class DeleteDialogBase;
}
class DeleteWidget : public QWidget, public Ui::DeleteDialogBase
class DeleteWidget : public QWidget
{
Q_OBJECT
public:
explicit DeleteWidget(QWidget *parent = 0, const char *name = 0);
DeleteWidget(QWidget *parent);
void setFiles(const QStringList &files);
bool shouldDelete() const;
signals:
void signalShouldDelete(bool);
protected slots:
virtual void slotShouldDelete(bool shouldDelete);
private:
Ui::DeleteDialogBase *m_ui;
};
class DeleteDialog : public KDialog
......@@ -43,11 +52,11 @@ class DeleteDialog : public KDialog
Q_OBJECT
public:
explicit DeleteDialog(QWidget *parent, const char *name = "delete_dialog");
DeleteDialog(QWidget *parent);
bool confirmDeleteList(const QStringList &condemnedFiles);
void setFiles(const QStringList &files);
bool shouldDelete() const { return m_widget->ddShouldDelete->isChecked(); }
bool shouldDelete() const { return m_widget->shouldDelete(); }
protected slots:
virtual void accept();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment