1 | |
---|
2 | |
---|
3 | #include "ogurlhandler.h" |
---|
4 | #include <QWebEngineUrlRequestJob> |
---|
5 | #include <QMessageBox> |
---|
6 | #include <QDebug> |
---|
7 | |
---|
8 | |
---|
9 | void OGBrowserUrlHandlerCommand::requestStarted(QWebEngineUrlRequestJob *job) { |
---|
10 | |
---|
11 | qInfo() << "Command request: " << job->requestUrl(); |
---|
12 | |
---|
13 | |
---|
14 | emit command(job->requestUrl().path(), askConfirmation(), returnOuput()); |
---|
15 | //job->redirect(QUrl()); |
---|
16 | job->fail(QWebEngineUrlRequestJob::NoError); |
---|
17 | |
---|
18 | return; |
---|
19 | /* |
---|
20 | // For all command with confirmation links, show a popup box |
---|
21 | if (askConfirmation()) { |
---|
22 | QMessageBox msgBox; |
---|
23 | msgBox.setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint); |
---|
24 | msgBox.setWindowTitle(tr(gettext("AVISO"))); |
---|
25 | msgBox.setIcon(QMessageBox::Question); |
---|
26 | msgBox.setTextFormat(Qt::RichText); |
---|
27 | 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."))); |
---|
28 | QPushButton *execButton = msgBox.addButton(tr(gettext("Ejecutar")), QMessageBox::ActionRole); |
---|
29 | msgBox.addButton(tr(gettext("Cancelar")), QMessageBox::RejectRole); |
---|
30 | msgBox.setDefaultButton(execButton); |
---|
31 | msgBox.exec(); |
---|
32 | // Continue if user press the execution button |
---|
33 | if (msgBox.clickedButton() == execButton) |
---|
34 | { |
---|
35 | // For command with confirmation and output link, show an output window to non-admin user |
---|
36 | if((urlScheme == COMMAND_CONFIRM_OUTPUT || urlScheme == COMMAND_OUTPUT_CONFIRM) && |
---|
37 | (! m_env.contains("ogactiveadmin") || m_env["ogactiveadmin"] != "true")) |
---|
38 | { |
---|
39 | int w=MainWindow::width(), h=MainWindow::height(); |
---|
40 | m_output->setWindowFlags(Qt::Window); |
---|
41 | m_output->move(100, 100); |
---|
42 | m_output->setFixedSize(w*0.8-100, h*0.8-100); |
---|
43 | m_output->show(); |
---|
44 | } |
---|
45 | } else { |
---|
46 | job->fail(QWebEngineUrlRequestJob::RequestDenied); |
---|
47 | return; |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
51 | // Execute the command |
---|
52 | executeCommand(urlString.remove(0, urlScheme.length()+1)); |
---|
53 | |
---|
54 | |
---|
55 | |
---|
56 | |
---|
57 | else if(urlScheme == COMMAND || urlScheme == COMMAND_OUTPUT) |
---|
58 | { |
---|
59 | // For command with output link, show an output window to non-admin user |
---|
60 | if(urlScheme == COMMAND_OUTPUT && |
---|
61 | (! m_env.contains("ogactiveadmin") || m_env["ogactiveadmin"] != "true")) |
---|
62 | { |
---|
63 | int w=MainWindow::width(), h=MainWindow::height(); |
---|
64 | m_output->setWindowFlags(Qt::Window); |
---|
65 | m_output->move(100, 100); |
---|
66 | m_output->setFixedSize(w*0.8-100, h*0.8-100); |
---|
67 | m_output->show(); |
---|
68 | } |
---|
69 | // Execute the command |
---|
70 | executeCommand(urlString.remove(0, urlScheme.length()+1)); |
---|
71 | } */ |
---|
72 | } |
---|