From c843e71c80a8fa35788c64ad7d136c9eee167304 Mon Sep 17 00:00:00 2001 From: ponchio Date: Tue, 19 Nov 2024 01:32:22 +0100 Subject: [PATCH] open folder in queue works. --- relightlab/queueitem.cpp | 16 +++++++++++++++- relightlab/queueitem.h | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/relightlab/queueitem.cpp b/relightlab/queueitem.cpp index 6b3f6cf..78535e6 100644 --- a/relightlab/queueitem.cpp +++ b/relightlab/queueitem.cpp @@ -5,6 +5,9 @@ #include #include #include +#include +#include + #include "task.h" #include "../relight/httpserver.h" @@ -63,9 +66,11 @@ QueueItem::QueueItem(Task *_task, QListWidget *parent): QListWidgetItem(parent) folder = new QPushButton(); folder->setIcon(QIcon::fromTheme("folder")); - folder->setEnabled(false); + folder->setEnabled(true); grid->addWidget(folder, 0, 3, 4, 1); + connect(folder, SIGNAL(clicked(bool)), this, SLOT(openFolder())); + widget->setLayout(grid); setSizeHint(widget->minimumSizeHint()); @@ -94,6 +99,7 @@ void QueueItem::update() { if(info.isDir()) cast->setEnabled(true); } + cast->setEnabled(true); break; case Task::STOPPED: status->setText("Stopped"); @@ -123,3 +129,11 @@ void QueueItem::casting() { QMessageBox::critical(nullptr, "Could not cast!", error); } } + +void QueueItem::openFolder() { + QFileInfo fileInfo(task->output); + QString path = fileInfo.isDir() ? fileInfo.absoluteFilePath() : fileInfo.absolutePath(); + + QUrl folderUrl = QUrl::fromLocalFile(path); + QDesktopServices::openUrl(folderUrl); +} diff --git a/relightlab/queueitem.h b/relightlab/queueitem.h index c5c9213..4aa9258 100644 --- a/relightlab/queueitem.h +++ b/relightlab/queueitem.h @@ -22,10 +22,12 @@ class QueueItem: public QObject, public QListWidgetItem { QueueItem(Task *task, QListWidget *parent); void update(); + public slots: void setSelected(bool selected); void progress(QString text, int percent); void casting(); + void openFolder(); private: QMap style;