diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4b43cd4..f1aeb90 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -121,18 +121,6 @@ MainWindow::MainWindow(QWidget *parent) // Clock m_clock=new DigitalClock(this); - // 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 - // 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))); @@ -148,7 +136,6 @@ MainWindow::MainWindow(QWidget *parent) // Dock signals connect(button,SIGNAL(clicked()),this,SLOT(slotCreateTerminal())); - connect(m_webBar,SIGNAL(returnPressed()),this,SLOT(slotWebBarReturnPressed())); // All schemes need registering first, then their handlers. registerScheme("command"); @@ -189,8 +176,6 @@ MainWindow::~MainWindow() } void MainWindow::registerScheme(const QString &name) { - qInfo() << "Registering" << name; - QWebEngineUrlScheme scheme(name.toLatin1()); scheme.setSyntax(QWebEngineUrlScheme::Syntax::Path); scheme.setDefaultPort(0); @@ -274,72 +259,6 @@ void MainWindow::commandQueued(const QString &command, bool confirm, bool return } -void MainWindow::slotLinkHandle(const QUrl &url) -{ - // Check if it's executing another process - if(m_command.process->state() != QProcess::NotRunning) - { - print(tr(gettext("Hay otro proceso en ejecución. Por favor espere."))); - return; - } - QString urlString = url.toString(); - QString urlScheme = url.scheme(); - // Clear the output widget for a normal user - if(!isAdmin()) - { - m_output->clear(); - } - if(urlScheme == COMMAND_CONFIRM || urlScheme == COMMAND_CONFIRM_OUTPUT || - urlScheme == COMMAND_OUTPUT_CONFIRM || urlScheme == COMMAND_WITH_CONFIRMATION) - { - // For all command with confirmation links, show a popup box - QMessageBox msgBox; - msgBox.setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint); - msgBox.setWindowTitle(tr(gettext("AVISO"))); - msgBox.setIcon(QMessageBox::Question); - msgBox.setTextFormat(Qt::RichText); - msgBox.setText(tr(gettext("La siguiente acción puede modificar datos o tardar varios minutos. El equipo no podrá ser utilizado durante su ejecución."))); - QPushButton *execButton = msgBox.addButton(tr(gettext("Ejecutar")), QMessageBox::ActionRole); - msgBox.addButton(tr(gettext("Cancelar")), QMessageBox::RejectRole); - msgBox.setDefaultButton(execButton); - msgBox.exec(); - // Continue if user press the execution button - if (msgBox.clickedButton() == execButton) - { - // For command with confirmation and output link, show an output window to non-admin user - if((urlScheme == COMMAND_CONFIRM_OUTPUT || urlScheme == COMMAND_OUTPUT_CONFIRM) && !isAdmin()) - { - int w=MainWindow::width(), h=MainWindow::height(); - m_output->setWindowFlags(Qt::Window); - m_output->move(100, 100); - m_output->setFixedSize(w*0.8-100, h*0.8-100); - m_output->show(); - } - // Execute the command - executeCommand(urlString.remove(0, urlScheme.length()+1)); - } - } - else if(urlScheme == COMMAND || urlScheme == COMMAND_OUTPUT) - { - // For command with output link, show an output window to non-admin user - if(urlScheme == COMMAND_OUTPUT && !isAdmin()) - { - int w=MainWindow::width(), h=MainWindow::height(); - m_output->setWindowFlags(Qt::Window); - m_output->move(100, 100); - m_output->setFixedSize(w*0.8-100, h*0.8-100); - m_output->show(); - } - // Execute the command - executeCommand(urlString.remove(0, urlScheme.length()+1)); - } - else - { - // For other link, load webpage - m_web->load(url); - } -} - void MainWindow::slotWebLoadStarted() { startProgressBar(); @@ -358,34 +277,6 @@ void MainWindow::slotWebLoadFinished(bool ok) // the return value is always true so we check the bytes received too qWarning() << "Load finished. URL: " << m_web->url() << "; ok = " << ok; -#if 0 - if(!ok && !m_web->url().isEmpty()) - { - QMessageBox msgBox; - msgBox.setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint); - msgBox.setWindowTitle(tr(gettext("AVISO"))); - msgBox.setIcon(QMessageBox::Question); - msgBox.setTextFormat(Qt::RichText); - msgBox.setText(tr(gettext("La página no se puede cargar."))); - - QPushButton *reloadButton = msgBox.addButton(tr(gettext("Recargar")), QMessageBox::ActionRole); - msgBox.addButton(tr(gettext("Abortar")), QMessageBox::RejectRole); - msgBox.exec(); - - if (msgBox.clickedButton() == reloadButton) - { - m_web->reload(); - } - else - { - close(); - } - } - else - { - finishProgressBar(); - } -#endif finishProgressBar(); } @@ -547,13 +438,6 @@ void MainWindow::slotDeleteTerminal() delete widget; } -void MainWindow::slotWebBarReturnPressed() -{ - QUrl url(m_webBar->text()); - if(url.isValid()) - slotLinkHandle(url); -} - int MainWindow::readEnvironmentValues() { // The return value @@ -648,28 +532,6 @@ void MainWindow::finishProgressBar() m_web->setEnabled(true); } -// Execute a command -void MainWindow::executeCommand(QString &string) -{ -/* QStringList list=string.split(" ",Qt::SkipEmptyParts); - QString program=list.takeFirst(); - m_process->setReadChannel(QProcess::StandardOutput); - // Assign the same Browser's environment to the process - m_process->setEnvironment(QProcess::systemEnvironment()); - m_process->start(program,list); - // Only show the command line to admin user - if(m_env.contains("ogactiveadmin") && m_env["ogactiveadmin"] == "true") - { - m_output->setTextColor(QColor(Qt::darkGreen)); - print(tr(gettext("Lanzando el comando: "))+string); - m_output->setTextColor(QColor(Qt::black)); - } - else - { - write(tr(gettext("Lanzando el comando: "))+string); - } - startProgressBar(); */ -} // Returns communication speed QString MainWindow::readSpeed() { diff --git a/src/mainwindow.h b/src/mainwindow.h index e81c9be..0a8d2b1 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -52,7 +52,6 @@ class MainWindow : public QMainWindow public slots: // Funcion que maneja los links - void slotLinkHandle(const QUrl& url); void slotWebLoadStarted(); void slotWebLoadFinished(bool ok); void slotWebLoadProgress(int progress); @@ -70,7 +69,6 @@ class MainWindow : public QMainWindow void slotDeleteTerminal(); // Funcion para el webar - void slotWebBarReturnPressed(); void slotUrlChanged(const QUrl &url); void commandQueued(const QString &command, bool confirm, bool returnOutput);