aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pyne <[email protected]>2017-09-29 19:51:51 -0400
committerMichael Pyne <[email protected]>2017-09-29 19:51:51 -0400
commit3081e3eeef8ed0b78a185652cad7cfa9f24a5739 (patch)
tree70816d6f9c60285cff633d28b7c87833b997f6ec
parent1838bb97a757271f6feacc3da080affaaca7fdf4 (diff)
Port the delete files dialog to QDialog.
-rw-r--r--deletedialog.cpp32
-rw-r--r--deletedialog.h16
-rw-r--r--deletedialogbase.ui52
3 files changed, 75 insertions, 25 deletions
diff --git a/deletedialog.cpp b/deletedialog.cpp
index e79004c..21e9fb5 100644
--- a/deletedialog.cpp
+++ b/deletedialog.cpp
@@ -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:
diff --git a/deletedialog.h b/deletedialog.h
index 826bbb2..e503009 100644
--- a/deletedialog.h
+++ b/deletedialog.h
@@ -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);
diff --git a/deletedialogbase.ui b/deletedialogbase.ui
index 6b65e10..424a1ce 100644
--- a/deletedialogbase.ui
+++ b/deletedialogbase.ui
@@ -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>