• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef GRAPHIC_LITE_MAIN_WIDGET_H
17 #define GRAPHIC_LITE_MAIN_WIDGET_H
18 
19 #include <QImage>
20 #include <QJsonDocument>
21 #include <QJsonObject>
22 #include <QLocalServer>
23 #include <QLocalSocket>
24 #include <QMessageBox>
25 #include <QMouseEvent>
26 #include <QPainter>
27 #include <QWidget>
28 
29 #include "common/graphic_startup.h"
30 #include "gui_thread.h"
31 #include "key_input.h"
32 #include "monitor.h"
33 #include "mouse_input.h"
34 #include "mousewheel_input.h"
35 #include "task_thread.h"
36 #include "ui_mainwidget.h"
37 
38 QT_BEGIN_NAMESPACE
39 namespace Ui {
40 class MainWidget;
41 }
42 QT_END_NAMESPACE
43 
44 namespace OHOS {
45 class MainWidget : public QWidget {
46     Q_OBJECT
47 public:
48     MainWidget(QWidget* parent = nullptr);
49     ~MainWidget();
50     void CreateGUIThread();
51     void CreateTaskThread();
52 
53 protected:
54     void mouseMoveEvent(QMouseEvent* event) override;
55     void mousePressEvent(QMouseEvent* event) override;
56     void mouseReleaseEvent(QMouseEvent* event) override;
57     void wheelEvent(QWheelEvent* event) override;
58     void paintEvent(QPaintEvent* event) override;
59     void keyPressEvent(QKeyEvent* event) override;
60     void keyReleaseEvent(QKeyEvent* event) override;
61 
62 private:
63     Ui::MainWidget* ui_;
64     QImage img_;
65     uint32_t width_;
66     uint32_t height_;
67     GUIThread* guiThread_;
68     TaskThread* taskThread_;
69 
70 public slots:
UpdatePaintSlot(uint32_t * tftFb,uint32_t imgWidth,uint32_t imgHeight)71     void UpdatePaintSlot(uint32_t* tftFb, uint32_t imgWidth, uint32_t imgHeight)
72     {
73         img_ = QImage(imgWidth, imgHeight, QImage::Format_RGB32);
74         uint32_t* p = tftFb;
75         for (uint32_t i = 0; i < imgHeight; i++) {
76             for (uint32_t j = 0; j < imgWidth; j++) {
77                 img_.setPixel(j, i, *p++);
78             }
79         }
80         update();
81     };
82 };
83 } // namespace OHOS
84 
85 #endif // GRAPHIC_LITE_MAIN_WIDGET_H
86