Update browser to Qt5
parent
9004d96f8c
commit
dae65b7d80
11
src/main.cpp
11
src/main.cpp
|
@ -1,7 +1,6 @@
|
|||
#include <QtGui/QApplication>
|
||||
#include <QApplication>
|
||||
#include <stdio.h>
|
||||
#include "mainwindow.h"
|
||||
#include <Qt/qtextcodec.h>
|
||||
// Internacionalización con GNU Gettext.
|
||||
#include <libintl.h>
|
||||
#define TEXTDOMAIN "browser"
|
||||
|
@ -21,10 +20,10 @@ int main(int argc, char *argv[])
|
|||
return -1;
|
||||
}
|
||||
// Codificación de caracteres.
|
||||
QTextCodec::setCodecForTr(QTextCodec::codecForName(CHARSET));
|
||||
QTextCodec::setCodecForCStrings(QTextCodec::codecForName(CHARSET));
|
||||
QTextCodec::setCodecForLocale(QTextCodec::codecForName(CHARSET));
|
||||
|
||||
//QTextCodec::setCodecForTr(QTextCodec::codecForName(CHARSET));
|
||||
// QTextCodec::setCodecForCStrings(QTextCodec::codecForName(CHARSET));
|
||||
//QTextCodec::setCodecForLocale(QTextCodec::codecForName(CHARSET));
|
||||
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include "mainwindow.h"
|
||||
#include <QtWebKit>
|
||||
#include <QtWebEngineWidgets>
|
||||
#include <QStringList>
|
||||
#include <QWebView>
|
||||
#include <QWebEngineView>
|
||||
#include <QDockWidget>
|
||||
#include <QtDebug>
|
||||
#include <QWebPage>
|
||||
#include <QWebEnginePage>
|
||||
#include <QProcess>
|
||||
#include <QTextEdit>
|
||||
#include <QMessageBox>
|
||||
|
@ -27,7 +27,7 @@
|
|||
#define CURRENT_TIME() QDateTime::currentDateTime().toString("dd/MM/yyyy hh:mm:ss")
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent),m_web(new QWebView()),m_output(new QTextEdit()),
|
||||
: QMainWindow(parent),m_web(new QWebEngineView()),m_output(new QTextEdit()),
|
||||
m_process(new QProcess(this)),
|
||||
m_logfile(0),m_logstream(0),m_numberTerminal(0)
|
||||
{
|
||||
|
@ -115,19 +115,29 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
// Clock
|
||||
m_clock=new DigitalClock(this);
|
||||
|
||||
m_web->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
|
||||
// Qindel:
|
||||
// https://doc.qt.io/qt-6/qtwebenginewidgets-qtwebkitportingguide.html
|
||||
// There is no way to connect a signal to run C++ code when a link is clicked.
|
||||
// However, link clicks can be delegated to the Qt application instead of having the HTML handler engine process them
|
||||
// by overloading the QWebEnginePage::acceptNavigationRequest() function.
|
||||
//
|
||||
//m_web->page()->setLinkDelegationPolicy(QWebEnginePage::DelegateAllLinks);
|
||||
|
||||
// Web signals
|
||||
connect(m_web,SIGNAL(linkClicked(const QUrl&)),this,
|
||||
SLOT(slotLinkHandle(const QUrl&)));
|
||||
// Qindel: This signal no longer exists, as per the above.
|
||||
//connect(m_web,SIGNAL(linkClicked(const QUrl&)),this, SLOT(slotLinkHandle(const QUrl&)));
|
||||
|
||||
connect(m_web,SIGNAL(loadStarted()),this,SLOT(slotWebLoadStarted()));
|
||||
connect(m_web,SIGNAL(loadFinished(bool)),this,SLOT(slotWebLoadFinished(bool)));
|
||||
connect(m_web,SIGNAL(loadProgress(int)),this,SLOT(slotWebLoadProgress(int)));
|
||||
connect(m_web,SIGNAL(urlChanged(const QUrl&)),this,SLOT(slotUrlChanged(const QUrl&)));
|
||||
// Ignore SSL errors.
|
||||
connect(m_web->page()->networkAccessManager(),
|
||||
SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError> &)), this,
|
||||
SLOT(slotSslErrors(QNetworkReply*)));
|
||||
|
||||
|
||||
// Qindel:
|
||||
//connect(m_web->page()->networkAccessManager(),
|
||||
// SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError> &)), this,
|
||||
// SLOT(slotSslErrors(QNetworkReply*)));
|
||||
|
||||
// Process signals
|
||||
connect(m_process,SIGNAL(started()),this,SLOT(slotProcessStarted()));
|
||||
|
@ -394,7 +404,7 @@ void MainWindow::slotCreateTerminal()
|
|||
QFont font = QApplication::font();
|
||||
font.setFamily("DejaVu Sans Mono");
|
||||
font.setPointSize(12);
|
||||
|
||||
|
||||
console->setTerminalFont(font);
|
||||
console->setFocusPolicy(Qt::StrongFocus);
|
||||
console->setScrollBarPosition(QTermWidget::ScrollBarRight);
|
||||
|
@ -437,7 +447,7 @@ int MainWindow::readEnvironmentValues()
|
|||
|
||||
foreach (QString str,variablelist)
|
||||
{
|
||||
// Look for the variable in the environment
|
||||
// Look for the variable in the environment
|
||||
stringlist=environmentlist.filter(str+"=");
|
||||
|
||||
if(stringlist.isEmpty())
|
||||
|
@ -517,7 +527,7 @@ void MainWindow::finishProgressBar()
|
|||
// Execute a command
|
||||
void MainWindow::executeCommand(QString &string)
|
||||
{
|
||||
QStringList list=string.split(" ",QString::SkipEmptyParts);
|
||||
QStringList list=string.split(" ",Qt::SkipEmptyParts);
|
||||
QString program=list.takeFirst();
|
||||
m_process->setReadChannel(QProcess::StandardOutput);
|
||||
// Assign the same Browser's environment to the process
|
||||
|
@ -542,9 +552,9 @@ QString MainWindow::readSpeed() {
|
|||
if(m_env.contains("OGLOGFILE"))
|
||||
{
|
||||
QString infoFile=m_env["OGLOGFILE"].replace(".log", ".info.html");
|
||||
QString command="grep -hoe \"[0-9]*Mb/s\" "+infoFile+" 2>/dev/null";
|
||||
//QString command="grep -hoe \"[0-9]*Mb/s\" "+infoFile+" 2>/dev/null";
|
||||
QProcess process;
|
||||
process.start(command);
|
||||
process.start("grep", QStringList({"-hoe", "[0-9]*Mb/s", infoFile}));
|
||||
process.waitForFinished();
|
||||
QString speed(process.readAllStandardOutput());
|
||||
return speed.simplified();
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#define COMMAND_OUTPUT_CONFIRM "command+output+confirm"
|
||||
#define ENVIRONMENT "OGLOGFILE,ogactiveadmin,DEFAULTSPEED"
|
||||
|
||||
|
||||
#include <QWidget>
|
||||
#include <QProcess>
|
||||
#include <QMap>
|
||||
|
@ -17,7 +18,7 @@
|
|||
#include <QSslError>
|
||||
#include "digitalclock.h"
|
||||
|
||||
class QWebView;
|
||||
class QWebEngineView;
|
||||
class QTextEdit;
|
||||
class QVBoxLayout;
|
||||
class QProcess;
|
||||
|
@ -75,7 +76,7 @@ class MainWindow : public QMainWindow
|
|||
void showErrorMessage(QString string);
|
||||
|
||||
protected:
|
||||
QWebView *m_web;
|
||||
QWebEngineView *m_web;
|
||||
QTextEdit *m_output;
|
||||
QLabel *m_logo;
|
||||
QProgressBar *m_progressBar;
|
||||
|
|
Loading…
Reference in New Issue