- Added legal notice dialog on startup. The user must agree for the program to start.

This commit is contained in:
Christophe Dumez 2010-01-09 15:26:20 +00:00
parent f6886b4749
commit ef19e8aeef
30 changed files with 1065 additions and 97 deletions

View file

@ -34,6 +34,7 @@
#ifndef DISABLE_GUI
#include <QApplication>
#include <QMessageBox>
#include <QSplashScreen>
#include <QPlastiqueStyle>
#include "qgnomelook.h"
@ -49,6 +50,8 @@
#include "ico.h"
#else
#include <QCoreApplication>
#include <iostream>
#include <stdio.h>
#include "headlessloader.h"
#endif
@ -73,7 +76,7 @@ QApplication *app;
#endif
class UsageDisplay: public QObject {
Q_OBJECT
Q_OBJECT
public:
static void displayUsage(char* prg_name) {
@ -88,6 +91,39 @@ public:
}
};
class LegalNotice: public QObject {
Q_OBJECT
public:
static bool userAgreesWithNotice() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
if(settings.value(QString::fromUtf8("LegalNotice/Accepted"), false).toBool()) // Already accepted once
return true;
#ifdef DISABLE_GUI
std::cout << std::endl << "*** " << tr("Legal Notice").toLocal8Bit().data() << " ***" << std::endl;
std::cout << tr("qBittorrent is a file sharing program. When you run a torrent, its data will be made available to others by mean of upload. And of course, any content you share if your sole responsatibility.\n\nYou probably knew this, so we won't tell you again.").toLocal8Bit().data() << std::endl << std::endl;
std::cout << tr("Press any key to accept and continue...").toLocal8Bit().data() << std::endl;
getchar(); // Read pressed key
// Save the answer
settings.setValue(QString::fromUtf8("LegalNotice/Accepted"), true);
return true;
#else
QMessageBox msgBox;
msgBox.setText(tr("qBittorrent is a file sharing program. When you run a torrent, its data will be made available to others by mean of upload. And of course, any content you share if your sole responsatibility.\n\nYou probably knew this, so we won't tell you again."));
msgBox.setWindowTitle(tr("Legal notice"));
msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
QAbstractButton *agree_button =(QAbstractButton*)msgBox.addButton(tr("I Agree"), QMessageBox::AcceptRole);
msgBox.exec();
if(msgBox.clickedButton() == agree_button) {
// Save the answer
settings.setValue(QString::fromUtf8("LegalNotice/Accepted"), true);
return true;
}
return false;
#endif
}
};
#include "main.moc"
#ifndef Q_WS_WIN
@ -262,6 +298,13 @@ int main(int argc, char *argv[]){
}
app->installTranslator(&translator);
app->setApplicationName(QString::fromUtf8("qBittorrent"));
if(!LegalNotice::userAgreesWithNotice()) {
#ifndef DISABLE_GUI
delete splash;
#endif
delete app;
return 0;
}
#ifndef DISABLE_GUI
app->setQuitOnLastWindowClosed(false);
#endif