Remove pointless const_cast in ProgressWidget

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad
2025-09-17 11:24:10 +01:00
parent 24726ea621
commit 7c9c9432dd
2 changed files with 6 additions and 6 deletions

View File

@@ -39,7 +39,7 @@ void ProgressWidget::progressFormat(QString format)
m_bar->setFormat(format);
}
void ProgressWidget::watch(const Task* task)
void ProgressWidget::watch(Task* task)
{
if (!task)
return;
@@ -61,11 +61,11 @@ void ProgressWidget::watch(const Task* task)
connect(m_task, &Task::started, this, &ProgressWidget::show);
}
void ProgressWidget::start(const Task* task)
void ProgressWidget::start(Task* task)
{
watch(task);
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)

View File

@@ -27,10 +27,10 @@ class ProgressWidget : public QWidget {
public slots:
/** 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 */
void start(const Task* task);
void start(Task* task);
/** Blocking way of waiting for a task to finish. */
bool exec(std::shared_ptr<Task> task);
@@ -50,7 +50,7 @@ class ProgressWidget : public QWidget {
private:
QLabel* m_label = nullptr;
QProgressBar* m_bar = nullptr;
const Task* m_task = nullptr;
Task* m_task = nullptr;
bool m_hide_if_inactive = false;
};