source: ogBrowser-Git/src/mainwindow.h @ 9c6539c

jenkinsmain
Last change on this file since 9c6539c was 476581b, checked in by Vadim Troshchinskiy Shmelev <vtroshchinskiy@…>, 16 months ago

Add desktop file parser

  • Property mode set to 100644
File size: 3.1 KB
Line 
1#ifndef MAINWINDOW_H
2#define MAINWINDOW_H
3
4#define COMMAND "command"
5#define COMMAND_CONFIRM "command+confirm"
6#define COMMAND_WITH_CONFIRMATION "commandwithconfirmation"  // Backwards compatibility
7#define COMMAND_OUTPUT "command+output"
8#define COMMAND_CONFIRM_OUTPUT "command+confirm+output"
9#define COMMAND_OUTPUT_CONFIRM "command+output+confirm"
10#define ENVIRONMENT "OGLOGFILE,ogactiveadmin,DEFAULTSPEED"
11
12
13#include <QWidget>
14#include <QProcess>
15#include <QMap>
16#include <QMainWindow>
17#include <QNetworkReply>
18#include <QSslError>
19#include <QProgressBar>
20#include <QLabel>
21#include <QLineEdit>
22#include <QTextEdit>
23#include <QFile>
24#include <QWebEngineView>
25#include <QVector>
26
27
28#include "digitalclock.h"
29
30
31
32struct PendingCommand {
33    QString command = "";
34    bool confirm = false;
35    bool returnOutput = false;
36
37    QProcess *process = nullptr;
38
39    bool operator==(const PendingCommand &other) {
40        return other.process == process;
41    }
42};
43
44
45class MainWindow : public QMainWindow
46{
47    Q_OBJECT
48
49    public:
50        MainWindow(QWidget *parent = 0);
51        void closeEvent(QCloseEvent *event) override;
52
53        ~MainWindow();
54
55    public slots:
56        // Funcion que maneja los links
57        void slotWebLoadStarted();
58        void slotWebLoadFinished(bool ok);
59        void slotWebLoadProgress(int progress);
60        void slotSslErrors(QNetworkReply* reply);
61
62        // Funciones que manejan cada vez que el proceso hace algo
63        void slotProcessStarted();
64        void slotProcessFinished(int code,QProcess::ExitStatus status);
65        void slotProcessError(QProcess::ProcessError error);
66        void slotProcessOutput();
67        void slotProcessErrorOutput();
68
69        // Funcion para crear terminales
70        void slotCreateTerminal();
71        void slotDeleteTerminal();
72
73        // Funcion para el webar
74        void slotUrlChanged(const QUrl &url);
75
76        void commandQueued(const QString &command, bool confirm, bool returnOutput);
77
78
79    private:
80        bool isAdmin() const { return m_is_admin; }
81        bool isKioskMode() const { return m_kiosk_mode; }
82        void registerScheme(const QString &name);
83        void registerHandler(const QString &name, bool confirm, bool output, const QString baseCommand = "");
84
85        bool m_is_admin{false};
86        bool m_kiosk_mode{false};
87
88
89    //Functions
90    protected:
91        int readEnvironmentValues();
92        void print(QString s);
93        void write(QString s);
94        void captureOutputForStatusBar(QString output);
95        void startProgressBar();
96        void finishProgressBar();
97        void executeCommand(QString &string);
98        QString readSpeed();
99        void showErrorMessage(QString string);
100
101    protected:
102        QWebEngineView *m_web;
103        QTextEdit *m_output;
104        QLabel *m_logo;
105        QProgressBar *m_progressBar;
106        QLabel *m_speedInfo;
107        DigitalClock *m_clock;
108        QTabWidget *m_tabs;
109        QLineEdit *m_webBar;
110
111        //QProcess *m_process;
112
113        QMap<QString,QString> m_env;
114        QFile *m_logfile;
115        QTextStream *m_logstream;
116
117        PendingCommand m_command;
118        //QVector<PendingCommand> m_commands;
119
120
121        int m_numberTerminal;
122};
123
124#endif // MAINWINDOW_H
Note: See TracBrowser for help on using the repository browser.