From kde-commits Sat Aug 20 18:17:39 2016 From: Tobias Leupold Date: Sat, 20 Aug 2016 18:17:39 +0000 To: kde-commits Subject: [kphotoalbum] /: Ported BackgroundTaskManager::JobViewer to QDialog and removed the UI file in favor Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=147171706816291 Git commit 5358f5f53b070c3f9e185975b0a6c82b78019bbc by Tobias Leupold. Committed on 20/08/2016 at 18:14. Pushed by tleupold into branch 'master'. Ported BackgroundTaskManager::JobViewer to QDialog and removed the UI file = in favor of setting up the UI via the constructor. M +28 -16 BackgroundTaskManager/JobViewer.cpp M +8 -5 BackgroundTaskManager/JobViewer.h D +0 -62 BackgroundTaskManager/JobViewer.ui M +0 -4 CMakeLists.txt http://commits.kde.org/kphotoalbum/5358f5f53b070c3f9e185975b0a6c82b78019bbc diff --git a/BackgroundTaskManager/JobViewer.cpp b/BackgroundTaskManager/Jo= bViewer.cpp index b1c2cb2..c0b8ae3 100644 --- a/BackgroundTaskManager/JobViewer.cpp +++ b/BackgroundTaskManager/JobViewer.cpp @@ -19,30 +19,43 @@ = #include "JobViewer.h" = +#include +#include +#include +#include + #include = -#include "ui_JobViewer.h" #include "JobModel.h" #include "JobManager.h" = namespace BackgroundTaskManager { = -JobViewer::JobViewer(QWidget *parent) : - KDialog(parent), ui( new Ui::JobViewer ), m_model( nullptr ) +JobViewer::JobViewer(QWidget *parent) : QDialog(parent), m_model( nullptr ) { - // disable default buttons (Ok, Cancel): - setButtons( None ); - ui->setupUi( mainWidget() ); setWindowTitle(i18n("Background Job Viewer")); - connect( ui->pause, SIGNAL(clicked()), this, SLOT(togglePause())); - connect( ui->pushButton, SIGNAL(clicked()), this, SLOT(accept())); + + QVBoxLayout* mainLayout =3D new QVBoxLayout; + setLayout(mainLayout); + + m_treeView =3D new QTreeView; + mainLayout->addWidget(m_treeView); + + QDialogButtonBox* buttonBox =3D new QDialogButtonBox; + m_pauseButton =3D buttonBox->addButton(i18n("Pause"), QDialogButtonBox= ::YesRole); + buttonBox->addButton(QDialogButtonBox::Close); + + connect(m_pauseButton, SIGNAL(clicked()), this, SLOT(togglePause())); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::accept= ); + + mainLayout->addWidget(buttonBox); } = void JobViewer::setVisible(bool b) { if (b) { m_model =3D new JobModel(this); - ui->view->setModel(m_model); + m_treeView->setModel(m_model); updatePauseButton(); } else { @@ -50,12 +63,11 @@ void JobViewer::setVisible(bool b) m_model =3D nullptr; } = - - ui->view->setColumnWidth(0, 50); - ui->view->setColumnWidth(1, 300); - ui->view->setColumnWidth(2, 300); - ui->view->setColumnWidth(3, 50); - KDialog::setVisible(b); + m_treeView->setColumnWidth(0, 50); + m_treeView->setColumnWidth(1, 300); + m_treeView->setColumnWidth(2, 300); + m_treeView->setColumnWidth(3, 50); + QDialog::setVisible(b); } = void JobViewer::togglePause() @@ -66,7 +78,7 @@ void JobViewer::togglePause() = void JobViewer::updatePauseButton() { - ui->pause->setText(JobManager::instance()->isPaused() ? i18n("Continue= ") : i18n("Pause")); + m_pauseButton->setText(JobManager::instance()->isPaused() ? i18n("Cont= inue") : i18n("Pause")); } = } // namespace BackgroundTaskManager diff --git a/BackgroundTaskManager/JobViewer.h b/BackgroundTaskManager/JobV= iewer.h index ff7b842..f30e1cf 100644 --- a/BackgroundTaskManager/JobViewer.h +++ b/BackgroundTaskManager/JobViewer.h @@ -20,16 +20,19 @@ #ifndef BACKGROUNDTASKS_JOBVIEWER_H #define BACKGROUNDTASKS_JOBVIEWER_H = -#include +#include = -namespace Ui { class JobViewer; } +class QTreeView; +class QPushButton; = namespace BackgroundTaskManager { + class JobModel; = -class JobViewer : public KDialog +class JobViewer : public QDialog { Q_OBJECT + public: explicit JobViewer(QWidget *parent =3D nullptr); void setVisible(bool) override; @@ -39,9 +42,9 @@ private slots: = private: void updatePauseButton(); - - Ui::JobViewer* ui; JobModel* m_model; + QTreeView* m_treeView; + QPushButton* m_pauseButton; }; = } // namespace BackgroundTaskManager diff --git a/BackgroundTaskManager/JobViewer.ui b/BackgroundTaskManager/Job= Viewer.ui deleted file mode 100644 index e8df058..0000000 --- a/BackgroundTaskManager/JobViewer.ui +++ /dev/null @@ -1,62 +0,0 @@ - - - JobViewer - - - - 0 - 0 - 801 - 715 - - - - - - - false - - - true - - - false - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Pause - - - - - - - Close - - - - - - - - - - diff --git a/CMakeLists.txt b/CMakeLists.txt index 9faf386..2c6d104 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -357,10 +357,6 @@ set(libBackgroundTaskManager_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/BackgroundTaskManager/PriorityQueue.cpp ) = -qt5_wrap_ui(libBackgroundTaskManager_SRCS - ${CMAKE_CURRENT_SOURCE_DIR}/BackgroundTaskManager/JobViewer.ui - ) - set(libBackgroundJobs_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/BackgroundJobs/SearchForVideosWithoutLengt= hInfo.cpp ${CMAKE_CURRENT_SOURCE_DIR}/BackgroundJobs/ReadVideoLengthJob.cpp