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

@ -1434,27 +1434,37 @@ void MainWindow::settingsChanged()
void MainWindow::externalLinkActivated(const QUrl &url)
{
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);
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());
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 {
//Not QGridLayout so add at end
mb.layout()->addWidget(checkbox) ;
mb.layout()->addWidget(dontAsk_CB);
mb.layout()->addWidget(neverAsk_CB);
}
int res = mb.exec() ;
if (res == QMessageBox::No)
return ;
else if(checkbox->isChecked())
if(dontAsk_CB->isChecked())
already_warned = true ;
if(neverAsk_CB->isChecked())
Settings->setValue("NeverAskMeForExternalLinkActivated",true);
}
QDesktopServices::openUrl(url) ;