[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kphotoalbum] /: Ported BackgroundTaskManager::JobViewer to QDialog and removed the UI file in favor
From: Tobias Leupold <tobias.leupold () web ! de>
Date: 2016-08-20 18:17:39
Message-ID: E1bbApv-0002Ub-Ro () code ! kde ! org
[Download RAW message or body]
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/JobViewer.cpp index b1c2cb2..c0b8ae3 100644
--- a/BackgroundTaskManager/JobViewer.cpp
+++ b/BackgroundTaskManager/JobViewer.cpp
@@ -19,30 +19,43 @@
#include "JobViewer.h"
+#include <QLayout>
+#include <QTreeView>
+#include <QDialogButtonBox>
+#include <QPushButton>
+
#include <KLocalizedString>
-#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 = new QVBoxLayout;
+ setLayout(mainLayout);
+
+ m_treeView = new QTreeView;
+ mainLayout->addWidget(m_treeView);
+
+ QDialogButtonBox* buttonBox = new QDialogButtonBox;
+ m_pauseButton = 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 = 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 = 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("Continue") : i18n("Pause")); }
} // namespace BackgroundTaskManager
diff --git a/BackgroundTaskManager/JobViewer.h b/BackgroundTaskManager/JobViewer.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 <KDialog>
+#include <QDialog>
-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 = 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/JobViewer.ui
deleted file mode 100644
index e8df058..0000000
--- a/BackgroundTaskManager/JobViewer.ui
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>JobViewer</class>
- <widget class="QWidget" name="JobViewer">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>801</width>
- <height>715</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QTreeView" name="view">
- <property name="showDropIndicator" stdset="0">
- <bool>false</bool>
- </property>
- <property name="alternatingRowColors">
- <bool>true</bool>
- </property>
- <property name="rootIsDecorated">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="pause">
- <property name="text">
- <string>Pause</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="pushButton">
- <property name="text">
- <string>Close</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
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/SearchForVideosWithoutLengthInfo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/BackgroundJobs/ReadVideoLengthJob.cpp
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic