Commit 3081e3ee authored by Michael Pyne's avatar Michael Pyne

Port the delete files dialog to QDialog.

parent 1838bb97
......@@ -24,19 +24,22 @@
#include <kconfiggroup.h>
#include <kglobal.h>
#include <QDialogButtonBox>
#include <QStringList>
#include <QCheckBox>
#include <QVBoxLayout>
//////////////////////////////////////////////////////////////////////////////
// DeleteWidget implementation
//////////////////////////////////////////////////////////////////////////////
DeleteWidget::DeleteWidget(QWidget *parent)
: QWidget(parent), m_ui(new Ui::DeleteDialogBase)
: QWidget(parent)
, m_ui(new Ui::DeleteDialogBase)
{
m_ui->setupUi(this);
setObjectName( QLatin1String("delete_dialog_widget" ));
setObjectName(QLatin1String("delete_dialog_widget"));
KConfigGroup messageGroup(KSharedConfig::openConfig(), "FileRemover");
......@@ -44,8 +47,10 @@ DeleteWidget::DeleteWidget(QWidget *parent)
slotShouldDelete(deleteInstead);
m_ui->ddShouldDelete->setChecked(deleteInstead);
// Forward on this signal.
// Forward on signals
connect(m_ui->ddShouldDelete, SIGNAL(toggled(bool)), SIGNAL(signalShouldDelete(bool)));
connect(m_ui->ddButtonBox, SIGNAL(accepted()), SIGNAL(accepted()));
connect(m_ui->ddButtonBox, SIGNAL(rejected()), SIGNAL(rejected()));
}
void DeleteWidget::setFiles(const QStringList &files)
......@@ -80,20 +85,18 @@ void DeleteWidget::slotShouldDelete(bool shouldDelete)
//////////////////////////////////////////////////////////////////////////////
DeleteDialog::DeleteDialog(QWidget *parent) :
KDialog(parent, Qt::MSWindowsFixedSizeDialogHint),
QDialog(parent),
m_trashGuiItem(i18n("&Send to Trash"), "user-trash-full")
{
setObjectName( QLatin1String("delete_dialog" ));
setObjectName(QLatin1String("juk_delete_dialog"));
setModal(true);
setCaption(i18n("About to delete selected files"));
setButtons(Ok | Cancel);
setDefaultButton(Cancel);
showButtonSeparator(true);
setWindowTitle(i18n("About to delete selected files"));
m_widget = new DeleteWidget(this);
setMainWidget(m_widget);
auto layout = new QVBoxLayout(this);
m_widget = new DeleteWidget(this);
m_widget->setMinimumSize(400, 300);
layout->addWidget(m_widget);
// 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?)
......@@ -102,6 +105,8 @@ DeleteDialog::DeleteDialog(QWidget *parent) :
slotShouldDelete(shouldDelete());
connect(m_widget, SIGNAL(accepted()), SLOT(accept()));
connect(m_widget, SIGNAL(rejected()), SLOT(reject()));
connect(m_widget, SIGNAL(signalShouldDelete(bool)), SLOT(slotShouldDelete(bool)));
}
......@@ -126,12 +131,13 @@ void DeleteDialog::accept()
messageGroup.writeEntry("deleteInsteadOfTrash", shouldDelete());
messageGroup.sync();
KDialog::accept();
QDialog::accept();
}
void DeleteDialog::slotShouldDelete(bool shouldDelete)
{
setButtonGuiItem(Ok, shouldDelete ? KStandardGuiItem::del() : m_trashGuiItem);
KGuiItem::assign(m_widget->m_ui->ddButtonBox->button(QDialogButtonBox::Ok),
shouldDelete ? KStandardGuiItem::del() : m_trashGuiItem);
}
// vim: set et sw=4 tw=0 sta:
......@@ -14,20 +14,23 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DELETEDIALOG_H
#define DELETEDIALOG_H
#ifndef JUK_DELETEDIALOG_H
#define JUK_DELETEDIALOG_H
class QStringList;
#include <QWidget>
#include <QDialog>
#include <KDialog>
#include <KGuiItem>
namespace Ui
{
class DeleteDialogBase;
}
class DeleteDialog;
class DeleteWidget : public QWidget
{
Q_OBJECT
......@@ -40,20 +43,23 @@ public:
signals:
void signalShouldDelete(bool);
void accepted();
void rejected();
protected slots:
virtual void slotShouldDelete(bool shouldDelete);
private:
friend DeleteDialog; // TODO: Move KGuiItem stuff into here too
Ui::DeleteDialogBase *m_ui;
};
class DeleteDialog : public KDialog
class DeleteDialog : public QDialog
{
Q_OBJECT
public:
DeleteDialog(QWidget *parent);
DeleteDialog(QWidget* parent);
bool confirmDeleteList(const QStringList &condemnedFiles);
void setFiles(const QStringList &files);
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>542</width>
<height>374</height>
<width>913</width>
<height>757</height>
</rect>
</property>
<property name="minimumSize">
......@@ -20,7 +20,16 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>11</number>
</property>
<property name="topMargin">
<number>11</number>
</property>
<property name="rightMargin">
<number>11</number>
</property>
<property name="bottomMargin">
<number>11</number>
</property>
<item>
......@@ -28,7 +37,16 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
......@@ -52,7 +70,16 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
......@@ -120,6 +147,13 @@
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="ddButtonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
......@@ -131,8 +165,8 @@
<slot>slotShouldDelete(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
<x>31</x>
<y>672</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
......@@ -141,4 +175,8 @@
</hints>
</connection>
</connections>
<slots>
<signal>accepted()</signal>
<signal>rejected()</signal>
</slots>
</ui>
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