]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/settings/viewpropsprogressinfo.cpp
Removed unused KGlobal includes and use KIO/Job instead of KIO/JobClasses
[dolphin.git] / src / settings / viewpropsprogressinfo.cpp
index a4a45da268fd042de52d0c4317bcb1fa64b00aa4..56fee80279f47f607a39fb84fa61c7cdaebe4dc1 100644 (file)
 #include <QLabel>
 #include <QProgressBar>
 #include <QTimer>
 #include <QLabel>
 #include <QProgressBar>
 #include <QTimer>
-#include <QBoxLayout>
+#include <QVBoxLayout>
+#include <QDialogButtonBox>
+#include <QPushButton>
 
 
-#include <KLocale>
-#include <KIO/JobClasses>
+#include <KConfigGroup>
+#include <KLocalizedString>
+#include <KIO/Job>
 
 #include <views/viewproperties.h>
 
 ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
 
 #include <views/viewproperties.h>
 
 ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
-                                             const KUrl& dir,
+                                             const QUrl& dir,
                                              const ViewProperties& viewProps) :
                                              const ViewProperties& viewProps) :
-    KDialog(parent),
+    QDialog(parent),
     m_dir(dir),
     m_viewProps(0),
     m_label(0),
     m_dir(dir),
     m_viewProps(0),
     m_label(0),
@@ -45,9 +48,8 @@ ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
 {
     const QSize minSize = minimumSize();
     setMinimumSize(QSize(320, minSize.height()));
 {
     const QSize minSize = minimumSize();
     setMinimumSize(QSize(320, minSize.height()));
-
-    setCaption(i18nc("@title:window", "Applying View Properties"));
-    setButtons(KDialog::Cancel);
+    setWindowTitle(i18nc("@title:window", "Applying View Properties"));
+    setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
 
     m_viewProps = new ViewProperties(dir);
     m_viewProps->setDirProperties(viewProps);
 
     m_viewProps = new ViewProperties(dir);
     m_viewProps->setDirProperties(viewProps);
@@ -56,20 +58,24 @@ ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
     // that the view properties are saved twice:
     m_viewProps->setAutoSaveEnabled(false);
 
     // that the view properties are saved twice:
     m_viewProps->setAutoSaveEnabled(false);
 
-    QWidget* main = new QWidget();
-    QVBoxLayout* topLayout = new QVBoxLayout();
+    auto layout = new QVBoxLayout(this);
+    setLayout(layout);
+
+    m_label = new QLabel(i18nc("@info:progress", "Counting folders: %1", 0), this);
+    layout->addWidget(m_label);
 
 
-    m_label = new QLabel(i18nc("@info:progress", "Counting folders: %1", 0), main);
-    m_progressBar = new QProgressBar(main);
+    m_progressBar = new QProgressBar(this);
     m_progressBar->setMinimum(0);
     m_progressBar->setMaximum(0);
     m_progressBar->setValue(0);
     m_progressBar->setMinimum(0);
     m_progressBar->setMaximum(0);
     m_progressBar->setValue(0);
+    layout->addWidget(m_progressBar);
 
 
-    topLayout->addWidget(m_label);
-    topLayout->addWidget(m_progressBar);
+    layout->addStretch();
 
 
-    main->setLayout(topLayout);
-    setMainWidget(main);
+    auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel, this);
+    connect(buttonBox, &QDialogButtonBox::accepted, this, &ViewPropsProgressInfo::accept);
+    connect(buttonBox, &QDialogButtonBox::rejected, this, &ViewPropsProgressInfo::reject);
+    layout->addWidget(buttonBox);
 
     // Use the directory size job to count the number of directories first. This
     // allows to give a progress indication for the user when applying the view
 
     // Use the directory size job to count the number of directories first. This
     // allows to give a progress indication for the user when applying the view
@@ -85,8 +91,6 @@ ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
     connect(m_timer, &QTimer::timeout,
             this, &ViewPropsProgressInfo::updateProgress);
     m_timer->start(300);
     connect(m_timer, &QTimer::timeout,
             this, &ViewPropsProgressInfo::updateProgress);
     m_timer->start(300);
-
-    connect(this, &ViewPropsProgressInfo::cancelClicked, this, &ViewPropsProgressInfo::cancelApplying);
 }
 
 ViewPropsProgressInfo::~ViewPropsProgressInfo()
 }
 
 ViewPropsProgressInfo::~ViewPropsProgressInfo()
@@ -99,7 +103,22 @@ void ViewPropsProgressInfo::closeEvent(QCloseEvent* event)
 {
     m_timer->stop();
     m_applyViewPropsJob = 0;
 {
     m_timer->stop();
     m_applyViewPropsJob = 0;
-    KDialog::closeEvent(event);
+    QDialog::closeEvent(event);
+}
+
+void ViewPropsProgressInfo::reject()
+{
+    if (m_dirSizeJob) {
+        m_dirSizeJob->kill();
+        m_dirSizeJob = 0;
+    }
+
+    if (m_applyViewPropsJob) {
+        m_applyViewPropsJob->kill();
+        m_applyViewPropsJob = 0;
+    }
+
+    QDialog::reject();
 }
 
 void ViewPropsProgressInfo::updateProgress()
 }
 
 void ViewPropsProgressInfo::updateProgress()
@@ -132,17 +151,3 @@ void ViewPropsProgressInfo::applyViewProperties()
             this, &ViewPropsProgressInfo::close);
 }
 
             this, &ViewPropsProgressInfo::close);
 }
 
-void ViewPropsProgressInfo::cancelApplying()
-{
-    if (m_dirSizeJob) {
-        m_dirSizeJob->kill();
-        m_dirSizeJob = 0;
-    }
-
-    if (m_applyViewPropsJob) {
-        m_applyViewPropsJob->kill();
-        m_applyViewPropsJob = 0;
-    }
-}
-
-#include "viewpropsprogressinfo.moc"