Remove pointless const_cast in ProgressWidget
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
@@ -39,7 +39,7 @@ void ProgressWidget::progressFormat(QString format)
|
|||||||
m_bar->setFormat(format);
|
m_bar->setFormat(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgressWidget::watch(const Task* task)
|
void ProgressWidget::watch(Task* task)
|
||||||
{
|
{
|
||||||
if (!task)
|
if (!task)
|
||||||
return;
|
return;
|
||||||
@@ -61,11 +61,11 @@ void ProgressWidget::watch(const Task* task)
|
|||||||
connect(m_task, &Task::started, this, &ProgressWidget::show);
|
connect(m_task, &Task::started, this, &ProgressWidget::show);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgressWidget::start(const Task* task)
|
void ProgressWidget::start(Task* task)
|
||||||
{
|
{
|
||||||
watch(task);
|
watch(task);
|
||||||
if (!m_task->isRunning())
|
if (!m_task->isRunning())
|
||||||
QMetaObject::invokeMethod(const_cast<Task*>(m_task), "start", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(m_task, "start", Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProgressWidget::exec(std::shared_ptr<Task> task)
|
bool ProgressWidget::exec(std::shared_ptr<Task> task)
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ class ProgressWidget : public QWidget {
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/** Watch the progress of a task. */
|
/** Watch the progress of a task. */
|
||||||
void watch(const Task* task);
|
void watch(Task* task);
|
||||||
|
|
||||||
/** Watch the progress of a task, and start it if needed */
|
/** Watch the progress of a task, and start it if needed */
|
||||||
void start(const Task* task);
|
void start(Task* task);
|
||||||
|
|
||||||
/** Blocking way of waiting for a task to finish. */
|
/** Blocking way of waiting for a task to finish. */
|
||||||
bool exec(std::shared_ptr<Task> task);
|
bool exec(std::shared_ptr<Task> task);
|
||||||
@@ -50,7 +50,7 @@ class ProgressWidget : public QWidget {
|
|||||||
private:
|
private:
|
||||||
QLabel* m_label = nullptr;
|
QLabel* m_label = nullptr;
|
||||||
QProgressBar* m_bar = nullptr;
|
QProgressBar* m_bar = nullptr;
|
||||||
const Task* m_task = nullptr;
|
Task* m_task = nullptr;
|
||||||
|
|
||||||
bool m_hide_if_inactive = false;
|
bool m_hide_if_inactive = false;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user