Accueil > > > [C++] NAVIGATEUR INTERNET QT
[C++] NAVIGATEUR INTERNET QT
Information sur la source
Description
Ce programme est réalisé grâce à la librairie Qt. Le dossier complet : DLLs, Executable et documentation, est disponible à cette adresse :
http://dl.free.fr/cZCMgGP2B (25Mo, j'y ai rajouté les plugins pour lire les vidéos et tous les types d'images)
Source
- //Host.h
-
- #ifndef HEADER_HOST
- #define HEADER_HOST
-
- #include <QtGui>
-
- class Host : public QMainWindow
- {
- Q_OBJECT
-
- public:
-
- Host(QWidget *parent = 0);
- void nouvelIp();
- void enregistrer(QString &texteAEnregistrer);
- void effacer();
-
- public slots:
-
- void nouveauProtocole();
- void rediger();
- void ouvrir();
- void remplacer();
- void changerApparence(bool plast);
-
- private:
-
- QList<QLineEdit *> ligneProtocole;
- QList<QLineEdit *> ligneIp;
- QVBoxLayout *layPro;
- QVBoxLayout *layProIp;
- QWidget *centre;
- int nbProtocoles;
- QTextEdit *texteHost;
- QVBoxLayout *layOuv;
- QTextEdit *ouvert;
- QPushButton *boutOuv;
- QFrame *fr;
- QLineEdit *adresseLE;
-
-
- };
-
- #endif
-
- //Host.cpp
-
- #include "Host.h"
-
-
- Host::Host(QWidget *parent) : QMainWindow (parent)
- {
- QApplication::setStyle(new QPlastiqueStyle);
-
- nbProtocoles = 0;
-
- layPro = new QVBoxLayout;
- layProIp = new QVBoxLayout;
- centre = new QWidget;
- texteHost = new QTextEdit;
- ouvert = new QTextEdit;
-
- layOuv = new QVBoxLayout;
- boutOuv = new QPushButton("Enregistrer");
-
- QLabel *sites = new QLabel("Redirection de (URL) : ");
- QLabel *ip = new QLabel("Vers (DNS) : ");
-
- QMenu *menuRy = new QMenu;
- menuRy = menuBar()->addMenu("&Ry-Hosts");
- QAction *actQuitter = new QAction("&Quitter", this);
- QAction *actChemin = new QAction("Affichier le &chemin", this);
- actChemin->setShortcut(QKeySequence("Ctrl+K"));
- actChemin->setCheckable(true);
- QAction *actApparence = new QAction("&Apparence Perso", this);
- actApparence->setCheckable(true);
- actApparence->setShortcut(QKeySequence("Ctrl+L"));
- actApparence->setChecked(true);
- menuRy->addAction(actChemin);
- menuRy->addAction(actApparence);
- menuRy->addAction(actQuitter);
- actQuitter->setShortcut(QKeySequence("Escape"));
-
- adresseLE = new QLineEdit;
- adresseLE->setVisible(false);
-
- QPushButton *nouveau = new QPushButton("Nouveau Protocole");
- QPushButton *rediger = new QPushButton("Valider");
- QPushButton *ouvrir = new QPushButton("Ouvrir");
- QPushButton *quitter = new QPushButton("Quitter");
-
- QHBoxLayout *layProP = new QHBoxLayout;
-
- layPro->addWidget(sites);
- layProIp->addWidget(ip);
- layProP->addWidget(nouveau);
- layProP->addWidget(rediger);
- layProP->addWidget(ouvrir);
- layProP->addWidget(quitter);
-
-
- layOuv->addWidget(ouvert);
- layOuv->addWidget(boutOuv);
- fr = new QFrame;
- fr->setLayout(layOuv);
-
- nouveauProtocole();
-
- QHBoxLayout *param = new QHBoxLayout;
- param->addLayout(layPro);
- param->addLayout(layProIp);
- QVBoxLayout *toutLay = new QVBoxLayout;
- toutLay->addLayout(param);
- toutLay->addLayout(layProP);
-
- centre->setLayout(toutLay);
-
- QStatusBar *barreEtat = statusBar();
-
- barreEtat->showMessage("Prêt");
- adresseLE->setText("C:/WINDOWS/system32/drivers/etc/hosts");
- barreEtat->addPermanentWidget(adresseLE);
-
- resize(460,143);
- setWindowTitle("RY-Host");
- setCentralWidget(centre);
-
- QObject::connect(actApparence, SIGNAL(toggled(bool)), this, SLOT(changerApparence(bool)));
- QObject::connect(actChemin, SIGNAL(toggled(bool)), adresseLE, SLOT(setVisible(bool)));
- QObject::connect(actQuitter, SIGNAL(triggered()), qApp, SLOT(quit()));
- QObject::connect(boutOuv, SIGNAL(clicked()), this, SLOT(remplacer()));
- QObject::connect(ouvrir, SIGNAL(clicked()), this, SLOT(ouvrir()));
- QObject::connect(nouveau, SIGNAL(clicked()), this, SLOT(nouveauProtocole()));
- QObject::connect(rediger, SIGNAL(clicked()), this, SLOT(rediger()));
- QObject::connect(quitter, SIGNAL(clicked()), this, SLOT(close()));
- }
-
-
- void Host::nouveauProtocole()
- {
-
- ligneProtocole.append(new QLineEdit);
-
- layPro->addWidget(ligneProtocole.at(nbProtocoles));
-
- nouvelIp();
-
- nbProtocoles++;
-
- }
-
- void Host::nouvelIp()
- {
-
- ligneIp.append(new QLineEdit("127.0.0.1"));
-
- layProIp->addWidget(ligneIp.at(nbProtocoles));
- ligneProtocole.at(nbProtocoles)->setFocus();
-
- }
-
- void Host::rediger()
- {
- QString host;
-
-
- for(int i = 0; i < nbProtocoles; i++)
- {
- QString site = ligneProtocole.at(i)->text();
- QString ips = ligneIp.at(i)->text();
- if (site != "")
- {
- host += ("\n" + ips);
- host += (" " + site + "\n");
- }
- }
- QString affiche = "#Redirection de RY-Host à ajouter\n" + host;
-
- effacer();
- enregistrer(host);
- }
-
- void Host::enregistrer(QString &texteAEnregistrer)
- {
-
- QString fichier = adresseLE->text();
- QFile hfile(fichier);
- if (! hfile.open (QIODevice::Append | QIODevice::Text))
-
- return;
-
-
- QTextStream out (& hfile);
- out << texteAEnregistrer;
-
- }
-
- void Host::effacer()
- {
- for(int i = 0; i < nbProtocoles ; i++)
- {
- ligneProtocole.at(i)->setText("");
- ligneIp.at(i)->setText("127.0.0.1");
- }
-
- }
-
- void Host::ouvrir()
- {
- QString line;
- QFile file(adresseLE->text());
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
- return;
-
- while(!file.atEnd())
- {
-
- line += file.readLine();
-
- }
-
-
- ouvert->setPlainText(line);
- ouvert->setMinimumSize(400,300);
- fr->show();
- }
-
- void Host::remplacer()
- {
-
- QString fichier = adresseLE->text();
- QFile hfile(fichier);
- if (! hfile.open (QIODevice::WriteOnly | QIODevice::Text))
-
- return;
-
- QTextStream out (& hfile);
- out << ouvert->toPlainText();
- fr->close();
- }
-
- void Host::changerApparence(bool plast)
- {
- if (plast)
- {
- QApplication::setStyle(new QPlastiqueStyle);
- }
- else
- {
- QApplication::setStyle(new QWindowsXPStyle);
- }
-
- }
-
-
- //NavRY.h
-
- #ifndef HEADER_FENPRINCIPALE
- #define HEADER_FENPRINCIPALE
-
- #include <QtGui>
- #include <QtWebKit>
- #include <QFile>
- #include <QSettings>
- #include <QUrl>
- #include <QtNetwork>
- #include <QHttp>
- #include "Host.h"
-
-
- class FenPrincipale : public QMainWindow
- {
- Q_OBJECT
-
- public:
- FenPrincipale();
- ~FenPrincipale();
-
- QString cryptIni (QString data);
- QString decryptIni (QString data);
- void appliqStyle();
- int getStyle();
- void setStyle(int numS);
-
- signals:
- void done();
-
-
-
- private slots:
-
- void b1();
- void b2();
- void b3();
- void b4();
- void b5();
- void b6();
- void b7();
- void b8();
- void b9();
-
- void sl_histoPlan();
- void pleinEcran();
- void sl_addsT();
- void sl_addsF();
- void sl_validationParam();
- void sl_choixCouleur();
- void sl_down();
- void sl_hosting();
- void httpDone(bool error);
- void getFile();
- void sl_codeS();
- void precedente();
- void suivante();
- void accueil();
- void stop();
- void actualiser();
- void googlePage();
- void navP();
- void aPropos();
- void nouvelOnglet();
- void fermerOnglet(int onglet = -1);
- void chargerPage();
- void changementOnglet(int index);
- void quitterHistorique();
- void afficherHistorique();
- void changementTitre(const QString & titreComplet);
- void changementUrl(const QUrl & url);
- void chargementDebut();
- void chargementEnCours(int pourcentage);
- void chargementTermine(bool ok);
- void rechercheGoogle();
- void sl_styleXP();
- void sl_styleWin();
- void sl_stylePlast();
- void sl_styleCDE();
- void sl_styleMotif();
- void sl_styleClean();
- void sl_impression();
- void sl_copy();
- void sl_cut();
- void sl_mParam();
-
-
- private:
- void creerActions();
- void creerMenus();
- void creerBarresOutils();
- void creerHistorique();
- void creerOptions();
- void creerBarreEtat();
- QWidget *creerOngletPageWeb(QString url = "");
- QWidget *histoPlan();
- QWebView *pageActuelle();
- QWebHistory * history();
- void Historique();
- void videChampGoogle();
-
-
- private:
-
- QPushButton *visitP1 ;
- QPushButton *visitP2;
- QPushButton *visitP3;
- QPushButton *visitP4;
- QPushButton *visitP5;
- QPushButton *visitP6;
- QPushButton *visitP7;
- QPushButton *visitP8;
- QPushButton *visitP9;
-
- QString couleurMenus;
- QTextEdit *te_sourceAva;
- QTabWidget *onglets;
- Host *host;
- QAction *actPleinEcran;
- QAction *actCS;
- QAction *actDown;
- QAction *actionNouvelOnglet;
- QAction *actionFermerOnglet;
- QAction *actionQuitter;
- QAction *actionAPropos;
- QAction *actionAProposQt;
- QAction *actionHistoPlan;
- QAction *actionPrecedente;
- QAction *actionSuivante;
- QAction *actionStop;
- QAction *actionActualiser;
- QAction *actionAccueil;
- QAction *actionGo;
- QAction *actionHistorique;
- QAction *actionGoogle;
- QAction *actionNPrivee;
- QAction *actionPrint;
- QAction *actionCopy;
- QAction *actionCut;
- QAction *actionParam;
- QAction *actChemin;
- QAction *actQuitter;
- QAction *actApparence;
-
- QAction *actHost;
-
-
- QFile file;
- QLineEdit *lineAdress;
- QPushButton *bout;
-
- QAction *actPlast;
- QAction *actClean;
- QAction *actXP;
- QAction *actWin;
- QAction *actMotif;
- QAction *actCDE;
-
- QPushButton *boutPartAcc;
- QPushButton *boutPart1;
- QPushButton *boutPart2;
- QPushButton *boutPart3;
- QPushButton *boutPartCl;
- bool m_navP;
- QVBoxLayout *vbox;
- QFrame *frame;
- QTextEdit *TEHisto;
- QString *textHisto;
- QDockWidget *dock;
- QDockWidget *dock2;
- QLineEdit *champAdresse;
- QLineEdit *champGoogle;
- QProgressBar *progression;
- QPushButton *b_cancel;
- QPushButton *b_ok;
- QCheckBox *ch_genNavP;
- QLineEdit *le_pageAcc;
- QComboBox *co_style;
- int indexStyle;
- QPushButton *colorBout;
- QColor couleur;
- QMainWindow *myParamWindow;
- QSettings *settings;
- bool modifCouleur;
- QString qsPa;
- QHttp http;
-
- };
-
-
- #endif
-
- //NavRY.cpp
-
- #include "NavRY.h"
- #include <iostream>
-
- QString text;
-
-
- FenPrincipale::FenPrincipale()
- {
- couleurMenus = "FFFFF";
-
-
- settings = new QSettings("imageformats/ry_ini/ry_nav_v1.4.ini",QSettings::IniFormat);
- qsPa = decryptIni(settings->value("Alpha/Tango").toString());
-
- QApplication::setFont ( QFont("Myriad",9, QFont::DemiBold));
- QApplication::setStyle(new QPlastiqueStyle);
-
- appliqStyle();
- creerActions();
- creerMenus();
- creerBarresOutils();
- creerBarreEtat();
- creerHistorique();
- te_sourceAva = new QTextEdit;
-
- m_navP = true;
-
- onglets = new QTabWidget;
- onglets->setTabsClosable(true);
-
- connect(onglets, SIGNAL(tabCloseRequested(int)), this, SLOT(fermerOnglet(int)));
-
-
- champAdresse->setStyleSheet ( "QLineEdit { border: 2px solid #8e9dff; border-radius: 6px; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #7F94C4, stop: 1 #6479A9); color : rgb(204,204,255)}");
-
- std::string pA = qsPa.toStdString();
- const char *pA_c = NULL;
- pA_c = pA.c_str();
- setPalette(QColor(87,86,114));
-
- onglets->addTab(creerOngletPageWeb(tr(pA_c)), tr("(Nouvelle page)"));
- connect(onglets, SIGNAL(currentChanged(int)), this, SLOT(changementOnglet(int)));
- setCentralWidget(onglets);
- connect(dock, SIGNAL(visibilityChanged(bool)), this, SLOT(quitterHistorique()));
-
-
- setMinimumSize(500, 350);
- setWindowIcon(QIcon("imageformats/images/Nav-RY.png"));
- setWindowTitle(tr("Nav-RY"));
- setWindowState(Qt::WindowMaximized);
- //setWindowState(Qt::WindowFullScreen);
- creerOptions();
- host = 0;
- champAdresse->setText(qsPa);
-
- modifCouleur = false;
- setPalette(QColor(settings->value("Delta/Bravo").value<QColor>()));
-
- couleurMenus = settings->value("Charly/Zebra").value<QString>();
-
- te_sourceAva->setPlainText("QMenuBar {background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 lightgray, stop:1 darkgrey); }\n\n"
- "QMenuBar::item {"
- " spacing: 3px; padding: 1px 4px; background: transparent;"
- " border-radius: 4px;}\n\n"
- "QMenuBar::item:selected { background: #a8a8a8;}\n\nQMenuBar::item:pressed {background: #888888;}");
-
- if (couleurMenus != "") {
- menuBar()->setStyleSheet(couleurMenus);
- te_sourceAva->setPlainText(couleurMenus);
- }else{
- menuBar()->setStyleSheet(te_sourceAva->toPlainText());
- }
-
-
- visitP1 = new QPushButton(tr("Codes-Sources"));
- visitP2 = new QPushButton(tr("Developpez.net"));
- visitP3 = new QPushButton(tr("Comment ça marche"));
- visitP4 = new QPushButton(tr("Google France"));
- visitP5 = new QPushButton(tr("Site Du Zero"));
- visitP6 = new QPushButton(tr("Google Maps"));
- visitP7 = new QPushButton(tr("Qt Development"));
- visitP8 = new QPushButton(tr("Youtube"));
- visitP9 = new QPushButton(tr("Orange"));
-
- connect(visitP1, SIGNAL(clicked()),this, SLOT(b1()));
- connect(visitP2, SIGNAL(clicked()),this, SLOT(b2()));
- connect(visitP3, SIGNAL(clicked()),this, SLOT(b3()));
- connect(visitP4, SIGNAL(clicked()),this, SLOT(b4()));
- connect(visitP5, SIGNAL(clicked()),this, SLOT(b5()));
- connect(visitP6, SIGNAL(clicked()),this, SLOT(b6()));
- connect(visitP7, SIGNAL(clicked()),this, SLOT(b7()));
- connect(visitP8, SIGNAL(clicked()),this, SLOT(b8()));
- connect(visitP9, SIGNAL(clicked()),this, SLOT(b9()));
-
-
-
-
-
- connect(champAdresse, SIGNAL(textEdited(const QString &)), this, SLOT (sl_addsT()));
- connect(champAdresse, SIGNAL(editingFinished ()), this, SLOT (sl_addsF()));
- champGoogle->setFocus();
- //connect(onglets, SIGNAL(tabCloseRequested(int)), this, SLOT(fermerOnglet()));
- }
-
-
-
-
-
- void FenPrincipale::b1()
- {
- int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb("http://www.codes-sources.com/"), "Codes-sources");
- onglets->setCurrentIndex(indexNouvelOnglet);
- actualiser();
- }
- void FenPrincipale::b2()
- {
- int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb("http://www.developpez.net/"), "Developpez.net");
- onglets->setCurrentIndex(indexNouvelOnglet);
- actualiser();
- }
- void FenPrincipale::b3()
- {
- int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb("http://www.commentcamarche.net/"), "Comment ça marche");
- onglets->setCurrentIndex(indexNouvelOnglet);
- actualiser();
- }
- void FenPrincipale::b4()
- {
- int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb("http://www.google.fr"), "Google France");
- onglets->setCurrentIndex(indexNouvelOnglet);
- actualiser();
- }
- void FenPrincipale::b5()
- {
- int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb("http://www.siteduzero.com/"), "Site Du Zero");
- onglets->setCurrentIndex(indexNouvelOnglet);
- actualiser();
- }
- void FenPrincipale::b6()
- {
- int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb("http://maps.google.fr/"), "Google Maps");
- onglets->setCurrentIndex(indexNouvelOnglet);
- actualiser();
- }
- void FenPrincipale::b7()
- {
- int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb("http://www.qtsoftware.com"), "Qt development");
- onglets->setCurrentIndex(indexNouvelOnglet);
- actualiser();
- }
- void FenPrincipale::b8()
- {
- int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb("http://www.youtube.com"), "Youtube");
- onglets->setCurrentIndex(indexNouvelOnglet);
- actualiser();
- }
- void FenPrincipale::b9()
- {
- int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb("http://www.orange.fr"), "Orange");
- onglets->setCurrentIndex(indexNouvelOnglet);
- actualiser();
- }
-
-
-
- QString FenPrincipale::cryptIni (QString data)
- {
- QString done = data;
-
- std::string _stdDone = done.toStdString();
- const char* _chDone = _stdDone.c_str();
-
- QString _toReturn = "";
-
- for (int i = 0; i < done.size(); i++)
- {
- _toReturn += (_chDone[i] + '5');
- }
-
- return _toReturn;
- }
-
- QString FenPrincipale::decryptIni (QString data)
- {
- QString done = data;
-
- QString _toReturn = "";
-
- std::string _stdDone = done.toStdString();
- const char* _chDone = _stdDone.c_str();
-
- for (int i = 0; i < done.size(); i++)
- {
- _toReturn += (_chDone[i] - '5');
- }
-
- return _toReturn;
- }
- void FenPrincipale::sl_addsT()
- {
- champAdresse->setStyleSheet ( "QLineEdit { border: 2px solid #8e9dff; border-radius: 6px; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #ADBBDA, stop: 1 #7B8DB7); color : rgb(194,218,245)}");
-
- }
- void FenPrincipale::sl_addsF()
- {
- champAdresse->setStyleSheet ( "QLineEdit { border: 2px solid #8e9dff; border-radius: 6px; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #7F94C4, stop: 1 #6479A9); color : rgb(204,204,255)}");
- }
-
-
- FenPrincipale::~FenPrincipale()
- {
-
-
- }
-
-
- void FenPrincipale::setStyle(int numStyle)
- {
-
- QFile file ("source/style.rySource");
- if (! file.open (QIODevice::WriteOnly | QIODevice::Text))
- {
-
- }
- else
- {
-
- QTextStream out (& file);
- out << indexStyle;
- }
-
- }
-
- void FenPrincipale::appliqStyle()
- {
- int sT = getStyle();
- switch(sT)
- {
- case 0:
- sl_stylePlast();
- break;
- case 1:
- sl_styleClean();
- break;
- case 2:
- sl_styleXP();
- break;
- case 3:
- sl_styleWin();
- break;
- case 4:
- sl_styleMotif();
- break;
- case 5:
- sl_styleCDE();
- break;
- }
-
-
- }
-
- int FenPrincipale::getStyle()
- {
- QString line;
-
- QFile file("source/style.rySource");
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
- {
- indexStyle = 0;
- }
- else
- {
- while(!file.atEnd())
- {
-
- line = file.readLine();
-
-
- }
- if (line != "")
- {
- if(line == "0"){indexStyle = 0; co_style->setCurrentIndex(0);}
-
- else if(line == "1"){indexStyle = 1; co_style->setCurrentIndex(1);}
-
- else if(line == "2"){indexStyle = 2; co_style->setCurrentIndex(2);}
-
- else if(line == "3"){indexStyle = 3; co_style->setCurrentIndex(3);}
-
- else if(line == "4"){indexStyle = 4; co_style->setCurrentIndex(4);}
-
- else if(line == "5"){indexStyle = 5; co_style->setCurrentIndex(5);}
-
-
- }
-
-
-
- else
- {
- indexStyle = 0;
- }
- file.close();
-
- return indexStyle;
- }
-
-
- }
-
-
-
- void FenPrincipale::pleinEcran()
- {
- if (actPleinEcran->isChecked())
- {
- setWindowState(Qt::WindowFullScreen);
- } else {
- setWindowState(Qt::WindowMaximized);
- }
-
-
- }
-
-
-
- void FenPrincipale::creerActions()
- {
- actionNouvelOnglet = new QAction(tr("&Nouvel onglet"), this);
- actionNouvelOnglet->setShortcut(tr("Ctrl+T"));
- connect(actionNouvelOnglet, SIGNAL(triggered()), this, SLOT(nouvelOnglet()));
- actionFermerOnglet = new QAction(tr("&Fermer l'onglet"), this);
- actionFermerOnglet->setShortcut(tr("Ctrl+W"));
- connect(actionFermerOnglet, SIGNAL(triggered()), this, SLOT(fermerOnglet()));
- actionPrint = new QAction(tr("&Imprimer..."), this);
- connect(actionPrint, SIGNAL(triggered()), this, SLOT(sl_impression()));
-
- actionQuitter = new QAction(tr("&Quitter"), this);
- actionQuitter->setShortcut(tr("Ctrl+Q"));
- connect(actionQuitter, SIGNAL(triggered()), qApp, SLOT(quit()));
-
- actionHistorique = new QAction (tr("&Historique"), this);
- actionHistorique->setShortcut(tr("Ctrl+H"));
- actionHistorique->setCheckable(true);
-
-
- connect(actionHistorique, SIGNAL(triggered()), this, SLOT(afficherHistorique()));
-
-
- actPleinEcran = new QAction (tr("&Plein écran"), this);
- actPleinEcran->setCheckable(true);
- actPleinEcran->setChecked(false);
- actPleinEcran->setShortcut(tr("F11"));
- connect(actPleinEcran, SIGNAL (triggered()), this, SLOT (pleinEcran()));
-
- actionNPrivee = new QAction (tr("Navigation &Privée"), this);
- actionNPrivee->setShortcut(tr("Ctrl+F"));
- actionNPrivee->setCheckable(true);
- actionNPrivee->setChecked(true);
- connect(actionNPrivee, SIGNAL(triggered()), this, SLOT(navP()));
-
- actionHistoPlan = new QAction (QIcon("imageformats/images/histoPlan.png"), tr ("&Visual Store"), this);
- connect(actionHistoPlan, SIGNAL(triggered()), this, SLOT (sl_histoPlan()));
-
- actionPrecedente = new QAction(QIcon("imageformats/images/precedente2.png"), tr("&Precedente"), this);
- actionPrecedente->setShortcut(QKeySequence::Back);
- connect(actionPrecedente, SIGNAL(triggered()), this, SLOT(precedente()));
- actionSuivante = new QAction(QIcon("imageformats/images/suivante2.png"), tr("&Suivante"), this);
- actionSuivante->setShortcut(QKeySequence::Forward);
- connect(actionSuivante, SIGNAL(triggered()), this, SLOT(suivante()));
- actionStop = new QAction(QIcon("imageformats/images/stop2.png"), tr("S&top"), this);
- actionStop->setShortcut(tr("Ctrl+S"));
- connect(actionStop, SIGNAL(triggered()), this, SLOT(stop()));
- actionActualiser = new QAction(QIcon("imageformats/images/actualiser.png"), tr("&Actualiser"), this);
- actionActualiser->setShortcut(QKeySequence::Refresh);
- connect(actionActualiser, SIGNAL(triggered()), this, SLOT(actualiser()));
- actionAccueil = new QAction(QIcon("imageformats/images/accueil.png"), tr("A&ccueil"), this);
- actionAccueil->setShortcut(tr("Ctrl+U"));
- connect(actionAccueil, SIGNAL(triggered()), this, SLOT(accueil()));
- actionGo = new QAction(QIcon("imageformats/images/go2.png"), tr("A&ller à"), this);
- connect(actionGo, SIGNAL(triggered()), this, SLOT(chargerPage()));
-
- actionGoogle = new QAction(QIcon("imageformats/images/google.png"), tr("Recherche &Google"), this);
- actionGoogle->setShortcut(tr("Ctrl+G"));
- connect(actionGoogle, SIGNAL(triggered()), this, SLOT(googlePage()));
-
- actionAPropos = new QAction(tr("&A propos..."), this);
- connect(actionAPropos, SIGNAL(triggered()), this, SLOT(aPropos()));
- actionAPropos->setShortcut(QKeySequence::HelpContents);
- actionAProposQt = new QAction(tr("A propos de &Qt..."), this);
- connect(actionAProposQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
-
- actDown = new QAction(tr("Téléchargement..."), this);
- connect(actDown, SIGNAL(triggered()), this, SLOT(sl_down()));
-
- actionCopy = new QAction (tr("Copier"), this);
- actionCopy->setShortcut(QKeySequence::Copy);
- connect(actionCopy, SIGNAL(triggered()), this, SLOT(sl_copy()));
- actionCut = new QAction (tr("Couper"), this);
- actionCut->setShortcut(QKeySequence::Cut);
- connect(actionCut, SIGNAL(triggered()), this, SLOT(sl_cut()));
-
- actionParam = new QAction (tr("Paramètres"), this);
- actionParam->setShortcut(tr("Ctrl+K"));
- connect(actionParam, SIGNAL(triggered()), this, SLOT(sl_mParam()));
- b_cancel = new QPushButton("Annuler");
- b_ok = new QPushButton("Valider");
-
-
-
-
- connect(b_ok, SIGNAL(clicked()), this,SLOT(sl_validationParam()));
- colorBout = new QPushButton("Choisir");
- connect(colorBout, SIGNAL(clicked()), this,SLOT(sl_choixCouleur()));
- actHost = new QAction(tr("Host"), this);
- connect(actHost, SIGNAL(triggered()), this,SLOT(sl_hosting()));
-
-
- }
-
- void FenPrincipale::sl_down()
- {
- QMainWindow *w = new QMainWindow(this);
- lineAdress = new QLineEdit;
- bout = new QPushButton("Obtenir le fichier");
- QVBoxLayout *lay = new QVBoxLayout;
- lay->addWidget(lineAdress);
- lay->addWidget(bout);
-
- QWidget *all = new QWidget;
- all->setLayout(lay);
- w->setCentralWidget(all);
- w->setWindowIcon(QIcon("imageformats/images/Nav-RY.png"));
- w->setFixedSize(370,100);
- w->setWindowTitle("Ry-HttpGet");
- connect (bout, SIGNAL(clicked()), this, SLOT(getFile()));
- connect(&http, SIGNAL(done(bool)), this, SLOT(httpDone(bool)));
- w->show();
- }
-
- void FenPrincipale::sl_choixCouleur()
- {
- QColor ac = couleur;
-
- couleur = QColorDialog::getColor(Qt::white, myParamWindow);
-
-
-
- if(couleur != ac)
- {
- modifCouleur = true;
- }
- }
-
- void FenPrincipale::sl_mParam()
- {
- myParamWindow = new QMainWindow;
-
- QMdiArea *mdiFen = new QMdiArea;
-
- QFrame *zn_generale = new QFrame;
- QFrame *zn_avance = new QFrame;
-
-
- QGridLayout *layGAva = new QGridLayout;
-
-
- QHBoxLayout *layGGen = new QHBoxLayout;
- QVBoxLayout *layGGen_g = new QVBoxLayout;
- QVBoxLayout *layGGen_d = new QVBoxLayout;
-
- co_style->setCurrentIndex(getStyle());
-
- QFormLayout *layFGGen = new QFormLayout;
- layFGGen->addRow("Page d'accueil : ", le_pageAcc);
- layFGGen->addRow("Style : ", co_style);
- layFGGen->addRow("Couleur : ", colorBout);
-
- co_style->setStyleSheet ( "QComboBox { border: 2px solid #8e9dff; border-radius: 6px; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #7F94C4, stop: 1 #6479A9)} QComboBox:on {color : rgb(215,215,255)}");
- le_pageAcc->setStyleSheet ( "QLineEdit { border: 2px solid #8e9dff; border-radius: 6px; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #7F94C4, stop: 1 #6479A9)}");
- colorBout->setStyleSheet ( "QPushButton { border: 2px solid #8e9dff; border-radius: 6px; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #7F94C4, stop: 1 #6479A9)}");
- layGGen_g->addWidget(ch_genNavP);
- layGGen_g->addLayout(layFGGen);
-
- layGGen->addLayout(layGGen_g);
- layGGen->addLayout(layGGen_d);
-
-
- layGAva->addWidget(te_sourceAva,0,0);
-
- zn_generale->setLayout(layGGen);
- zn_avance->setLayout(layGAva);
-
- QMdiSubWindow *sFenGenerale = mdiFen->addSubWindow(zn_generale);
- QMdiSubWindow *sFenAvance = mdiFen->addSubWindow(zn_avance);
-
- sFenGenerale->setWindowTitle("Général");
- sFenAvance->setWindowTitle("Avancé");
-
- mdiFen->setViewMode(QMdiArea::TabbedView);
-
- QVBoxLayout *myLay = new QVBoxLayout;
- QHBoxLayout *myLayOfBout = new QHBoxLayout;
- connect(b_cancel, SIGNAL(clicked()), myParamWindow, SLOT(close()));
- connect(b_ok, SIGNAL(clicked()), myParamWindow, SLOT(close()));
-
- myLayOfBout->addWidget(b_cancel);
- myLayOfBout->addWidget(b_ok);
- myLay->addWidget(mdiFen);
- myLay->addLayout(myLayOfBout);
- QFrame *myFrame = new QFrame;
- myFrame->setLayout(myLay);
- myParamWindow->setCentralWidget(myFrame);
- myParamWindow->setGeometry(200,200,400,300);
- myParamWindow->setWindowTitle(tr("Paramètres"));
- myParamWindow->setWindowOpacity(0.95);
- myParamWindow->setWindowIcon(QIcon("imageformats/images/Nav-RY.png"));
-
- myParamWindow->setStyleSheet ( "QPushButton { border: 2px solid #8e9dff; border-radius: 6px; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #b48250, stop: 1 #c69b69); min-width: 80px; }");
- myParamWindow->setFixedSize(400,300);
- myParamWindow->show();
- te_sourceAva->setFont(QFont("Courier New"));
- mdiFen->setActiveSubWindow(sFenGenerale);
-
- }
- void FenPrincipale::sl_validationParam()
- {
- if(modifCouleur)
- {
- QPalette palette;
- setPalette(QPalette(QColor(couleur)));
- setAutoFillBackground(true);
- settings->setValue("Delta/Bravo", couleur);
-
- modifCouleur = false;
- }
- QString url = le_pageAcc->text();
- QString pageA;
- pageA = url;
- le_pageAcc->setText(pageA);
- QString _pageA = cryptIni(pageA);
- settings->setValue("Alpha/Tango", _pageA);
-
- if(ch_genNavP->isChecked() == true)
- {
- m_navP = true;
- setWindowOpacity(1);
- actionNPrivee->setChecked(true);
- }
- else
- {
- m_navP = false;
- setWindowOpacity(0.875);
- actionNPrivee->setChecked(false);
- }
-
- switch(co_style->currentIndex())
- {
- case 0:
- sl_stylePlast();
-
- break;
- case 1:
- sl_styleClean();
-
- break;
- case 2:
- sl_styleXP();
-
- break;
- case 3:
- sl_styleWin();
-
- break;
- case 4:
- sl_styleMotif();
-
- break;
- case 5:
- sl_styleCDE();
-
- break;
-
- }
- menuBar()->setStyleSheet (te_sourceAva->toPlainText());
- couleurMenus = te_sourceAva->toPlainText();
- settings->setValue("Charly/Zebra", couleurMenus);
- te_sourceAva->setPlainText(couleurMenus);
- }
-
-
-
- void FenPrincipale::sl_copy()
- {
- QString actualText = pageActuelle()->selectedText();
- QClipboard* copier = QApplication::clipboard();
- copier->setText(actualText);
-
-
- }
-
- void FenPrincipale::sl_cut()
- {
- QString actualText = pageActuelle()->selectedText();
- QClipboard* copier = QApplication::clipboard();
- copier->setText(actualText);
- }
-
- void FenPrincipale::sl_impression()
- {
-
- QPrinter impression(QPrinter::HighResolution);
- QPrintDialog *dialogImpression = new QPrintDialog(&impression, this);
- dialogImpression->show();
- QWebView *w_b = pageActuelle();
- QWebFrame *w_f = w_b->findChild<QWebFrame *>();
- w_f->print(&impression);
- }
-
- void FenPrincipale::sl_codeS()
- {
- QWebView *w_b = pageActuelle();
- QWebFrame *w_f = w_b->findChild<QWebFrame *>();
-
- QString cs = w_f->toHtml();
- QMainWindow *myW = new QMainWindow(this);
- QTextEdit *myT = new QTextEdit;
- QFont f ("MS Reference Sans Serif",8);
-
- myT->setCurrentFont(f);
- myT->setPlainText(cs);
- myW->setCentralWidget(myT);
- myW->setMinimumSize(600,500);
- myW->show();
- }
-
- void FenPrincipale::sl_styleXP()
- {
-
- QApplication::setStyle(new QWindowsXPStyle);
- indexStyle = 2;
- setStyle(indexStyle);
- }
-
- void FenPrincipale::sl_styleWin()
- {
- QApplication::setStyle(new QWindowsStyle);
- indexStyle = 3;
- setStyle(indexStyle);
- }
-
- void FenPrincipale::sl_stylePlast()
- {
-
- QApplication::setStyle(new QPlastiqueStyle);
- indexStyle = 0;
- setStyle(indexStyle);
- }
-
-
- void FenPrincipale::sl_styleCDE()
- {
-
- QApplication::setStyle(new QCDEStyle);
- indexStyle = 5;
- setStyle(indexStyle);
- }
-
- void FenPrincipale::sl_styleMotif()
- {
-
- QApplication::setStyle(new QMotifStyle);
- indexStyle = 4;
- setStyle(indexStyle);
- }
-
- void FenPrincipale::sl_styleClean()
- {
-
- QApplication::setStyle(new QCleanlooksStyle);
- indexStyle = 1;
- setStyle(indexStyle);
- }
-
-
- void FenPrincipale::navP()
- {
- if(actionNPrivee->isChecked())
- {
- m_navP = true;
- QSettings settings;
- settings.beginGroup(QLatin1String("websettings"));
-
- QWebSettings *defaultSettings = QWebSettings::globalSettings();
- defaultSettings->setAttribute(QWebSettings::PrivateBrowsingEnabled, settings.value(QLatin1String("enablePrivateBrowsing"), true).toBool());
- ch_genNavP->setChecked(true);
- setWindowOpacity(1);
- }
- else
- {
- QSettings settings;
- settings.beginGroup(QLatin1String("websettings"));
-
- QWebSettings *defaultSettings = QWebSettings::globalSettings();
- defaultSettings->setAttribute(QWebSettings::PrivateBrowsingEnabled, settings.value(QLatin1String("enablePrivateBrowsing"), false).toBool());
- ch_genNavP->setChecked(false);
- m_navP = false;
- setWindowOpacity(0.875);
- }
- }
-
- void FenPrincipale::creerMenus()
- {
-
- QMenu *menuFichier = menuBar()->addMenu(tr("&Ry-Nav"));
-
- menuFichier->addAction(actionNouvelOnglet);
- menuFichier->addAction(actionFermerOnglet);
- menuFichier->addAction(actionPrint);
- menuFichier->addSeparator();
- menuFichier->addAction(actionQuitter);
-
-
- QMenu *menuEdition = menuBar()->addMenu(tr("&Edition"));
- menuEdition->addAction(actionCopy);
- menuEdition->addAction(actionCut);
-
- QMenu *menuAffichage = menuBar()->addMenu(tr("&Affichage"));
-
- menuAffichage->addAction(actPleinEcran);
- menuAffichage->addAction(actionHistorique);
-
-
-
-
-
- QMenu *menuNavigation = menuBar()->addMenu(tr("&Navigation"));
- QMenu *smenuOption = menuNavigation->addMenu(tr("&Options"));
- smenuOption->addAction(actionNPrivee);
- smenuOption->addAction(actionParam);
- QMenu *smenuActions = menuNavigation->addMenu(tr("&Actions"));
- menuNavigation->addSeparator();
- menuNavigation->addAction(actDown);
- menuNavigation->addAction(actHost);
- actCS = menuNavigation->addAction(tr("Code source"));
- smenuActions->addAction(actionHistoPlan);
- smenuActions->addAction(actionPrecedente);
- smenuActions->addAction(actionSuivante);
- smenuActions->addAction(actionStop);
- smenuActions->addAction(actionActualiser);
- smenuActions->addAction(actionAccueil);
- smenuActions->addAction(actionGoogle);
-
-
-
- QMenu *menuStyle = menuBar()->addMenu("&Style");
- QMenu *theme = menuStyle->addMenu("&Thèmes");
- actPlast = theme->addAction("Plastique");
- actClean = theme->addAction("Cleanlooks");
- actXP = theme->addAction("Windows XP");
- actWin = theme->addAction("Windows");
- actMotif = theme->addAction("Motif");
- actCDE = theme->addAction("CDE");
-
- connect(actCS, SIGNAL(triggered()),this, SLOT(sl_codeS()));
- connect(actPlast, SIGNAL(triggered()),this, SLOT(sl_stylePlast()));
- connect(actXP, SIGNAL(triggered()),this, SLOT(sl_styleXP()));
- connect(actWin, SIGNAL(triggered()),this, SLOT(sl_styleWin()));
- connect(actClean, SIGNAL(triggered()),this, SLOT(sl_styleClean()));
- connect(actMotif, SIGNAL(triggered()),this, SLOT(sl_styleMotif()));
- connect(actCDE, SIGNAL(triggered()),this, SLOT(sl_styleCDE()));
-
- QMenu *menuAide = menuBar()->addMenu(tr("&?"));
-
- menuAide->addAction(actionAPropos);
- menuAide->addAction(actionAProposQt);
-
- menuBar()->setStyleSheet ( "QMenuBar {background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 lightgray, stop:1 darkgrey); }"
- "QMenuBar::item {"
- " spacing: 3px; padding: 1px 4px; background: transparent;"
- " border-radius: 4px;}"
- "QMenuBar::item:selected { background: #a8a8a8;} QMenuBar::item:pressed {background: #888888;}");
- }
-
-
- void FenPrincipale::creerBarresOutils()
- {
-
- champAdresse = new QLineEdit;
- champGoogle = new QLineEdit;
- champGoogle->setFixedWidth(130);
- champGoogle->setStyleSheet("QLineEdit {background : qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #7F94C4, stop: 1 #6479A9); color : black}");
- connect(champGoogle, SIGNAL(returnPressed()), this, SLOT(rechercheGoogle()));
-
- connect(champAdresse, SIGNAL(returnPressed()), this, SLOT(chargerPage()));
-
- QToolBar *toolBarNavigation = addToolBar(tr("Navigation"));
-
- toolBarNavigation->addAction(actionHistoPlan);
- toolBarNavigation->addAction(actionPrecedente);
- toolBarNavigation->addAction(actionSuivante);
- toolBarNavigation->addAction(actionStop);
- toolBarNavigation->addAction(actionActualiser);
- toolBarNavigation->addAction(actionAccueil);
- toolBarNavigation->addWidget(champAdresse);
- toolBarNavigation->addAction(actionGo);
- toolBarNavigation->addWidget(champGoogle);
- toolBarNavigation->addAction(actionGoogle);
- }
-
- void FenPrincipale::rechercheGoogle()
- {
- QString urlG ="http://www.google.fr/search?hl=fr&q=";
- urlG += champGoogle->text();
- urlG += "&btnG=Recherche+Google&meta=&aq=f&oq=";
-
- pageActuelle()->load(QUrl(urlG));
- //videChampGoogle();
- }
-
- void FenPrincipale::videChampGoogle()
- {
- champGoogle->setText("");
- champGoogle->setFocus();
-
- }
-
-
- void FenPrincipale::creerHistorique()
- {
- dock = new QDockWidget("Historique", this);
- vbox = new QVBoxLayout;
-
- TEHisto = new QTextEdit;
-
- frame = new QFrame;
-
-
- TEHisto->setPlainText(text);
- vbox->addWidget(TEHisto);
- frame->setLayout(vbox);
- dock->setWidget(frame);
- addDockWidget(Qt::RightDockWidgetArea, dock);
-
- dock->setWindowOpacity(0.85);
- QColor bleu(0,0,45);
- QPalette palette;
- palette.setColor(QPalette::Base,bleu);
- dock->setPalette(palette);
- QColor blanc(255,255,255);
- TEHisto->setTextColor(blanc);
-
- dock->setVisible(false);
- }
-
- void FenPrincipale::creerOptions()
- {
-
- QSettings settings;
- settings.beginGroup(QLatin1String("websettings"));
-
- QWebSettings *defaultSettings = QWebSettings::globalSettings();
- QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont);
- int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize);
- QFont standardFont = QFont(standardFontFamily, standardFontSize);
- standardFont = qVariantValue<QFont>(settings.value(QLatin1String("standardFont"), standardFont));
- defaultSettings->setFontFamily(QWebSettings::StandardFont, standardFont.family());
- defaultSettings->setFontSize(QWebSettings::DefaultFontSize, standardFont.pointSize());
-
- QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont);
- int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize);
- QFont fixedFont = QFont(fixedFontFamily, fixedFontSize);
- fixedFont = qVariantValue<QFont>(settings.value(QLatin1String("fixedFont"), fixedFont));
- defaultSettings->setFontFamily(QWebSettings::FixedFont, fixedFont.family());
- defaultSettings->setFontSize(QWebSettings::DefaultFixedFontSize, fixedFont.pointSize());
-
- defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, settings.value(QLatin1String("enableJavascript"), true).toBool());
- defaultSettings->setAttribute(QWebSettings::PluginsEnabled, settings.value(QLatin1String("enablePlugins"), true).toBool());
- defaultSettings->setAttribute(QWebSettings::JavaEnabled, settings.value(QLatin1String("enableJava"), true).toBool());
-
- defaultSettings->setAttribute(QWebSettings::PrivateBrowsingEnabled, settings.value(QLatin1String("enablePrivateBrowsing"), true).toBool());
- defaultSettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, settings.value(QLatin1String("enableJavascriptCanOpenWindows"), true).toBool());
- defaultSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, settings.value(QLatin1String("enableJavascriptCanAccessClipboard"), true).toBool());
-
-
- settings.endGroup();
- ch_genNavP = new QCheckBox("Navigation privée");
- ch_genNavP->setChecked(true);
-
- le_pageAcc = new QLineEdit(qsPa);
- co_style = new QComboBox;
- co_style->addItem("Plastique");
- co_style->addItem("Cleanlooks");
- co_style->addItem("Windows XP");
- co_style->addItem("Windows");
- co_style->addItem("Motif");
- co_style->addItem("CDE");
-
-
-
-
- }
-
- void FenPrincipale::afficherHistorique()
- {
-
-
-
- if (actionHistorique->isChecked())
- {
- Historique();
- dock->setVisible(true);
- }
- else
- {
- dock->setVisible(false);
- }
-
- }
-
-
-
- void FenPrincipale::quitterHistorique()
- {
- if (dock->isVisible())
- {
- actionHistorique->setChecked(true);
- }
- else
- {
- actionHistorique->setChecked(false);
- }
- }
-
-
-
-
- void FenPrincipale::creerBarreEtat()
- {
- QLabel *infos = new QLabel ("Pop70");
- statusBar()->addPermanentWidget(infos);
- progression = new QProgressBar(this);
- progression->setVisible(false);
- progression->setMaximumHeight(14);
- statusBar()->addWidget(progression, 1);
-
- }
-
-
- QWidget *FenPrincipale::creerOngletPageWeb(QString url)
- {
- QWidget *pageOnglet = new QWidget;
- QWebView *pageWeb = new QWebView;
- pageWeb->setStyleSheet(" QWebView {background : rgb(238,238,238); color : blue}");
- QVBoxLayout *layout = new QVBoxLayout;
- layout->setContentsMargins(0,0,0,0);
- layout->addWidget(pageWeb);
- pageOnglet->setLayout(layout);
-
- if (url.isEmpty())
- {
- pageWeb->load(QUrl(tr("html/page_blanche.html")));
- }
-
-
- else
- {
- pageWeb->load(QUrl(url));
- }
-
-
-
- connect(pageWeb, SIGNAL(titleChanged(QString)), this, SLOT(changementTitre(QString)));
- connect(pageWeb, SIGNAL(urlChanged(QUrl)), this, SLOT(changementUrl(QUrl)));
- connect(pageWeb, SIGNAL(loadStarted()), this, SLOT(chargementDebut()));
- connect(pageWeb, SIGNAL(loadProgress(int)), this, SLOT(chargementEnCours(int)));
- connect(pageWeb, SIGNAL(loadFinished(bool)), this, SLOT(chargementTermine(bool)));
-
- return pageOnglet;
- }
-
-
- QWidget *FenPrincipale::histoPlan()
- {
-
- QWidget *pageOnglet = new QWidget;
-
- QWebView *pageWeb_1 = new QWebView;
- QWebView *pageWeb_2 = new QWebView;
- QWebView *pageWeb_3 = new QWebView;
- QWebView *pageWeb_4 = new QWebView;
- QWebView *pageWeb_5 = new QWebView;
- QWebView *pageWeb_6 = new QWebView;
- QWebView *pageWeb_7 = new QWebView;
- QWebView *pageWeb_8 = new QWebView;
- QWebView *pageWeb_9 = new QWebView;
-
-
-
-
- pageWeb_1->load(QUrl(tr("http://www.codes-sources.com/")));
- pageWeb_2->load(QUrl(tr("http://www.developpez.net/")));
- pageWeb_3->load(QUrl(tr("http://www.commentcamarche.net/")));
- pageWeb_4->load(QUrl(tr("http://www.google.fr")));
- pageWeb_5->load(QUrl(tr("http://www.siteduzero.com/")));
- pageWeb_6->load(QUrl(tr("http://maps.google.fr/")));
- pageWeb_7->load(QUrl(tr("http://www.qtsoftware.com")));
- pageWeb_8->load(QUrl(tr("http://www.youtube.com")));
- pageWeb_9->load(QUrl(tr("http://www.orange.fr")));
-
-
-
- pageWeb_1->setZoomFactor(0.50);
- pageWeb_2->setZoomFactor(0.50);
- pageWeb_3->setZoomFactor(0.50);
- pageWeb_4->setZoomFactor(0.50);
- pageWeb_5->setZoomFactor(0.50);
- pageWeb_6->setZoomFactor(0.50);
- pageWeb_7->setZoomFactor(0.50);
- pageWeb_8->setZoomFactor(0.50);
- pageWeb_9->setZoomFactor(0.60);
-
-
- QHBoxLayout *layoutH_1To3 = new QHBoxLayout;
- layoutH_1To3->addWidget(pageWeb_1);
- layoutH_1To3->addWidget(pageWeb_2);
- layoutH_1To3->addWidget(pageWeb_3);
- QHBoxLayout *layoutB_1To3 = new QHBoxLayout;
- layoutB_1To3->addWidget(visitP1);
- layoutB_1To3->addWidget(visitP2);
- layoutB_1To3->addWidget(visitP3);
-
- QHBoxLayout *layoutH_4To6 = new QHBoxLayout;
-
- layoutH_4To6->addWidget(pageWeb_4);
- layoutH_4To6->addWidget(pageWeb_5);
- layoutH_4To6->addWidget(pageWeb_6);
- QHBoxLayout *layoutB_4To6 = new QHBoxLayout;
- layoutB_4To6->addWidget(visitP4);
- layoutB_4To6->addWidget(visitP5);
- layoutB_4To6->addWidget(visitP6);
-
- QHBoxLayout *layoutH_7To9 = new QHBoxLayout;
- layoutH_7To9->addWidget(pageWeb_7);
- layoutH_7To9->addWidget(pageWeb_8);
- layoutH_7To9->addWidget(pageWeb_9);
- QHBoxLayout *layoutB_7To9 = new QHBoxLayout;
- layoutB_7To9->addWidget(visitP7);
- layoutB_7To9->addWidget(visitP8);
- layoutB_7To9->addWidget(visitP9);
-
- QVBoxLayout *layoutOfLays = new QVBoxLayout;
- layoutOfLays->addLayout(layoutH_1To3);
- layoutOfLays->addLayout(layoutB_1To3);
- layoutOfLays->addLayout(layoutH_4To6);
- layoutOfLays->addLayout(layoutB_4To6);
- layoutOfLays->addLayout(layoutH_7To9);
- layoutOfLays->addLayout(layoutB_7To9);
-
-
-
- pageOnglet->setLayout(layoutOfLays);
-
-
- return pageOnglet;
- }
-
-
- QWebView *FenPrincipale::pageActuelle()
- {
- return onglets->currentWidget()->findChild<QWebView *>();
- }
-
-
-
- void FenPrincipale::precedente()
- {
- pageActuelle()->back();
- }
-
-
-
- void FenPrincipale::suivante()
- {
- pageActuelle()->forward();
- }
-
-
-
- void FenPrincipale::accueil()
- {
- pageActuelle()->load(QUrl(tr(qsPa.toStdString().c_str())));
- }
- void FenPrincipale::googlePage()
- {
-
-
- if(champGoogle->text() == "")
- {
- pageActuelle()->load(QUrl(tr("http://www.google.fr")));
- }
- else
- {
- rechercheGoogle();
- }
-
-
- }
-
-
- void FenPrincipale::stop()
- {
- pageActuelle()->stop();
- }
-
-
-
- void FenPrincipale::actualiser()
- {
- pageActuelle()->reload();
-
- }
-
-
- void FenPrincipale::Historique()
- {
-
- TEHisto->setPlainText(text);
-
- }
-
-
-
-
-
- void FenPrincipale::aPropos()
- {
- QMessageBox::information(this, tr("A propos..."), tr("Nav-RY est un navigateur programmé par Pop70.<br>Il est interdit d'en faire une utilisation commerciale."));
- }
-
-
-
- void FenPrincipale::nouvelOnglet()
- {
-
- int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb(), tr("(Nouvelle page)"));
-
- onglets->setCurrentIndex(indexNouvelOnglet);
-
- champAdresse->setText("");
- champAdresse->setFocus(Qt::OtherFocusReason);
- }
-
- void FenPrincipale::sl_histoPlan()
- {
-
- int indexNouvelOnglet = onglets->addTab(histoPlan(), "Visual Store");
-
- onglets->setCurrentIndex(indexNouvelOnglet);
-
- champAdresse->setText("");
- champAdresse->setFocus(Qt::OtherFocusReason);
- onglets->setTabText(onglets->currentIndex(), "Visual Story");
-
- }
-
-
- void FenPrincipale::fermerOnglet(int onglet)
- {
- if (onglet == -1)
- {
-
- if (onglets->count() > 1)
- {
- pageActuelle()->deleteLater();
- onglets->removeTab(onglets->currentIndex());
-
-
- }
- else
- {
- QMessageBox::critical(this, tr("Erreur"), tr("Il faut au moins un onglet !"));
- }
- }
-
- else
- {
- if (onglets->count() > 1)
- {
- pageActuelle()->deleteLater();
- onglets->removeTab(onglet);
-
-
- }
- else
- {
- QMessageBox::critical(this, tr("Erreur"), tr("Il faut au moins un onglet !"));
- }
- }
- }
-
-
-
- void FenPrincipale::chargerPage()
- {
- QString url = champAdresse->text();
- bool ch = false;
-
- if(url == "about:config")
- {
- sl_mParam();
- ch = true;
- }
-
- if(!ch)
- {
- pageActuelle()->load(QUrl(url));
- QString a = "start" + url;
- std::string e = a.toStdString();
- const char *ak = e.c_str();
- if (url.right(4) == ".jpg")
- {
- system (ak);
- }
- }
- }
-
-
-
- void FenPrincipale::changementOnglet(int index)
- {
- changementTitre(pageActuelle()->title());
- changementUrl(pageActuelle()->url());
- }
-
-
-
- void FenPrincipale::changementTitre(const QString & titreComplet)
- {
- QString titreCourt = titreComplet;
-
-
- if (titreComplet.size() > 40)
- {
- titreCourt = titreComplet.left(40) + "...";
- }
-
- setWindowTitle(titreCourt + " - " + tr("Nav-RY"));
- onglets->setTabText(onglets->currentIndex(), titreCourt);
-
- }
-
-
-
- void FenPrincipale::changementUrl(const QUrl & url)
- {
- if (url.toString() != tr("html/page_blanche.html"))
- {
- champAdresse->setText(url.toString());
- QString urls = champAdresse->text();
- text += urls + "\n";
-
- Historique();
- if (m_navP)
- {
- }
- else
- {
- QFile file("Historique.txt");
- if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))
- return;
-
- QTextStream out(&file);
- out << text;
- }
-
- }
-
- }
-
-
-
- void FenPrincipale::chargementDebut()
- {
- progression->setVisible(true);
- }
-
-
-
- void FenPrincipale::chargementEnCours(int pourcentage)
- {
- progression->setValue(pourcentage);
- }
-
-
-
- void FenPrincipale::chargementTermine(bool ok)
- {
- progression->setVisible(false);
- statusBar()->showMessage(tr("Prêt"), 2000);
- }
-
-
- void FenPrincipale::sl_hosting()
- {
- if (!host){
- host = new Host (this);
- }
- host->show();
- }
-
-
-
- void FenPrincipale::getFile()
- {
- QUrl url = lineAdress->text();
- bool no = false;
- if (!url.isValid()) {
- QMessageBox::critical (this, "Erreur","Erreur: URL invalide" );
- no = true;
- }
-
- if (url.scheme() != "http") {
- QMessageBox::critical (this, "Erreur","Erreur: L'URL doit commencer par 'http:'" );
- no = true;
- }
-
- if (url.path().isEmpty()) {
- QMessageBox::critical (this, "Erreur","Erreur: L'URL n'a pas de chemin" );
- no = true;
- }
- if(!no) {
- QString localFileName;
- QString dir = QFileDialog::getSaveFileName(this, "Enregistrer le document", QString(), "Tous les fichiers (*.*)");
- if(!dir.isEmpty()) {
-
- localFileName = dir;
-
-
- if (localFileName.isEmpty())
- localFileName = "httpget.out";
-
- file.setFileName(localFileName);
- if (!file.open(QIODevice::WriteOnly)) {
-
- QString za = "Erreur: Ne peut pas ouvrir<br />";
- za+= qPrintable(file.fileName());
- za+= " pour écriture: <br />";
- za += qPrintable(file.errorString());
-
- QMessageBox::critical (this, "Erreur",za);
-
-
- }
-
- http.setHost(url.host(), url.port(80));
- http.get(url.path(), &file);
- http.close();
-
- }
- }
- }
-
- void FenPrincipale::httpDone(bool error)
- {
- if (error) {
- QString za = "Erreur: ";
- za += qPrintable(http.errorString());
- QMessageBox::critical (this, "Erreur", za);
- } else {
- QString za ="Le fichier a été télechargé dans : <br />";
- za += qPrintable(file.fileName());
- QMessageBox::information (this, "Erreur",za);
- }
- file.close();
- emit done();
- }
-
- //main.cpp
-
- #include <QApplication>
- #include <QTranslator>
- #include <QLocale>
- #include <QLibraryInfo>
- #include "NavRY.h"
-
-
- int main(int argc, char* argv[])
- {
- QApplication app(argc, argv);
-
- QString locale = QLocale::system().name();
- QTranslator translator;
- translator.load(QString("qt_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
- app.installTranslator(&translator);
-
-
- FenPrincipale principale;
- principale.show();
-
- return app.exec();
- }
//Host.h
#ifndef HEADER_HOST
#define HEADER_HOST
#include <QtGui>
class Host : public QMainWindow
{
Q_OBJECT
public:
Host(QWidget *parent = 0);
void nouvelIp();
void enregistrer(QString &texteAEnregistrer);
void effacer();
public slots:
void nouveauProtocole();
void rediger();
void ouvrir();
void remplacer();
void changerApparence(bool plast);
private:
QList<QLineEdit *> ligneProtocole;
QList<QLineEdit *> ligneIp;
QVBoxLayout *layPro;
QVBoxLayout *layProIp;
QWidget *centre;
int nbProtocoles;
QTextEdit *texteHost;
QVBoxLayout *layOuv;
QTextEdit *ouvert;
QPushButton *boutOuv;
QFrame *fr;
QLineEdit *adresseLE;
};
#endif
//Host.cpp
#include "Host.h"
Host::Host(QWidget *parent) : QMainWindow (parent)
{
QApplication::setStyle(new QPlastiqueStyle);
nbProtocoles = 0;
layPro = new QVBoxLayout;
layProIp = new QVBoxLayout;
centre = new QWidget;
texteHost = new QTextEdit;
ouvert = new QTextEdit;
layOuv = new QVBoxLayout;
boutOuv = new QPushButton("Enregistrer");
QLabel *sites = new QLabel("Redirection de (URL) : ");
QLabel *ip = new QLabel("Vers (DNS) : ");
QMenu *menuRy = new QMenu;
menuRy = menuBar()->addMenu("&Ry-Hosts");
QAction *actQuitter = new QAction("&Quitter", this);
QAction *actChemin = new QAction("Affichier le &chemin", this);
actChemin->setShortcut(QKeySequence("Ctrl+K"));
actChemin->setCheckable(true);
QAction *actApparence = new QAction("&Apparence Perso", this);
actApparence->setCheckable(true);
actApparence->setShortcut(QKeySequence("Ctrl+L"));
actApparence->setChecked(true);
menuRy->addAction(actChemin);
menuRy->addAction(actApparence);
menuRy->addAction(actQuitter);
actQuitter->setShortcut(QKeySequence("Escape"));
adresseLE = new QLineEdit;
adresseLE->setVisible(false);
QPushButton *nouveau = new QPushButton("Nouveau Protocole");
QPushButton *rediger = new QPushButton("Valider");
QPushButton *ouvrir = new QPushButton("Ouvrir");
QPushButton *quitter = new QPushButton("Quitter");
QHBoxLayout *layProP = new QHBoxLayout;
layPro->addWidget(sites);
layProIp->addWidget(ip);
layProP->addWidget(nouveau);
layProP->addWidget(rediger);
layProP->addWidget(ouvrir);
layProP->addWidget(quitter);
layOuv->addWidget(ouvert);
layOuv->addWidget(boutOuv);
fr = new QFrame;
fr->setLayout(layOuv);
nouveauProtocole();
QHBoxLayout *param = new QHBoxLayout;
param->addLayout(layPro);
param->addLayout(layProIp);
QVBoxLayout *toutLay = new QVBoxLayout;
toutLay->addLayout(param);
toutLay->addLayout(layProP);
centre->setLayout(toutLay);
QStatusBar *barreEtat = statusBar();
barreEtat->showMessage("Prêt");
adresseLE->setText("C:/WINDOWS/system32/drivers/etc/hosts");
barreEtat->addPermanentWidget(adresseLE);
resize(460,143);
setWindowTitle("RY-Host");
setCentralWidget(centre);
QObject::connect(actApparence, SIGNAL(toggled(bool)), this, SLOT(changerApparence(bool)));
QObject::connect(actChemin, SIGNAL(toggled(bool)), adresseLE, SLOT(setVisible(bool)));
QObject::connect(actQuitter, SIGNAL(triggered()), qApp, SLOT(quit()));
QObject::connect(boutOuv, SIGNAL(clicked()), this, SLOT(remplacer()));
QObject::connect(ouvrir, SIGNAL(clicked()), this, SLOT(ouvrir()));
QObject::connect(nouveau, SIGNAL(clicked()), this, SLOT(nouveauProtocole()));
QObject::connect(rediger, SIGNAL(clicked()), this, SLOT(rediger()));
QObject::connect(quitter, SIGNAL(clicked()), this, SLOT(close()));
}
void Host::nouveauProtocole()
{
ligneProtocole.append(new QLineEdit);
layPro->addWidget(ligneProtocole.at(nbProtocoles));
nouvelIp();
nbProtocoles++;
}
void Host::nouvelIp()
{
ligneIp.append(new QLineEdit("127.0.0.1"));
layProIp->addWidget(ligneIp.at(nbProtocoles));
ligneProtocole.at(nbProtocoles)->setFocus();
}
void Host::rediger()
{
QString host;
for(int i = 0; i < nbProtocoles; i++)
{
QString site = ligneProtocole.at(i)->text();
QString ips = ligneIp.at(i)->text();
if (site != "")
{
host += ("\n" + ips);
host += (" " + site + "\n");
}
}
QString affiche = "#Redirection de RY-Host à ajouter\n" + host;
effacer();
enregistrer(host);
}
void Host::enregistrer(QString &texteAEnregistrer)
{
QString fichier = adresseLE->text();
QFile hfile(fichier);
if (! hfile.open (QIODevice::Append | QIODevice::Text))
return;
QTextStream out (& hfile);
out << texteAEnregistrer;
}
void Host::effacer()
{
for(int i = 0; i < nbProtocoles ; i++)
{
ligneProtocole.at(i)->setText("");
ligneIp.at(i)->setText("127.0.0.1");
}
}
void Host::ouvrir()
{
QString line;
QFile file(adresseLE->text());
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
while(!file.atEnd())
{
line += file.readLine();
}
ouvert->setPlainText(line);
ouvert->setMinimumSize(400,300);
fr->show();
}
void Host::remplacer()
{
QString fichier = adresseLE->text();
QFile hfile(fichier);
if (! hfile.open (QIODevice::WriteOnly | QIODevice::Text))
return;
QTextStream out (& hfile);
out << ouvert->toPlainText();
fr->close();
}
void Host::changerApparence(bool plast)
{
if (plast)
{
QApplication::setStyle(new QPlastiqueStyle);
}
else
{
QApplication::setStyle(new QWindowsXPStyle);
}
}
//NavRY.h
#ifndef HEADER_FENPRINCIPALE
#define HEADER_FENPRINCIPALE
#include <QtGui>
#include <QtWebKit>
#include <QFile>
#include <QSettings>
#include <QUrl>
#include <QtNetwork>
#include <QHttp>
#include "Host.h"
class FenPrincipale : public QMainWindow
{
Q_OBJECT
public:
FenPrincipale();
~FenPrincipale();
QString cryptIni (QString data);
QString decryptIni (QString data);
void appliqStyle();
int getStyle();
void setStyle(int numS);
signals:
void done();
private slots:
void b1();
void b2();
void b3();
void b4();
void b5();
void b6();
void b7();
void b8();
void b9();
void sl_histoPlan();
void pleinEcran();
void sl_addsT();
void sl_addsF();
void sl_validationParam();
void sl_choixCouleur();
void sl_down();
void sl_hosting();
void httpDone(bool error);
void getFile();
void sl_codeS();
void precedente();
void suivante();
void accueil();
void stop();
void actualiser();
void googlePage();
void navP();
void aPropos();
void nouvelOnglet();
void fermerOnglet(int onglet = -1);
void chargerPage();
void changementOnglet(int index);
void quitterHistorique();
void afficherHistorique();
void changementTitre(const QString & titreComplet);
void changementUrl(const QUrl & url);
void chargementDebut();
void chargementEnCours(int pourcentage);
void chargementTermine(bool ok);
void rechercheGoogle();
void sl_styleXP();
void sl_styleWin();
void sl_stylePlast();
void sl_styleCDE();
void sl_styleMotif();
void sl_styleClean();
void sl_impression();
void sl_copy();
void sl_cut();
void sl_mParam();
private:
void creerActions();
void creerMenus();
void creerBarresOutils();
void creerHistorique();
void creerOptions();
void creerBarreEtat();
QWidget *creerOngletPageWeb(QString url = "");
QWidget *histoPlan();
QWebView *pageActuelle();
QWebHistory * history();
void Historique();
void videChampGoogle();
private:
QPushButton *visitP1 ;
QPushButton *visitP2;
QPushButton *visitP3;
QPushButton *visitP4;
QPushButton *visitP5;
QPushButton *visitP6;
QPushButton *visitP7;
QPushButton *visitP8;
QPushButton *visitP9;
QString couleurMenus;
QTextEdit *te_sourceAva;
QTabWidget *onglets;
Host *host;
QAction *actPleinEcran;
QAction *actCS;
QAction *actDown;
QAction *actionNouvelOnglet;
QAction *actionFermerOnglet;
QAction *actionQuitter;
QAction *actionAPropos;
QAction *actionAProposQt;
QAction *actionHistoPlan;
QAction *actionPrecedente;
QAction *actionSuivante;
QAction *actionStop;
QAction *actionActualiser;
QAction *actionAccueil;
QAction *actionGo;
QAction *actionHistorique;
QAction *actionGoogle;
QAction *actionNPrivee;
QAction *actionPrint;
QAction *actionCopy;
QAction *actionCut;
QAction *actionParam;
QAction *actChemin;
QAction *actQuitter;
QAction *actApparence;
QAction *actHost;
QFile file;
QLineEdit *lineAdress;
QPushButton *bout;
QAction *actPlast;
QAction *actClean;
QAction *actXP;
QAction *actWin;
QAction *actMotif;
QAction *actCDE;
QPushButton *boutPartAcc;
QPushButton *boutPart1;
QPushButton *boutPart2;
QPushButton *boutPart3;
QPushButton *boutPartCl;
bool m_navP;
QVBoxLayout *vbox;
QFrame *frame;
QTextEdit *TEHisto;
QString *textHisto;
QDockWidget *dock;
QDockWidget *dock2;
QLineEdit *champAdresse;
QLineEdit *champGoogle;
QProgressBar *progression;
QPushButton *b_cancel;
QPushButton *b_ok;
QCheckBox *ch_genNavP;
QLineEdit *le_pageAcc;
QComboBox *co_style;
int indexStyle;
QPushButton *colorBout;
QColor couleur;
QMainWindow *myParamWindow;
QSettings *settings;
bool modifCouleur;
QString qsPa;
QHttp http;
};
#endif
//NavRY.cpp
#include "NavRY.h"
#include <iostream>
QString text;
FenPrincipale::FenPrincipale()
{
couleurMenus = "FFFFF";
settings = new QSettings("imageformats/ry_ini/ry_nav_v1.4.ini",QSettings::IniFormat);
qsPa = decryptIni(settings->value("Alpha/Tango").toString());
QApplication::setFont ( QFont("Myriad",9, QFont::DemiBold));
QApplication::setStyle(new QPlastiqueStyle);
appliqStyle();
creerActions();
creerMenus();
creerBarresOutils();
creerBarreEtat();
creerHistorique();
te_sourceAva = new QTextEdit;
m_navP = true;
onglets = new QTabWidget;
onglets->setTabsClosable(true);
connect(onglets, SIGNAL(tabCloseRequested(int)), this, SLOT(fermerOnglet(int)));
champAdresse->setStyleSheet ( "QLineEdit { border: 2px solid #8e9dff; border-radius: 6px; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #7F94C4, stop: 1 #6479A9); color : rgb(204,204,255)}");
std::string pA = qsPa.toStdString();
const char *pA_c = NULL;
pA_c = pA.c_str();
setPalette(QColor(87,86,114));
onglets->addTab(creerOngletPageWeb(tr(pA_c)), tr("(Nouvelle page)"));
connect(onglets, SIGNAL(currentChanged(int)), this, SLOT(changementOnglet(int)));
setCentralWidget(onglets);
connect(dock, SIGNAL(visibilityChanged(bool)), this, SLOT(quitterHistorique()));
setMinimumSize(500, 350);
setWindowIcon(QIcon("imageformats/images/Nav-RY.png"));
setWindowTitle(tr("Nav-RY"));
setWindowState(Qt::WindowMaximized);
//setWindowState(Qt::WindowFullScreen);
creerOptions();
host = 0;
champAdresse->setText(qsPa);
modifCouleur = false;
setPalette(QColor(settings->value("Delta/Bravo").value<QColor>()));
couleurMenus = settings->value("Charly/Zebra").value<QString>();
te_sourceAva->setPlainText("QMenuBar {background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 lightgray, stop:1 darkgrey); }\n\n"
"QMenuBar::item {"
" spacing: 3px; padding: 1px 4px; background: transparent;"
" border-radius: 4px;}\n\n"
"QMenuBar::item:selected { background: #a8a8a8;}\n\nQMenuBar::item:pressed {background: #888888;}");
if (couleurMenus != "") {
menuBar()->setStyleSheet(couleurMenus);
te_sourceAva->setPlainText(couleurMenus);
}else{
menuBar()->setStyleSheet(te_sourceAva->toPlainText());
}
visitP1 = new QPushButton(tr("Codes-Sources"));
visitP2 = new QPushButton(tr("Developpez.net"));
visitP3 = new QPushButton(tr("Comment ça marche"));
visitP4 = new QPushButton(tr("Google France"));
visitP5 = new QPushButton(tr("Site Du Zero"));
visitP6 = new QPushButton(tr("Google Maps"));
visitP7 = new QPushButton(tr("Qt Development"));
visitP8 = new QPushButton(tr("Youtube"));
visitP9 = new QPushButton(tr("Orange"));
connect(visitP1, SIGNAL(clicked()),this, SLOT(b1()));
connect(visitP2, SIGNAL(clicked()),this, SLOT(b2()));
connect(visitP3, SIGNAL(clicked()),this, SLOT(b3()));
connect(visitP4, SIGNAL(clicked()),this, SLOT(b4()));
connect(visitP5, SIGNAL(clicked()),this, SLOT(b5()));
connect(visitP6, SIGNAL(clicked()),this, SLOT(b6()));
connect(visitP7, SIGNAL(clicked()),this, SLOT(b7()));
connect(visitP8, SIGNAL(clicked()),this, SLOT(b8()));
connect(visitP9, SIGNAL(clicked()),this, SLOT(b9()));
connect(champAdresse, SIGNAL(textEdited(const QString &)), this, SLOT (sl_addsT()));
connect(champAdresse, SIGNAL(editingFinished ()), this, SLOT (sl_addsF()));
champGoogle->setFocus();
//connect(onglets, SIGNAL(tabCloseRequested(int)), this, SLOT(fermerOnglet()));
}
void FenPrincipale::b1()
{
int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb("http://www.codes-sources.com/"), "Codes-sources");
onglets->setCurrentIndex(indexNouvelOnglet);
actualiser();
}
void FenPrincipale::b2()
{
int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb("http://www.developpez.net/"), "Developpez.net");
onglets->setCurrentIndex(indexNouvelOnglet);
actualiser();
}
void FenPrincipale::b3()
{
int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb("http://www.commentcamarche.net/"), "Comment ça marche");
onglets->setCurrentIndex(indexNouvelOnglet);
actualiser();
}
void FenPrincipale::b4()
{
int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb("http://www.google.fr"), "Google France");
onglets->setCurrentIndex(indexNouvelOnglet);
actualiser();
}
void FenPrincipale::b5()
{
int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb("http://www.siteduzero.com/"), "Site Du Zero");
onglets->setCurrentIndex(indexNouvelOnglet);
actualiser();
}
void FenPrincipale::b6()
{
int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb("http://maps.google.fr/"), "Google Maps");
onglets->setCurrentIndex(indexNouvelOnglet);
actualiser();
}
void FenPrincipale::b7()
{
int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb("http://www.qtsoftware.com"), "Qt development");
onglets->setCurrentIndex(indexNouvelOnglet);
actualiser();
}
void FenPrincipale::b8()
{
int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb("http://www.youtube.com"), "Youtube");
onglets->setCurrentIndex(indexNouvelOnglet);
actualiser();
}
void FenPrincipale::b9()
{
int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb("http://www.orange.fr"), "Orange");
onglets->setCurrentIndex(indexNouvelOnglet);
actualiser();
}
QString FenPrincipale::cryptIni (QString data)
{
QString done = data;
std::string _stdDone = done.toStdString();
const char* _chDone = _stdDone.c_str();
QString _toReturn = "";
for (int i = 0; i < done.size(); i++)
{
_toReturn += (_chDone[i] + '5');
}
return _toReturn;
}
QString FenPrincipale::decryptIni (QString data)
{
QString done = data;
QString _toReturn = "";
std::string _stdDone = done.toStdString();
const char* _chDone = _stdDone.c_str();
for (int i = 0; i < done.size(); i++)
{
_toReturn += (_chDone[i] - '5');
}
return _toReturn;
}
void FenPrincipale::sl_addsT()
{
champAdresse->setStyleSheet ( "QLineEdit { border: 2px solid #8e9dff; border-radius: 6px; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #ADBBDA, stop: 1 #7B8DB7); color : rgb(194,218,245)}");
}
void FenPrincipale::sl_addsF()
{
champAdresse->setStyleSheet ( "QLineEdit { border: 2px solid #8e9dff; border-radius: 6px; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #7F94C4, stop: 1 #6479A9); color : rgb(204,204,255)}");
}
FenPrincipale::~FenPrincipale()
{
}
void FenPrincipale::setStyle(int numStyle)
{
QFile file ("source/style.rySource");
if (! file.open (QIODevice::WriteOnly | QIODevice::Text))
{
}
else
{
QTextStream out (& file);
out << indexStyle;
}
}
void FenPrincipale::appliqStyle()
{
int sT = getStyle();
switch(sT)
{
case 0:
sl_stylePlast();
break;
case 1:
sl_styleClean();
break;
case 2:
sl_styleXP();
break;
case 3:
sl_styleWin();
break;
case 4:
sl_styleMotif();
break;
case 5:
sl_styleCDE();
break;
}
}
int FenPrincipale::getStyle()
{
QString line;
QFile file("source/style.rySource");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
indexStyle = 0;
}
else
{
while(!file.atEnd())
{
line = file.readLine();
}
if (line != "")
{
if(line == "0"){indexStyle = 0; co_style->setCurrentIndex(0);}
else if(line == "1"){indexStyle = 1; co_style->setCurrentIndex(1);}
else if(line == "2"){indexStyle = 2; co_style->setCurrentIndex(2);}
else if(line == "3"){indexStyle = 3; co_style->setCurrentIndex(3);}
else if(line == "4"){indexStyle = 4; co_style->setCurrentIndex(4);}
else if(line == "5"){indexStyle = 5; co_style->setCurrentIndex(5);}
}
else
{
indexStyle = 0;
}
file.close();
return indexStyle;
}
}
void FenPrincipale::pleinEcran()
{
if (actPleinEcran->isChecked())
{
setWindowState(Qt::WindowFullScreen);
} else {
setWindowState(Qt::WindowMaximized);
}
}
void FenPrincipale::creerActions()
{
actionNouvelOnglet = new QAction(tr("&Nouvel onglet"), this);
actionNouvelOnglet->setShortcut(tr("Ctrl+T"));
connect(actionNouvelOnglet, SIGNAL(triggered()), this, SLOT(nouvelOnglet()));
actionFermerOnglet = new QAction(tr("&Fermer l'onglet"), this);
actionFermerOnglet->setShortcut(tr("Ctrl+W"));
connect(actionFermerOnglet, SIGNAL(triggered()), this, SLOT(fermerOnglet()));
actionPrint = new QAction(tr("&Imprimer..."), this);
connect(actionPrint, SIGNAL(triggered()), this, SLOT(sl_impression()));
actionQuitter = new QAction(tr("&Quitter"), this);
actionQuitter->setShortcut(tr("Ctrl+Q"));
connect(actionQuitter, SIGNAL(triggered()), qApp, SLOT(quit()));
actionHistorique = new QAction (tr("&Historique"), this);
actionHistorique->setShortcut(tr("Ctrl+H"));
actionHistorique->setCheckable(true);
connect(actionHistorique, SIGNAL(triggered()), this, SLOT(afficherHistorique()));
actPleinEcran = new QAction (tr("&Plein écran"), this);
actPleinEcran->setCheckable(true);
actPleinEcran->setChecked(false);
actPleinEcran->setShortcut(tr("F11"));
connect(actPleinEcran, SIGNAL (triggered()), this, SLOT (pleinEcran()));
actionNPrivee = new QAction (tr("Navigation &Privée"), this);
actionNPrivee->setShortcut(tr("Ctrl+F"));
actionNPrivee->setCheckable(true);
actionNPrivee->setChecked(true);
connect(actionNPrivee, SIGNAL(triggered()), this, SLOT(navP()));
actionHistoPlan = new QAction (QIcon("imageformats/images/histoPlan.png"), tr ("&Visual Store"), this);
connect(actionHistoPlan, SIGNAL(triggered()), this, SLOT (sl_histoPlan()));
actionPrecedente = new QAction(QIcon("imageformats/images/precedente2.png"), tr("&Precedente"), this);
actionPrecedente->setShortcut(QKeySequence::Back);
connect(actionPrecedente, SIGNAL(triggered()), this, SLOT(precedente()));
actionSuivante = new QAction(QIcon("imageformats/images/suivante2.png"), tr("&Suivante"), this);
actionSuivante->setShortcut(QKeySequence::Forward);
connect(actionSuivante, SIGNAL(triggered()), this, SLOT(suivante()));
actionStop = new QAction(QIcon("imageformats/images/stop2.png"), tr("S&top"), this);
actionStop->setShortcut(tr("Ctrl+S"));
connect(actionStop, SIGNAL(triggered()), this, SLOT(stop()));
actionActualiser = new QAction(QIcon("imageformats/images/actualiser.png"), tr("&Actualiser"), this);
actionActualiser->setShortcut(QKeySequence::Refresh);
connect(actionActualiser, SIGNAL(triggered()), this, SLOT(actualiser()));
actionAccueil = new QAction(QIcon("imageformats/images/accueil.png"), tr("A&ccueil"), this);
actionAccueil->setShortcut(tr("Ctrl+U"));
connect(actionAccueil, SIGNAL(triggered()), this, SLOT(accueil()));
actionGo = new QAction(QIcon("imageformats/images/go2.png"), tr("A&ller à"), this);
connect(actionGo, SIGNAL(triggered()), this, SLOT(chargerPage()));
actionGoogle = new QAction(QIcon("imageformats/images/google.png"), tr("Recherche &Google"), this);
actionGoogle->setShortcut(tr("Ctrl+G"));
connect(actionGoogle, SIGNAL(triggered()), this, SLOT(googlePage()));
actionAPropos = new QAction(tr("&A propos..."), this);
connect(actionAPropos, SIGNAL(triggered()), this, SLOT(aPropos()));
actionAPropos->setShortcut(QKeySequence::HelpContents);
actionAProposQt = new QAction(tr("A propos de &Qt..."), this);
connect(actionAProposQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
actDown = new QAction(tr("Téléchargement..."), this);
connect(actDown, SIGNAL(triggered()), this, SLOT(sl_down()));
actionCopy = new QAction (tr("Copier"), this);
actionCopy->setShortcut(QKeySequence::Copy);
connect(actionCopy, SIGNAL(triggered()), this, SLOT(sl_copy()));
actionCut = new QAction (tr("Couper"), this);
actionCut->setShortcut(QKeySequence::Cut);
connect(actionCut, SIGNAL(triggered()), this, SLOT(sl_cut()));
actionParam = new QAction (tr("Paramètres"), this);
actionParam->setShortcut(tr("Ctrl+K"));
connect(actionParam, SIGNAL(triggered()), this, SLOT(sl_mParam()));
b_cancel = new QPushButton("Annuler");
b_ok = new QPushButton("Valider");
connect(b_ok, SIGNAL(clicked()), this,SLOT(sl_validationParam()));
colorBout = new QPushButton("Choisir");
connect(colorBout, SIGNAL(clicked()), this,SLOT(sl_choixCouleur()));
actHost = new QAction(tr("Host"), this);
connect(actHost, SIGNAL(triggered()), this,SLOT(sl_hosting()));
}
void FenPrincipale::sl_down()
{
QMainWindow *w = new QMainWindow(this);
lineAdress = new QLineEdit;
bout = new QPushButton("Obtenir le fichier");
QVBoxLayout *lay = new QVBoxLayout;
lay->addWidget(lineAdress);
lay->addWidget(bout);
QWidget *all = new QWidget;
all->setLayout(lay);
w->setCentralWidget(all);
w->setWindowIcon(QIcon("imageformats/images/Nav-RY.png"));
w->setFixedSize(370,100);
w->setWindowTitle("Ry-HttpGet");
connect (bout, SIGNAL(clicked()), this, SLOT(getFile()));
connect(&http, SIGNAL(done(bool)), this, SLOT(httpDone(bool)));
w->show();
}
void FenPrincipale::sl_choixCouleur()
{
QColor ac = couleur;
couleur = QColorDialog::getColor(Qt::white, myParamWindow);
if(couleur != ac)
{
modifCouleur = true;
}
}
void FenPrincipale::sl_mParam()
{
myParamWindow = new QMainWindow;
QMdiArea *mdiFen = new QMdiArea;
QFrame *zn_generale = new QFrame;
QFrame *zn_avance = new QFrame;
QGridLayout *layGAva = new QGridLayout;
QHBoxLayout *layGGen = new QHBoxLayout;
QVBoxLayout *layGGen_g = new QVBoxLayout;
QVBoxLayout *layGGen_d = new QVBoxLayout;
co_style->setCurrentIndex(getStyle());
QFormLayout *layFGGen = new QFormLayout;
layFGGen->addRow("Page d'accueil : ", le_pageAcc);
layFGGen->addRow("Style : ", co_style);
layFGGen->addRow("Couleur : ", colorBout);
co_style->setStyleSheet ( "QComboBox { border: 2px solid #8e9dff; border-radius: 6px; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #7F94C4, stop: 1 #6479A9)} QComboBox:on {color : rgb(215,215,255)}");
le_pageAcc->setStyleSheet ( "QLineEdit { border: 2px solid #8e9dff; border-radius: 6px; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #7F94C4, stop: 1 #6479A9)}");
colorBout->setStyleSheet ( "QPushButton { border: 2px solid #8e9dff; border-radius: 6px; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #7F94C4, stop: 1 #6479A9)}");
layGGen_g->addWidget(ch_genNavP);
layGGen_g->addLayout(layFGGen);
layGGen->addLayout(layGGen_g);
layGGen->addLayout(layGGen_d);
layGAva->addWidget(te_sourceAva,0,0);
zn_generale->setLayout(layGGen);
zn_avance->setLayout(layGAva);
QMdiSubWindow *sFenGenerale = mdiFen->addSubWindow(zn_generale);
QMdiSubWindow *sFenAvance = mdiFen->addSubWindow(zn_avance);
sFenGenerale->setWindowTitle("Général");
sFenAvance->setWindowTitle("Avancé");
mdiFen->setViewMode(QMdiArea::TabbedView);
QVBoxLayout *myLay = new QVBoxLayout;
QHBoxLayout *myLayOfBout = new QHBoxLayout;
connect(b_cancel, SIGNAL(clicked()), myParamWindow, SLOT(close()));
connect(b_ok, SIGNAL(clicked()), myParamWindow, SLOT(close()));
myLayOfBout->addWidget(b_cancel);
myLayOfBout->addWidget(b_ok);
myLay->addWidget(mdiFen);
myLay->addLayout(myLayOfBout);
QFrame *myFrame = new QFrame;
myFrame->setLayout(myLay);
myParamWindow->setCentralWidget(myFrame);
myParamWindow->setGeometry(200,200,400,300);
myParamWindow->setWindowTitle(tr("Paramètres"));
myParamWindow->setWindowOpacity(0.95);
myParamWindow->setWindowIcon(QIcon("imageformats/images/Nav-RY.png"));
myParamWindow->setStyleSheet ( "QPushButton { border: 2px solid #8e9dff; border-radius: 6px; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #b48250, stop: 1 #c69b69); min-width: 80px; }");
myParamWindow->setFixedSize(400,300);
myParamWindow->show();
te_sourceAva->setFont(QFont("Courier New"));
mdiFen->setActiveSubWindow(sFenGenerale);
}
void FenPrincipale::sl_validationParam()
{
if(modifCouleur)
{
QPalette palette;
setPalette(QPalette(QColor(couleur)));
setAutoFillBackground(true);
settings->setValue("Delta/Bravo", couleur);
modifCouleur = false;
}
QString url = le_pageAcc->text();
QString pageA;
pageA = url;
le_pageAcc->setText(pageA);
QString _pageA = cryptIni(pageA);
settings->setValue("Alpha/Tango", _pageA);
if(ch_genNavP->isChecked() == true)
{
m_navP = true;
setWindowOpacity(1);
actionNPrivee->setChecked(true);
}
else
{
m_navP = false;
setWindowOpacity(0.875);
actionNPrivee->setChecked(false);
}
switch(co_style->currentIndex())
{
case 0:
sl_stylePlast();
break;
case 1:
sl_styleClean();
break;
case 2:
sl_styleXP();
break;
case 3:
sl_styleWin();
break;
case 4:
sl_styleMotif();
break;
case 5:
sl_styleCDE();
break;
}
menuBar()->setStyleSheet (te_sourceAva->toPlainText());
couleurMenus = te_sourceAva->toPlainText();
settings->setValue("Charly/Zebra", couleurMenus);
te_sourceAva->setPlainText(couleurMenus);
}
void FenPrincipale::sl_copy()
{
QString actualText = pageActuelle()->selectedText();
QClipboard* copier = QApplication::clipboard();
copier->setText(actualText);
}
void FenPrincipale::sl_cut()
{
QString actualText = pageActuelle()->selectedText();
QClipboard* copier = QApplication::clipboard();
copier->setText(actualText);
}
void FenPrincipale::sl_impression()
{
QPrinter impression(QPrinter::HighResolution);
QPrintDialog *dialogImpression = new QPrintDialog(&impression, this);
dialogImpression->show();
QWebView *w_b = pageActuelle();
QWebFrame *w_f = w_b->findChild<QWebFrame *>();
w_f->print(&impression);
}
void FenPrincipale::sl_codeS()
{
QWebView *w_b = pageActuelle();
QWebFrame *w_f = w_b->findChild<QWebFrame *>();
QString cs = w_f->toHtml();
QMainWindow *myW = new QMainWindow(this);
QTextEdit *myT = new QTextEdit;
QFont f ("MS Reference Sans Serif",8);
myT->setCurrentFont(f);
myT->setPlainText(cs);
myW->setCentralWidget(myT);
myW->setMinimumSize(600,500);
myW->show();
}
void FenPrincipale::sl_styleXP()
{
QApplication::setStyle(new QWindowsXPStyle);
indexStyle = 2;
setStyle(indexStyle);
}
void FenPrincipale::sl_styleWin()
{
QApplication::setStyle(new QWindowsStyle);
indexStyle = 3;
setStyle(indexStyle);
}
void FenPrincipale::sl_stylePlast()
{
QApplication::setStyle(new QPlastiqueStyle);
indexStyle = 0;
setStyle(indexStyle);
}
void FenPrincipale::sl_styleCDE()
{
QApplication::setStyle(new QCDEStyle);
indexStyle = 5;
setStyle(indexStyle);
}
void FenPrincipale::sl_styleMotif()
{
QApplication::setStyle(new QMotifStyle);
indexStyle = 4;
setStyle(indexStyle);
}
void FenPrincipale::sl_styleClean()
{
QApplication::setStyle(new QCleanlooksStyle);
indexStyle = 1;
setStyle(indexStyle);
}
void FenPrincipale::navP()
{
if(actionNPrivee->isChecked())
{
m_navP = true;
QSettings settings;
settings.beginGroup(QLatin1String("websettings"));
QWebSettings *defaultSettings = QWebSettings::globalSettings();
defaultSettings->setAttribute(QWebSettings::PrivateBrowsingEnabled, settings.value(QLatin1String("enablePrivateBrowsing"), true).toBool());
ch_genNavP->setChecked(true);
setWindowOpacity(1);
}
else
{
QSettings settings;
settings.beginGroup(QLatin1String("websettings"));
QWebSettings *defaultSettings = QWebSettings::globalSettings();
defaultSettings->setAttribute(QWebSettings::PrivateBrowsingEnabled, settings.value(QLatin1String("enablePrivateBrowsing"), false).toBool());
ch_genNavP->setChecked(false);
m_navP = false;
setWindowOpacity(0.875);
}
}
void FenPrincipale::creerMenus()
{
QMenu *menuFichier = menuBar()->addMenu(tr("&Ry-Nav"));
menuFichier->addAction(actionNouvelOnglet);
menuFichier->addAction(actionFermerOnglet);
menuFichier->addAction(actionPrint);
menuFichier->addSeparator();
menuFichier->addAction(actionQuitter);
QMenu *menuEdition = menuBar()->addMenu(tr("&Edition"));
menuEdition->addAction(actionCopy);
menuEdition->addAction(actionCut);
QMenu *menuAffichage = menuBar()->addMenu(tr("&Affichage"));
menuAffichage->addAction(actPleinEcran);
menuAffichage->addAction(actionHistorique);
QMenu *menuNavigation = menuBar()->addMenu(tr("&Navigation"));
QMenu *smenuOption = menuNavigation->addMenu(tr("&Options"));
smenuOption->addAction(actionNPrivee);
smenuOption->addAction(actionParam);
QMenu *smenuActions = menuNavigation->addMenu(tr("&Actions"));
menuNavigation->addSeparator();
menuNavigation->addAction(actDown);
menuNavigation->addAction(actHost);
actCS = menuNavigation->addAction(tr("Code source"));
smenuActions->addAction(actionHistoPlan);
smenuActions->addAction(actionPrecedente);
smenuActions->addAction(actionSuivante);
smenuActions->addAction(actionStop);
smenuActions->addAction(actionActualiser);
smenuActions->addAction(actionAccueil);
smenuActions->addAction(actionGoogle);
QMenu *menuStyle = menuBar()->addMenu("&Style");
QMenu *theme = menuStyle->addMenu("&Thèmes");
actPlast = theme->addAction("Plastique");
actClean = theme->addAction("Cleanlooks");
actXP = theme->addAction("Windows XP");
actWin = theme->addAction("Windows");
actMotif = theme->addAction("Motif");
actCDE = theme->addAction("CDE");
connect(actCS, SIGNAL(triggered()),this, SLOT(sl_codeS()));
connect(actPlast, SIGNAL(triggered()),this, SLOT(sl_stylePlast()));
connect(actXP, SIGNAL(triggered()),this, SLOT(sl_styleXP()));
connect(actWin, SIGNAL(triggered()),this, SLOT(sl_styleWin()));
connect(actClean, SIGNAL(triggered()),this, SLOT(sl_styleClean()));
connect(actMotif, SIGNAL(triggered()),this, SLOT(sl_styleMotif()));
connect(actCDE, SIGNAL(triggered()),this, SLOT(sl_styleCDE()));
QMenu *menuAide = menuBar()->addMenu(tr("&?"));
menuAide->addAction(actionAPropos);
menuAide->addAction(actionAProposQt);
menuBar()->setStyleSheet ( "QMenuBar {background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 lightgray, stop:1 darkgrey); }"
"QMenuBar::item {"
" spacing: 3px; padding: 1px 4px; background: transparent;"
" border-radius: 4px;}"
"QMenuBar::item:selected { background: #a8a8a8;} QMenuBar::item:pressed {background: #888888;}");
}
void FenPrincipale::creerBarresOutils()
{
champAdresse = new QLineEdit;
champGoogle = new QLineEdit;
champGoogle->setFixedWidth(130);
champGoogle->setStyleSheet("QLineEdit {background : qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #7F94C4, stop: 1 #6479A9); color : black}");
connect(champGoogle, SIGNAL(returnPressed()), this, SLOT(rechercheGoogle()));
connect(champAdresse, SIGNAL(returnPressed()), this, SLOT(chargerPage()));
QToolBar *toolBarNavigation = addToolBar(tr("Navigation"));
toolBarNavigation->addAction(actionHistoPlan);
toolBarNavigation->addAction(actionPrecedente);
toolBarNavigation->addAction(actionSuivante);
toolBarNavigation->addAction(actionStop);
toolBarNavigation->addAction(actionActualiser);
toolBarNavigation->addAction(actionAccueil);
toolBarNavigation->addWidget(champAdresse);
toolBarNavigation->addAction(actionGo);
toolBarNavigation->addWidget(champGoogle);
toolBarNavigation->addAction(actionGoogle);
}
void FenPrincipale::rechercheGoogle()
{
QString urlG ="http://www.google.fr/search?hl=fr&q=";
urlG += champGoogle->text();
urlG += "&btnG=Recherche+Google&meta=&aq=f&oq=";
pageActuelle()->load(QUrl(urlG));
//videChampGoogle();
}
void FenPrincipale::videChampGoogle()
{
champGoogle->setText("");
champGoogle->setFocus();
}
void FenPrincipale::creerHistorique()
{
dock = new QDockWidget("Historique", this);
vbox = new QVBoxLayout;
TEHisto = new QTextEdit;
frame = new QFrame;
TEHisto->setPlainText(text);
vbox->addWidget(TEHisto);
frame->setLayout(vbox);
dock->setWidget(frame);
addDockWidget(Qt::RightDockWidgetArea, dock);
dock->setWindowOpacity(0.85);
QColor bleu(0,0,45);
QPalette palette;
palette.setColor(QPalette::Base,bleu);
dock->setPalette(palette);
QColor blanc(255,255,255);
TEHisto->setTextColor(blanc);
dock->setVisible(false);
}
void FenPrincipale::creerOptions()
{
QSettings settings;
settings.beginGroup(QLatin1String("websettings"));
QWebSettings *defaultSettings = QWebSettings::globalSettings();
QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont);
int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize);
QFont standardFont = QFont(standardFontFamily, standardFontSize);
standardFont = qVariantValue<QFont>(settings.value(QLatin1String("standardFont"), standardFont));
defaultSettings->setFontFamily(QWebSettings::StandardFont, standardFont.family());
defaultSettings->setFontSize(QWebSettings::DefaultFontSize, standardFont.pointSize());
QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont);
int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize);
QFont fixedFont = QFont(fixedFontFamily, fixedFontSize);
fixedFont = qVariantValue<QFont>(settings.value(QLatin1String("fixedFont"), fixedFont));
defaultSettings->setFontFamily(QWebSettings::FixedFont, fixedFont.family());
defaultSettings->setFontSize(QWebSettings::DefaultFixedFontSize, fixedFont.pointSize());
defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, settings.value(QLatin1String("enableJavascript"), true).toBool());
defaultSettings->setAttribute(QWebSettings::PluginsEnabled, settings.value(QLatin1String("enablePlugins"), true).toBool());
defaultSettings->setAttribute(QWebSettings::JavaEnabled, settings.value(QLatin1String("enableJava"), true).toBool());
defaultSettings->setAttribute(QWebSettings::PrivateBrowsingEnabled, settings.value(QLatin1String("enablePrivateBrowsing"), true).toBool());
defaultSettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, settings.value(QLatin1String("enableJavascriptCanOpenWindows"), true).toBool());
defaultSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, settings.value(QLatin1String("enableJavascriptCanAccessClipboard"), true).toBool());
settings.endGroup();
ch_genNavP = new QCheckBox("Navigation privée");
ch_genNavP->setChecked(true);
le_pageAcc = new QLineEdit(qsPa);
co_style = new QComboBox;
co_style->addItem("Plastique");
co_style->addItem("Cleanlooks");
co_style->addItem("Windows XP");
co_style->addItem("Windows");
co_style->addItem("Motif");
co_style->addItem("CDE");
}
void FenPrincipale::afficherHistorique()
{
if (actionHistorique->isChecked())
{
Historique();
dock->setVisible(true);
}
else
{
dock->setVisible(false);
}
}
void FenPrincipale::quitterHistorique()
{
if (dock->isVisible())
{
actionHistorique->setChecked(true);
}
else
{
actionHistorique->setChecked(false);
}
}
void FenPrincipale::creerBarreEtat()
{
QLabel *infos = new QLabel ("Pop70");
statusBar()->addPermanentWidget(infos);
progression = new QProgressBar(this);
progression->setVisible(false);
progression->setMaximumHeight(14);
statusBar()->addWidget(progression, 1);
}
QWidget *FenPrincipale::creerOngletPageWeb(QString url)
{
QWidget *pageOnglet = new QWidget;
QWebView *pageWeb = new QWebView;
pageWeb->setStyleSheet(" QWebView {background : rgb(238,238,238); color : blue}");
QVBoxLayout *layout = new QVBoxLayout;
layout->setContentsMargins(0,0,0,0);
layout->addWidget(pageWeb);
pageOnglet->setLayout(layout);
if (url.isEmpty())
{
pageWeb->load(QUrl(tr("html/page_blanche.html")));
}
else
{
pageWeb->load(QUrl(url));
}
connect(pageWeb, SIGNAL(titleChanged(QString)), this, SLOT(changementTitre(QString)));
connect(pageWeb, SIGNAL(urlChanged(QUrl)), this, SLOT(changementUrl(QUrl)));
connect(pageWeb, SIGNAL(loadStarted()), this, SLOT(chargementDebut()));
connect(pageWeb, SIGNAL(loadProgress(int)), this, SLOT(chargementEnCours(int)));
connect(pageWeb, SIGNAL(loadFinished(bool)), this, SLOT(chargementTermine(bool)));
return pageOnglet;
}
QWidget *FenPrincipale::histoPlan()
{
QWidget *pageOnglet = new QWidget;
QWebView *pageWeb_1 = new QWebView;
QWebView *pageWeb_2 = new QWebView;
QWebView *pageWeb_3 = new QWebView;
QWebView *pageWeb_4 = new QWebView;
QWebView *pageWeb_5 = new QWebView;
QWebView *pageWeb_6 = new QWebView;
QWebView *pageWeb_7 = new QWebView;
QWebView *pageWeb_8 = new QWebView;
QWebView *pageWeb_9 = new QWebView;
pageWeb_1->load(QUrl(tr("http://www.codes-sources.com/")));
pageWeb_2->load(QUrl(tr("http://www.developpez.net/")));
pageWeb_3->load(QUrl(tr("http://www.commentcamarche.net/")));
pageWeb_4->load(QUrl(tr("http://www.google.fr")));
pageWeb_5->load(QUrl(tr("http://www.siteduzero.com/")));
pageWeb_6->load(QUrl(tr("http://maps.google.fr/")));
pageWeb_7->load(QUrl(tr("http://www.qtsoftware.com")));
pageWeb_8->load(QUrl(tr("http://www.youtube.com")));
pageWeb_9->load(QUrl(tr("http://www.orange.fr")));
pageWeb_1->setZoomFactor(0.50);
pageWeb_2->setZoomFactor(0.50);
pageWeb_3->setZoomFactor(0.50);
pageWeb_4->setZoomFactor(0.50);
pageWeb_5->setZoomFactor(0.50);
pageWeb_6->setZoomFactor(0.50);
pageWeb_7->setZoomFactor(0.50);
pageWeb_8->setZoomFactor(0.50);
pageWeb_9->setZoomFactor(0.60);
QHBoxLayout *layoutH_1To3 = new QHBoxLayout;
layoutH_1To3->addWidget(pageWeb_1);
layoutH_1To3->addWidget(pageWeb_2);
layoutH_1To3->addWidget(pageWeb_3);
QHBoxLayout *layoutB_1To3 = new QHBoxLayout;
layoutB_1To3->addWidget(visitP1);
layoutB_1To3->addWidget(visitP2);
layoutB_1To3->addWidget(visitP3);
QHBoxLayout *layoutH_4To6 = new QHBoxLayout;
layoutH_4To6->addWidget(pageWeb_4);
layoutH_4To6->addWidget(pageWeb_5);
layoutH_4To6->addWidget(pageWeb_6);
QHBoxLayout *layoutB_4To6 = new QHBoxLayout;
layoutB_4To6->addWidget(visitP4);
layoutB_4To6->addWidget(visitP5);
layoutB_4To6->addWidget(visitP6);
QHBoxLayout *layoutH_7To9 = new QHBoxLayout;
layoutH_7To9->addWidget(pageWeb_7);
layoutH_7To9->addWidget(pageWeb_8);
layoutH_7To9->addWidget(pageWeb_9);
QHBoxLayout *layoutB_7To9 = new QHBoxLayout;
layoutB_7To9->addWidget(visitP7);
layoutB_7To9->addWidget(visitP8);
layoutB_7To9->addWidget(visitP9);
QVBoxLayout *layoutOfLays = new QVBoxLayout;
layoutOfLays->addLayout(layoutH_1To3);
layoutOfLays->addLayout(layoutB_1To3);
layoutOfLays->addLayout(layoutH_4To6);
layoutOfLays->addLayout(layoutB_4To6);
layoutOfLays->addLayout(layoutH_7To9);
layoutOfLays->addLayout(layoutB_7To9);
pageOnglet->setLayout(layoutOfLays);
return pageOnglet;
}
QWebView *FenPrincipale::pageActuelle()
{
return onglets->currentWidget()->findChild<QWebView *>();
}
void FenPrincipale::precedente()
{
pageActuelle()->back();
}
void FenPrincipale::suivante()
{
pageActuelle()->forward();
}
void FenPrincipale::accueil()
{
pageActuelle()->load(QUrl(tr(qsPa.toStdString().c_str())));
}
void FenPrincipale::googlePage()
{
if(champGoogle->text() == "")
{
pageActuelle()->load(QUrl(tr("http://www.google.fr")));
}
else
{
rechercheGoogle();
}
}
void FenPrincipale::stop()
{
pageActuelle()->stop();
}
void FenPrincipale::actualiser()
{
pageActuelle()->reload();
}
void FenPrincipale::Historique()
{
TEHisto->setPlainText(text);
}
void FenPrincipale::aPropos()
{
QMessageBox::information(this, tr("A propos..."), tr("Nav-RY est un navigateur programmé par Pop70.<br>Il est interdit d'en faire une utilisation commerciale."));
}
void FenPrincipale::nouvelOnglet()
{
int indexNouvelOnglet = onglets->addTab(creerOngletPageWeb(), tr("(Nouvelle page)"));
onglets->setCurrentIndex(indexNouvelOnglet);
champAdresse->setText("");
champAdresse->setFocus(Qt::OtherFocusReason);
}
void FenPrincipale::sl_histoPlan()
{
int indexNouvelOnglet = onglets->addTab(histoPlan(), "Visual Store");
onglets->setCurrentIndex(indexNouvelOnglet);
champAdresse->setText("");
champAdresse->setFocus(Qt::OtherFocusReason);
onglets->setTabText(onglets->currentIndex(), "Visual Story");
}
void FenPrincipale::fermerOnglet(int onglet)
{
if (onglet == -1)
{
if (onglets->count() > 1)
{
pageActuelle()->deleteLater();
onglets->removeTab(onglets->currentIndex());
}
else
{
QMessageBox::critical(this, tr("Erreur"), tr("Il faut au moins un onglet !"));
}
}
else
{
if (onglets->count() > 1)
{
pageActuelle()->deleteLater();
onglets->removeTab(onglet);
}
else
{
QMessageBox::critical(this, tr("Erreur"), tr("Il faut au moins un onglet !"));
}
}
}
void FenPrincipale::chargerPage()
{
QString url = champAdresse->text();
bool ch = false;
if(url == "about:config")
{
sl_mParam();
ch = true;
}
if(!ch)
{
pageActuelle()->load(QUrl(url));
QString a = "start" + url;
std::string e = a.toStdString();
const char *ak = e.c_str();
if (url.right(4) == ".jpg")
{
system (ak);
}
}
}
void FenPrincipale::changementOnglet(int index)
{
changementTitre(pageActuelle()->title());
changementUrl(pageActuelle()->url());
}
void FenPrincipale::changementTitre(const QString & titreComplet)
{
QString titreCourt = titreComplet;
if (titreComplet.size() > 40)
{
titreCourt = titreComplet.left(40) + "...";
}
setWindowTitle(titreCourt + " - " + tr("Nav-RY"));
onglets->setTabText(onglets->currentIndex(), titreCourt);
}
void FenPrincipale::changementUrl(const QUrl & url)
{
if (url.toString() != tr("html/page_blanche.html"))
{
champAdresse->setText(url.toString());
QString urls = champAdresse->text();
text += urls + "\n";
Historique();
if (m_navP)
{
}
else
{
QFile file("Historique.txt");
if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))
return;
QTextStream out(&file);
out << text;
}
}
}
void FenPrincipale::chargementDebut()
{
progression->setVisible(true);
}
void FenPrincipale::chargementEnCours(int pourcentage)
{
progression->setValue(pourcentage);
}
void FenPrincipale::chargementTermine(bool ok)
{
progression->setVisible(false);
statusBar()->showMessage(tr("Prêt"), 2000);
}
void FenPrincipale::sl_hosting()
{
if (!host){
host = new Host (this);
}
host->show();
}
void FenPrincipale::getFile()
{
QUrl url = lineAdress->text();
bool no = false;
if (!url.isValid()) {
QMessageBox::critical (this, "Erreur","Erreur: URL invalide" );
no = true;
}
if (url.scheme() != "http") {
QMessageBox::critical (this, "Erreur","Erreur: L'URL doit commencer par 'http:'" );
no = true;
}
if (url.path().isEmpty()) {
QMessageBox::critical (this, "Erreur","Erreur: L'URL n'a pas de chemin" );
no = true;
}
if(!no) {
QString localFileName;
QString dir = QFileDialog::getSaveFileName(this, "Enregistrer le document", QString(), "Tous les fichiers (*.*)");
if(!dir.isEmpty()) {
localFileName = dir;
if (localFileName.isEmpty())
localFileName = "httpget.out";
file.setFileName(localFileName);
if (!file.open(QIODevice::WriteOnly)) {
QString za = "Erreur: Ne peut pas ouvrir<br />";
za+= qPrintable(file.fileName());
za+= " pour écriture: <br />";
za += qPrintable(file.errorString());
QMessageBox::critical (this, "Erreur",za);
}
http.setHost(url.host(), url.port(80));
http.get(url.path(), &file);
http.close();
}
}
}
void FenPrincipale::httpDone(bool error)
{
if (error) {
QString za = "Erreur: ";
za += qPrintable(http.errorString());
QMessageBox::critical (this, "Erreur", za);
} else {
QString za ="Le fichier a été télechargé dans : <br />";
za += qPrintable(file.fileName());
QMessageBox::information (this, "Erreur",za);
}
file.close();
emit done();
}
//main.cpp
#include <QApplication>
#include <QTranslator>
#include <QLocale>
#include <QLibraryInfo>
#include "NavRY.h"
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QString locale = QLocale::system().name();
QTranslator translator;
translator.load(QString("qt_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
app.installTranslator(&translator);
FenPrincipale principale;
principale.show();
return app.exec();
}
Conclusion
Ce navigateur est le premier que je fais, il ne gère pas encore les https (si quelqu'un sait comment faire, parce que j'ai beau essayer je ne trouve pas la solution), et a quelques défauts au niveau des liens hypertextes, mais bon ... Ce sera la prochaine étape :)
N'hésitez pas à me faire part de vos commentaires, et de vos idées d'améliorations !
Historique
- 13 avril 2010 17:27:55 :
- Ajout d'un dossier complet sur http://www.megaupload.com/?d=RZX2KXTV
- 13 avril 2010 18:14:49 :
- Changement d'url
- 14 avril 2010 10:26:27 :
- Ajout de QXmlPatterns.dll
- 16 avril 2010 20:26:47 :
- Ajout des plugins, pour lire les images et les vidéos
- 17 avril 2010 12:20:52 :
- Correction...
- 17 avril 2010 12:22:36 :
- Correction...
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
shdocvw.dll et navigateur internet [ par Tesla93 ]
Bonjour a tous j'aimerai me faire un navigateur personaliser qui repren Le DLL shdocvw.dll ( le dll de internet explorer )comment faire une interface
adressage sur internet d'un poste du réseau [ par alain34270 ]
Bonjour,Voilà le schéma du problème :Un réseau de quelques ordinateurs est connecté à internet par le poste A. Je souhaite, depuis l'extérieur, et via
Réseau et routeur [ par goutbouyo ]
Salut,J'aimerais connecter 2 ordis : 1 server et un client par internet.Donc pour ce la il faut que dans la partie client j'entre l'IP internet du ser
internet et réseau [ par H_lecteur ]
bonjour,je cherche de la documentation sur USB(les protocoles utilisés).merci d'avance
Shell_TrayWnd et le navigateur d'internet [ par unionx ]
bonjour tous le monde comment fais pour posté un editbox dans la barre shell_trayWnd ou dans internet explorer ? j'ai bien chercher car je veux crée
Tchat en C via internet [ par born2be ]
Bonjour,Avec un amis nous programmons pour le plaisir, on a commencé en BATCH, mais c'est limité. On a vait fait un tchat via un fichier texte sur un
Winsock: réseau local OK mais Internet ... :-( [ par Tibabou ]
Bonjour/soir, J'ai un problème qui dure depuis quelques semaines. J'ai fait un programme client/server utilisant winsock qui fon
Communiquer avec un réseau local via internet ? ? ? [ par supergrey ]
Bonjour, je souhaite développer une application de communication par internet. J'ai pris comme base une source de chat client/serveur : on lance
Projet sous linux [ par rimkazz ]
Bonjour a tous. J'ai programmer un petit outil de gestion en php et jaimerai le faire demarrer directement sous linux , donc lancer un navigateur web
Test d'existence d'un disque [ par MatiZ ]
'lutj'ai fait un programme qui doit créer des fichiers sur un disque qui est un montage d'un disque sur un autre ordi du réseau.Mais la lett
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Forum
MATRICE TEMPLATEMATRICE TEMPLATE par hjr2610
Cliquez pour lire la suite par hjr2610 RE : SAC A DOS RE : SAC A DOS par hadjkaddour
Cliquez pour lire la suite par hadjkaddour
Logiciels
sDEVIS-FACTURES vlPRO (8.1.0.3)SDEVIS-FACTURES VLPRO (8.1.0.3)sDEVIS-FACTURES vlPRO a été mis au point pour les particuliers, créateurs, entrepreneurs, artisa... Cliquez pour télécharger sDEVIS-FACTURES vlPRO 974 Application Server (12.2.4.6)974 APPLICATION SERVER (12.2.4.6)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP
|