SBI_NetworkIconDialog::SBI_NetworkIconDialog(QWidget* parent) : QDialog(parent) , ui(new Ui::SBI_NetworkIconDialog) { setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(this); ui->addButton->setIcon(QIcon::fromTheme("document-new", QIcon(":sbi/data/add.png"))); ui->removeButton->setIcon(QIcon::fromTheme("edit-delete", QIcon(":sbi/data/remove.png"))); const QHash<QString, SBI_NetworkProxy*> &proxies = SBINetManager->proxies(); QHashIterator<QString, SBI_NetworkProxy*> it(proxies); while (it.hasNext()) { it.next(); ui->comboBox->addItem(it.key()); } updateWidgets(); showProxy(ui->comboBox->currentText()); connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addProxy())); connect(ui->removeButton, SIGNAL(clicked()), this, SLOT(removeProxy())); connect(ui->comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(showProxy(QString))); connect(ui->proxyButtonBox, SIGNAL(accepted()), this, SLOT(saveProxy())); connect(ui->closeButton, SIGNAL(clicked(QAbstractButton*)), this, SLOT(close())); }
void ProxyEditWindow::saveProxyButtonClicked() { QModelIndexList selection = ProxyView->selectionModel()->selectedIndexes(); if (1 != selection.size()) return; saveProxy(selection.at(0).data(NetworkProxyRole).value<NetworkProxy>()); }
bool ProxyEditWindow::canChangeProxy(const QItemSelection &selection) { if (selection.size() == 0) return true; if (selection.size() != 1) return false; QModelIndex selectedItem = selection.at(0).topLeft(); NetworkProxy proxy = selectedItem.data(NetworkProxyRole).value<NetworkProxy>(); if (ForceProxyChange) return true; ConfigurationValueState currenState = state(proxy); if (StateNotChanged == currenState) return true; if (StateChangedDataValid == currenState) { QMessageBox::StandardButton result = QMessageBox::question(this, tr("Proxy"), tr("You have unsaved changes in current proxy.<br />Do you want to save them?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes); switch (result) { case QMessageBox::Yes: saveProxy(proxy); return true; case QMessageBox::No: return true; default: return false; } } if (StateChangedDataInvalid == currenState) { QMessageBox::StandardButton result = QMessageBox::question(this, tr("Proxy"), tr("You have unsaved changes in current proxy.<br />This data is invalid, so you will loose all changes.<br />Do you want to go back to edit them?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); switch (result) { case QMessageBox::No: return true; default: return false; } } return true; }