mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
PluginsManager: Move UserRoles to own Enum
Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
parent
95b1f3ce3c
commit
5f60faf024
@ -77,7 +77,7 @@ void PluginsManager::save()
|
|||||||
QListWidgetItem* item = ui->list->item(i);
|
QListWidgetItem* item = ui->list->item(i);
|
||||||
|
|
||||||
if (item->checkState() == Qt::Checked) {
|
if (item->checkState() == Qt::Checked) {
|
||||||
const Plugins::Plugin plugin = item->data(Qt::UserRole + 10).value<Plugins::Plugin>();
|
const Plugins::Plugin plugin = item->data(PluginRoles::Plugin).value<Plugins::Plugin>();
|
||||||
allowedPlugins.append(plugin.pluginId);
|
allowedPlugins.append(plugin.pluginId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,13 +116,13 @@ void PluginsManager::refresh()
|
|||||||
item->setToolTip(pluginInfo);
|
item->setToolTip(pluginInfo);
|
||||||
|
|
||||||
item->setText(spec.name);
|
item->setText(spec.name);
|
||||||
item->setData(Qt::UserRole, spec.version);
|
item->setData(PluginRoles::Version, spec.version);
|
||||||
item->setData(Qt::UserRole + 1, spec.author);
|
item->setData(PluginRoles::Author, spec.author);
|
||||||
item->setData(Qt::UserRole + 2, spec.description);
|
item->setData(PluginRoles::Description, spec.description);
|
||||||
|
|
||||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||||
item->setCheckState(plugin.isLoaded() ? Qt::Checked : Qt::Unchecked);
|
item->setCheckState(plugin.isLoaded() ? Qt::Checked : Qt::Unchecked);
|
||||||
item->setData(Qt::UserRole + 10, QVariant::fromValue(plugin));
|
item->setData(PluginRoles::Plugin, QVariant::fromValue(plugin));
|
||||||
|
|
||||||
ui->list->addItem(item);
|
ui->list->addItem(item);
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ void PluginsManager::currentChanged(QListWidgetItem* item)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Plugins::Plugin plugin = item->data(Qt::UserRole + 10).value<Plugins::Plugin>();
|
const Plugins::Plugin plugin = item->data(PluginRoles::Plugin).value<Plugins::Plugin>();
|
||||||
ui->butSettings->setEnabled(plugin.isLoaded() && plugin.pluginSpec.hasSettings);
|
ui->butSettings->setEnabled(plugin.isLoaded() && plugin.pluginSpec.hasSettings);
|
||||||
ui->butRemove->setEnabled(plugin.isRemovable());
|
ui->butRemove->setEnabled(plugin.isRemovable());
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ void PluginsManager::itemChanged(QListWidgetItem* item)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugins::Plugin plugin = item->data(Qt::UserRole + 10).value<Plugins::Plugin>();
|
Plugins::Plugin plugin = item->data(PluginRoles::Plugin).value<Plugins::Plugin>();
|
||||||
|
|
||||||
m_blockRefresh = true;
|
m_blockRefresh = true;
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ void PluginsManager::itemChanged(QListWidgetItem* item)
|
|||||||
QMessageBox::critical(this, tr("Error!"), tr("Cannot load extension!"));
|
QMessageBox::critical(this, tr("Error!"), tr("Cannot load extension!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
item->setData(Qt::UserRole + 10, QVariant::fromValue(plugin));
|
item->setData(PluginRoles::Plugin, QVariant::fromValue(plugin));
|
||||||
|
|
||||||
connect(ui->list, &QListWidget::itemChanged, this, &PluginsManager::itemChanged);
|
connect(ui->list, &QListWidget::itemChanged, this, &PluginsManager::itemChanged);
|
||||||
|
|
||||||
@ -212,12 +212,12 @@ void PluginsManager::settingsClicked()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugins::Plugin plugin = item->data(Qt::UserRole + 10).value<Plugins::Plugin>();
|
Plugins::Plugin plugin = item->data(PluginRoles::Plugin).value<Plugins::Plugin>();
|
||||||
|
|
||||||
if (!plugin.isLoaded()) {
|
if (!plugin.isLoaded()) {
|
||||||
mApp->plugins()->loadPlugin(&plugin);
|
mApp->plugins()->loadPlugin(&plugin);
|
||||||
|
|
||||||
item->setData(Qt::UserRole + 10, QVariant::fromValue(plugin));
|
item->setData(PluginRoles::Plugin, QVariant::fromValue(plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.isLoaded() && plugin.pluginSpec.hasSettings) {
|
if (plugin.isLoaded() && plugin.pluginSpec.hasSettings) {
|
||||||
@ -232,7 +232,7 @@ void PluginsManager::removeClicked()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugins::Plugin plugin = item->data(Qt::UserRole + 10).value<Plugins::Plugin>();
|
Plugins::Plugin plugin = item->data(PluginRoles::Plugin).value<Plugins::Plugin>();
|
||||||
|
|
||||||
const auto button = QMessageBox::warning(this, tr("Confirmation"),
|
const auto button = QMessageBox::warning(this, tr("Confirmation"),
|
||||||
tr("Are you sure you want to remove '%1'?").arg(plugin.pluginSpec.name),
|
tr("Are you sure you want to remove '%1'?").arg(plugin.pluginSpec.name),
|
||||||
|
@ -34,6 +34,13 @@ class FALKON_EXPORT PluginsManager : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum PluginRoles {
|
||||||
|
Version = Qt::UserRole,
|
||||||
|
Author = Qt::UserRole + 1,
|
||||||
|
Description = Qt::UserRole + 2,
|
||||||
|
Plugin = Qt::UserRole + 10
|
||||||
|
};
|
||||||
|
|
||||||
explicit PluginsManager(QWidget* parent = nullptr);
|
explicit PluginsManager(QWidget* parent = nullptr);
|
||||||
~PluginsManager();
|
~PluginsManager();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user