19#include "ui_schememanager.h"
23#include <QInputDialog>
30 setAttribute(Qt::WA_DeleteOnClose);
37 connect(m_ui->buttonBox->button(QDialogButtonBox::Reset), &QAbstractButton::clicked,
this, &SchemeManager::reset);
38 connect(m_ui->blockButton, &QAbstractButton::clicked,
this, &SchemeManager::blockScheme);
39 connect(m_ui->allowedAddButton, &QAbstractButton::clicked,
this, &SchemeManager::allowedAdd);
40 connect(m_ui->allowedRemoveButton, &QAbstractButton::clicked,
this, &SchemeManager::allowedRemove);
41 connect(m_ui->blockedAddButton, &QAbstractButton::clicked,
this, &SchemeManager::blockedAdd);
42 connect(m_ui->blockedRemoveButton, &QAbstractButton::clicked,
this, &SchemeManager::blockedRemove);
45void SchemeManager::reset()
50 m_ui->allowedList->clear();
51 m_ui->allowedList->addItems(settings.
value(
QSL(
"AllowedSchemes"), QStringList()).toStringList());
53 m_ui->blockedList->clear();
54 m_ui->blockedList->addItems(settings.
value(
QSL(
"BlockedSchemes"), QStringList()).toStringList());
65 for (
int i = 0;
i < m_ui->allowedList->count(); ++
i) {
66 list.append(m_ui->allowedList->item(
i)->text().toLower());
68 list.removeDuplicates();
72 for (
int i = 0;
i < m_ui->blockedList->count(); ++
i) {
73 list.append(m_ui->blockedList->item(
i)->text().toLower());
75 list.removeDuplicates();
82void SchemeManager::allowedAdd()
84 const QString scheme = QInputDialog::getText(
this, tr(
"Add allowed scheme"), tr(
"Scheme:"));
86 if (scheme.isEmpty()) {
90 if (m_ui->allowedList->findItems(scheme, Qt::MatchFixedString).isEmpty()) {
91 m_ui->allowedList->addItem(scheme);
95void SchemeManager::allowedRemove()
97 int currentRow = m_ui->allowedList->currentRow();
98 auto* item = m_ui->allowedList->item(currentRow);
100 if ((item !=
nullptr) && (item->isSelected())) {
101 m_ui->allowedList->takeItem(m_ui->allowedList->currentRow());
105void SchemeManager::blockScheme()
107 int currentRow = m_ui->allowedList->currentRow();
108 auto* item = m_ui->allowedList->item(currentRow);
110 if ((item !=
nullptr) && (item->isSelected())) {
111 if (m_ui->blockedList->findItems(item->text(), Qt::MatchFixedString).isEmpty()) {
112 m_ui->blockedList->addItem(item->text());
117void SchemeManager::blockedAdd()
119 const QString scheme = QInputDialog::getText(
this, tr(
"Add blocked scheme"), tr(
"Scheme:"));
121 if (scheme.isEmpty()) {
125 if (m_ui->blockedList->findItems(scheme, Qt::MatchFixedString).isEmpty()) {
126 m_ui->blockedList->addItem(scheme);
130void SchemeManager::blockedRemove()
132 int currentRow = m_ui->blockedList->currentRow();
133 auto* item = m_ui->blockedList->item(currentRow);
135 if ((item !=
nullptr) && (item->isSelected())) {
136 m_ui->blockedList->takeItem(m_ui->blockedList->currentRow());
SchemeManager(QWidget *parent=nullptr)
~SchemeManager() override
void beginGroup(const QString &prefix)
QVariant value(const QString &key, const QVariant &defaultValue=QVariant())
void setValue(const QString &key, const QVariant &defaultValue=QVariant())