Revert async Access Confirm Dialog

This commit is contained in:
Sami Vänttinen 2022-10-26 10:24:49 +03:00 committed by Jonathan White
parent 3ad205f733
commit 4f07a6592c
6 changed files with 102 additions and 286 deletions

View file

@ -32,30 +32,16 @@ BrowserAccessControlDialog::BrowserAccessControlDialog(QWidget* parent)
m_ui->setupUi(this);
connect(m_ui->allowButton, SIGNAL(clicked()), SLOT(acceptSelections()));
connect(m_ui->denyButton, SIGNAL(clicked()), SLOT(rejectSelections()));
connect(this, SIGNAL(rejected()), this, SIGNAL(closed()));
connect(m_ui->allowButton, SIGNAL(clicked()), SLOT(accept()));
connect(m_ui->denyButton, SIGNAL(clicked()), SLOT(reject()));
}
BrowserAccessControlDialog::~BrowserAccessControlDialog()
{
}
void BrowserAccessControlDialog::closeEvent(QCloseEvent* event)
void BrowserAccessControlDialog::setItems(const QList<Entry*>& items, const QString& urlString, bool httpAuth)
{
// Emits closed signal when clicking X from title bar
emit closed();
event->accept();
}
void BrowserAccessControlDialog::setItems(const QList<Entry*>& entriesToConfirm,
const QList<Entry*>& allowedEntries,
const QString& urlString,
bool httpAuth)
{
m_entriesToConfirm = entriesToConfirm;
m_allowedEntries = allowedEntries;
QUrl url(urlString);
m_ui->siteLabel->setText(m_ui->siteLabel->text().arg(
url.toDisplayString(QUrl::RemoveUserInfo | QUrl::RemovePath | QUrl::RemoveQuery | QUrl::RemoveFragment)));
@ -63,11 +49,11 @@ void BrowserAccessControlDialog::setItems(const QList<Entry*>& entriesToConfirm,
m_ui->rememberDecisionCheckBox->setVisible(!httpAuth);
m_ui->rememberDecisionCheckBox->setChecked(false);
m_ui->itemsTable->setRowCount(entriesToConfirm.count());
m_ui->itemsTable->setRowCount(items.count());
m_ui->itemsTable->setColumnCount(2);
int row = 0;
for (const auto& entry : entriesToConfirm) {
for (const auto& entry : items) {
auto item = new QTableWidgetItem();
item->setText(entry->title() + " - " + entry->username());
item->setData(Qt::UserRole, row);
@ -77,23 +63,18 @@ void BrowserAccessControlDialog::setItems(const QList<Entry*>& entriesToConfirm,
auto disableButton = new QPushButton(tr("Disable for this site"));
disableButton->setAutoDefault(false);
connect(disableButton, &QAbstractButton::pressed, [&, item] {
emit disableAccess(item);
m_ui->itemsTable->removeRow(item->row());
if (m_ui->itemsTable->rowCount() == 0) {
emit closed();
reject();
}
});
m_ui->itemsTable->setCellWidget(row, 1, disableButton);
++row;
}
m_ui->itemsTable->resizeColumnsToContents();
m_ui->itemsTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
m_ui->allowButton->setFocus();
}
@ -102,11 +83,6 @@ bool BrowserAccessControlDialog::remember() const
return m_ui->rememberDecisionCheckBox->isChecked();
}
bool BrowserAccessControlDialog::entriesAccepted() const
{
return m_entriesAccepted;
}
QList<QTableWidgetItem*> BrowserAccessControlDialog::getSelectedEntries() const
{
QList<QTableWidgetItem*> selected;
@ -130,19 +106,3 @@ QList<QTableWidgetItem*> BrowserAccessControlDialog::getNonSelectedEntries() con
}
return notSelected;
}
void BrowserAccessControlDialog::acceptSelections()
{
auto selectedEntries = getSelectedEntries();
m_entriesAccepted = true;
emit acceptEntries(selectedEntries, m_entriesToConfirm, m_allowedEntries);
emit closed();
}
void BrowserAccessControlDialog::rejectSelections()
{
auto rejectedEntries = getNonSelectedEntries();
emit rejectEntries(rejectedEntries, m_entriesToConfirm);
emit closed();
}