Merge pull request #1269 from PhenomRetroShare/Add_NeverAskMeForExternalLinkActivated

Add Never Ask Me For External Link Activated
This commit is contained in:
csoler 2018-05-26 11:23:33 +02:00 committed by GitHub
commit 57dde55f56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -733,16 +733,16 @@ void MainWindow::updateStatus()
if (ratesstatus) if (ratesstatus)
ratesstatus->getRatesStatus(downKb, upKb); ratesstatus->getRatesStatus(downKb, upKb);
if(torstatus) if(torstatus)
torstatus->getTorStatus(); torstatus->getTorStatus();
if(!hiddenmode) if(!hiddenmode)
{ {
if (natstatus) if (natstatus)
natstatus->getNATStatus(); natstatus->getNATStatus();
if (dhtstatus) if (dhtstatus)
dhtstatus->getDHTStatus(); dhtstatus->getDHTStatus();
} }
if (discstatus) { if (discstatus) {
@ -1434,27 +1434,37 @@ void MainWindow::settingsChanged()
void MainWindow::externalLinkActivated(const QUrl &url) void MainWindow::externalLinkActivated(const QUrl &url)
{ {
static bool already_warned = false ; static bool already_warned = false ;
bool never_ask_me = Settings->value("NeverAskMeForExternalLinkActivated",false).toBool();
if(!already_warned) if(!already_warned && !never_ask_me)
{ {
QMessageBox mb(QObject::tr("Confirmation"), QObject::tr("Do you want this link to be handled by your system?")+"<br/><br/>"+ url.toString()+"<br/><br/>"+tr("Make sure this link has not been forged to drag you to a malicious website."), QMessageBox::Question, QMessageBox::Yes,QMessageBox::No, 0); QMessageBox mb(QObject::tr("Confirmation"), QObject::tr("Do you want this link to be handled by your system?")+"<br/><br/>"+ url.toString()+"<br/><br/>"+tr("Make sure this link has not been forged to drag you to a malicious website."), QMessageBox::Question, QMessageBox::Yes,QMessageBox::No, 0);
QCheckBox *checkbox = new QCheckBox(tr("Don't ask me again")) ; QCheckBox *dontAsk_CB = new QCheckBox(tr("Don't ask me again"));
QCheckBox *neverAsk_CB = new QCheckBox(tr("Never ask me again"));
dontAsk_CB->setToolTip(tr("This will be saved only for this session."));
neverAsk_CB->setToolTip(tr("This will be saved permanently. You'll need to clean RetroShare.conf to revert."));
QGridLayout* layout = qobject_cast<QGridLayout*>(mb.layout()); QGridLayout* layout = qobject_cast<QGridLayout*>(mb.layout());
if (layout) if (layout)
{ {
layout->addWidget(checkbox,layout->rowCount(),0,1, layout->columnCount(), Qt::AlignLeft); layout->addWidget(dontAsk_CB,layout->rowCount(),0,1, layout->columnCount(), Qt::AlignLeft);
layout->addWidget(neverAsk_CB,layout->rowCount(),0,1, layout->columnCount(), Qt::AlignLeft);
} else { } else {
//Not QGridLayout so add at end //Not QGridLayout so add at end
mb.layout()->addWidget(checkbox) ; mb.layout()->addWidget(dontAsk_CB);
mb.layout()->addWidget(neverAsk_CB);
} }
int res = mb.exec() ; int res = mb.exec() ;
if (res == QMessageBox::No) if (res == QMessageBox::No)
return ; return ;
else if(checkbox->isChecked())
if(dontAsk_CB->isChecked())
already_warned = true ; already_warned = true ;
if(neverAsk_CB->isChecked())
Settings->setValue("NeverAskMeForExternalLinkActivated",true);
} }
QDesktopServices::openUrl(url) ; QDesktopServices::openUrl(url) ;