#ifndef MAINWINDOW_H #define MAINWINDOW_H #define COMMAND "command" #define COMMAND_CONFIRM "command+confirm" #define COMMAND_WITH_CONFIRMATION "commandwithconfirmation" // Backwards compatibility #define COMMAND_OUTPUT "command+output" #define COMMAND_CONFIRM_OUTPUT "command+confirm+output" #define COMMAND_OUTPUT_CONFIRM "command+output+confirm" #define ENVIRONMENT "OGLOGFILE,ogactiveadmin,DEFAULTSPEED" #include #include #include #include #include #include #include #include #include #include #include #include #include #include "digitalclock.h" struct PendingCommand { QString command = ""; bool confirm = false; bool returnOutput = false; QProcess *process = nullptr; bool operator==(const PendingCommand &other) { return other.process == process; } }; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = 0); void closeEvent(QCloseEvent *event) override; ~MainWindow(); public slots: // Funcion que maneja los links void slotWebLoadStarted(); void slotWebLoadFinished(bool ok); void slotWebLoadProgress(int progress); void slotSslErrors(QNetworkReply* reply); void slotCertificateErrors(const QWebEngineCertificateError &certificateError); // Funciones que manejan cada vez que el proceso hace algo void slotProcessStarted(); void slotProcessFinished(int code,QProcess::ExitStatus status); void slotProcessError(QProcess::ProcessError error); void slotProcessOutput(); void slotProcessErrorOutput(); // Funcion para crear terminales void slotCreateTerminal(); void slotDeleteTerminal(); // Funcion para el webar void slotUrlChanged(const QUrl &url); void commandQueued(const QString &command, bool confirm, bool returnOutput); private: bool isAdmin() const { return m_is_admin; } bool isKioskMode() const { return m_kiosk_mode; } void registerScheme(const QString &name); void registerHandler(const QString &name, bool confirm, bool output, const QString baseCommand = ""); bool m_is_admin{false}; bool m_kiosk_mode{false}; //Functions protected: int readEnvironmentValues(); void print(QString s); void write(QString s); void captureOutputForStatusBar(QString output); void startProgressBar(); void finishProgressBar(); void executeCommand(QString &string); QString readSpeed(); void showErrorMessage(QString string); protected: QWebEngineView *m_web; QTextEdit *m_output; QLabel *m_logo; QProgressBar *m_progressBar; QLabel *m_speedInfo; DigitalClock *m_clock; QTabWidget *m_tabs; QLineEdit *m_webBar; //QProcess *m_process; QMap m_env; QFile *m_logfile; QTextStream *m_logstream; PendingCommand m_command; //QVector m_commands; int m_numberTerminal; }; #endif // MAINWINDOW_H