diff options
Diffstat (limited to 'src/mainwindow/taskmanager.cpp')
-rw-r--r-- | src/mainwindow/taskmanager.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/mainwindow/taskmanager.cpp b/src/mainwindow/taskmanager.cpp new file mode 100644 index 00000000..9025f461 --- /dev/null +++ b/src/mainwindow/taskmanager.cpp @@ -0,0 +1,62 @@ +/* ============================================================ + * The rekonq project + * ============================================================ + * SPDX-License-Identifier: GPL-3.0-only + * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net> + * ============================================================ + * Description: Task Manager + * ============================================================ */ + +#include "taskmanager.h" +#include "application.hpp" +#include "plugins/pluginloader.h" +#include "ui_taskmanager.h" + +TaskManager::TaskManager(QWidget *parent) : QDialog(parent), ui(new Ui::TaskManager) +{ + ui->setupUi(this); + ui->pluginStateBox->setVisible(false); + + auto *app = Application::instance(); + + // Plugins Tab + auto pluginList = app->pluginList(); + for (auto &plugin : pluginList) { + auto *item = new QListWidgetItem(plugin->fileName(), ui->plugins); + item->setData(Qt::UserRole, QVariant::fromValue(plugin)); + } + connect(ui->plugins, &QListWidget::itemClicked, this, &TaskManager::showPluginDetails); + connect(ui->pluginState, &QPushButton::clicked, [this](bool checked) { + auto *item = ui->plugins->currentItem(); + auto plugin = item->data(Qt::UserRole).value<QPointer<PluginLoader>>(); + Q_CHECK_PTR(plugin); + + if (checked) plugin->load(); + else + plugin->unload(); + + showPluginDetails(item); + }); + + // Windows Tab + const auto windowList = app->windowList(); + for (const auto &window : windowList) ui->windows->addItem(window->windowTitle()); + + // Views Tab + const auto viewList = app->viewList(); + for (const auto &view : viewList) ui->views->addItem(view->title()); +} + +TaskManager::~TaskManager() { delete ui; } + +void TaskManager::showPluginDetails(QListWidgetItem *item) +{ + auto plugin = item->data(Qt::UserRole).value<QPointer<PluginLoader>>(); + Q_CHECK_PTR(plugin); + + ui->pluginStateBox->setVisible(true); + ui->pluginState->setText(plugin->isLoaded() ? tr("Loaded") : tr("Not loaded")); + ui->pluginState->setChecked(plugin->isLoaded()); + ui->pluginError->setText(plugin->errorString()); + ui->pluginSchemes->setText(plugin->schemes().join(' ')); +}
\ No newline at end of file |