├── .gitignore ├── HardhatSystem ├── HardhatSystem.pro ├── components │ ├── CameraGroup │ │ ├── CameraGroup │ │ ├── CameraGroup.pri │ │ ├── cameragroup.h │ │ ├── cpp │ │ │ ├── camera │ │ │ ├── camera.cpp │ │ │ ├── camera.h │ │ │ ├── camerathread.cpp │ │ │ ├── camerathread.h │ │ │ ├── cvcamera.cpp │ │ │ └── cvcamera.h │ │ └── qml │ │ │ ├── Camera.qml │ │ │ └── Camera.qrc │ ├── SearchGroup │ │ ├── SearchGroup │ │ ├── SearchGroup.pri │ │ ├── cpp │ │ │ ├── cvsearch.cpp │ │ │ ├── cvsearch.h │ │ │ ├── search.cpp │ │ │ ├── search.h │ │ │ ├── searchthread.cpp │ │ │ ├── searchthread.h │ │ │ ├── videolistmodel.cpp │ │ │ └── videolistmodel.h │ │ ├── qml │ │ │ ├── Search.qml │ │ │ └── Search.qrc │ │ └── searchgroup.h │ ├── VideoGroup │ │ ├── VideoGroup │ │ ├── VideoGroup.pri │ │ ├── cpp │ │ │ ├── cvvideo.cpp │ │ │ ├── cvvideo.h │ │ │ ├── video │ │ │ ├── video.cpp │ │ │ ├── video.h │ │ │ ├── videothread.cpp │ │ │ └── videothread.h │ │ ├── qml │ │ │ ├── Video.qml │ │ │ └── Video.qrc │ │ └── videogroup.h │ ├── WelcomeGroup │ │ ├── WelcomeGroup │ │ ├── WelcomeGroup.pri │ │ ├── cpp │ │ │ ├── Welcome │ │ │ ├── welcome.cpp │ │ │ └── welcome.h │ │ ├── qml │ │ │ ├── Welcome.qml │ │ │ └── Welcome.qrc │ │ └── welcomegroup.h │ └── components.pri ├── cpp │ ├── JQToolsManage │ ├── bettervideocapture.hpp │ ├── dataface.cpp │ ├── dataface.h │ ├── jqtools_manage.hpp │ ├── main.cpp │ ├── stable.h │ ├── utils.cpp │ ├── utils.h │ ├── yolo_cpp_dll.lib │ └── yolo_v2_class.hpp ├── library │ ├── JQToolsLibrary │ │ ├── JQToolsLibrary.pri │ │ ├── include │ │ │ ├── JQToolsLibrary │ │ │ └── jqtoolslibrary.h │ │ └── src │ │ │ └── jqtoolslibrary.cpp │ └── MaterialUI │ │ ├── Element │ │ ├── BaseListItem.qml │ │ ├── BottomSheet.qml │ │ ├── CircleMask.qml │ │ ├── Divider.qml │ │ ├── Dropdown.qml │ │ ├── Ink.qml │ │ ├── PopupBase.qml │ │ ├── Scrollbar.qml │ │ ├── Standard.qml │ │ ├── Subheader.qml │ │ ├── ThemePalette.qml │ │ ├── ThinDivider.qml │ │ └── View.qml │ │ ├── Interface │ │ ├── MaterialActionButton.qml │ │ ├── MaterialAnimation.qml │ │ ├── MaterialBottomActionSheet.qml │ │ ├── MaterialButton.qml │ │ ├── MaterialCheckBox.qml │ │ ├── MaterialDatePicker.qml │ │ ├── MaterialDialog.qml │ │ ├── MaterialDialogAlert.qml │ │ ├── MaterialDialogConfirm.qml │ │ ├── MaterialDialogDatePicker.qml │ │ ├── MaterialDialogPrompt.qml │ │ ├── MaterialDialogScrolling.qml │ │ ├── MaterialDialogTextArea.qml │ │ ├── MaterialDialogTimePicker.qml │ │ ├── MaterialLabel.qml │ │ ├── MaterialMenuField.qml │ │ ├── MaterialPage.qml │ │ ├── MaterialProgressBar.qml │ │ ├── MaterialProgressCircle.qml │ │ ├── MaterialRadioButton.qml │ │ ├── MaterialSlider.qml │ │ ├── MaterialSnackbar.qml │ │ ├── MaterialSwipeToRefresh.qml │ │ ├── MaterialSwitch.qml │ │ ├── MaterialTabbed.qml │ │ ├── MaterialTableView.qml │ │ ├── MaterialTabs.qml │ │ ├── MaterialTextField.qml │ │ ├── MaterialTimePicker.qml │ │ └── MaterialTreeView.qml │ │ ├── Material-Design-Iconic-Font.ttf │ │ ├── MaterialUI.pri │ │ ├── MaterialUI.qml │ │ └── MaterialUI.qrc └── qml │ ├── main.qml │ └── qml.qrc ├── LICENSE ├── README.md └── preview ├── HardhatSystem.png ├── camera1.png ├── camera3.png ├── camera5.png ├── camera6.png ├── camera7.png ├── database.png ├── search1.png ├── search2.png ├── search3.png ├── search4.png ├── search5.png ├── video1.png ├── video2.png ├── video3.png ├── video4.png └── video5.png /.gitignore: -------------------------------------------------------------------------------- 1 | # qtcreator generated files 2 | HardhatSystem/*.pro.user* 3 | *Release/ 4 | *Debug/ 5 | 6 | *.doc -------------------------------------------------------------------------------- /HardhatSystem/HardhatSystem.pro: -------------------------------------------------------------------------------- 1 | QT += quick qml widgets concurrent multimedia sql 2 | CONFIG += c++11 3 | 4 | 5 | include( $$PWD/library/JQToolsLibrary/JQToolsLibrary.pri ) 6 | include( $$PWD/library/MaterialUI/MaterialUI.pri ) 7 | include( $$PWD/components/components.pri ) 8 | 9 | # The following define makes your compiler emit warnings if you use 10 | # any feature of Qt which as been marked deprecated (the exact warnings 11 | # depend on your compiler). Please consult the documentation of the 12 | # deprecated API in order to know how to port your code away from it. 13 | DEFINES += QT_DEPRECATED_WARNINGS 14 | 15 | # You can also make your code fail to compile if you use deprecated APIs. 16 | # In order to do so, uncomment the following line. 17 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 18 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 19 | 20 | INCLUDEPATH += $$PWD/cpp/ 21 | unix:INCLUDEPATH += /usr/local/include/ 22 | win32:INCLUDEPATH += C:/opencv_3.0/opencv/build/include/ 23 | 24 | HEADERS += \ 25 | $$PWD/cpp/jqtools_manage.hpp \ 26 | $$PWD/cpp/yolo_v2_class.hpp \ 27 | $$PWD/cpp/utils.h \ 28 | $$PWD/cpp/bettervideocapture.hpp \ 29 | cpp/dataface.h 30 | 31 | SOURCES += \ 32 | $$PWD/cpp/main.cpp \ 33 | cpp/utils.cpp \ 34 | cpp/dataface.cpp 35 | 36 | RESOURCES += \ 37 | $$PWD/qml/qml.qrc 38 | 39 | unix:LIBS += -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_videoio 40 | unix:LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgcodecs -lopencv_highgui 41 | unix:LIBS += -ldarknet 42 | win32:LIBS += C:/opencv_3.0/opencv/build/x64/vc14/lib/opencv_world340.lib 43 | win32:LIBS += $$PWD/cpp/yolo_cpp_dll.lib 44 | 45 | # Additional import path used to resolve QML modules in Qt Creator's code model 46 | QML_IMPORT_PATH = 47 | 48 | # Additional import path used to resolve QML modules just for Qt Quick Designer 49 | QML_DESIGNER_IMPORT_PATH = 50 | 51 | # Default rules for deployment. 52 | qnx: target.path = /tmp/$${TARGET}/bin 53 | else: unix:!android: target.path = /opt/$${TARGET}/bin 54 | !isEmpty(target.path): INSTALLS += target 55 | -------------------------------------------------------------------------------- /HardhatSystem/components/CameraGroup/CameraGroup: -------------------------------------------------------------------------------- 1 | #include "cameragroup.h" -------------------------------------------------------------------------------- /HardhatSystem/components/CameraGroup/CameraGroup.pri: -------------------------------------------------------------------------------- 1 | 2 | INCLUDEPATH *= \ 3 | $$PWD/cpp/ \ 4 | $$PWD/ 5 | 6 | HEADERS *= \ 7 | $$PWD/cpp/camera.h \ 8 | $$PWD/cameragroup.h \ 9 | $$PWD/cpp/camerathread.h \ 10 | $$PWD/cpp/cvcamera.h 11 | 12 | SOURCES *= \ 13 | $$PWD/cpp/camera.cpp \ 14 | $$PWD/cpp/camerathread.cpp \ 15 | $$PWD/cpp/cvcamera.cpp 16 | 17 | RESOURCES *= \ 18 | $$PWD/qml/Camera.qrc 19 | -------------------------------------------------------------------------------- /HardhatSystem/components/CameraGroup/cameragroup.h: -------------------------------------------------------------------------------- 1 |  2 | #ifndef CAMERAGROUP_CAMERAGROUP_H_ 3 | #define CAMERAGROUP_CAMERAGROUP_H_ 4 | 5 | // CameraGroup lib import 6 | #include "camera.h" 7 | #include "cvcamera.h" 8 | 9 | #define CAMERAGROUP_INITIALIZA \ 10 | CAMERA_INITIALIZA; \ 11 | CVCAMERA_INITIALIZA; 12 | 13 | #endif//CAMERAGROUP_CAMERAGROUP_H_ 14 | -------------------------------------------------------------------------------- /HardhatSystem/components/CameraGroup/cpp/camera: -------------------------------------------------------------------------------- 1 | #ifndef GROUP_CAMERAGROUP_CPP_CAMERA_H_ 2 | #define GROUP_CAMERAGROUP_CPP_CAMERA_H_ 3 | 4 | // JQToolsLibrary import 5 | #include 6 | 7 | #define CAMERA_INITIALIZA \ 8 | { \ 9 | qmlRegisterType("Camera", 1, 0, "CameraManage"); \ 10 | } 11 | 12 | namespace Camera 13 | { 14 | 15 | class Manage: public AbstractTool 16 | { 17 | Q_OBJECT 18 | Q_DISABLE_COPY(Manage) 19 | 20 | public: 21 | Manage() = default; 22 | 23 | ~Manage() = default; 24 | 25 | public slots: 26 | void openGitHubLink(); 27 | 28 | void openLatestVersionDownloadLink(); 29 | }; 30 | 31 | } 32 | 33 | #endif//GROUP_CAMERAGROUP_CPP_CAMERA_H_ 34 | -------------------------------------------------------------------------------- /HardhatSystem/components/CameraGroup/cpp/camera.cpp: -------------------------------------------------------------------------------- 1 | #include "camera.h" 2 | 3 | 4 | 5 | using namespace Camera; 6 | 7 | void Manage::openGitHubLink() 8 | { 9 | 10 | } 11 | 12 | void Manage::openLatestVersionDownloadLink() 13 | { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /HardhatSystem/components/CameraGroup/cpp/camera.h: -------------------------------------------------------------------------------- 1 | #ifndef GROUP_CAMERAGROUP_CPP_CAMERA_H_ 2 | #define GROUP_CAMERAGROUP_CPP_CAMERA_H_ 3 | 4 | // JQToolsLibrary import 5 | #include 6 | 7 | #define CAMERA_INITIALIZA \ 8 | { \ 9 | qmlRegisterType("Camera", 1, 0, "CameraManage"); \ 10 | } 11 | 12 | namespace Camera 13 | { 14 | 15 | class Manage: public AbstractTool 16 | { 17 | Q_OBJECT 18 | Q_DISABLE_COPY(Manage) 19 | 20 | public: 21 | Manage() = default; 22 | 23 | ~Manage() = default; 24 | 25 | public slots: 26 | void openGitHubLink(); 27 | 28 | void openLatestVersionDownloadLink(); 29 | }; 30 | 31 | } 32 | 33 | #endif//GROUP_CAMERAGROUP_CPP_CAMERA_H_ 34 | -------------------------------------------------------------------------------- /HardhatSystem/components/CameraGroup/cpp/camerathread.cpp: -------------------------------------------------------------------------------- 1 | #include "camerathread.h" 2 | #include "utils.h" 3 | 4 | 5 | 6 | CameraTask::CameraTask(std::vector *results, BetterVideoCapture *camera, QVideoFrame *videoFrame, unsigned char *cvImageBuf, int width, int height) 7 | { 8 | this->running = true; 9 | this->camera = camera; 10 | this->videoFrame = videoFrame; 11 | this->cvImageBuf = cvImageBuf; 12 | this->width = width; 13 | this->height = height; 14 | this->results = results; 15 | 16 | } 17 | 18 | CameraTask::~CameraTask() 19 | { 20 | //Leave camera and videoFrame alone, they will be destroyed elsewhere 21 | } 22 | 23 | void CameraTask::stop() 24 | { 25 | imageReady(); 26 | running = false; 27 | } 28 | 29 | void CameraTask::doWork() 30 | { 31 | running = true; 32 | if(videoFrame) 33 | videoFrame->map(QAbstractVideoBuffer::ReadOnly); 34 | 35 | cv::Mat screenImage; 36 | if(videoFrame) 37 | screenImage = cv::Mat(height,width,CV_8UC4,videoFrame->bits()); 38 | 39 | while(running && videoFrame != NULL && camera != NULL) 40 | { 41 | if(!camera->grabFrame()) 42 | continue; 43 | unsigned char* cameraFrame = camera->retrieveFrame(); 44 | 45 | //Get camera image into screen frame buffer 46 | if(videoFrame) 47 | { 48 | // Assuming desktop, RGB camera image and RGBA QVideoFrame 49 | cv::Mat tempMat(height, width, CV_8UC3, cameraFrame); 50 | 51 | std::shared_ptr img = detector->mat_to_image(tempMat); 52 | image_t *iii = img.get(); 53 | std::vector tmpres = detector->detect(*iii); 54 | results->assign(tmpres.begin(), tmpres.end()); 55 | 56 | qDebug() << "Person numbers: " << results->size(); 57 | cv::putText(tempMat, getCurrentTime2().toStdString(), cv::Point(10, 20), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(255, 255, 255), 1); 58 | videoWriter->write(tempMat); 59 | 60 | int nohat = 0; 61 | for(size_t i = 0; i < results->size(); i++) 62 | { 63 | int classid = (*results)[i].obj_id; 64 | int x = (*results)[i].x; 65 | int y = (*results)[i].y; 66 | if(classid == 1) 67 | { 68 | nohat++; 69 | cv::putText(tempMat, "No Hardhat!", cv::Point(x, y-10), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 0, 255), 1); 70 | cv::Rect rec((*results)[i].x, (*results)[i].y, (*results)[i].w, (*results)[i].h); 71 | cv::rectangle(tempMat, rec, cv::Scalar(0, 0, 255), 4); 72 | } 73 | else 74 | { 75 | cv::Rect rec((*results)[i].x, (*results)[i].y, (*results)[i].w, (*results)[i].h); 76 | cv::rectangle(tempMat, rec, cv::Scalar(0, 250, 0), 4); 77 | } 78 | } 79 | // cv::putText(tempMat, "[Total] " + QString::number(results->size(), 10).toStdString() + " [No Hardhat] " + 80 | // QString::number(nohat, 10).toStdString(), cv::Point(10, tempMat.rows - 10), cv::FONT_HERSHEY_SIMPLEX, 1, cv::Scalar(0, 0, 255), 2); 81 | 82 | 83 | cv::cvtColor(tempMat, screenImage, cv::COLOR_RGB2RGBA); 84 | } 85 | 86 | if(cvImageBuf) 87 | { 88 | // Assuming desktop, RGB camera image 89 | memcpy(cvImageBuf, cameraFrame, height*width*3); 90 | } 91 | 92 | emit imageReady(); 93 | } 94 | 95 | } 96 | 97 | 98 | CameraThread::CameraThread(std::vector *results, BetterVideoCapture *camera, QVideoFrame *videoFrame, unsigned char *cvImageBuf, int width, int height) 99 | { 100 | task = new CameraTask(results, camera,videoFrame,cvImageBuf,width,height); 101 | task->moveToThread(&workerThread); 102 | connect(&workerThread, SIGNAL(started()), task, SLOT(doWork())); 103 | connect(task, SIGNAL(imageReady()), this, SIGNAL(imageReady())); 104 | } 105 | 106 | CameraThread::~CameraThread() 107 | { 108 | stop(); 109 | delete task; 110 | } 111 | 112 | void CameraThread::start() 113 | { 114 | if(!workerThread.isRunning()) 115 | workerThread.start(); 116 | else 117 | { 118 | task->doWork(); 119 | } 120 | } 121 | 122 | void CameraThread::stop() 123 | { 124 | if(task != NULL) 125 | task->stop(); 126 | workerThread.quit(); 127 | workerThread.wait(); 128 | } 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /HardhatSystem/components/CameraGroup/cpp/camerathread.h: -------------------------------------------------------------------------------- 1 | #ifndef CAMERATHREAD_H 2 | #define CAMERATHREAD_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include "bettervideocapture.hpp" 18 | #include "utils.h" 19 | 20 | 21 | #define DPRINT(...) while(0); 22 | 23 | 24 | /** 25 | * @brief Object that contains the camera loop and its parameters 26 | */ 27 | class CameraTask : public QObject{ 28 | Q_OBJECT 29 | 30 | public: 31 | 32 | /** 33 | * @brief Creates a new camera access task 34 | * 35 | * @param camera Camera object to get data from 36 | * @param videoFrame Place to draw the camera image, pass NULL to not draw camera image to a QVideoFrame 37 | * @param cvImageBuf Place to export the camera image, pass NULL to not export the camera image 38 | * @param width Width of the camera image 39 | * @param height Height of the camera image 40 | */ 41 | CameraTask(std::vector *results, BetterVideoCapture* camera, QVideoFrame* videoFrame, unsigned char* cvImageBuf, int width, int height); 42 | 43 | /** 44 | * @brief Destroys this camera access task, does not touch the camera or the videoFrame 45 | */ 46 | virtual ~CameraTask(); 47 | 48 | /** 49 | * @brief Asks for the main loop to stop 50 | */ 51 | void stop(); 52 | 53 | private: 54 | 55 | int width; ///< Width of the camera image 56 | int height; ///< Height of the camera image 57 | BetterVideoCapture* camera; ///< The camera to get data from 58 | bool running = false; ///< Whether the worker thread is running 59 | QVideoFrame* videoFrame; ///< Place to draw camera image to 60 | unsigned char* cvImageBuf; ///< Place to export camera image to 61 | \ 62 | std::vector *results; 63 | 64 | public slots: 65 | /** 66 | * @brief Continuously gets data from the camera 67 | */ 68 | void doWork(); 69 | 70 | 71 | signals: 72 | 73 | /** 74 | * @brief Emitted when image from a new frame is ready 75 | */ 76 | void imageReady(); 77 | 78 | }; 79 | 80 | 81 | 82 | /** 83 | * @brief Object that starts and stops the camera loop 84 | */ 85 | class CameraThread : public QObject 86 | { 87 | Q_OBJECT 88 | public: 89 | 90 | /** 91 | * @brief Creates a new camera controller 92 | * 93 | * @param camera Camera object to get data from 94 | * @param videoFrame Place to draw the camera image, pass NULL to not draw camera image to a QVideoFrame 95 | * @param cvImageBuf Place to export the camera image, pass NULL to not export the camera image 96 | * @param width Width of the camera image 97 | * @param height Height of the camera image 98 | */ 99 | CameraThread(std::vector *results, BetterVideoCapture* camera, QVideoFrame* videoFrame, unsigned char* cvImageBuf, int width, int height); 100 | 101 | /** 102 | * @brief Destroys this camera controller 103 | */ 104 | virtual ~CameraThread(); 105 | 106 | /** 107 | * @brief Starts the camera loop 108 | */ 109 | void start(); 110 | 111 | /** 112 | * @brief Asks the camera loop to stop 113 | */ 114 | void stop(); 115 | 116 | private: 117 | 118 | QThread workerThread; ///< The thread that the camera will work in 119 | CameraTask* task = NULL; ///< The camera loop method and parameter container 120 | 121 | signals: 122 | 123 | /** 124 | * @brief Emitted when image from a new frame is ready 125 | */ 126 | void imageReady(); 127 | 128 | 129 | }; 130 | 131 | #endif // CAMERATHREAD_H 132 | -------------------------------------------------------------------------------- /HardhatSystem/components/CameraGroup/cpp/cvcamera.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file cvcamera.h 3 | * @brief Nice QML wrapper for camera access with OpenCV 4 | */ 5 | 6 | #ifndef CVCAMERA_H 7 | #define CVCAMERA_H 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | #include "camerathread.h" 22 | #include "utils.h" 23 | 24 | #define CVCAMERA_INITIALIZA \ 25 | { \ 26 | qmlRegisterType("com.nuaa.CVCamera", 1, 0, "CVCamera"); \ 27 | } 28 | 29 | 30 | 31 | class CVCamera : public QQuickItem 32 | { 33 | Q_OBJECT 34 | Q_DISABLE_COPY(CVCamera) 35 | Q_PROPERTY(int frameNow READ getFrameNow WRITE setFrameNow NOTIFY frameNowChanged) 36 | Q_PROPERTY(int totalNow READ getTotalNow NOTIFY totalNowChanged) 37 | Q_PROPERTY(int noHatNow READ getNoHatNow NOTIFY noHatNowChanged) 38 | 39 | Q_PROPERTY(int device READ getDevice WRITE setDevice) 40 | Q_PROPERTY(QAbstractVideoSurface* videoSurface READ getVideoSurface WRITE setVideoSurface) 41 | Q_PROPERTY(QSize size READ getSize WRITE setSize NOTIFY sizeChanged) 42 | Q_PROPERTY(QStringList deviceList READ getDeviceList NOTIFY deviceListChanged) 43 | Q_PROPERTY(cv::Mat cvImage READ getCvImage NOTIFY cvImageChanged) 44 | 45 | 46 | 47 | public: 48 | CVCamera(QQuickItem* parent = 0); 49 | 50 | ~CVCamera(); 51 | 52 | int getDevice() const; 53 | 54 | void setDevice(int device); 55 | 56 | QSize getSize() const; 57 | 58 | void setSize(QSize size); 59 | 60 | QStringList getDeviceList() const; 61 | 62 | QAbstractVideoSurface* getVideoSurface() const; 63 | 64 | void setVideoSurface(QAbstractVideoSurface* videoSurface); 65 | 66 | cv::Mat getCvImage(); 67 | 68 | 69 | int getFrameNow() const; 70 | int getTotalNow() const; 71 | int getNoHatNow() const; 72 | 73 | void setFrameNow(int f); 74 | 75 | signals: 76 | void sizeChanged(); 77 | 78 | void deviceListChanged(); 79 | 80 | void cvImageChanged(); 81 | 82 | void frameNowChanged(); 83 | void totalNowChanged(); 84 | void noHatNowChanged(); 85 | 86 | private: 87 | const QVideoFrame::PixelFormat VIDEO_OUTPUT_FORMAT = QVideoFrame::PixelFormat::Format_ARGB32; 88 | 89 | bool isrunning = true; 90 | int device = -1; 91 | QStringList deviceList; 92 | QSize size; 93 | 94 | double fps; 95 | int frameNow = 0; 96 | int totalNow = 0; 97 | int noHatNow = 0; 98 | std::vector results; 99 | 100 | QVariantList qFrameNow, qBoxID, qObjID, qX, qY, qW, qH, qProb; // Database variant 101 | QString fileUrl; 102 | 103 | 104 | 105 | 106 | BetterVideoCapture* camera = NULL; ///< The camera object 107 | CameraThread* thread = NULL; ///< Thread to run camera image acquisition 108 | 109 | 110 | QVideoFrame* videoFrame = NULL; 111 | QAbstractVideoSurface* videoSurface = NULL; 112 | 113 | 114 | bool exportCvImage = false; 115 | cv::Mat cvImage; 116 | unsigned char* cvImageBuf = NULL; 117 | 118 | void update(); 119 | void allocateCvImage(); 120 | void allocateVideoFrame(); 121 | void clearQVariant(); 122 | bool saveDatabase(); 123 | 124 | 125 | public slots: 126 | 127 | void changeParent(QQuickItem* parent); 128 | void videoControl(); 129 | 130 | 131 | private slots: 132 | 133 | void imageReceived(); 134 | 135 | 136 | }; 137 | 138 | #endif // CVCAMERA_H 139 | -------------------------------------------------------------------------------- /HardhatSystem/components/CameraGroup/qml/Camera.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.7 2 | import QtQuick.Controls 1.4 3 | import QtMultimedia 5.4 4 | import QtQuick.Dialogs 1.0 5 | import "qrc:/MaterialUI/Interface/" 6 | import Camera 1.0 7 | 8 | import com.nuaa.CVCamera 1.0 9 | 10 | Item { 11 | id: video 12 | width: 820 13 | height: 590 14 | 15 | CameraManage { 16 | id: cameraManage 17 | } 18 | 19 | CVCamera { 20 | id: mediaPlayer 21 | device: deviceBox.currentIndex 22 | 23 | onFrameNowChanged: { 24 | totalNumLabel.text = mediaPlayer.totalNow 25 | nohatNumLabel.text = mediaPlayer.noHatNow 26 | } 27 | } 28 | 29 | Rectangle { 30 | id: playerRect 31 | x: 0 32 | y: 0 33 | width: parent.width 34 | height:520 35 | color: "black" 36 | 37 | VideoOutput { 38 | id: out 39 | x: 0 40 | y: 0 41 | width: parent.width 42 | height: parent.height 43 | 44 | source: mediaPlayer 45 | } 46 | 47 | Label { 48 | id: nohatNumLabel 49 | x: 756 50 | y: 52 51 | width: 37 52 | height: 32 53 | color: "#79d1fc" 54 | text: qsTr("0") 55 | z: 4 56 | font.bold: true 57 | horizontalAlignment: Text.AlignHCenter 58 | clip: false 59 | font.pointSize: 15 60 | opacity: 1 61 | font.family: "Courier" 62 | verticalAlignment: Text.AlignVCenter 63 | } 64 | 65 | Label { 66 | id: totalNumLabel 67 | x: 756 68 | y: 17 69 | width: 37 70 | height: 32 71 | color: "#79d1fc" 72 | text: qsTr("0") 73 | z: 3 74 | font.bold: true 75 | horizontalAlignment: Text.AlignHCenter 76 | verticalAlignment: Text.AlignVCenter 77 | font.family: "Courier" 78 | clip: false 79 | opacity: 1 80 | font.pointSize: 15 81 | } 82 | 83 | Label { 84 | id: nohatLabel 85 | x: 676 86 | y: 52 87 | width: 82 88 | height: 32 89 | color: "#82d5fd" 90 | text: qsTr("未戴帽:") 91 | z: 1 92 | font.bold: true 93 | clip: false 94 | opacity: 1 95 | font.pointSize: 15 96 | } 97 | 98 | Label { 99 | id: totalLabel 100 | x: 676 101 | y: 17 102 | width: 82 103 | height: 32 104 | color: "#79d1fc" 105 | text: qsTr("总人数:") 106 | z: 2 107 | font.bold: true 108 | font.pointSize: 15 109 | opacity: 1 110 | clip: false 111 | } 112 | 113 | Rectangle { 114 | id: shadowRec 115 | x: 657 116 | y: 8 117 | width: 155 118 | height: 86 119 | color: "#000000" 120 | radius: 0 121 | border.color: "#dc1c04" 122 | border.width: 5 123 | opacity: 0.5 124 | } 125 | 126 | 127 | 128 | 129 | } 130 | 131 | onVisibleChanged: { 132 | console.log("camera visible changed! Visible: ", video.visible) 133 | if(video.visible === false) 134 | { 135 | if(controlbutton.text === "初始") 136 | controlbutton.text = "暂停" 137 | else if(controlbutton.text === "暂停") 138 | { 139 | controlbutton.text = "开始" 140 | mediaPlayer.videoControl() 141 | } 142 | } 143 | } 144 | 145 | MaterialButton { 146 | id: controlbutton 147 | x: 692 148 | y: 532 149 | width: 120 150 | height: 40 151 | text: "初始" 152 | 153 | onClicked: { 154 | if(text === "暂停") 155 | text = "继续" 156 | else 157 | text = "暂停" 158 | mediaPlayer.videoControl() 159 | } 160 | } 161 | 162 | 163 | ComboBox { 164 | id: deviceBox 165 | x: 8 166 | y: 526 167 | width: 300 168 | height: 34 169 | 170 | model: mediaPlayer.deviceList 171 | 172 | } 173 | 174 | 175 | 176 | 177 | 178 | 179 | } 180 | -------------------------------------------------------------------------------- /HardhatSystem/components/CameraGroup/qml/Camera.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Camera.qml 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /HardhatSystem/components/SearchGroup/SearchGroup: -------------------------------------------------------------------------------- 1 | #include "searchgroup.h" -------------------------------------------------------------------------------- /HardhatSystem/components/SearchGroup/SearchGroup.pri: -------------------------------------------------------------------------------- 1 | 2 | INCLUDEPATH *= \ 3 | $$PWD/cpp/ \ 4 | $$PWD/ 5 | 6 | HEADERS *= \ 7 | $$PWD/cpp/search.h \ 8 | $$PWD/searchgroup.h \ 9 | $$PWD/cpp/videolistmodel.h \ 10 | $$PWD/cpp/cvsearch.h \ 11 | $$PWD/cpp/searchthread.h 12 | 13 | 14 | SOURCES *= \ 15 | $$PWD/cpp/search.cpp \ 16 | $$PWD/cpp/videolistmodel.cpp \ 17 | $$PWD/cpp/cvsearch.cpp \ 18 | $$PWD/cpp/searchthread.cpp 19 | 20 | 21 | RESOURCES *= \ 22 | $$PWD/qml/Search.qrc 23 | -------------------------------------------------------------------------------- /HardhatSystem/components/SearchGroup/cpp/cvsearch.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file cvsearch.h 3 | * @brief Nice QML wrapper for video access with OpenCV 4 | */ 5 | 6 | #ifndef CVSEARCH_H 7 | #define CVSEARCH_H 8 | 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "searchthread.h" 24 | #include "utils.h" 25 | 26 | #define CVSEARCH_INITIALIZA \ 27 | { \ 28 | qmlRegisterType("com.nuaa.CVSearch", 1, 0, "CVSearch"); \ 29 | } 30 | 31 | class CVSearch : public QQuickItem 32 | { 33 | Q_OBJECT 34 | Q_DISABLE_COPY(CVSearch) 35 | Q_PROPERTY(int frameNow READ getFrameNow WRITE setFrameNow NOTIFY frameNowChanged) 36 | Q_PROPERTY(int totalNow READ getTotalNow NOTIFY totalNowChanged) 37 | Q_PROPERTY(int noHatNow READ getNoHatNow NOTIFY noHatNowChanged) 38 | 39 | Q_PROPERTY(QString fileUrl READ getFileUrl WRITE setFileUrl NOTIFY fileUrlChanged) 40 | Q_PROPERTY(QAbstractVideoSurface* videoSurface READ getVideoSurface WRITE setVideoSurface) 41 | Q_PROPERTY(QSize size READ getSize WRITE setSize NOTIFY sizeChanged) 42 | Q_PROPERTY(cv::Mat cvImage READ getCvImage NOTIFY cvImageChanged) 43 | Q_PROPERTY(QString heatMapString READ getHeatMap NOTIFY heatMapChanged) 44 | 45 | public: 46 | CVSearch(QQuickItem* parent = 0); 47 | ~CVSearch(); 48 | 49 | QString getFileUrl() const; 50 | void setFileUrl(QString fileUrl); 51 | 52 | QSize getSize() const; 53 | 54 | void setSize(QSize size); 55 | 56 | QAbstractVideoSurface* getVideoSurface() const; 57 | 58 | void setVideoSurface(QAbstractVideoSurface* videoSurface); 59 | 60 | cv::Mat getCvImage(); 61 | QString getHeatMap(); 62 | 63 | 64 | int getFrameNow() const; 65 | int getTotalNow() const; 66 | int getNoHatNow() const; 67 | 68 | void setFrameNow(int f); 69 | void updateHeatMap(); 70 | 71 | signals: 72 | void frameNowChanged(); 73 | void totalNowChanged(); 74 | void noHatNowChanged(); 75 | 76 | void sizeChanged(); 77 | void fileUrlChanged(); 78 | void cvImageChanged(); 79 | void heatMapChanged(); 80 | 81 | private: 82 | const QVideoFrame::PixelFormat VIDEO_OUTPUT_FORMAT = QVideoFrame::PixelFormat::Format_ARGB32; 83 | 84 | QString fileUrl = NULL; 85 | 86 | QSize size; 87 | double fps; 88 | int frameCount = 0; 89 | int frameNow = 0; 90 | int totalNow = 0; 91 | int noHatNow = 0; 92 | int detectionCount = 0; 93 | 94 | QList qFrameNow, qBoxID, qObjID, qX, qY, qW, qH; // Database variant 95 | 96 | cv::Mat *heatMap; 97 | QImage qHeatMap; 98 | QString heatMapString; 99 | 100 | BetterVideoCapture* video = NULL; ///< The camera object 101 | SearchThread* thread = NULL; ///< Thread to run camera image acquisition 102 | 103 | 104 | QVideoFrame* videoFrame = NULL; 105 | QAbstractVideoSurface* videoSurface = NULL; 106 | 107 | 108 | bool exportCvImage = false; 109 | cv::Mat cvImage; 110 | unsigned char* cvImageBuf = NULL; 111 | 112 | bool isrunning = true; 113 | 114 | void update(); 115 | void allocateCvImage(); 116 | void allocateVideoFrame(); 117 | void clearQVariant(); 118 | 119 | 120 | public slots: 121 | 122 | void changeParent(QQuickItem* parent); 123 | void videoControl(); 124 | int getFrameCount(); 125 | 126 | 127 | private slots: 128 | void fileUrlGeted(); 129 | void imageReceived(); 130 | 131 | }; 132 | 133 | 134 | 135 | #endif // CVSEARCH_H 136 | -------------------------------------------------------------------------------- /HardhatSystem/components/SearchGroup/cpp/search.cpp: -------------------------------------------------------------------------------- 1 | #include "search.h" 2 | #include 3 | #include 4 | 5 | void Search::Manage::save(QString videoName) 6 | { 7 | 8 | int idx = videoName.lastIndexOf("."); 9 | txtName = videoName.left(idx) + ".txt"; 10 | idx = txtName.indexOf("file://"); 11 | if(idx >= 0) 12 | txtName.replace(idx, 7, ""); 13 | 14 | qDebug() << txtName << "......................"; 15 | 16 | QFile file(txtName); 17 | if(!file.open(QIODevice::ReadWrite)) 18 | return; 19 | QTextStream out(&file); 20 | 21 | QString s1 = "Video File: " + videoName; 22 | out << s1 << "\r\n\r\n"; 23 | out << "Detection Results: \r\n"; 24 | 25 | out.setFieldWidth(15); 26 | out.setFieldAlignment(QTextStream::AlignCenter); 27 | out << "FrameID" << "Total" << "No hardhat" << "\r\n"; 28 | 29 | int frameCount = df->getFrameCount(); 30 | if(frameCount <= 0) 31 | return; 32 | for(int i = 0; i < frameCount; i++) 33 | { 34 | std::vector results = df->getResult(i); 35 | int total = results.size(); 36 | int nohat = 0; 37 | for(int k = 0; k < total; k++) 38 | { 39 | if(results[k].obj_id == 1) 40 | nohat++; 41 | } 42 | 43 | 44 | out << i << total << nohat << "\r\n"; 45 | 46 | } 47 | 48 | file.flush(); 49 | file.close(); 50 | } 51 | 52 | QString Search::Manage::getTxtName() 53 | { 54 | return txtName; 55 | } 56 | -------------------------------------------------------------------------------- /HardhatSystem/components/SearchGroup/cpp/search.h: -------------------------------------------------------------------------------- 1 | #ifndef GROUP_SEARCHGROUP_CPP_SEARCH_H_ 2 | #define GROUP_SEARCHGROUP_CPP_SEARCH_H_ 3 | 4 | // JQToolsLibrary import 5 | #include 6 | #include "utils.h" 7 | 8 | #define SEARCH_INITIALIZA \ 9 | { \ 10 | qmlRegisterType("Search", 1, 0, "SearchManage"); \ 11 | } 12 | 13 | namespace Search 14 | { 15 | 16 | class Manage: public AbstractTool 17 | { 18 | Q_OBJECT 19 | Q_DISABLE_COPY(Manage) 20 | 21 | 22 | public: 23 | Manage() = default; 24 | ~Manage() = default; 25 | 26 | Q_INVOKABLE void save(QString videoName); 27 | Q_INVOKABLE QString getTxtName(); 28 | 29 | // QString source() const; 30 | // void setSouce(const QString &); 31 | 32 | public slots: 33 | 34 | private: 35 | QString txtName; 36 | 37 | }; 38 | 39 | } 40 | 41 | #endif//GROUP_SEARCHGROUP_CPP_SEARCH_H_ 42 | -------------------------------------------------------------------------------- /HardhatSystem/components/SearchGroup/cpp/searchthread.cpp: -------------------------------------------------------------------------------- 1 | #include "searchthread.h" 2 | #include "utils.h" 3 | 4 | SearchTask::SearchTask( BetterVideoCapture *camera, QVideoFrame *videoFrame, unsigned char *cvImageBuf, int width, int height) 5 | { 6 | this->running = true; 7 | this->camera = camera; 8 | this->videoFrame = videoFrame; 9 | this->cvImageBuf = cvImageBuf; 10 | this->width = width; 11 | this->height = height; 12 | } 13 | 14 | SearchTask::~SearchTask() 15 | { 16 | //Leave camera and videoFrame alone, they will be destroyed elsewhere 17 | } 18 | 19 | void SearchTask::stop() 20 | { 21 | running = false; 22 | } 23 | 24 | void SearchTask::doWork() 25 | { 26 | running = true; 27 | fps = camera->getProperty(CV_CAP_PROP_FPS); 28 | // qDebug() << "开始工作"; 29 | // qDebug() << "开始frame: " << frameNow; 30 | // qDebug() << "开始frame: " << camera->getProperty(CV_CAP_PROP_POS_AVI_RATIO) * camera->getProperty(CV_CAP_PROP_FRAME_COUNT); 31 | // qDebug() << "video的帧指针位置:" << camera->getProperty(CV_CAP_PROP_POS_AVI_RATIO); 32 | 33 | if(videoFrame) 34 | videoFrame->map(QAbstractVideoBuffer::ReadOnly); 35 | 36 | cv::Mat screenImage; 37 | if(videoFrame) 38 | screenImage = cv::Mat(height,width,CV_8UC4,videoFrame->bits()); 39 | 40 | while(running && videoFrame != NULL && camera != NULL) 41 | { 42 | if(!camera->grabFrame()) 43 | break; 44 | unsigned char* cameraFrame = camera->retrieveFrame(); 45 | 46 | //Get camera image into screen frame buffer 47 | if(videoFrame) 48 | { 49 | 50 | // Assuming desktop, RGB camera image and RGBA QVideoFrame 51 | cv::Mat tempMat(height, width, CV_8UC3, cameraFrame); 52 | QThread::msleep((fps == 20) ? fps*2 : fps); 53 | 54 | frameNow = camera->getProperty(cv::CAP_PROP_POS_FRAMES); 55 | // frameNow = (frameNow + 1) % (int)(camera->getProperty(CV_CAP_PROP_FRAME_COUNT) + 1); 56 | // qDebug() << "opencv frame: " << frameNow; 57 | 58 | std::vector results = df->getResult(frameNow); 59 | 60 | for(size_t i = 0; i < results.size(); i++) 61 | { 62 | int classid = results[i].obj_id; 63 | int x = results[i].x; 64 | int y = results[i].y; 65 | if(classid == 1) 66 | { 67 | cv::putText(tempMat, "No Hardhat!", cv::Point(x, y-10), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 0, 255), 1); 68 | cv::Rect rec(results[i].x, results[i].y, results[i].w, results[i].h); 69 | cv::rectangle(tempMat, rec, cv::Scalar(0, 0, 255), 4); 70 | } 71 | else 72 | { 73 | cv::Rect rec(results[i].x, results[i].y, results[i].w, results[i].h); 74 | cv::rectangle(tempMat, rec, cv::Scalar(0, 250, 0), 4); 75 | } 76 | } 77 | cv::putText(tempMat, getCurrentTime2().toStdString(), cv::Point(10, 20), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(255, 255, 255), 1); 78 | cv::cvtColor(tempMat, screenImage, cv::COLOR_RGB2RGBA); 79 | 80 | if(cvImageBuf) 81 | { 82 | // Assuming desktop, RGB camera image 83 | memcpy(cvImageBuf, cameraFrame, height*width*3); 84 | } 85 | 86 | 87 | emit imageReady(); 88 | } 89 | } 90 | 91 | } 92 | 93 | 94 | SearchThread::SearchThread(BetterVideoCapture *camera, QVideoFrame *videoFrame, unsigned char *cvImageBuf, int width, int height) 95 | { 96 | task = new SearchTask(camera,videoFrame,cvImageBuf,width,height); 97 | task->moveToThread(&workerThread); 98 | connect(&workerThread, SIGNAL(started()), task, SLOT(doWork())); 99 | connect(task, SIGNAL(imageReady()), this, SIGNAL(imageReady())); 100 | } 101 | 102 | SearchThread::~SearchThread() 103 | { 104 | stop(); 105 | delete task; 106 | } 107 | 108 | void SearchThread::start() 109 | { 110 | if(!workerThread.isRunning()) 111 | workerThread.start(); 112 | else 113 | { 114 | task->doWork(); 115 | } 116 | } 117 | 118 | void SearchThread::stop() 119 | { 120 | if(task != NULL) 121 | task->stop(); 122 | workerThread.quit(); 123 | workerThread.wait(); 124 | } 125 | 126 | -------------------------------------------------------------------------------- /HardhatSystem/components/SearchGroup/cpp/searchthread.h: -------------------------------------------------------------------------------- 1 | #ifndef SEARCHTHREAD_H 2 | #define SEARCHTHREAD_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include "bettervideocapture.hpp" 18 | #include "yolo_v2_class.hpp" 19 | 20 | #define DPRINT(...) while(0); 21 | 22 | class SearchTask : public QObject 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | SearchTask(BetterVideoCapture* camera, QVideoFrame* videoFrame, unsigned char* cvImageBuf, int width, int height); 28 | virtual ~SearchTask(); 29 | void stop(); 30 | 31 | private: 32 | int width; ///< Width of the camera image 33 | int height; ///< Height of the camera image 34 | BetterVideoCapture* camera; ///< The camera to get data from 35 | bool running = false; ///< Whether the worker thread is running 36 | QVideoFrame* videoFrame; ///< Place to draw camera image to 37 | unsigned char* cvImageBuf; ///< Place to export camera image to 38 | 39 | int frameNow = 0; 40 | int fps; 41 | 42 | public slots: 43 | void doWork(); 44 | 45 | signals: 46 | void imageReady(); 47 | 48 | }; 49 | 50 | 51 | class SearchThread : public QObject 52 | { 53 | Q_OBJECT 54 | public: 55 | SearchThread(BetterVideoCapture* camera, QVideoFrame* videoFrame, unsigned char* cvImageBuf, int width, int height); 56 | virtual ~SearchThread(); 57 | void start(); 58 | void stop(); 59 | 60 | private: 61 | 62 | QThread workerThread; ///< The thread that the camera will work in 63 | SearchTask* task = NULL; ///< The camera loop method and parameter container 64 | 65 | signals: 66 | void imageReady(); 67 | 68 | }; 69 | 70 | 71 | #endif //SEARCHTHREAD_H 72 | -------------------------------------------------------------------------------- /HardhatSystem/components/SearchGroup/cpp/videolistmodel.cpp: -------------------------------------------------------------------------------- 1 | #include "videolistmodel.h" 2 | #include 3 | #include 4 | #include "utils.h" 5 | 6 | typedef QVector VideoData; 7 | class VideoListModelPrivate 8 | { 9 | public: 10 | VideoListModelPrivate() 11 | { 12 | int role = Qt::UserRole; 13 | m_roleNames.insert(role++, "path"); 14 | m_roleNames.insert(role++, "fps"); 15 | m_roleNames.insert(role++, "frameCount"); 16 | m_roleNames.insert(role++, "saveTime"); 17 | } 18 | ~VideoListModelPrivate() 19 | { 20 | clear(); 21 | } 22 | 23 | void load() 24 | { 25 | QList pathL; 26 | QList fpsL; 27 | QList frameCountL; 28 | QList saveTimeL; 29 | int videoCount = df->searchVideo(pathL, fpsL, frameCountL, saveTimeL); 30 | qDebug() << "videoCount: " << videoCount; 31 | 32 | VideoData *video; 33 | for(int i = 0; i < videoCount; i++) 34 | { 35 | video = new VideoData(); 36 | 37 | QString path = pathL.first(); 38 | QString fps = QString::number(fpsL.first(), 10, 2); 39 | QString frameCount = QString::number(frameCountL.first(), 10); 40 | QString saveTime = saveTimeL.first().toString("yyyy-MM-dd hh:mm:ss"); 41 | 42 | pathL.pop_front(); 43 | fpsL.pop_front(); 44 | frameCountL.pop_front(); 45 | saveTimeL.pop_front(); 46 | 47 | video->append(path); 48 | video->append(fps); 49 | video->append(frameCount); 50 | video->append(saveTime); 51 | 52 | m_videos.append(video); 53 | video = 0; 54 | } 55 | 56 | QVector temp; 57 | QVector::reverse_iterator riter; 58 | for(riter = m_videos.rbegin(); riter != m_videos.rend(); riter++) 59 | temp.push_back(*riter); 60 | m_videos = temp; 61 | } 62 | 63 | void reset() 64 | { 65 | clear(); 66 | } 67 | 68 | void clear() 69 | { 70 | int count = m_videos.size(); 71 | if(count > 0) 72 | { 73 | for(int i = 0; i < count; i++) 74 | { 75 | delete m_videos.at(i); 76 | } 77 | m_videos.clear(); 78 | } 79 | } 80 | 81 | QHash m_roleNames; 82 | QVector m_videos; 83 | }; 84 | 85 | 86 | 87 | 88 | VideoListModel::VideoListModel(QObject *parent) 89 | : QAbstractListModel(parent) 90 | , m_dptr(new VideoListModelPrivate) 91 | { 92 | m_dptr->load(); 93 | } 94 | 95 | VideoListModel::~VideoListModel() 96 | { 97 | delete m_dptr; 98 | } 99 | 100 | int VideoListModel::rowCount(const QModelIndex &parent) const 101 | { 102 | return m_dptr->m_videos.size(); 103 | } 104 | 105 | QVariant VideoListModel::data(const QModelIndex &index, int role) const 106 | { 107 | VideoData *d = m_dptr->m_videos[index.row()]; 108 | return d->at(role - Qt::UserRole); 109 | } 110 | 111 | QVariant VideoListModel::getPath(int index) const 112 | { 113 | VideoData *d = m_dptr->m_videos[index]; 114 | return d->at(0); 115 | } 116 | 117 | void VideoListModel::reload() 118 | { 119 | beginResetModel(); 120 | m_dptr->reset(); 121 | m_dptr->load(); 122 | endResetModel(); 123 | } 124 | 125 | bool VideoListModel::deleteVideo(QString path) const 126 | { 127 | QFile file(path); 128 | if(file.exists()) 129 | file.remove(); 130 | return df->deleteVideo(path); 131 | } 132 | 133 | QHash VideoListModel::roleNames() const 134 | { 135 | return m_dptr->m_roleNames; 136 | } 137 | 138 | -------------------------------------------------------------------------------- /HardhatSystem/components/SearchGroup/cpp/videolistmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef VIDEOLISTMODEL_H 2 | #define VIDEOLISTMODEL_H 3 | #include 4 | #include 5 | 6 | #define VIDEOLISTMODEL_INITIALIZA \ 7 | { \ 8 | qmlRegisterType("com.nuaa.CModel", 1, 0, "VideoListModel"); \ 9 | } 10 | 11 | class VideoListModelPrivate; 12 | class VideoListModel : public QAbstractListModel 13 | { 14 | Q_OBJECT 15 | public: 16 | VideoListModel(QObject *parent = 0); 17 | ~VideoListModel(); 18 | 19 | int rowCount(const QModelIndex &parent) const; 20 | QVariant data(const QModelIndex &index, int role) const; 21 | QHash roleNames() const; 22 | 23 | Q_INVOKABLE QVariant getPath(int index) const; 24 | Q_INVOKABLE void reload(); 25 | Q_INVOKABLE bool deleteVideo(QString path) const; 26 | 27 | private: 28 | VideoListModelPrivate *m_dptr; 29 | 30 | }; 31 | 32 | #endif // VIDEOLISTMODEL_H 33 | -------------------------------------------------------------------------------- /HardhatSystem/components/SearchGroup/qml/Search.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Search.qml 4 | 5 | -------------------------------------------------------------------------------- /HardhatSystem/components/SearchGroup/searchgroup.h: -------------------------------------------------------------------------------- 1 | #ifndef SEARCHGROUP_SEARCHROUP_H_ 2 | #define SEARCHGROUP_SEARCHROUP_H_ 3 | 4 | // SearchGroup lib import 5 | #include "search.h" 6 | #include "videolistmodel.h" 7 | #include "cvsearch.h" 8 | 9 | #define SEARCHGROUP_INITIALIZA \ 10 | SEARCH_INITIALIZA; \ 11 | VIDEOLISTMODEL_INITIALIZA; \ 12 | CVSEARCH_INITIALIZA; 13 | 14 | 15 | #endif//SEARCHGROUP_SEARCHROUP_H_ 16 | -------------------------------------------------------------------------------- /HardhatSystem/components/VideoGroup/VideoGroup: -------------------------------------------------------------------------------- 1 | #include "videogroup.h" -------------------------------------------------------------------------------- /HardhatSystem/components/VideoGroup/VideoGroup.pri: -------------------------------------------------------------------------------- 1 | 2 | INCLUDEPATH *= \ 3 | $$PWD/cpp/ \ 4 | $$PWD/ 5 | 6 | HEADERS *= \ 7 | $$PWD/cpp/video.h \ 8 | $$PWD/videogroup.h \ 9 | $$PWD/cpp/videothread.h \ 10 | $$PWD/cpp/cvvideo.h 11 | 12 | SOURCES *= \ 13 | $$PWD/cpp/video.cpp \ 14 | $$PWD/cpp/videothread.cpp \ 15 | $$PWD/cpp/cvvideo.cpp 16 | 17 | RESOURCES *= \ 18 | $$PWD/qml/Video.qrc 19 | -------------------------------------------------------------------------------- /HardhatSystem/components/VideoGroup/cpp/cvvideo.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file cvvideo.h 3 | * @brief Nice QML wrapper for video access with OpenCV 4 | */ 5 | 6 | #ifndef CVVIDEO_H 7 | #define CVVIDEO_H 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | #include "videothread.h" 23 | #include "utils.h" 24 | 25 | #define CVVIDEO_INITIALIZA \ 26 | { \ 27 | qmlRegisterType("com.nuaa.CVVideo", 1, 0, "CVVideo"); \ 28 | } 29 | 30 | 31 | class CVVideo : public QQuickItem 32 | { 33 | Q_OBJECT 34 | Q_DISABLE_COPY(CVVideo) 35 | Q_PROPERTY(int frameNow READ getFrameNow WRITE setFrameNow NOTIFY frameNowChanged) 36 | Q_PROPERTY(int totalNow READ getTotalNow NOTIFY totalNowChanged) 37 | Q_PROPERTY(int noHatNow READ getNoHatNow NOTIFY noHatNowChanged) 38 | 39 | Q_PROPERTY(QString fileUrl READ getFileUrl WRITE setFileUrl NOTIFY fileUrlChanged) 40 | Q_PROPERTY(QAbstractVideoSurface* videoSurface READ getVideoSurface WRITE setVideoSurface) 41 | Q_PROPERTY(QSize size READ getSize WRITE setSize NOTIFY sizeChanged) 42 | Q_PROPERTY(cv::Mat cvImage READ getCvImage NOTIFY cvImageChanged) 43 | 44 | 45 | 46 | 47 | 48 | public: 49 | CVVideo(QQuickItem* parent = 0); 50 | 51 | ~CVVideo(); 52 | 53 | QString getFileUrl() const; 54 | void setFileUrl(QString fileUrl); 55 | 56 | QSize getSize() const; 57 | 58 | void setSize(QSize size); 59 | 60 | QAbstractVideoSurface* getVideoSurface() const; 61 | 62 | void setVideoSurface(QAbstractVideoSurface* videoSurface); 63 | 64 | cv::Mat getCvImage(); 65 | 66 | 67 | int getFrameNow() const; 68 | int getTotalNow() const; 69 | int getNoHatNow() const; 70 | 71 | void setFrameNow(int f); 72 | 73 | 74 | signals: 75 | void frameNowChanged(); 76 | void totalNowChanged(); 77 | void noHatNowChanged(); 78 | 79 | void sizeChanged(); 80 | void fileUrlChanged(); 81 | void cvImageChanged(); 82 | 83 | private: 84 | const QVideoFrame::PixelFormat VIDEO_OUTPUT_FORMAT = QVideoFrame::PixelFormat::Format_ARGB32; 85 | 86 | QString fileUrl = NULL; 87 | 88 | QSize size; 89 | double fps; 90 | int frameCount = 0; 91 | int frameNow = 0; 92 | int totalNow = 0; 93 | int noHatNow = 0; 94 | std::vector results; 95 | 96 | 97 | QVariantList qFrameNow, qBoxID, qObjID, qX, qY, qW, qH, qProb; // Database variant 98 | 99 | 100 | BetterVideoCapture* video = NULL; ///< The camera object 101 | VideoThread* thread = NULL; ///< Thread to run camera image acquisition 102 | 103 | 104 | QVideoFrame* videoFrame = NULL; 105 | QAbstractVideoSurface* videoSurface = NULL; 106 | 107 | 108 | bool exportCvImage = false; 109 | cv::Mat cvImage; 110 | unsigned char* cvImageBuf = NULL; 111 | 112 | bool isrunning = true; 113 | 114 | void update(); 115 | void allocateCvImage(); 116 | void allocateVideoFrame(); 117 | void clearQVariant(); 118 | 119 | 120 | public slots: 121 | 122 | void changeParent(QQuickItem* parent); 123 | void videoControl(); 124 | int getFrameCount(); 125 | 126 | 127 | private slots: 128 | void fileUrlGeted(); 129 | void imageReceived(); 130 | 131 | 132 | }; 133 | 134 | #endif // CVVIDEO_H 135 | -------------------------------------------------------------------------------- /HardhatSystem/components/VideoGroup/cpp/video: -------------------------------------------------------------------------------- 1 | #ifndef GROUP_VIDEOGROUP_CPP_VIDEO_H_ 2 | #define GROUP_VIDEOGROUP_CPP_VIDEO_H_ 3 | 4 | // JQToolsLibrary import 5 | #include 6 | 7 | #define VIDEOGROUP_INITIALIZA \ 8 | { \ 9 | qmlRegisterType("Video", 1, 0, "VideoManage"); \ 10 | } 11 | 12 | namespace Video 13 | { 14 | 15 | class Manage: public AbstractTool 16 | { 17 | Q_OBJECT 18 | Q_DISABLE_COPY(Manage) 19 | 20 | public: 21 | Manage() = default; 22 | 23 | ~Manage() = default; 24 | 25 | public slots: 26 | void openGitHubLink(); 27 | 28 | void openLatestVersionDownloadLink(); 29 | }; 30 | 31 | } 32 | 33 | #endif//GROUP_VIDEOGROUP_CPP_VIDEO_H_ 34 | -------------------------------------------------------------------------------- /HardhatSystem/components/VideoGroup/cpp/video.cpp: -------------------------------------------------------------------------------- 1 | #include "video.h" 2 | 3 | 4 | 5 | using namespace Video; 6 | 7 | void Manage::openGitHubLink() 8 | { 9 | 10 | } 11 | 12 | void Manage::openLatestVersionDownloadLink() 13 | { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /HardhatSystem/components/VideoGroup/cpp/video.h: -------------------------------------------------------------------------------- 1 | #ifndef GROUP_VIDEOGROUP_CPP_VIDEO_H_ 2 | #define GROUP_VIDEOGROUP_CPP_VIDEO_H_ 3 | 4 | // JQToolsLibrary import 5 | #include 6 | 7 | #define VIDEO_INITIALIZA \ 8 | { \ 9 | qmlRegisterType("Video", 1, 0, "VideoManage"); \ 10 | } 11 | 12 | namespace Video 13 | { 14 | 15 | class Manage: public AbstractTool 16 | { 17 | Q_OBJECT 18 | Q_DISABLE_COPY(Manage) 19 | 20 | public: 21 | Manage() = default; 22 | 23 | ~Manage() = default; 24 | 25 | public slots: 26 | void openGitHubLink(); 27 | 28 | void openLatestVersionDownloadLink(); 29 | }; 30 | 31 | } 32 | 33 | #endif//GROUP_VIDEOGROUP_CPP_VIDEO_H_ 34 | -------------------------------------------------------------------------------- /HardhatSystem/components/VideoGroup/cpp/videothread.cpp: -------------------------------------------------------------------------------- 1 | #include "videothread.h" 2 | #include "utils.h" 3 | 4 | VideoTask::VideoTask(std::vector *results, BetterVideoCapture *camera, QVideoFrame *videoFrame, unsigned char *cvImageBuf, int width, int height) 5 | { 6 | this->running = true; 7 | this->camera = camera; 8 | this->videoFrame = videoFrame; 9 | this->cvImageBuf = cvImageBuf; 10 | this->width = width; 11 | this->height = height; 12 | this->results = results; 13 | 14 | } 15 | 16 | VideoTask::~VideoTask() 17 | { 18 | //Leave camera and videoFrame alone, they will be destroyed elsewhere 19 | } 20 | 21 | void VideoTask::stop() 22 | { 23 | running = false; 24 | } 25 | 26 | void VideoTask::doWork() 27 | { 28 | running = true; 29 | if(videoFrame) 30 | videoFrame->map(QAbstractVideoBuffer::ReadOnly); 31 | 32 | cv::Mat screenImage; 33 | if(videoFrame) 34 | screenImage = cv::Mat(height,width,CV_8UC4,videoFrame->bits()); 35 | 36 | while(running && videoFrame != NULL && camera != NULL) 37 | { 38 | // QThread::msleep(10); 39 | 40 | 41 | if(!camera->grabFrame()) 42 | continue; 43 | unsigned char* cameraFrame = camera->retrieveFrame(); 44 | 45 | //Get camera image into screen frame buffer 46 | if(videoFrame) 47 | { 48 | 49 | // Assuming desktop, RGB camera image and RGBA QVideoFrame 50 | cv::Mat tempMat(height, width, CV_8UC3, cameraFrame); 51 | 52 | std::shared_ptr img = detector->mat_to_image(tempMat); 53 | image_t *iii = img.get(); 54 | std::vector tmpres = detector->detect(*iii); 55 | results->assign(tmpres.begin(), tmpres.end()); 56 | 57 | int nohat = 0; 58 | for(size_t i = 0; i < results->size(); i++) 59 | { 60 | int classid = (*results)[i].obj_id; 61 | int x = (*results)[i].x; 62 | int y = (*results)[i].y; 63 | if(classid == 1) 64 | { 65 | nohat++; 66 | cv::putText(tempMat, "No Hardhat!", cv::Point(x, y-10), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 0, 255), 1); 67 | cv::Rect rec((*results)[i].x, (*results)[i].y, (*results)[i].w, (*results)[i].h); 68 | cv::rectangle(tempMat, rec, cv::Scalar(0, 0, 255), 4); 69 | } 70 | else 71 | { 72 | cv::Rect rec((*results)[i].x, (*results)[i].y, (*results)[i].w, (*results)[i].h); 73 | cv::rectangle(tempMat, rec, cv::Scalar(0, 250, 0), 4); 74 | } 75 | } 76 | // cv::putText(tempMat, "[Total] " + QString::number(results->size(), 10).toStdString() + " [No Hardhat] " + 77 | // QString::number(nohat, 10).toStdString(), cv::Point(10, tempMat.rows - 10), cv::FONT_HERSHEY_SIMPLEX, 1, cv::Scalar(0, 0, 255), 2); 78 | cv::putText(tempMat, getCurrentTime2().toStdString(), cv::Point(10, 20), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(255, 255, 255), 1); 79 | 80 | cv::cvtColor(tempMat, screenImage, cv::COLOR_RGB2RGBA); 81 | 82 | 83 | if(cvImageBuf) 84 | { 85 | // Assuming desktop, RGB camera image 86 | memcpy(cvImageBuf, cameraFrame, height*width*3); 87 | } 88 | emit imageReady(); 89 | } 90 | } 91 | 92 | } 93 | 94 | 95 | 96 | VideoThread::VideoThread(std::vector *results, BetterVideoCapture *camera, QVideoFrame *videoFrame, unsigned char *cvImageBuf, int width, int height) 97 | { 98 | task = new VideoTask(results, camera,videoFrame,cvImageBuf,width,height); 99 | task->moveToThread(&workerThread); 100 | connect(&workerThread, SIGNAL(started()), task, SLOT(doWork())); 101 | connect(task, SIGNAL(imageReady()), this, SIGNAL(imageReady())); 102 | } 103 | 104 | VideoThread::~VideoThread() 105 | { 106 | stop(); 107 | delete task; 108 | } 109 | 110 | void VideoThread::start() 111 | { 112 | if(!workerThread.isRunning()) 113 | workerThread.start(); 114 | else 115 | { 116 | task->doWork(); 117 | } 118 | } 119 | 120 | void VideoThread::stop() 121 | { 122 | if(task != NULL) 123 | task->stop(); 124 | workerThread.quit(); 125 | workerThread.wait(); 126 | } 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /HardhatSystem/components/VideoGroup/cpp/videothread.h: -------------------------------------------------------------------------------- 1 | #ifndef VIDEOTHREAD_H 2 | #define VIDEOTHREAD_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include "bettervideocapture.hpp" 18 | #include "yolo_v2_class.hpp" 19 | 20 | #define DPRINT(...) while(0); 21 | 22 | 23 | /** 24 | * @brief Object that contains the video loop and its parameters 25 | */ 26 | class VideoTask : public QObject{ 27 | Q_OBJECT 28 | 29 | public: 30 | 31 | /** 32 | * @brief Creates a new camera access task 33 | * 34 | * @param camera Camera object to get data from 35 | * @param videoFrame Place to draw the camera image, pass NULL to not draw camera image to a QVideoFrame 36 | * @param cvImageBuf Place to export the camera image, pass NULL to not export the camera image 37 | * @param width Width of the camera image 38 | * @param height Height of the camera image 39 | */ 40 | VideoTask(std::vector *results, BetterVideoCapture* camera, QVideoFrame* videoFrame, unsigned char* cvImageBuf, int width, int height); 41 | 42 | /** 43 | * @brief Destroys this camera access task, does not touch the camera or the videoFrame 44 | */ 45 | virtual ~VideoTask(); 46 | 47 | /** 48 | * @brief Asks for the main loop to stop 49 | */ 50 | void stop(); 51 | 52 | private: 53 | 54 | int width; ///< Width of the camera image 55 | int height; ///< Height of the camera image 56 | BetterVideoCapture* camera; ///< The camera to get data from 57 | bool running = false; ///< Whether the worker thread is running 58 | QVideoFrame* videoFrame; ///< Place to draw camera image to 59 | unsigned char* cvImageBuf; ///< Place to export camera image to 60 | std::vector *results; 61 | 62 | public slots: 63 | /** 64 | * @brief Continuously gets data from the camera 65 | */ 66 | void doWork(); 67 | 68 | 69 | signals: 70 | 71 | /** 72 | * @brief Emitted when image from a new frame is ready 73 | */ 74 | void imageReady(); 75 | 76 | }; 77 | 78 | 79 | 80 | /** 81 | * @brief Object that starts and stops the camera loop 82 | */ 83 | class VideoThread : public QObject 84 | { 85 | Q_OBJECT 86 | public: 87 | 88 | /** 89 | * @brief Creates a new camera controller 90 | * 91 | * @param camera Camera object to get data from 92 | * @param videoFrame Place to draw the camera image, pass NULL to not draw camera image to a QVideoFrame 93 | * @param cvImageBuf Place to export the camera image, pass NULL to not export the camera image 94 | * @param width Width of the camera image 95 | * @param height Height of the camera image 96 | */ 97 | VideoThread(std::vector *results, BetterVideoCapture* camera, QVideoFrame* videoFrame, unsigned char* cvImageBuf, int width, int height); 98 | 99 | /** 100 | * @brief Destroys this camera controller 101 | */ 102 | virtual ~VideoThread(); 103 | 104 | /** 105 | * @brief Starts the camera loop 106 | */ 107 | void start(); 108 | 109 | /** 110 | * @brief Asks the camera loop to stop 111 | */ 112 | void stop(); 113 | 114 | private: 115 | 116 | QThread workerThread; ///< The thread that the camera will work in 117 | VideoTask* task = NULL; ///< The camera loop method and parameter container 118 | 119 | signals: 120 | 121 | /** 122 | * @brief Emitted when image from a new frame is ready 123 | */ 124 | void imageReady(); 125 | 126 | 127 | }; 128 | 129 | #endif // VIDEOTHREAD_H 130 | -------------------------------------------------------------------------------- /HardhatSystem/components/VideoGroup/qml/Video.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.7 2 | import QtQuick.Controls 1.4 3 | import QtMultimedia 5.4 4 | import QtQuick.Dialogs 1.0 5 | import "qrc:/MaterialUI/Interface/" 6 | import Video 1.0 7 | 8 | import com.nuaa.CVVideo 1.0 9 | 10 | Item { 11 | id: video 12 | width: 820 13 | height: 590 14 | 15 | VideoManage { 16 | id: videoManage 17 | } 18 | 19 | CVVideo { 20 | id: mediaPlayer 21 | fileUrl: "" 22 | 23 | onFrameNowChanged: { 24 | totalNumLabel.text = mediaPlayer.totalNow 25 | nohatNumLabel.text = mediaPlayer.noHatNow 26 | pastBar.width = mediaPlayer.frameNow / mediaPlayer.getFrameCount() * parent.width 27 | if(pastBar.width == parent.width) 28 | controlbutton.text = "重新开始" 29 | // console.log(pastBar.width) 30 | } 31 | 32 | } 33 | 34 | Rectangle { 35 | id: playerRect 36 | x: 0 37 | y: 0 38 | width: parent.width 39 | height: 520 40 | visible: false 41 | 42 | VideoOutput { 43 | id: out 44 | x: 0 45 | y: 0 46 | width: parent.width 47 | height: parent.height 48 | 49 | source: mediaPlayer 50 | } 51 | 52 | Rectangle { 53 | id: pastBar 54 | x: 0 55 | y: 510 56 | width: 0 57 | height: 10 58 | color: "orange" 59 | z: 1 60 | } 61 | 62 | Rectangle { 63 | id: futureBar 64 | x: 0 65 | y: 510 66 | width: parent.width 67 | height: 10 68 | color: "gray" 69 | } 70 | 71 | Label { 72 | id: nohatNumLabel 73 | x: 756 74 | y: 52 75 | width: 37 76 | height: 32 77 | color: "#79d1fc" 78 | text: qsTr("0") 79 | z: 4 80 | font.bold: true 81 | horizontalAlignment: Text.AlignHCenter 82 | clip: false 83 | font.pointSize: 15 84 | opacity: 1 85 | font.family: "Courier" 86 | verticalAlignment: Text.AlignVCenter 87 | } 88 | 89 | Label { 90 | id: totalNumLabel 91 | x: 756 92 | y: 17 93 | width: 37 94 | height: 32 95 | color: "#79d1fc" 96 | text: qsTr("0") 97 | z: 3 98 | font.bold: true 99 | horizontalAlignment: Text.AlignHCenter 100 | verticalAlignment: Text.AlignVCenter 101 | font.family: "Courier" 102 | clip: false 103 | opacity: 1 104 | font.pointSize: 15 105 | } 106 | 107 | Label { 108 | id: nohatLabel 109 | x: 676 110 | y: 52 111 | width: 82 112 | height: 32 113 | color: "#82d5fd" 114 | text: qsTr("未戴帽:") 115 | z: 1 116 | font.bold: true 117 | clip: false 118 | opacity: 1 119 | font.pointSize: 15 120 | } 121 | 122 | Label { 123 | id: totalLabel 124 | x: 676 125 | y: 17 126 | width: 82 127 | height: 32 128 | color: "#79d1fc" 129 | text: qsTr("总人数:") 130 | z: 2 131 | font.bold: true 132 | font.pointSize: 15 133 | opacity: 1 134 | clip: false 135 | } 136 | 137 | Rectangle { 138 | id: shadowRec 139 | x: 657 140 | y: 8 141 | width: 155 142 | height: 86 143 | color: "#000000" 144 | radius: 0 145 | border.color: "#dc1c04" 146 | border.width: 5 147 | opacity: 0.5 148 | } 149 | 150 | } 151 | 152 | MaterialButton { 153 | id: choicebuttom 154 | width: 200 155 | height: 84 156 | text: qsTr("选择视频") 157 | textFontFamily: "Roboto" 158 | textSize: 35 159 | anchors.verticalCenterOffset: 0 160 | anchors.horizontalCenterOffset: 0 161 | 162 | 163 | anchors.horizontalCenter: parent.horizontalCenter 164 | anchors.verticalCenter: parent.verticalCenter 165 | 166 | onClicked: { 167 | fileDialog.open() 168 | anchors.verticalCenterOffset = 261 169 | anchors.horizontalCenterOffset = 185 170 | 171 | width = 120 172 | height = 40 173 | textSize = 16 174 | controlbutton.visible = true 175 | 176 | playerRect.color = "black" 177 | playerRect.visible = true; 178 | } 179 | } 180 | 181 | FileDialog { 182 | id: fileDialog 183 | 184 | onAccepted: { 185 | controlbutton.text = "暂停" 186 | mediaPlayer.fileUrl = fileUrl 187 | } 188 | } 189 | 190 | 191 | onVisibleChanged: { 192 | console.log("video visible changed! Visible: ", video.visible) 193 | if(video.visible === false) 194 | { 195 | if(controlbutton.text === "初始") 196 | controlbutton.text = "初始" 197 | else if(controlbutton.text === "暂停") 198 | { 199 | controlbutton.text = "继续" 200 | mediaPlayer.videoControl() 201 | } 202 | } 203 | } 204 | 205 | MaterialButton { 206 | id: controlbutton 207 | visible: false 208 | 209 | x: 8 210 | y: -2 211 | width: 120 212 | height: 40 213 | text: "初始" 214 | anchors.verticalCenter: parent.verticalCenter 215 | anchors.horizontalCenter: parent.horizontalCenter 216 | anchors.verticalCenterOffset: 261 217 | anchors.horizontalCenterOffset: 328 218 | 219 | onClicked: { 220 | if(text === "暂停") 221 | text = "继续" 222 | else 223 | text = "暂停" 224 | mediaPlayer.videoControl() 225 | } 226 | } 227 | 228 | 229 | } 230 | -------------------------------------------------------------------------------- /HardhatSystem/components/VideoGroup/qml/Video.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Video.qml 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /HardhatSystem/components/VideoGroup/videogroup.h: -------------------------------------------------------------------------------- 1 |  2 | #ifndef VIDEOGROUP_VIDEOGROUP_H_ 3 | #define VIDEOGROUP_VIDEOGROUP_H_ 4 | 5 | // VideoGroup lib import 6 | #include "video.h" 7 | #include "cvvideo.h" 8 | 9 | #define VIDEOGROUP_INITIALIZA \ 10 | VIDEO_INITIALIZA; \ 11 | CVVIDEO_INITIALIZA; 12 | 13 | #endif//VIDEOGROUP_VIDEOGROUP_H_ 14 | -------------------------------------------------------------------------------- /HardhatSystem/components/WelcomeGroup/WelcomeGroup: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of JQTools 3 | 4 | Project introduce: https://github.com/188080501/JQTools 5 | 6 | Copyright: Jason 7 | 8 | Contact email: Jason@JasonServer.com 9 | 10 | GitHub: https://github.com/188080501/ 11 | */ 12 | 13 | #include "welcomegroup.h" 14 | -------------------------------------------------------------------------------- /HardhatSystem/components/WelcomeGroup/WelcomeGroup.pri: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of JQTools 3 | # 4 | # Project introduce: https://github.com/188080501/JQTools 5 | # 6 | # Copyright: Jason 7 | # 8 | # Contact email: Jason@JasonServer.com 9 | # 10 | # GitHub: https://github.com/188080501/ 11 | # 12 | # Edited by Lue Tao, 201806 13 | # 14 | 15 | INCLUDEPATH *= \ 16 | $$PWD/cpp/ \ 17 | $$PWD/ 18 | 19 | HEADERS *= \ 20 | $$PWD/cpp/welcome.h \ 21 | $$PWD/welcomegroup.h 22 | 23 | SOURCES *= \ 24 | $$PWD/cpp/welcome.cpp 25 | 26 | RESOURCES *= \ 27 | $$PWD/qml/Welcome.qrc 28 | -------------------------------------------------------------------------------- /HardhatSystem/components/WelcomeGroup/cpp/Welcome: -------------------------------------------------------------------------------- 1 | #ifndef __GROUP_WELCOMEGROUP_CPP_WELCOME_H__ 2 | #define __GROUP_WELCOMEGROUP_CPP_WELCOME_H__ 3 | 4 | // JQToolsLibrary import 5 | #include "JQToolsLibrary.h" 6 | 7 | #define WELCOME_INITIALIZA \ 8 | { \ 9 | qmlRegisterType("Welcome", 1, 0, "WelcomeManage"); \ 10 | } 11 | 12 | namespace Welcome 13 | { 14 | 15 | class Manage: public AbstractTool 16 | { 17 | Q_OBJECT 18 | Q_DISABLE_COPY(Manage) 19 | 20 | public: 21 | Manage() = default; 22 | 23 | ~Manage() = default; 24 | 25 | public slots: 26 | void openGitHubLink(); 27 | 28 | void openLatestVersionDownloadLink(); 29 | }; 30 | 31 | } 32 | 33 | #endif//__GROUP_WELCOME_CPP_WELCOME_H__ 34 | -------------------------------------------------------------------------------- /HardhatSystem/components/WelcomeGroup/cpp/welcome.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of JQTools 3 | 4 | Project introduce: https://github.com/188080501/JQTools 5 | 6 | Copyright: Jason 7 | 8 | Contact email: Jason@JasonServer.com 9 | 10 | GitHub: https://github.com/188080501/ 11 | */ 12 | 13 | #include "welcome.h" 14 | 15 | // Qt lib import 16 | #include 17 | #include 18 | 19 | using namespace Welcome; 20 | 21 | void Manage::openGitHubLink() 22 | { 23 | QDesktopServices::openUrl( QUrl( "https://github.com/188080501/JQTools" ) ); 24 | } 25 | 26 | void Manage::openLatestVersionDownloadLink() 27 | { 28 | QDesktopServices::openUrl( QUrl( "https://github.com/188080501/JQTools/releases/latest" ) ); 29 | } 30 | -------------------------------------------------------------------------------- /HardhatSystem/components/WelcomeGroup/cpp/welcome.h: -------------------------------------------------------------------------------- 1 | #ifndef GROUP_WELCOMEGROUP_CPP_WELCOME_H_ 2 | #define GROUP_WELCOMEGROUP_CPP_WELCOME_H_ 3 | 4 | // JQToolsLibrary import 5 | #include 6 | 7 | #define WELCOME_INITIALIZA \ 8 | { \ 9 | qmlRegisterType("Welcome", 1, 0, "WelcomeManage"); \ 10 | } 11 | 12 | namespace Welcome 13 | { 14 | 15 | class Manage: public AbstractTool 16 | { 17 | Q_OBJECT 18 | Q_DISABLE_COPY(Manage) 19 | 20 | public: 21 | Manage() = default; 22 | 23 | ~Manage() = default; 24 | 25 | public slots: 26 | void openGitHubLink(); 27 | 28 | void openLatestVersionDownloadLink(); 29 | }; 30 | 31 | } 32 | 33 | #endif//GROUP_WELCOMEGROUP_CPP_WELCOME_H_ 34 | -------------------------------------------------------------------------------- /HardhatSystem/components/WelcomeGroup/qml/Welcome.qml: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of JQTools 3 | 4 | Project introduce: https://github.com/188080501/JQTools 5 | 6 | Copyright: Jason 7 | 8 | Contact email: Jason@JasonServer.com 9 | 10 | GitHub: https://github.com/188080501/ 11 | 12 | Edited by Lue Tao, 201806 13 | */ 14 | 15 | import QtQuick 2.7 16 | import QtQuick.Controls 1.4 17 | import "qrc:/MaterialUI/Interface/" 18 | import Welcome 1.0 19 | 20 | Item { 21 | id: welcome 22 | width: 820 23 | height: 590 24 | 25 | WelcomeManage { 26 | id: welcomeManage 27 | } 28 | 29 | MaterialLabel { 30 | x: 162 31 | y: 170 32 | text: 33 | "安全帽智能检测系统" 34 | font.pixelSize: 45 35 | anchors.verticalCenterOffset: -146 36 | anchors.horizontalCenterOffset: 1 37 | anchors.horizontalCenter: parent.horizontalCenter 38 | anchors.verticalCenter: parent.verticalCenter 39 | verticalAlignment: Text.AlignVCenter 40 | horizontalAlignment: Text.AlignHCenter 41 | } 42 | 43 | MaterialButton { 44 | x: 254 45 | y: 278 46 | width: 120 47 | height: 40 48 | text: "视频文件分析" 49 | anchors.verticalCenterOffset: 14 50 | anchors.horizontalCenterOffset: 1 51 | anchors.horizontalCenter: parent.horizontalCenter 52 | anchors.verticalCenter: parent.verticalCenter 53 | 54 | onClicked: { 55 | mainPageContains.showPage( "视频文件分析", "qrc:/Video/Video.qml" ); 56 | // welcomeManage.openGitHubLink(); 57 | } 58 | } 59 | 60 | MaterialButton { 61 | x: 254 62 | y: 278 63 | width: 120 64 | height: 40 65 | text: "实时视频分析" 66 | anchors.verticalCenterOffset: 74 67 | anchors.horizontalCenterOffset: 1 68 | anchors.horizontalCenter: parent.horizontalCenter 69 | anchors.verticalCenter: parent.verticalCenter 70 | 71 | onClicked: { 72 | mainPageContains.showPage( "实时视频分析", "qrc:/Camera/Camera.qml" ); 73 | // welcomeManage.openLatestVersionDownloadLink(); 74 | } 75 | } 76 | 77 | MaterialButton { 78 | x: 254 79 | y: 278 80 | width: 120 81 | height: 40 82 | text: "信息查询" 83 | anchors.verticalCenterOffset: 134 84 | anchors.horizontalCenterOffset: 1 85 | anchors.horizontalCenter: parent.horizontalCenter 86 | anchors.verticalCenter: parent.verticalCenter 87 | 88 | onClicked: { 89 | mainPageContains.showPage( "信息查询", "qrc:/Search/Search.qml" ); 90 | // welcomeManage.openLatestVersionDownloadLink(); 91 | } 92 | } 93 | 94 | MaterialLabel { 95 | anchors.right: parent.right 96 | anchors.rightMargin: 5 97 | anchors.bottom: parent.bottom 98 | anchors.bottomMargin: 3 99 | text: "作者:Perceptron 当前版本:V" + welcomeManage.jqToolsVersionString(); 100 | verticalAlignment: Text.AlignBottom 101 | horizontalAlignment: Text.AlignRight 102 | color: "#a1a1a1" 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /HardhatSystem/components/WelcomeGroup/qml/Welcome.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Welcome.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /HardhatSystem/components/WelcomeGroup/welcomegroup.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of JQTools 3 | 4 | Project introduce: https://github.com/188080501/JQTools 5 | 6 | Copyright: Jason 7 | 8 | Contact email: Jason@JasonServer.com 9 | 10 | GitHub: https://github.com/188080501/ 11 | */ 12 | 13 | #ifndef WELCOMEGROUP_WELCOMEGROUP_H_ 14 | #define WELCOMEGROUP_WELCOMEGROUP_H_ 15 | 16 | // WelcomeGroup lib import 17 | #include "welcome.h" 18 | 19 | #define WELCOMEGROUP_INITIALIZA \ 20 | WELCOME_INITIALIZA; 21 | 22 | #endif//WELCOMEGROUP_WELCOMEGROUP_H_ 23 | -------------------------------------------------------------------------------- /HardhatSystem/components/components.pri: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of JQTools 3 | # 4 | # Project introduce: https://github.com/188080501/JQTools 5 | # 6 | # Copyright: Jason 7 | # 8 | # Contact email: Jason@JasonServer.com 9 | # 10 | # GitHub: https://github.com/188080501/ 11 | # 12 | # Edited by Lue Tao, 201806 13 | # 14 | 15 | include( $$PWD/WelcomeGroup/WelcomeGroup.pri ) 16 | include( $$PWD/VideoGroup/VideoGroup.pri ) 17 | include( $$PWD/CameraGroup/CameraGroup.pri ) 18 | include( $$PWD/SearchGroup/SearchGroup.pri ) -------------------------------------------------------------------------------- /HardhatSystem/cpp/JQToolsManage: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of JQTools 3 | 4 | Project introduce: https://github.com/188080501/JQTools 5 | 6 | Copyright: Jason 7 | 8 | Contact email: Jason@JasonServer.com 9 | 10 | GitHub: https://github.com/188080501/ 11 | */ 12 | 13 | #include "jqtools_manage.hpp" 14 | -------------------------------------------------------------------------------- /HardhatSystem/cpp/bettervideocapture.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BETTERVIDEOCAPTURE_H 2 | #define BETTERVIDEOCAPTURE_H 3 | 4 | #include 5 | #include 6 | 7 | class BetterVideoCapture 8 | { 9 | public: 10 | BetterVideoCapture() 11 | { 12 | capture = new cv::VideoCapture(); 13 | } 14 | 15 | virtual ~BetterVideoCapture() 16 | { 17 | delete capture; 18 | } 19 | 20 | bool open(int device) 21 | { 22 | return capture->open(device); 23 | } 24 | 25 | void close() 26 | { 27 | return capture->release(); 28 | } 29 | 30 | bool open(QString file) 31 | { 32 | return capture->open(file.toStdString()); 33 | } 34 | 35 | double getProperty(int propIdx) 36 | { 37 | return capture->get(propIdx); 38 | } 39 | 40 | bool setProperty(int propIdx, double propVal) 41 | { 42 | return capture->set(propIdx,propVal); 43 | } 44 | 45 | 46 | bool grabFrame() 47 | { 48 | return capture->grab(); 49 | } 50 | 51 | unsigned char* retrieveFrame() 52 | { 53 | capture->retrieve(rawImage); 54 | return rawImage.ptr(); 55 | } 56 | 57 | bool isOpened() 58 | { 59 | return capture->isOpened(); 60 | } 61 | 62 | private: 63 | cv::VideoCapture* capture; 64 | cv::Mat rawImage; 65 | }; 66 | 67 | 68 | #endif // BETTERVIDEOCAPTURE_H 69 | -------------------------------------------------------------------------------- /HardhatSystem/cpp/dataface.h: -------------------------------------------------------------------------------- 1 | #ifndef DATAFACE_H 2 | #define DATAFACE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "yolo_v2_class.hpp" 13 | 14 | class DataFace 15 | { 16 | public: 17 | DataFace(); 18 | ~DataFace(); 19 | bool open(); 20 | bool insertVideo(QString path, float fps, int frameCount); 21 | bool insertDetection(QString path, QVariantList qFrameNow, QVariantList qBoxID, \ 22 | QVariantList qObjID, QVariantList qX, QVariantList qY, \ 23 | QVariantList qW, QVariantList qH, QVariantList qProb); 24 | bool deleteVideo(QString path); 25 | int searchVideo(QList &pathL, QList &fpsL, QList &frameCountL, QList &saveTimeL); 26 | int searchDetection(QString path, QList &frameNowL, QList &boxIDL, QList &objIDL, QList &xL, QList &yL, QList &wL, QList &hL); 27 | int countNoHat(int frameNow); 28 | int countTotal(int frameNow); 29 | std::vector getResult(int frameNow); 30 | int getFrameCount(); 31 | 32 | 33 | private: 34 | //数据库变量 35 | QString dbName = "hardhat_system"; 36 | 37 | QSqlDatabase db; 38 | 39 | QList qFrameNow, qBoxID, qObjID, qX, qY, qW, qH; 40 | std::vector *results; 41 | 42 | int frameCount; 43 | }; 44 | 45 | #endif // DATAFACE_H 46 | 47 | 48 | void testDataFace(); 49 | -------------------------------------------------------------------------------- /HardhatSystem/cpp/jqtools_manage.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of JQTools 3 | 4 | Project introduce: https://github.com/188080501/JQTools 5 | 6 | Copyright: Jason 7 | 8 | Contact email: Jason@JasonServer.com 9 | 10 | GitHub: https://github.com/188080501/ 11 | */ 12 | 13 | #ifndef __CPP_JQTOOLS_MANAGE_HPP__ 14 | #define __CPP_JQTOOLS_MANAGE_HPP__ 15 | 16 | // Qt ib import 17 | #include 18 | #include 19 | 20 | // JQToolsLibrary import 21 | #include 22 | 23 | class JQToolsManage: public AbstractTool 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | JQToolsManage() = default; 29 | 30 | ~JQToolsManage() = default; 31 | }; 32 | 33 | #endif//__CPP_JQTOOLS_MANAGE_HPP__ 34 | -------------------------------------------------------------------------------- /HardhatSystem/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | // Qt lib import 2 | #include 3 | #include 4 | #include 5 | //#include 6 | #include 7 | #include 8 | 9 | // JQToolsLibrary import 10 | #include 11 | 12 | // Project lib import 13 | #include 14 | 15 | // Group import 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "dataface.h" 22 | 23 | 24 | 25 | int main(int argc, char *argv[]) 26 | { 27 | // testDataFace(); 28 | // getVideoDir(); 29 | 30 | QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 31 | 32 | QGuiApplication app(argc, argv); 33 | 34 | QQmlApplicationEngine engine; 35 | JQToolsManage JQToolsManage; 36 | 37 | JQToolsManage.setQmlApplicationEngine(&engine); 38 | 39 | 40 | // Group initialize 41 | WELCOMEGROUP_INITIALIZA; 42 | VIDEOGROUP_INITIALIZA; 43 | CAMERAGROUP_INITIALIZA; 44 | SEARCHGROUP_INITIALIZA; 45 | 46 | engine.rootContext()->setContextProperty("JQToolsManage", &JQToolsManage); 47 | 48 | engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); 49 | if (engine.rootObjects().isEmpty()) 50 | return -1; 51 | 52 | return app.exec(); 53 | } 54 | -------------------------------------------------------------------------------- /HardhatSystem/cpp/stable.h: -------------------------------------------------------------------------------- 1 | #if defined __cplusplus 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /HardhatSystem/cpp/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | #include 3 | #include 4 | #include 5 | 6 | //Detector *detector = new Detector("yolov3.cfg", "yolov3.weights"); 7 | Detector *detector = new Detector("perceptron.cfg", "perceptron.weights"); 8 | 9 | DataFace *df = new DataFace(); 10 | 11 | cv::VideoWriter *videoWriter = new cv::VideoWriter(); 12 | 13 | QSound *sound = new QSound("beep.wav"); 14 | 15 | QString getCurrentTime() 16 | { 17 | QDateTime time = QDateTime::currentDateTime(); 18 | return time.toString("yyyy-MM-dd-hh-mm-ss"); 19 | } 20 | 21 | QString getCurrentTime2() 22 | { 23 | QDateTime time = QDateTime::currentDateTime(); 24 | return time.toString("yyyy-MM-dd hh:mm:ss"); 25 | } 26 | 27 | QString getVideoDir() 28 | { 29 | QString videoDir = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation); 30 | videoDir += "/hardhat_video_data/"; 31 | QDir dir(videoDir); 32 | if(!dir.exists()) 33 | dir.mkdir(videoDir);//只创建一级子目录,即必须保证上级目录存在 34 | 35 | // qDebug() << "videoDir: " << videoDir; 36 | return videoDir; 37 | } 38 | -------------------------------------------------------------------------------- /HardhatSystem/cpp/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_H 2 | #define UTILS_H 3 | 4 | #include "yolo_v2_class.hpp" 5 | #include "dataface.h" 6 | #include 7 | 8 | extern Detector *detector; 9 | 10 | static cv::Scalar obj_id_to_color(int obj_id); 11 | 12 | extern DataFace *df; 13 | 14 | extern cv::VideoWriter *videoWriter; 15 | 16 | extern QSound *sound; 17 | 18 | QString getCurrentTime(); 19 | QString getCurrentTime2(); 20 | 21 | QString getVideoDir(); 22 | 23 | #endif // UTILS_H 24 | -------------------------------------------------------------------------------- /HardhatSystem/cpp/yolo_cpp_dll.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TLMichael/Perceptron/a76dc4b88771b0179f150d6e3964dfb9e88f869a/HardhatSystem/cpp/yolo_cpp_dll.lib -------------------------------------------------------------------------------- /HardhatSystem/library/JQToolsLibrary/JQToolsLibrary.pri: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of JQTools 3 | # 4 | # Project introduce: https://github.com/188080501/JQTools 5 | # 6 | # Copyright: Jason 7 | # 8 | # Contact email: Jason@JasonServer.com 9 | # 10 | # GitHub: https://github.com/188080501/ 11 | # 12 | # Edited by Lue Tao, 2018,06 13 | # 14 | 15 | INCLUDEPATH *= \ 16 | $$PWD/include/ 17 | 18 | HEADERS *= \ 19 | $$PWD/include/jqtoolslibrary.h 20 | 21 | SOURCES *= \ 22 | $$PWD/src/jqtoolslibrary.cpp 23 | -------------------------------------------------------------------------------- /HardhatSystem/library/JQToolsLibrary/include/JQToolsLibrary: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of JQTools 3 | 4 | Project introduce: https://github.com/188080501/JQTools 5 | 6 | Copyright: Jason 7 | 8 | Contact email: Jason@JasonServer.com 9 | 10 | GitHub: https://github.com/188080501/ 11 | */ 12 | 13 | #include "jqtoolslibrary.h" 14 | -------------------------------------------------------------------------------- /HardhatSystem/library/JQToolsLibrary/include/jqtoolslibrary.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of JQTools 3 | 4 | Project introduce: https://github.com/188080501/JQTools 5 | 6 | Copyright: Jason 7 | 8 | Contact email: Jason@JasonServer.com 9 | 10 | GitHub: https://github.com/188080501/ 11 | 12 | Edited by Lue Tao, 2018,06 13 | */ 14 | 15 | #ifndef JQTOOLSLIBRARY_H_ 16 | #define JQTOOLSLIBRARY_H_ 17 | 18 | // Qt lib import 19 | #include 20 | #include 21 | 22 | #define JQTOOLS_VERSIONSTRING "2.2.0" 23 | 24 | class QQmlApplicationEngine; 25 | 26 | class AbstractTool: public QObject 27 | { 28 | Q_OBJECT 29 | 30 | public slots: 31 | QString jqToolsVersionString(); 32 | 33 | QString clipboardText(); 34 | 35 | void setClipboardText(const QString &string); 36 | 37 | static void setQmlApplicationEngine(QQmlApplicationEngine *qmlApplicationEngine); 38 | 39 | static QPointer< QQmlApplicationEngine > qmlApplicationEngine(); 40 | 41 | private: 42 | static QPointer< QQmlApplicationEngine > qmlApplicationEngine_; 43 | }; 44 | 45 | #endif//JQTOOLSLIBRARY_H_ 46 | -------------------------------------------------------------------------------- /HardhatSystem/library/JQToolsLibrary/src/jqtoolslibrary.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of JQTools 3 | 4 | Project introduce: https://github.com/188080501/JQTools 5 | 6 | Copyright: Jason 7 | 8 | Contact email: Jason@JasonServer.com 9 | 10 | GitHub: https://github.com/188080501/ 11 | */ 12 | 13 | #include "jqtoolslibrary.h" 14 | 15 | // Qt lib import 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | QPointer< QQmlApplicationEngine > AbstractTool::qmlApplicationEngine_; 22 | 23 | QString AbstractTool::jqToolsVersionString() 24 | { 25 | return JQTOOLS_VERSIONSTRING; 26 | } 27 | 28 | QString AbstractTool::clipboardText() 29 | { 30 | return qApp->clipboard()->text(); 31 | } 32 | 33 | void AbstractTool::setClipboardText(const QString &string) 34 | { 35 | qApp->clipboard()->setText( string ); 36 | } 37 | 38 | void AbstractTool::setQmlApplicationEngine(QQmlApplicationEngine *qmlApplicationEngine) 39 | { 40 | qmlApplicationEngine_ = qmlApplicationEngine; 41 | } 42 | 43 | QPointer< QQmlApplicationEngine > AbstractTool::qmlApplicationEngine() 44 | { 45 | return qmlApplicationEngine_; 46 | } 47 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Element/BaseListItem.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.5 2 | 3 | View { 4 | id: listItem 5 | anchors { 6 | left: parent.left 7 | right: parent.right 8 | } 9 | 10 | property int margins: (16) 11 | 12 | property bool selected 13 | property bool interactive: true 14 | 15 | property int dividerInset: 0 16 | property bool showDivider: false 17 | 18 | signal clicked() 19 | signal pressAndHold() 20 | 21 | ThinDivider { 22 | anchors.bottom: parent.bottom 23 | anchors.leftMargin: dividerInset 24 | 25 | visible: showDivider 26 | } 27 | 28 | Ink { 29 | id: ink 30 | 31 | onClicked: listItem.clicked() 32 | onPressAndHold: listItem.pressAndHold() 33 | 34 | anchors.fill: parent 35 | 36 | enabled: listItem.interactive 37 | z: -1 38 | } 39 | 40 | tintColor: selected 41 | ? Qt.rgba(0,0,0,0.05) 42 | : ink.containsMouse ? Qt.rgba(0,0,0,0.03) : Qt.rgba(0,0,0,0) 43 | } 44 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Element/BottomSheet.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * QML Material - An application framework implementing Material Design. 3 | * Copyright (C) 2015 Steve Coffey 4 | * 2015 Michael Spencer 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 2.1 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | import QtQuick 2.5 20 | 21 | /*! 22 | \qmltype BottomSheet 23 | \inqmlmodule Material 0.1 24 | 25 | \brief A bottom sheet is a sheet of paper that slides up from the bottom edge 26 | of the screen and presents a set of clear and simple actions. 27 | */ 28 | PopupBase { 29 | id: bottomSheet 30 | 31 | /*! 32 | The maximum height of the bottom sheet. This is useful when used with a flickable, 33 | so the bottom sheet will scroll when the content is higher than the maximum height. 34 | */ 35 | property int maxHeight: parent.height * 0.9 36 | 37 | default property alias content: containerView.data 38 | 39 | overlayLayer: "dialogOverlayLayer" 40 | overlayColor: Qt.rgba(0, 0, 0, 0.2) 41 | height: Math.min(maxHeight, implicitHeight) 42 | implicitHeight: containerView.childrenRect.height 43 | width: parent.width 44 | 45 | visible: percentOpen > 0 46 | 47 | property real percentOpen: showing ? 1 : 0 48 | 49 | Behavior on percentOpen { 50 | 51 | NumberAnimation { 52 | 53 | duration: 400 54 | easing { 55 | type: Easing.OutCubic 56 | } 57 | } 58 | } 59 | 60 | anchors { 61 | bottom: parent.bottom 62 | bottomMargin: (bottomSheet.percentOpen - 1) * height 63 | } 64 | 65 | View { 66 | id:containerView 67 | 68 | anchors.fill: parent 69 | 70 | elevation: 2 71 | backgroundColor: "#fff" 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Element/CircleMask.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * QML Extras - Extra types and utilities to make QML even more awesome 3 | * 4 | * Copyright (C) 2015 Michael Spencer 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 2.1 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | import QtQuick 2.5 21 | import QtGraphicalEffects 1.0 22 | 23 | Item { 24 | id: item 25 | 26 | property alias source: mask.source 27 | 28 | Rectangle { 29 | id: circleMask 30 | anchors.fill: parent 31 | 32 | smooth: true 33 | visible: false 34 | 35 | radius: Math.max(width/2, height/2) 36 | } 37 | 38 | OpacityMask { 39 | id: mask 40 | 41 | anchors.fill: parent 42 | maskSource: circleMask 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Element/Divider.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * QML Material - An application framework implementing Material Design. 3 | * Copyright (C) 2015 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | import QtQuick 2.5 19 | 20 | /*! 21 | \qmltype Divider 22 | \inqmlmodule Material.ListItems 0.1 23 | 24 | \brief A divider divides content in a list. 25 | */ 26 | Item { 27 | id: divider 28 | 29 | anchors { 30 | left: parent.left 31 | right: parent.right 32 | } 33 | 34 | height: (8) 35 | 36 | ThinDivider { 37 | anchors.verticalCenter: parent.verticalCenter 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Element/Dropdown.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * QML Material - An application framework implementing Material Design. 3 | * Copyright (C) 2015 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | import QtQuick 2.5 19 | 20 | PopupBase { 21 | id: dropdown 22 | 23 | default property alias data: view.data 24 | property int anchor: Item.TopRight 25 | property alias internalView: view 26 | 27 | visible: view.opacity > 0 28 | 29 | function findRoot(obj) { 30 | while (obj.parent) { 31 | obj = obj.parent 32 | } 33 | 34 | return obj 35 | } 36 | 37 | function open(caller, offsetX, offsetY) { 38 | if (typeof offsetX === "undefined") 39 | offsetX = 0 40 | 41 | if (typeof offsetY === "undefined") 42 | offsetY = 0 43 | 44 | var position = caller.mapToItem(dropdown.parent, 0, 0) 45 | 46 | // Check to make sure we are within the window bounds, move if we need to 47 | var globalPos = caller.mapToItem(null, 0, 0) 48 | var root = findRoot(dropdown) 49 | 50 | if (__internal.left) { 51 | dropdown.x = position.x 52 | } else if (__internal.center) { 53 | dropdown.x = caller.width / 2 - dropdown.width / 2 54 | } else { 55 | dropdown.x = position.x + caller.width - dropdown.width 56 | } 57 | 58 | if (__internal.top) { 59 | dropdown.y = position.y 60 | } else if (__internal.center) { 61 | dropdown.y = caller.height / 2 - dropdown.height / 2 62 | } else { 63 | dropdown.y = position.y + caller.height - dropdown.height 64 | } 65 | 66 | if (dropdown.y + height > root.height) 67 | offsetY = -((globalPos.y + height + (16)) - root.height) 68 | if (dropdown.x + width > root.width) 69 | offsetX = -((globalPos.x + width + (16)) - root.width) 70 | 71 | dropdown.x += offsetX 72 | dropdown.y += offsetY 73 | 74 | if (showing) 75 | { 76 | close(); 77 | } 78 | else 79 | { 80 | showing = true 81 | opened() 82 | } 83 | } 84 | 85 | function close() { 86 | showing = false 87 | } 88 | 89 | QtObject { 90 | id: __internal 91 | 92 | property bool left: dropdown.anchor == Item.Left || dropdown.anchor == Item.TopLeft || 93 | dropdown.anchor == Item.BottomLeft 94 | property bool right: dropdown.anchor == Item.Right || dropdown.anchor == Item.TopRight || 95 | dropdown.anchor == Item.BottomRight 96 | property bool top: dropdown.anchor == Item.Top || dropdown.anchor == Item.TopLeft || 97 | dropdown.anchor == Item.TopRight 98 | property bool bottom: dropdown.anchor == Item.Bottom || 99 | dropdown.anchor == Item.BottomLeft || 100 | dropdown.anchor == Item.BottomRight 101 | property bool center: dropdown.anchor == Item.Center 102 | } 103 | 104 | View { 105 | id: view 106 | elevation: 2 107 | radius: (2) 108 | anchors.left: __internal.left ? parent.left : undefined 109 | anchors.right: __internal.right ? parent.right : undefined 110 | anchors.top: __internal.top ? parent.top : undefined 111 | anchors.bottom: __internal.bottom ? parent.bottom : undefined 112 | anchors.horizontalCenter: __internal.center ? parent.horizontalCenter : undefined 113 | anchors.verticalCenter: __internal.center ? parent.verticalCenter : undefined 114 | } 115 | 116 | state: showing ? "open" : "closed" 117 | 118 | states: [ 119 | State { 120 | name: "closed" 121 | PropertyChanges { 122 | target: view 123 | opacity: 0 124 | width: 0 125 | height: 0 126 | } 127 | }, 128 | 129 | State { 130 | name: "open" 131 | PropertyChanges { 132 | target: view 133 | opacity: 1 134 | width: dropdown.width 135 | height: dropdown.height 136 | } 137 | } 138 | ] 139 | 140 | transitions: [ 141 | Transition { 142 | from: "open" 143 | to: "closed" 144 | 145 | NumberAnimation { 146 | target: internalView 147 | property: "opacity" 148 | duration: 400 149 | easing.type: Easing.InOutQuad 150 | } 151 | 152 | SequentialAnimation { 153 | 154 | PauseAnimation { 155 | duration: 200 156 | } 157 | 158 | NumberAnimation { 159 | target: internalView 160 | property: "width" 161 | duration: 200 162 | easing.type: Easing.InOutQuad 163 | } 164 | } 165 | 166 | NumberAnimation { 167 | target: internalView 168 | property: "height" 169 | duration: 400 170 | easing.type: Easing.InOutQuad 171 | } 172 | }, 173 | 174 | Transition { 175 | from: "closed" 176 | to: "open" 177 | 178 | NumberAnimation { 179 | target: internalView 180 | property: "opacity" 181 | duration: 400 182 | easing.type: Easing.InOutQuad 183 | } 184 | 185 | NumberAnimation { 186 | target: internalView 187 | property: "width" 188 | duration: 200 189 | easing.type: Easing.InOutQuad 190 | } 191 | 192 | NumberAnimation { 193 | target: internalView 194 | property: "height" 195 | duration: 400 196 | easing.type: Easing.InOutQuad 197 | } 198 | } 199 | ] 200 | } 201 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Element/PopupBase.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * QML Material - An application framework implementing Material Design. 3 | * Copyright (C) 2015 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | import QtQuick 2.5 19 | 20 | FocusScope { 21 | id: popup 22 | 23 | property color overlayColor: "transparent" 24 | property string overlayLayer: "overlayLayer" 25 | property bool showing: false 26 | 27 | signal opened 28 | 29 | function toggle(widget) { 30 | if (showing) { 31 | close() 32 | } else { 33 | open(widget) 34 | } 35 | } 36 | 37 | function open() { 38 | showing = true 39 | forceActiveFocus() 40 | 41 | opened() 42 | } 43 | 44 | function close() { 45 | showing = false 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Element/Scrollbar.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * QML Material - An application framework implementing Material Design. 3 | * Copyright (C) 2014 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | import QtQuick 2.5 19 | 20 | /*! 21 | \qmltype Scrollbar 22 | \inqmlmodule Material 0.1 23 | 24 | \brief Scrollbars show scrolling progress for listviews and flickables. 25 | */ 26 | Item { 27 | id: root 28 | 29 | property Flickable flickableItem 30 | property int orientation: Qt.Vertical 31 | property int thickness: 5 32 | property bool moving: flickableItem.moving 33 | 34 | width: thickness 35 | height: thickness 36 | clip: true 37 | smooth: true 38 | visible: orientation === Qt.Vertical ? flickableItem.contentHeight > flickableItem.height 39 | : flickableItem.contentWidth > flickableItem.width 40 | 41 | anchors { 42 | top: orientation === Qt.Vertical ? flickableItem.top : undefined 43 | bottom: flickableItem.bottom 44 | left: orientation === Qt.Horizontal ? flickableItem.left : undefined 45 | right: flickableItem.right 46 | margins: 2 47 | } 48 | 49 | Component.onCompleted: hideAnimation.start() 50 | 51 | onMovingChanged: { 52 | if (moving) { 53 | hideAnimation.stop() 54 | showAnimation.start() 55 | } else { 56 | hideAnimation.start() 57 | showAnimation.stop() 58 | } 59 | } 60 | 61 | NumberAnimation { 62 | id: showAnimation 63 | target: scrollBar; 64 | property: "opacity"; 65 | to: 0.3; 66 | duration: 200; 67 | easing.type: Easing.InOutQuad 68 | } 69 | 70 | SequentialAnimation { 71 | id: hideAnimation 72 | 73 | NumberAnimation { duration: 500 } 74 | NumberAnimation { 75 | target: scrollBar; 76 | property: "opacity"; 77 | to: 0; 78 | duration: 500; 79 | easing.type: Easing.InOutQuad 80 | } 81 | } 82 | 83 | onOrientationChanged: { 84 | if (orientation == Qt.Vertical) { 85 | width = thickness 86 | } else { 87 | height = thickness 88 | } 89 | } 90 | 91 | Rectangle { 92 | id: scrollBar 93 | property int length: orientation == Qt.Vertical ? root.height 94 | : root.width; 95 | property int targetLength: orientation == Qt.Vertical ? flickableItem.height 96 | : flickableItem.width; 97 | property int contentStart: orientation == Qt.Vertical ? flickableItem.contentY 98 | : flickableItem.contentX; 99 | property int contentLength: orientation == Qt.Vertical ? flickableItem.contentHeight 100 | : flickableItem.contentWidth; 101 | property int start: Math.max(0, length * contentStart/contentLength); 102 | property int end: Math.min(length, 103 | length * (contentStart + targetLength)/contentLength) 104 | 105 | color: "black"//theme.foreground 106 | opacity: 0.3 107 | radius: thickness/2 108 | width: Math.max(orientation == Qt.Horizontal ? end - start : 0, thickness) 109 | height: Math.max(orientation == Qt.Vertical ? end - start : 0, thickness) 110 | x: orientation == Qt.Horizontal ? start : 0 111 | y: orientation == Qt.Vertical ? start : 0 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Element/Standard.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * QML Air - A lightweight and mostly flat UI widget collection for QML 3 | * Copyright (C) 2014 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | import QtQuick 2.5 19 | import QtGraphicalEffects 1.0 20 | import QtQuick.Layouts 1.1 21 | import "../Interface" 22 | 23 | BaseListItem { 24 | id: listItem 25 | 26 | height: (48) 27 | 28 | property alias text: label.text 29 | property alias valueText: valueLabel.text 30 | 31 | property alias action: actionItem.children 32 | property alias secondaryItem: secondaryItem.children 33 | property alias content: contentItem.children 34 | 35 | property alias itemLabel: label 36 | 37 | property var labelHorizontalAlignment: Text.AlignLeft 38 | 39 | dividerInset: actionItem.visible ? listItem.height : 0 40 | 41 | interactive: contentItem.children.length == 0 42 | 43 | RowLayout { 44 | anchors.fill: parent 45 | 46 | anchors.leftMargin: listItem.margins 47 | anchors.rightMargin: listItem.margins 48 | 49 | spacing: (16) 50 | 51 | Item { 52 | id: actionItem 53 | 54 | Layout.preferredWidth: (40) 55 | Layout.preferredHeight: width 56 | Layout.alignment: Qt.AlignCenter 57 | 58 | visible: children.length > 1 59 | } 60 | 61 | ColumnLayout { 62 | Layout.alignment: Qt.AlignVCenter 63 | Layout.preferredHeight: parent.height 64 | 65 | Item { 66 | id: contentItem 67 | 68 | Layout.fillWidth: true 69 | Layout.preferredHeight: parent.height 70 | 71 | visible: children.length > 0 72 | } 73 | 74 | MaterialLabel { 75 | id: label 76 | 77 | Layout.alignment: Qt.AlignVCenter 78 | Layout.fillWidth: true 79 | 80 | elide: Text.ElideRight 81 | style: "subheading" 82 | 83 | color: listItem.selected ? "#fafafa" : "#d8000000" 84 | 85 | visible: !contentItem.visible 86 | 87 | horizontalAlignment: listItem.labelHorizontalAlignment 88 | } 89 | } 90 | 91 | MaterialLabel { 92 | id: valueLabel 93 | 94 | Layout.alignment: Qt.AlignVCenter 95 | 96 | color: "#89000000" 97 | elide: Text.ElideRight 98 | style: "body1" 99 | 100 | visible: text != "" 101 | 102 | horizontalAlignment: listItem.labelHorizontalAlignment 103 | } 104 | 105 | Item { 106 | id: secondaryItem 107 | 108 | Layout.alignment: Qt.AlignCenter 109 | Layout.preferredWidth: childrenRect.width 110 | Layout.preferredHeight: parent.height 111 | 112 | visible: childrenRect.width > 0 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Element/Subheader.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * QML Material - An application framework implementing Material Design. 3 | * Copyright (C) 2014-2015 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | import QtQuick 2.5 19 | import "../Interface" 20 | 21 | /*! 22 | \qmltype Subheader 23 | \inqmlmodule Material.ListItems 0.1 24 | 25 | \brief Subheaders are special list tiles that delineate distinct sections of a list or grid list. 26 | */ 27 | View { 28 | id: listItem 29 | 30 | //----- STYLE PROPERTIES -----// 31 | 32 | height: (48) 33 | property int margins: (16) 34 | 35 | anchors { 36 | left: parent.left 37 | right: parent.right 38 | } 39 | 40 | property int spacing 41 | 42 | property alias text: label.text 43 | property alias style: label.style 44 | 45 | MaterialLabel { 46 | id: label 47 | 48 | style: "body1" 49 | 50 | anchors { 51 | verticalCenter: parent.verticalCenter 52 | left: parent.left 53 | right: parent.right 54 | margins: margins 55 | } 56 | 57 | horizontalAlignment: Text.AlignHCenter 58 | 59 | color: "#89000000" 60 | } 61 | 62 | property bool showDivider: false 63 | 64 | ThinDivider { 65 | anchors.bottom: parent.bottom 66 | visible: showDivider 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Element/ThemePalette.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * QML Material - An application framework implementing Material Design. 3 | * Copyright (C) 2014-2015 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | import QtQuick 2.5 19 | 20 | /*! 21 | \qmltype Theme 22 | \inqmlmodule Material 0.1 23 | 24 | \brief Provides access to standard colors that follow the Material Design specification, but 25 | specifically designed for light or dark surfaces. 26 | 27 | See \l {http://www.google.com/design/spec/style/color.html#color-ui-color-application} for 28 | details about choosing a color scheme for your application. 29 | */ 30 | QtObject { 31 | id: palette 32 | 33 | property bool light 34 | 35 | readonly property color textColor: light ? shade(0.85) : shade(1) 36 | readonly property color subTextColor: light ? shade(0.54) : shade(0.70) 37 | readonly property color iconColor: light ? subTextColor : textColor 38 | readonly property color hintColor: light ? shade(0.26) : shade(0.30) 39 | readonly property color dividerColor: shade(0.12) 40 | 41 | /*! 42 | A version of the accent color specifically for lighter or darker backgrounds. This is 43 | normally the same as the global \l Theme::accentColor, but for some application's color 44 | schemes, the accent color is too dark or too light and a lighter/darker version is needed 45 | for some surfaces. This can be customized via the \l ApplicationWindow::theme group property. 46 | According to the Material Design guidelines, this should taken from a second color palette 47 | that complements the primary color palette at 48 | \l {http://www.google.com/design/spec/style/color.html#color-color-palette}. 49 | */ 50 | property color accentColor: "#2196f3" 51 | 52 | function shade(alpha) { 53 | if (light) { 54 | return Qt.rgba(0,0,0,alpha) 55 | } else { 56 | return Qt.rgba(1,1,1,alpha) 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Element/ThinDivider.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * QML Material - An application framework implementing Material Design. 3 | * Copyright (C) 2014 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | import QtQuick 2.5 19 | 20 | Rectangle { 21 | anchors { 22 | left: parent.left 23 | right: parent.right 24 | } 25 | 26 | color: Qt.rgba(0,0,0,0.1) 27 | height: 1 28 | } 29 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Element/View.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * QML Material - An application framework implementing Material Design. 3 | * Copyright (C) 2014-2015 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | import QtQuick 2.5 19 | import QtGraphicalEffects 1.0 20 | 21 | /*! 22 | \qmltype View 23 | \inqmlmodule Material 0.1 24 | 25 | \brief Provides a base view component, with support for Material Design elevation, 26 | background colors, and tinting. 27 | */ 28 | Item { 29 | id: item 30 | width: 100 31 | height: 62 32 | 33 | property int elevation: 0 34 | property real radius: 0 35 | 36 | property string style: "default" 37 | 38 | property color backgroundColor: elevation > 0 ? "white" : "transparent" 39 | property color tintColor: "transparent" 40 | 41 | property alias border: rect.border 42 | 43 | property bool fullWidth 44 | property bool fullHeight 45 | 46 | property alias clipContent: rect.clip 47 | 48 | default property alias data: rect.data 49 | 50 | property bool elevationInverted: false 51 | 52 | property var bottomShadowData: [ 53 | { 54 | "opacity": 0, 55 | "offset": 0, 56 | "blur": 0 57 | }, 58 | 59 | { 60 | "opacity": 0.24, 61 | "offset": 1, 62 | "blur": 1 63 | }, 64 | 65 | { 66 | "opacity": 0.23, 67 | "offset": 3, 68 | "blur": 3 69 | }, 70 | 71 | { 72 | "opacity": 0.23, 73 | "offset": 6, 74 | "blur": 6 75 | }, 76 | 77 | { 78 | "opacity": 0.22, 79 | "offset": 10, 80 | "blur": 10 81 | }, 82 | 83 | { 84 | "opacity": 0.22, 85 | "offset": 15, 86 | "blur": 6 87 | } 88 | ] 89 | 90 | property var topShadowData: [ 91 | { 92 | "opacity": 0, 93 | "offset": 0, 94 | "blur": 0 95 | }, 96 | 97 | { 98 | "opacity": 0.12, 99 | "offset": 1, 100 | "blur": 1.5 101 | }, 102 | 103 | { 104 | "opacity": 0.16, 105 | "offset": 3, 106 | "blur": 3 107 | }, 108 | 109 | { 110 | "opacity": 0.19, 111 | "offset": 10, 112 | "blur": 10 113 | }, 114 | 115 | { 116 | "opacity": 0.25, 117 | "offset": 14, 118 | "blur": 14 119 | }, 120 | 121 | { 122 | "opacity": 0.30, 123 | "offset": 19, 124 | "blur": 19 125 | } 126 | ] 127 | 128 | Connections { 129 | onElevationChanged: { 130 | bottomShadowBlurAnimation.to = bottomShadowData[Math.min(elevation, 5)]["blur"]; 131 | topShadowBlurAnimation.to = topShadowData[Math.min(elevation, 5)]["blur"]; 132 | 133 | bottomShadowBlurAnimation.restart(); 134 | topShadowBlurAnimation.restart(); 135 | } 136 | 137 | Component.onCompleted: { 138 | bottomShadow.blur = bottomShadowData[Math.min(elevation, 5)]["blur"]; 139 | topShadow.blur = topShadowData[Math.min(elevation, 5)]["blur"]; 140 | } 141 | } 142 | 143 | NumberAnimation { 144 | id: bottomShadowBlurAnimation 145 | target: bottomShadow 146 | property: "blur" 147 | duration: 150 148 | easing.type: Easing.OutQuad 149 | } 150 | 151 | NumberAnimation { 152 | id: topShadowBlurAnimation 153 | target: topShadow 154 | property: "blur" 155 | duration: 150 156 | easing.type: Easing.OutQuad 157 | } 158 | 159 | RectangularGlow { 160 | id: bottomShadow 161 | property var elevationInfo: bottomShadowData[Math.min(elevation, 5)] 162 | property int blur: bottomShadowData[1]["blur"]; 163 | property real horizontalShadowOffset: elevationInfo.offset * Math.sin((2 * Math.PI) * (parent.rotation / 360.0)) 164 | property real verticalShadowOffset: elevationInfo.offset * Math.cos((2 * Math.PI) * (parent.rotation / 360.0)) 165 | 166 | anchors.centerIn: parent 167 | width: parent.width + (fullWidth ? 10 : 0) 168 | height: parent.height + (fullHeight ? 20 : 0) 169 | anchors.horizontalCenterOffset: horizontalShadowOffset * (elevationInverted ? -1 : 1) 170 | anchors.verticalCenterOffset: verticalShadowOffset * (elevationInverted ? -1 : 1) 171 | glowRadius: blur 172 | opacity: elevationInfo.opacity 173 | spread: 0.05 174 | color: "black" 175 | cornerRadius: item.radius + glowRadius * 2.5 176 | } 177 | 178 | RectangularGlow { 179 | id: topShadow 180 | property var elevationInfo: topShadowData[Math.min(elevation, 5)] 181 | property int blur: topShadowData[1]["blur"]; 182 | property real horizontalShadowOffset: elevationInfo.offset * Math.sin((2 * Math.PI) * (parent.rotation / 360.0)) 183 | property real verticalShadowOffset: elevationInfo.offset * Math.cos((2 * Math.PI) * (parent.rotation / 360.0)) 184 | 185 | anchors.centerIn: parent 186 | width: parent.width + (fullWidth ? 10 : 0) 187 | height: parent.height + (fullHeight ? 20 : 0) 188 | anchors.horizontalCenterOffset: horizontalShadowOffset * (elevationInverted ? -1 : 1) 189 | anchors.verticalCenterOffset: verticalShadowOffset * (elevationInverted ? -1 : 1) 190 | glowRadius: blur 191 | opacity: elevationInfo.opacity 192 | spread: 0.05 193 | color: "black" 194 | cornerRadius: item.radius + glowRadius * 2.5 195 | } 196 | 197 | Rectangle { 198 | id: rect 199 | anchors.fill: parent 200 | color: Qt.tint(backgroundColor, tintColor) 201 | radius: item.radius 202 | antialiasing: parent.rotation || radius > 0 ? true : false 203 | clip: true 204 | 205 | Behavior on color { 206 | ColorAnimation { duration: 200 } 207 | } 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialActionButton.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * QML Material - An application framework implementing Material Design. 3 | * Copyright (C) 2015 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | import QtQuick 2.5 19 | import QtQuick.Controls 1.4 as Controls 20 | import QtQuick.Controls.Styles 1.4 as ControlStyles 21 | import QtGraphicalEffects 1.0 22 | import "../Element" 23 | 24 | Controls.Button { 25 | id: button 26 | width: 56 27 | height: 56 28 | 29 | property color backgroundColor: "#2196f3" 30 | property color textColor: lightDark(button.backgroundColor, 31 | "#89000000", 32 | "#ffffff") 33 | 34 | property int textSize: 15 35 | 36 | property string textFontFamily: { 37 | switch (Qt.platform.os) 38 | { 39 | case "windows": return "微软雅黑"; 40 | default: return "Roboto"; 41 | } 42 | } 43 | 44 | property int elevation: backgroundColor == "white" ? 0 : 1 45 | 46 | function lightDark(background, lightColor, darkColor) { 47 | return isDarkColor(background) ? darkColor : lightColor 48 | } 49 | 50 | function isDarkColor(background) { 51 | var temp = Qt.darker(background, 1) 52 | 53 | var a = 1 - ( 0.299 * temp.r + 0.587 * temp.g + 0.114 * temp.b); 54 | 55 | return temp.a > 0 && a >= 0.3 56 | } 57 | 58 | style: ControlStyles.ButtonStyle { 59 | background: Item { 60 | RectangularGlow { 61 | anchors.centerIn: parent 62 | anchors.verticalCenterOffset: elevation == 1 ? (1.5) 63 | : (1) 64 | 65 | width: parent.width 66 | height: parent.height 67 | visible: elevation > 0 68 | 69 | glowRadius: elevation == 1 ? (0.75) : (0.3) 70 | opacity: elevation == 1 ? 0.6 : 0.3 71 | spread: elevation == 1 ? 0.7 : 0.85 72 | color: "black" 73 | cornerRadius: height/2 74 | } 75 | 76 | View { 77 | anchors.fill: parent 78 | radius: width/2 79 | 80 | backgroundColor: button.backgroundColor 81 | 82 | tintColor: control.pressed || 83 | (control.focus && !button.elevation) || 84 | (control.hovered && !button.elevation) ? 85 | Qt.rgba(0,0,0, control.pressed ? 0.1 : 0.05) : "transparent" 86 | 87 | Ink { 88 | id: mouseArea 89 | anchors.fill: parent 90 | Connections { 91 | target: control.__behavior 92 | onPressed: mouseArea.onPressed(mouse) 93 | onCanceled: mouseArea.onCanceled() 94 | onReleased: mouseArea.onReleased(mouse) 95 | } 96 | 97 | circular: true 98 | } 99 | } 100 | } 101 | label: Controls.Label { 102 | font.pixelSize: textSize 103 | verticalAlignment: Text.AlignVCenter 104 | horizontalAlignment: Text.AlignHCenter 105 | text: control.text 106 | color: textColor 107 | elide: Text.ElideLeft 108 | font.family: button.textFontFamily 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialAnimation.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.7 2 | 3 | SequentialAnimation { 4 | id: animation 5 | 6 | property var target: null 7 | property string property 8 | property int duration: 1500 9 | property real from 10 | property real to 11 | 12 | property real fromToOffset: to - from 13 | 14 | ParallelAnimation { 15 | 16 | NumberAnimation { 17 | target: animation.target 18 | property: animation.property 19 | easing.type: Easing.InCubic 20 | duration: animation.duration * 0.27 21 | from: animation.from 22 | to: animation.from + animation.fromToOffset * 0.27 23 | } 24 | } 25 | 26 | ParallelAnimation { 27 | 28 | NumberAnimation { 29 | target: animation.target 30 | property: animation.property 31 | easing.type: Easing.OutExpo 32 | duration: animation.duration * 1.43 33 | to: animation.from + animation.fromToOffset * 1.022369 34 | } 35 | 36 | SequentialAnimation { 37 | 38 | PauseAnimation { 39 | duration: animation.duration * 0.73 40 | } 41 | 42 | ScriptAction { 43 | 44 | script: { 45 | animation.running = false; 46 | 47 | var buf = animation.property.toString().split( "." ); 48 | if ( buf.length === 1 ) 49 | { 50 | animation.target[ buf[ 0 ] ] = animation.to; 51 | } 52 | else if ( buf.length === 2 ) 53 | { 54 | animation.target[ buf[ 0 ] ][ buf[ 1 ] ] = animation.to; 55 | } 56 | else 57 | { 58 | print( "error property:", animation.property ); 59 | } 60 | } 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialBottomActionSheet.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * QML Material - An application framework implementing Material Design. 3 | * Copyright (C) 2015 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | import QtQuick 2.5 19 | import QtQuick.Controls 1.4 20 | import "../Element" 21 | 22 | /*! 23 | \qmltype BottomActionSheet 24 | \inqmlmodule Material 0.1 25 | 26 | \brief Represents a bottom sheet displaying a list of actions with an optional title. 27 | 28 | */ 29 | BottomSheet { 30 | id: bottomSheet 31 | 32 | property string title 33 | 34 | property var callbackOnCancel: null 35 | property var callbackOnOK: null 36 | 37 | implicitHeight: title !== "" ? header.height + listViewContainer.implicitHeight 38 | : listViewContainer.implicitHeight 39 | 40 | function show(title, sheetData, callbackOnCancel, callbackOnOK) { 41 | bottomSheet.title = title; 42 | bottomSheet.callbackOnCancel = callbackOnCancel; 43 | bottomSheet.callbackOnOK = callbackOnOK; 44 | bottomSheet.open(); 45 | 46 | materialUI.showDarkBackground(function() { 47 | bottomSheet.close(); 48 | materialUI.hideDarkBackground(); 49 | 50 | if (bottomSheet.callbackOnCancel) 51 | { 52 | bottomSheet.callbackOnCancel(); 53 | } 54 | }); 55 | 56 | listModel.clear(); 57 | for (var index = 0; index < sheetData.length; index++) 58 | { 59 | listModel.append({ 60 | itemIndex: index, 61 | itemText: sheetData[index]["text"], 62 | itemFlag: ("flag" in sheetData[index]) ? (sheetData[index]["flag"]) : (null), 63 | hasDividerAfter: ("hasDividerAfter" in sheetData[index]) ? (sheetData[index]["hasDividerAfter"]) : (false) 64 | }); 65 | } 66 | } 67 | 68 | Column { 69 | id: column 70 | 71 | anchors.fill: parent 72 | 73 | Subheader { 74 | id: header 75 | text: title 76 | visible: title !== "" 77 | height: (56) 78 | style: "subheading" 79 | backgroundColor: "white" 80 | elevation: listView.atYBeginning ? 0 : 1 81 | fullWidth: true 82 | z: 2 83 | } 84 | 85 | Item { 86 | id: listViewContainer 87 | 88 | width: parent.width 89 | height: title !== "" ? parent.height - header.height : parent.height 90 | 91 | implicitHeight: listView.contentHeight + listView.topMargin + listView.bottomMargin 92 | 93 | Flickable { 94 | id: listView 95 | width: parent.width 96 | height: parent.height 97 | 98 | interactive: bottomSheet.height < bottomSheet.implicitHeight 99 | 100 | topMargin: title !== "" ? 0 : (8) 101 | bottomMargin: (8) 102 | 103 | contentWidth: width 104 | contentHeight: subColumn.height 105 | 106 | Column { 107 | id: subColumn 108 | width: parent.width 109 | 110 | Repeater { 111 | model: ListModel { 112 | id: listModel 113 | } 114 | 115 | delegate: Column { 116 | width: subColumn.width 117 | 118 | Standard { 119 | id: listItem 120 | text: itemText 121 | visible: subColumn.visible 122 | enabled: subColumn.enabled 123 | labelHorizontalAlignment: Text.AlignHCenter 124 | 125 | onClicked: { 126 | actionSheet.close(); 127 | 128 | materialUI.hideDarkBackground(); 129 | 130 | if (callbackOnOK) 131 | { 132 | callbackOnOK(itemIndex, itemText, (((typeof itemFlag) !== "undefined") ? (itemFlag) : (null))); 133 | } 134 | } 135 | } 136 | 137 | Divider { 138 | visible: hasDividerAfter 139 | } 140 | } 141 | } 142 | } 143 | } 144 | 145 | Scrollbar { 146 | flickableItem: listView 147 | } 148 | } 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialButton.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * QML Material - An application framework implementing Material Design. 3 | * Copyright (C) 2014 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | import QtQuick 2.5 19 | import QtQuick.Controls 1.4 as Controls 20 | import QtQuick.Controls.Styles 1.4 as ControlStyles 21 | import "../Element" 22 | 23 | Controls.Button { 24 | id: button 25 | height: 36 26 | 27 | property int elevation: 1 28 | property color backgroundColor: elevation > 0 ? "white" : "transparent" 29 | property color textColor: lightDark(button.backgroundColor, 30 | "#d8000000", 31 | "#ffffff") 32 | property string textFontFamily: { 33 | switch (Qt.platform.os) 34 | { 35 | case "windows": return "微软雅黑"; 36 | default: return "Roboto"; 37 | } 38 | } 39 | property int textSize: 16 40 | property int textVerticalAlignment: Text.AlignVCenter 41 | property int textHorizontalAlignment: Text.AlignHCenter 42 | property bool textFontBold: false 43 | 44 | property string context: "default" // or "dialog" or "snackbar" 45 | 46 | property int labelWidth 47 | 48 | property var itemForLabel: null 49 | 50 | property bool iconVisible: false 51 | property int iconSize: 40 52 | property string iconFontFamily: "" 53 | property string iconText: "" 54 | 55 | function lightDark(background, lightColor, darkColor) { 56 | return isDarkColor(background) ? darkColor : lightColor 57 | } 58 | 59 | function isDarkColor(background) { 60 | var temp = Qt.darker(background, 1) 61 | 62 | var a = 1 - ( 0.299 * temp.r + 0.587 * temp.g + 0.114 * temp.b); 63 | 64 | return temp.a > 0 && a >= 0.3 65 | } 66 | 67 | style: ControlStyles.ButtonStyle { 68 | 69 | padding { 70 | left: 0 71 | right: 0 72 | top: 0 73 | bottom: 0 74 | } 75 | 76 | background: View { 77 | radius: (2) 78 | 79 | elevation: { 80 | var elevation = button.elevation 81 | 82 | if (elevation > 0 && (control.focus || mouseArea.currentCircle)) 83 | elevation++; 84 | 85 | return elevation; 86 | } 87 | backgroundColor: button.backgroundColor 88 | 89 | tintColor: mouseArea.currentCircle || control.focus || ((isSmartPhone()) ? (false) : (control.hovered)) 90 | ? Qt.rgba(0,0,0, mouseArea.currentCircle 91 | ? 0.1 : button.elevation > 0 ? 0.03 : 0.05) 92 | : "transparent" 93 | 94 | function isSmartPhone() { 95 | return (Qt.platform.os === "ios") || (Qt.platform.os === "android"); 96 | } 97 | 98 | Ink { 99 | id: mouseArea 100 | 101 | anchors.fill: parent 102 | focused: control.focus && button.context != "dialog" && button.context != "snackbar" 103 | focusWidth: parent.width - (30) 104 | focusColor: Qt.darker(button.backgroundColor, 1.05) 105 | 106 | Connections { 107 | target: control.__behavior 108 | onPressed: mouseArea.onPressed(mouse) 109 | onCanceled: mouseArea.onCanceled() 110 | onReleased: mouseArea.onReleased(mouse) 111 | } 112 | } 113 | } 114 | 115 | label: Item { 116 | implicitHeight: Math.max((36), label.height + (16)) 117 | implicitWidth: button.context == "dialog" ? Math.max((64), label.width + (16)) 118 | : button.context == "snackbar" ? label.width + (16) 119 | : Math.max((88), label.width + (32)) 120 | 121 | Controls.Label { 122 | id: label 123 | anchors.horizontalCenter: parent.horizontalCenter 124 | anchors.verticalCenter: parent.verticalCenter 125 | anchors.horizontalCenterOffset: (iconVisible) ? (iconSize / 2) : (0) 126 | font.pixelSize: textSize 127 | text: control.text 128 | font.family: textFontFamily 129 | verticalAlignment: Text.AlignVCenter 130 | horizontalAlignment: Text.AlignHCenter 131 | color: (control.enabled) ? (button.textColor) : (alpha(button.textColor, 0.4)) 132 | renderType: Text.QtRendering 133 | 134 | function alpha(color, alpha) { 135 | var realColor = Qt.darker(color, 1) 136 | realColor.a = alpha 137 | return realColor 138 | } 139 | 140 | onWidthChanged: { 141 | labelWidth = width; 142 | } 143 | 144 | Component.onCompleted: { 145 | button.itemForLabel = this; 146 | } 147 | 148 | Controls.Label { 149 | anchors.right: parent.left 150 | anchors.rightMargin: 5 151 | anchors.verticalCenter: parent.verticalCenter 152 | font.pixelSize: iconSize 153 | font.family: iconFontFamily 154 | visible: iconVisible 155 | color: parent.color 156 | text: iconText 157 | } 158 | } 159 | } 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialDialogAlert.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.5 2 | import QtQuick.Controls 1.4 as Controls 3 | import QtQuick.Controls.Styles 1.4 as ControlStyles 4 | 5 | MaterialDialog { 6 | id: dialog 7 | 8 | negativeButtonText: "" 9 | positiveButtonText: ("OK") 10 | 11 | property var callbackOnOK: null 12 | 13 | function show(title, message, callbackOnOK) { 14 | dialog.title = title; 15 | dialog.text = message; 16 | dialog.callbackOnOK = callbackOnOK; 17 | dialog.open(); 18 | 19 | materialUI.showDarkBackground(function() { 20 | dialog.close(); 21 | materialUI.hideDarkBackground(); 22 | 23 | if (dialog.callbackOnOK) 24 | { 25 | dialog.callbackOnOK(); 26 | } 27 | }); 28 | } 29 | 30 | onAccepted: { 31 | materialUI.hideDarkBackground(); 32 | 33 | if (callbackOnOK) 34 | { 35 | callbackOnOK(); 36 | } 37 | } 38 | 39 | onRejected: { 40 | materialUI.hideDarkBackground(); 41 | 42 | if (callbackOnOK) 43 | { 44 | callbackOnOK(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialDialogConfirm.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.5 2 | import QtQuick.Controls 1.4 as Controls 3 | import QtQuick.Controls.Styles 1.4 as ControlStyles 4 | 5 | MaterialDialog { 6 | id: dialog 7 | 8 | negativeButtonText: ("Cancel") 9 | positiveButtonText: ("OK") 10 | 11 | property var callbackOnCancel: null 12 | property var callbackOnOK: null 13 | 14 | function show(title, message, callbackOnCancel, callbackOnOK) { 15 | dialog.title = title; 16 | dialog.text = message; 17 | dialog.callbackOnCancel = callbackOnCancel; 18 | dialog.callbackOnOK = callbackOnOK; 19 | dialog.open(); 20 | 21 | // materialUI.showDarkBackground(); 22 | } 23 | 24 | onAccepted: { 25 | console.log("accepted") 26 | // materialUI.hideDarkBackground(); 27 | 28 | if (callbackOnOK) 29 | { 30 | callbackOnOK(); 31 | } 32 | } 33 | 34 | onRejected: { 35 | // materialUI.hideDarkBackground(); 36 | 37 | if (callbackOnCancel) 38 | { 39 | callbackOnCancel(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialDialogDatePicker.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.5 2 | import QtQuick.Controls 1.4 as Controls 3 | import QtQuick.Controls.Styles 1.4 as ControlStyles 4 | 5 | MaterialDialog { 6 | id: dialog 7 | 8 | negativeButtonText: ("Cancel") 9 | positiveButtonText: ("OK") 10 | 11 | property var callbackOnCancel: null 12 | property var callbackOnOK: null 13 | 14 | function show(title, message, currentDate, callbackOnCancel, callbackOnOK) { 15 | dialog.title = title; 16 | dialog.text = message; 17 | dialog.callbackOnCancel = callbackOnCancel; 18 | dialog.callbackOnOK = callbackOnOK; 19 | dialog.open(); 20 | 21 | if (currentDate) 22 | { 23 | datePicker.selectedDate = currentDate; 24 | } 25 | else 26 | { 27 | datePicker.selectedDate = new Date; 28 | } 29 | 30 | materialUI.showDarkBackground(); 31 | } 32 | 33 | onAccepted: { 34 | materialUI.hideDarkBackground(); 35 | 36 | if (callbackOnOK) 37 | { 38 | callbackOnOK( datePicker.selectedDate ); 39 | } 40 | } 41 | 42 | onRejected: { 43 | materialUI.hideDarkBackground(); 44 | 45 | if (callbackOnCancel) 46 | { 47 | callbackOnCancel(); 48 | } 49 | } 50 | 51 | Item { 52 | width: datePicker.width 53 | height: datePicker.height 54 | 55 | MaterialDatePicker { 56 | id: datePicker 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialDialogPrompt.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.5 2 | import QtQuick.Layouts 1.1 3 | 4 | MaterialDialog { 5 | id: dialog 6 | 7 | negativeButtonText: ("Cancel") 8 | positiveButtonText: ("OK") 9 | 10 | property var callbackOnCancel: null 11 | property var callbackOnOK: null 12 | 13 | function show(title, message, placeholderText, currentText, callbackOnCancel, callbackOnOK) { 14 | dialog.title = title; 15 | dialog.text = message; 16 | dialog.callbackOnCancel = callbackOnCancel; 17 | dialog.callbackOnOK = callbackOnOK; 18 | dialog.open(); 19 | 20 | textField.placeholderText = placeholderText; 21 | textField.text = currentText; 22 | 23 | materialUI.showDarkBackground(); 24 | } 25 | 26 | onAccepted: { 27 | materialUI.hideDarkBackground(); 28 | 29 | if (callbackOnOK) 30 | { 31 | callbackOnOK(textField.text); 32 | } 33 | } 34 | 35 | onRejected: { 36 | materialUI.hideDarkBackground(); 37 | 38 | if (callbackOnCancel) 39 | { 40 | callbackOnCancel(); 41 | } 42 | } 43 | 44 | Item { 45 | width: parent.width 46 | height: 64 47 | 48 | MaterialTextField { 49 | id: textField 50 | y: 0 51 | z: 2 52 | width: parent.width 53 | height: 56 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialDialogScrolling.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.5 2 | import QtQuick.Controls 1.4 3 | import QtQuick.Controls.Styles 1.4 4 | 5 | MaterialDialog { 6 | id: dialog 7 | 8 | negativeButtonText: ("Cancel") 9 | positiveButtonText: ("OK") 10 | 11 | positiveButtonEnabled: currentItemIndex !== -1 12 | 13 | property var callbackOnCancel: null 14 | property var callbackOnOK: null 15 | 16 | property int currentItemIndex 17 | property string currentItemText 18 | property var currentItemFlag 19 | 20 | function show(title, message, listData, callbackOnCancel, callbackOnOK) { 21 | dialog.title = title; 22 | dialog.text = message; 23 | dialog.callbackOnCancel = callbackOnCancel; 24 | dialog.callbackOnOK = callbackOnOK; 25 | dialog.open(); 26 | 27 | listView.contentY = 0; 28 | currentItemIndex = -1; 29 | currentItemText = ""; 30 | currentItemFlag = null; 31 | 32 | materialUI.showDarkBackground(); 33 | 34 | listModel.clear(); 35 | for (var index = 0; index < listData.length; index++) 36 | { 37 | listModel.append({ 38 | itemIndex: index, 39 | itemText: listData[index]["text"], 40 | itemFlag: ("flag" in listData[index]) ? (listData[index]["flag"]) : (""), 41 | itemTooltip: ("tooltip" in listData[index]) ? (listData[index]["tooltip"]) : (""), 42 | defaultChecked: ("checked" in listData[index]) ? (listData[index]["checked"]) : (false) 43 | }); 44 | } 45 | } 46 | 47 | onAccepted: { 48 | materialUI.hideDarkBackground(); 49 | 50 | if (callbackOnOK) 51 | { 52 | callbackOnOK(currentItemIndex, currentItemText, currentItemFlag); 53 | } 54 | } 55 | 56 | onRejected: { 57 | materialUI.hideDarkBackground(); 58 | 59 | if (callbackOnCancel) 60 | { 61 | callbackOnCancel(); 62 | } 63 | } 64 | 65 | ExclusiveGroup { 66 | id: checkGroup 67 | } 68 | 69 | ListView { 70 | id: listView 71 | x: 0 72 | y: 55 73 | width: 270 74 | height: 150 75 | clip: true 76 | boundsBehavior: Flickable.StopAtBounds 77 | 78 | onContentYChanged: { 79 | slider.value = -1 * contentY; 80 | } 81 | 82 | delegate: Item { 83 | width: 270 84 | height: 50 85 | 86 | Component.onCompleted: { 87 | if (defaultChecked || (itemIndex === 0)) 88 | { 89 | radioButton.checked = true; 90 | currentItemIndex = itemIndex; 91 | currentItemText = itemText; 92 | currentItemFlag = itemFlag; 93 | } 94 | } 95 | 96 | MaterialButton { 97 | anchors.fill: parent 98 | tooltip: itemTooltip 99 | 100 | elevation: 0 101 | 102 | onClicked: { 103 | radioButton.checked = true; 104 | currentItemIndex = itemIndex; 105 | currentItemText = itemText; 106 | currentItemFlag = itemFlag; 107 | } 108 | } 109 | 110 | Rectangle { 111 | x: 10 112 | y: 49 113 | width: 270 114 | height: 1 115 | color: "#50afafbc" 116 | } 117 | 118 | MaterialLabel { 119 | x: 50 120 | y: 15 121 | text: itemText 122 | font.pixelSize: 17 123 | } 124 | 125 | MaterialRadioButton { 126 | id: radioButton 127 | y: 15 128 | width: 25 129 | height: 20 130 | exclusiveGroup: checkGroup 131 | checked: defaultChecked 132 | 133 | onCheckedChanged: { 134 | if ( !checked ) { return; } 135 | 136 | radioButton.checked = true; 137 | currentItemIndex = itemIndex; 138 | currentItemText = itemText; 139 | currentItemFlag = itemFlag; 140 | } 141 | } 142 | } 143 | 144 | model: ListModel { 145 | id: listModel 146 | } 147 | 148 | Rectangle { 149 | width: parent.width 150 | height: 1 151 | color: "#e7e7e7" 152 | anchors.left: listView.left 153 | anchors.bottom: listView.bottom 154 | } 155 | 156 | Rectangle { 157 | width: parent.width 158 | height: 1 159 | color: "#e7e7e7" 160 | anchors.left: listView.left 161 | anchors.top: listView.top 162 | } 163 | 164 | Slider { 165 | id: slider 166 | anchors.right: listView.right 167 | anchors.rightMargin: line.width - 16 168 | anchors.top: listView.top 169 | width: 16 170 | height: listView.height 171 | minimumValue: -1 * (((listView.contentHeight - listView.height) > 0) ? (listView.contentHeight - listView.height) : (0)) 172 | maximumValue: listModel.count * 0 173 | orientation: Qt.Vertical 174 | visible: ((listView.contentHeight - listView.height) > 0) && !materialUI.isSmartPhone() 175 | 176 | onValueChanged: { 177 | listView.contentY = -1 * value; 178 | } 179 | 180 | style: SliderStyle { 181 | 182 | groove: Rectangle { 183 | color: "#00000000" 184 | } 185 | 186 | handle: Rectangle { 187 | width: 32 188 | height: 16 189 | color: "#00000000" 190 | 191 | Rectangle { 192 | x: 1 193 | y: (height - 2) / 5 194 | width: 30 195 | height: (control.hovered || control.pressed) ? (12) : (7) 196 | color: "#dd666666" 197 | implicitWidth: 34 198 | implicitHeight: 34 199 | radius: height / 2 200 | opacity: 0.8 201 | 202 | onHeightChanged: { 203 | line.width = height + 4; 204 | } 205 | 206 | Behavior on height { PropertyAnimation { } } 207 | } 208 | } 209 | } 210 | 211 | Rectangle { 212 | id: line 213 | y: -1 214 | width: 10 215 | height: parent.height + 2 216 | border.color: "#88999999" 217 | color: "#11999999" 218 | opacity: (width - 11) / 5 219 | } 220 | } 221 | } 222 | } 223 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialDialogTextArea.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.5 2 | import QtQuick.Controls 1.4 as Controls 3 | import QtQuick.Controls.Styles 1.4 as ControlStyles 4 | 5 | MaterialDialog { 6 | id: dialog 7 | 8 | negativeButtonText: ("Cancel") 9 | positiveButtonText: ("OK") 10 | 11 | Component.onCompleted: { 12 | dialog.open() 13 | } 14 | 15 | property var callbackOnCancel: null 16 | property var callbackOnOK: null 17 | 18 | function show(title, message, currentText, callbackOnCancel, callbackOnOK) { 19 | dialog.title = title; 20 | dialog.text = message; 21 | dialog.callbackOnCancel = callbackOnCancel; 22 | dialog.callbackOnOK = callbackOnOK; 23 | dialog.open(); 24 | 25 | textArea.text = currentText; 26 | 27 | materialUI.showDarkBackground(); 28 | } 29 | 30 | onAccepted: { 31 | materialUI.hideDarkBackground(); 32 | 33 | if (callbackOnOK) 34 | { 35 | callbackOnOK(textArea.text); 36 | } 37 | } 38 | 39 | onRejected: { 40 | materialUI.hideDarkBackground(); 41 | 42 | if (callbackOnCancel) 43 | { 44 | callbackOnCancel(); 45 | } 46 | } 47 | 48 | Item { 49 | width: 300 50 | height: 300 51 | clip: true 52 | 53 | Controls.TextArea { 54 | id: textArea 55 | x: -5 56 | y: -5 57 | width: parent.width + 10 58 | height: parent.height + 10 59 | wrapMode: TextInput.WordWrap 60 | textMargin: 10 61 | 62 | style: ControlStyles.TextAreaStyle { 63 | selectedTextColor: "#ffffff" 64 | selectionColor: "#2799f3" 65 | textColor: "#000000" 66 | } 67 | } 68 | 69 | Rectangle { 70 | x: 1 71 | y: 1 72 | width: parent.width - 2 73 | height: parent.height - 2 74 | border.color: "#a1a1a1" 75 | border.width: 1 76 | color: "#00000000" 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialDialogTimePicker.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.5 2 | import QtQuick.Controls 1.4 as Controls 3 | import QtQuick.Controls.Styles 1.4 as ControlStyles 4 | 5 | MaterialDialog { 6 | id: dialog 7 | 8 | negativeButtonText: ("Cancel") 9 | positiveButtonText: ("OK") 10 | 11 | property var callbackOnCancel: null 12 | property var callbackOnOK: null 13 | 14 | function show(title, message, currentTime, callbackOnCancel, callbackOnOK) { 15 | dialog.title = title; 16 | dialog.text = message; 17 | dialog.callbackOnCancel = callbackOnCancel; 18 | dialog.callbackOnOK = callbackOnOK; 19 | dialog.open(); 20 | 21 | if (currentTime) 22 | { 23 | timePicker.setIsHours(false); 24 | timePicker.setDigitsPressed(currentTime.getMinutes()); 25 | 26 | timePicker.setIsHours(true); 27 | timePicker.setDigitsPressed(currentTime.getHours()); 28 | } 29 | else 30 | { 31 | var dateTime = new Date; 32 | 33 | timePicker.setIsHours(false); 34 | timePicker.setDigitsPressed(dateTime.getMinutes()); 35 | 36 | timePicker.setIsHours(true); 37 | timePicker.setDigitsPressed(dateTime.getHours()); 38 | } 39 | 40 | materialUI.showDarkBackground(); 41 | } 42 | 43 | onAccepted: { 44 | materialUI.hideDarkBackground(); 45 | 46 | if (callbackOnOK) 47 | { 48 | callbackOnOK( timePicker.getCurrentTime() ); 49 | } 50 | } 51 | 52 | onRejected: { 53 | materialUI.hideDarkBackground(); 54 | 55 | if (callbackOnCancel) 56 | { 57 | callbackOnCancel(); 58 | } 59 | } 60 | 61 | Item { 62 | width: timePicker.width 63 | height: timePicker.height 64 | 65 | MaterialTimePicker { 66 | id: timePicker 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialLabel.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * QML Material - An application framework implementing Material Design. 3 | * Copyright (C) 2014 Michael Spencer 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | import QtQuick 2.5 19 | import QtQuick.Controls 1.4 20 | 21 | Label { 22 | id: label 23 | property string style: "body1" 24 | 25 | property var fontStyles: { 26 | "display4": { 27 | "size": 112, 28 | "font": "light" 29 | }, 30 | 31 | "display3": { 32 | "size": 56, 33 | "font": "regular" 34 | }, 35 | 36 | "display2": { 37 | "size": 45, 38 | "font": "regular" 39 | }, 40 | 41 | "display1": { 42 | "size": 34, 43 | "font": "regular" 44 | }, 45 | 46 | "headline": { 47 | "size": 24, 48 | "font": "regular" 49 | }, 50 | 51 | "title": { 52 | "size": 20, 53 | "font": "regular" 54 | }, 55 | 56 | "dialog": { 57 | "size": 18, 58 | "font": "regular" 59 | }, 60 | 61 | "subheading": { 62 | "size": 16, 63 | "font": "regular" 64 | }, 65 | 66 | "body2": { 67 | "size": 14, 68 | "font": "medium" 69 | }, 70 | 71 | "body1": { 72 | "size": 14, 73 | "font": "regular" 74 | }, 75 | 76 | "caption": { 77 | "size": 12, 78 | "font": "regular" 79 | }, 80 | 81 | "menu": { 82 | "size": 14, 83 | "font": "medium" 84 | }, 85 | 86 | "button": { 87 | "size": 14, 88 | "font": "medium" 89 | }, 90 | 91 | "tooltip": { 92 | "size": 14, 93 | "font": "medium" 94 | }, 95 | } 96 | 97 | property var fontInfo: fontStyles[style] 98 | 99 | renderType: Text.QtRendering 100 | 101 | font.pixelSize: fontInfo.size 102 | font.family: { 103 | switch (Qt.platform.os) 104 | { 105 | case "windows": return "微软雅黑"; 106 | default: return "Roboto"; 107 | } 108 | } 109 | 110 | color: "#d8000000" 111 | } 112 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialMenuField.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.5 2 | import QtQuick.Layouts 1.1 3 | import "../Element" 4 | 5 | Item { 6 | id: field 7 | width: 100 8 | height: 56 9 | z: (dropdown.visible) ? (2) : (0) 10 | 11 | implicitHeight: hasHelperText ? helperTextLabel.y + helperTextLabel.height + (4) 12 | : underline.y + (8) 13 | implicitWidth: spinBoxContents.implicitWidth 14 | 15 | activeFocusOnTab: true 16 | 17 | property int itemWidth: field.width 18 | property int itemHeight: 48 19 | 20 | property bool autoOffsetY: false 21 | property bool fixedOffsetY: false 22 | property int fixedOffsetYValue: -24 23 | 24 | property color accentColor: "#2196f3" 25 | property color errorColor: "#F44336" 26 | 27 | property alias model: listView.model 28 | readonly property string selectedText: listView.currentItem.text 29 | property alias selectedIndex: listView.currentIndex 30 | property int maxVisibleItems: 4 31 | 32 | property string textPrefix: " " 33 | property alias textVerticalAlignment: label.verticalAlignment 34 | property alias textHorizontalAlignment: label.horizontalAlignment 35 | 36 | property alias placeholderText: fieldPlaceholder.text 37 | property alias helperText: helperTextLabel.text 38 | 39 | property bool floatingLabel: false 40 | property bool hasError: false 41 | property bool hasHelperText: helperText.length > 0 42 | 43 | property alias dropdownVisible: dropdown.visible 44 | property alias dropdownWidth: dropdown.width 45 | property alias dropdownHeight: dropdown.height 46 | 47 | readonly property rect inputRect: Qt.rect(spinBox.x, spinBox.y, spinBox.width, spinBox.height) 48 | 49 | signal itemSelected(int index, string text); 50 | 51 | Ink { 52 | anchors.fill: parent 53 | 54 | onClicked: { 55 | listView.positionViewAtIndex(listView.currentIndex, ListView.Center) 56 | var offset = listView.currentItem.itemLabel.mapToItem(dropdown, 0, 0) 57 | 58 | if (autoOffsetY) 59 | { 60 | dropdown.open(label, 0, -offset.y - (4)); 61 | } 62 | else if (fixedOffsetY) 63 | { 64 | dropdown.open(label, 0, fixedOffsetYValue); 65 | } 66 | else 67 | { 68 | dropdown.open(label, 0, -24); 69 | } 70 | 71 | if ( Qt.platform.os !== "android" ) 72 | { 73 | materialUI.showStealthBackground(function() { 74 | dropdown.close(); 75 | materialUI.hideStealthBackground(); 76 | }, dropdown); 77 | } 78 | } 79 | } 80 | 81 | Item { 82 | z: 2 83 | id: spinBox 84 | 85 | height: (24) 86 | width: parent.width 87 | 88 | y: { 89 | if (!floatingLabel) 90 | return (16) 91 | if (floatingLabel && !hasHelperText) 92 | return (40) 93 | return (28) 94 | } 95 | 96 | RowLayout { 97 | id: spinBoxContents 98 | 99 | height: parent.height 100 | width: parent.width 101 | 102 | MaterialLabel { 103 | id: label 104 | 105 | Layout.fillWidth: true 106 | Layout.alignment: Qt.AlignVCenter 107 | 108 | text: field.textPrefix + listView.currentItem.text 109 | 110 | style: "subheading" 111 | elide: Text.ElideRight 112 | } 113 | } 114 | 115 | Dropdown { 116 | id: dropdown 117 | anchor: Item.TopLeft 118 | width: itemWidth 119 | height: Math.min(maxVisibleItems * (48), listView.height) 120 | 121 | ListView { 122 | id: listView 123 | 124 | width: dropdown.width 125 | height: Math.min(count > 0 ? contentHeight : 0, maxVisibleItems * (48)); 126 | 127 | interactive: true 128 | 129 | delegate: Standard { 130 | id: delegateItem 131 | width: dropdown.width 132 | height: field.itemHeight 133 | 134 | text: modelData 135 | 136 | onClicked: { 137 | listView.currentIndex = index 138 | 139 | dropdown.close() 140 | 141 | materialUI.hideStealthBackground(); 142 | 143 | itemSelected(index, listView.currentItem.text); 144 | } 145 | } 146 | } 147 | 148 | Scrollbar { 149 | flickableItem: listView 150 | } 151 | } 152 | } 153 | 154 | MaterialLabel { 155 | id: fieldPlaceholder 156 | anchors.bottom: spinBox.top 157 | text: field.placeholderText 158 | visible: floatingLabel 159 | font.pixelSize: 13 160 | color: "#42000000" 161 | } 162 | 163 | Rectangle { 164 | id: underline 165 | 166 | color: field.hasError ? field.errorColor : field.activeFocus ? field.accentColor : "#42000000" 167 | 168 | height: field.activeFocus ? (2) : (1) 169 | 170 | anchors { 171 | left: parent.left 172 | right: parent.right 173 | top: spinBox.bottom 174 | topMargin: (6) 175 | } 176 | 177 | Behavior on height { NumberAnimation { duration: 200 } } 178 | 179 | Behavior on color { ColorAnimation { duration: 200 } } 180 | } 181 | 182 | MaterialLabel { 183 | id: helperTextLabel 184 | 185 | anchors { 186 | left: parent.left 187 | right: parent.right 188 | top: underline.top 189 | topMargin: (4) 190 | } 191 | 192 | visible: hasHelperText 193 | font.pixelSize: (12) 194 | color: field.hasError ? field.errorColor : Qt.darker("#42000000") 195 | 196 | Behavior on color { 197 | ColorAnimation { duration: 200 } 198 | } 199 | } 200 | } 201 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialPage.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.5 2 | import QtQuick.Controls 1.4 3 | import QtGraphicalEffects 1.0 4 | 5 | Rectangle { 6 | id: materialPage 7 | width: parent.width 8 | height: parent.height 9 | color: "#efefef" 10 | 11 | property alias titleText: labelForTitle.text 12 | 13 | property alias tabbedModel: tabbed.model 14 | property alias tabbedIconDatas: tabbed.iconDatas 15 | property alias tabbedItemWidth: tabbed.itemWidth 16 | property alias tabbedZ: tabbed.z 17 | 18 | property bool hideBackButton: false 19 | property bool hideTopShadow: false 20 | 21 | property bool destroyOnHide: false 22 | 23 | signal tabbedItemSelected(int index, string text) 24 | 25 | function show() { 26 | visible = true; 27 | animationForShowAndClose.from = width; 28 | animationForShowAndClose.to = 0; 29 | animationForShowAndClose.easing.type = Easing.OutQuad; 30 | animationForShowAndClose.duration = Math.min(width * 1.5, 800); 31 | animationForShowAndClose.start(); 32 | } 33 | 34 | function hide() { 35 | animationForShowAndClose.from = 0; 36 | animationForShowAndClose.to = width; 37 | animationForShowAndClose.easing.type = Easing.InQuad; 38 | animationForShowAndClose.duration = Math.min(width * 1.2, 800); 39 | animationForShowAndClose.start(); 40 | } 41 | 42 | MouseArea { 43 | anchors.fill: parent 44 | } 45 | 46 | RectangularGlow { 47 | z: 1 48 | anchors.fill: topRectangle 49 | glowRadius: 6 50 | spread: 0.22 51 | color: "#40000000" 52 | visible: !hideTopShadow 53 | } 54 | 55 | RectangularGlow { 56 | z: -1 57 | anchors.fill: materialPage 58 | glowRadius: 6 59 | spread: 0.22 60 | color: "#40000000" 61 | visible: !hideTopShadow 62 | } 63 | 64 | Rectangle { 65 | id: topRectangle 66 | z: 2 67 | width: parent.width 68 | height: (48) 69 | color: "#07bdd3" 70 | 71 | MaterialActionButton { 72 | width: height 73 | height: parent.height 74 | elevation: 0 75 | textFontFamily: "Material-Design-Iconic-Font" 76 | text: "\uF297" 77 | textSize: 22 78 | textColor: "#ffffff" 79 | backgroundColor: topRectangle.color 80 | visible: !hideBackButton 81 | 82 | onClicked: { 83 | materialPage.hide(); 84 | } 85 | } 86 | 87 | MaterialLabel { 88 | id: labelForTitle 89 | anchors.centerIn: parent 90 | color: "#ffffff" 91 | font.pixelSize: 18 92 | } 93 | } 94 | 95 | MaterialTabbed { 96 | id: tabbed 97 | z: 2 98 | width: height 99 | height: topRectangle.height 100 | anchors.top: topRectangle.top 101 | anchors.right: topRectangle.right 102 | visible: (model) ? (model.length > 0) : (false) 103 | textColor: "#ffffff" 104 | backgroundColor: topRectangle.color 105 | 106 | onItemSelected: { 107 | tabbedItemSelected(index, text); 108 | } 109 | } 110 | 111 | NumberAnimation { 112 | id: animationForShowAndClose 113 | target: materialPage 114 | property: "x" 115 | 116 | onStopped: { 117 | if (to === width) 118 | { 119 | visible = false; 120 | if (destroyOnHide) 121 | { 122 | materialPage.destroy(); 123 | } 124 | } 125 | else 126 | { 127 | focus = true; 128 | } 129 | } 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialProgressBar.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * QML Material - An application framework implementing Material Design. 3 | * Copyright (C) 2014 Michael Spencer 4 | * Copyright (C) 2015 Ricardo Vieira 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 2.1 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | import QtQuick 2.5 20 | import QtQuick.Controls 1.4 as Controls 21 | import QtQuick.Controls.Styles 1.4 as ControlStyles 22 | import "../Element" 23 | 24 | /*! 25 | \qmltype ProgressBar 26 | \inqmlmodule Material 27 | \ingroup material 28 | 29 | \brief Visual indicator of progress in some operation. 30 | */ 31 | 32 | Controls.ProgressBar { 33 | /*! 34 | The color for the progress bar. By default this is 35 | the primary color defined in \l Theme::primaryColor 36 | */ 37 | property color color: "#2196F3" 38 | 39 | width: units.dp(200) 40 | height: units.dp(4) 41 | 42 | style: ControlStyles.ProgressBarStyle { 43 | background: Rectangle { 44 | width: control.width 45 | height: control.height 46 | color: control.color 47 | opacity: 0.2 48 | } 49 | progress: Rectangle { 50 | color: control.indeterminate ? "transparent" : control.color 51 | 52 | // Indeterminate animation 53 | Item { 54 | id: independentRect 55 | anchors.fill: parent 56 | visible: control.indeterminate 57 | Rectangle { 58 | id: rect 59 | property var end: 0 60 | width: end - x 61 | height: control.height 62 | color: control.color 63 | ParallelAnimation { 64 | running: control.indeterminate 65 | SequentialAnimation { 66 | loops: Animation.Infinite 67 | PauseAnimation { 68 | duration: 500 69 | } 70 | 71 | NumberAnimation{ 72 | target: rect; property: "x" 73 | from: 0; to: control.width 74 | duration: 1500 75 | easing.type: Easing.InCubic 76 | } 77 | } 78 | SequentialAnimation { 79 | loops: Animation.Infinite 80 | NumberAnimation { 81 | target: rect; property: "end" 82 | from: 0; to: control.width 83 | duration: 1500 84 | } 85 | PauseAnimation { 86 | duration: 500 87 | } 88 | ScriptAction { 89 | script: rect.x = 0 90 | } 91 | } 92 | } 93 | } 94 | } 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialRadioButton.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * QML Material - An application framework implementing Material Design. 3 | * Copyright (C) 2014 Jordan Neidlinger 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | import QtQuick 2.5 19 | import QtQuick.Controls 1.4 as Controls 20 | import QtQuick.Controls.Styles 1.4 as ControlStyles 21 | import "../Element" 22 | 23 | Controls.RadioButton { 24 | id: radioButton 25 | 26 | /*! 27 | The switch color. By default this is the app's accent color 28 | */ 29 | property color color: "#2196f3" 30 | 31 | /*! 32 | Set to \c true if the switch is on a dark background 33 | */ 34 | property bool darkBackground 35 | 36 | style: ControlStyles.RadioButtonStyle { 37 | label: MaterialLabel { 38 | text: control.text 39 | color: control.enabled ? radioButton.darkBackground ? "#ffffff" 40 | : "#d8000000" 41 | : radioButton.darkBackground ? "#4cffffff" 42 | : "#42000000" 43 | } 44 | 45 | background: Rectangle { 46 | color: "transparent" 47 | } 48 | 49 | indicator: Rectangle { 50 | implicitWidth: (48) 51 | implicitHeight: (48) 52 | radius: implicitHeight / 2 53 | color: control.activeFocus ? alpha(radioButton.color, 0.20) : "transparent" 54 | 55 | function alpha(color, alpha) { 56 | var realColor = Qt.darker(color, 1) 57 | realColor.a = alpha 58 | return realColor 59 | } 60 | 61 | Rectangle { 62 | anchors.centerIn: parent 63 | implicitWidth: (20) 64 | implicitHeight: (20) 65 | radius: implicitHeight / 2 66 | color: "transparent" 67 | border.color: control.enabled 68 | ? control.checked ? radioButton.color 69 | : radioButton.darkBackground ? "#b2ffffff" 70 | : "#89000000" 71 | : radioButton.darkBackground ? "#4cffffff" 72 | : "#42000000" 73 | border.width: (2) 74 | antialiasing: true 75 | 76 | Behavior on border.color { 77 | ColorAnimation { duration: 200} 78 | } 79 | 80 | Rectangle { 81 | anchors.centerIn: parent 82 | implicitWidth: control.checked ? (10) : 0 83 | implicitHeight: control.checked ? (10) : 0 84 | color: control.enabled ? radioButton.color 85 | : radioButton.darkBackground ? "#4cffffff" 86 | : "#42000000" 87 | radius: implicitHeight / 2 88 | antialiasing: true 89 | 90 | Behavior on implicitWidth { 91 | NumberAnimation { easing.type: Easing.InOutQuad; duration: 200 } 92 | } 93 | 94 | Behavior on implicitHeight { 95 | NumberAnimation { easing.type: Easing.InOutQuad; duration: 200 } 96 | } 97 | } 98 | } 99 | } 100 | 101 | spacing: 0 102 | } 103 | 104 | Ink { 105 | anchors { 106 | left: parent.left 107 | leftMargin: (4) 108 | verticalCenter: parent.verticalCenter 109 | } 110 | 111 | width: (40) 112 | height: (40) 113 | color: radioButton.checked ? alpha(radioButton.color, 0.20) : Qt.rgba(0,0,0,0.1) 114 | 115 | circular: true 116 | centered: true 117 | 118 | onClicked: { 119 | if (radioButton.canToggle || !radioButton.checked) 120 | radioButton.checked = !radioButton.checked 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialSnackbar.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * QML Material - An application framework implementing Material Design. 3 | * Copyright (C) 2014 Bogdan Cuza 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | import QtQuick 2.5 19 | import "../Element" 20 | 21 | View { 22 | id: snackbar 23 | 24 | property string buttonText 25 | property color buttonColor: "#2196f3" 26 | property string text 27 | property bool opened 28 | property int duration: 2000 29 | property bool fullWidth: materialUI.isSmartPhone() 30 | 31 | signal clicked 32 | 33 | function open(text) { 34 | snackbar.text = text 35 | opened = true; 36 | timer.restart(); 37 | } 38 | 39 | anchors { 40 | left: parent.left 41 | right: fullWidth ? parent.right : undefined 42 | bottom: parent.bottom 43 | leftMargin: fullWidth ? 0 : (16) 44 | bottomMargin: opened ? fullWidth ? 0 : (16) : -snackbar.height 45 | 46 | Behavior on bottomMargin { 47 | NumberAnimation { duration: 400; easing.type: Easing.OutQuad } 48 | } 49 | } 50 | radius: fullWidth ? 0 : (2) 51 | backgroundColor: "#cc323232" 52 | height: (48) 53 | width: fullWidth ? parent.width 54 | : Math.min(Math.max(implicitWidth, (288)), (568)) 55 | opacity: opened ? 1 : 0 56 | implicitWidth: buttonText == "" ? snackText.paintedWidth + (48) 57 | : snackText.paintedWidth + (72) + snackButton.width 58 | 59 | Timer { 60 | id: timer 61 | 62 | interval: snackbar.duration 63 | 64 | onTriggered: { 65 | if (!running) { 66 | snackbar.opened = false; 67 | } 68 | } 69 | } 70 | 71 | MaterialLabel { 72 | id: snackText 73 | anchors { 74 | right: snackbar.buttonText == "" ? parent.right : snackButton.left 75 | left: parent.left 76 | top: parent.top 77 | bottom: parent.bottom 78 | leftMargin: (24) 79 | topMargin: (16) 80 | rightMargin: (24) 81 | } 82 | text: snackbar.text 83 | color: "white" 84 | } 85 | 86 | MaterialButton { 87 | id: snackButton 88 | opacity: snackbar.buttonText == "" ? 0 : 1 89 | textColor: snackbar.buttonColor 90 | text: snackbar.buttonText 91 | context: "snackbar" 92 | elevation: 0 93 | onClicked: snackbar.clicked() 94 | anchors { 95 | right: parent.right 96 | //left: snackText.right 97 | top: parent.top 98 | bottom: parent.bottom 99 | 100 | // Recommended button touch target is 36dp 101 | topMargin: (6) 102 | bottomMargin: (6) 103 | 104 | // Normal margin is 24dp, but button itself uses 8dp margins 105 | rightMargin: snackbar.buttonText == "" ? 0 : (16) 106 | } 107 | } 108 | 109 | Behavior on opacity { 110 | NumberAnimation { duration: 300 } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialSwipeToRefresh.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.5 2 | import QtQuick.Controls 1.4 3 | import QtQuick.Window 2.2 4 | import QtQuick.Dialogs 1.2 5 | 6 | Rectangle { 7 | id: swipeToRefresh 8 | width: parent.width 9 | height: 0 10 | color: "#00000000" 11 | 12 | property var base: parent.parent 13 | 14 | property int targetHeight: 150 15 | property real offsetY: 0 16 | property real swipePercentage: 0 17 | property real buttonBottomMargin: 5 18 | 19 | property var onRefreshCallback: null 20 | property var onCancelCallback: null 21 | 22 | property bool refreshing: false 23 | property bool finishing: false 24 | 25 | function refresh() { 26 | refreshing = true; 27 | } 28 | 29 | function finish() { 30 | refreshing = false; 31 | finishing = true; 32 | swipePercentage = 0; 33 | 34 | animation.start(); 35 | } 36 | 37 | Component.onCompleted: { 38 | parent.z = 2; 39 | 40 | onRefreshCallback = materialUI.swipeToRefreshOnRefreshCallback; 41 | onCancelCallback = materialUI.swipeToRefreshOnCancelCallback; 42 | 43 | if (materialUI.swipeToRefreshOnCompleted) 44 | { 45 | materialUI.swipeToRefreshOnCompleted(swipeToRefresh); 46 | } 47 | 48 | materialUI.swipeToRefreshOnRefreshCallback = null; 49 | materialUI.swipeToRefreshOnCancelCallback = null; 50 | materialUI.swipeToRefreshOnCompleted = null; 51 | } 52 | 53 | Connections { 54 | target: base 55 | 56 | onYChanged: { 57 | if (base.y > 0) 58 | { 59 | var bufHeight; 60 | 61 | if (base.y > 2) 62 | { 63 | bufHeight = (((base.y - 2) < targetHeight) ? (base.y - 2) : (targetHeight)); 64 | } 65 | else 66 | { 67 | bufHeight = 0; 68 | } 69 | 70 | if (refreshing) 71 | { 72 | if (bufHeight > (targetHeight * 0.6)) 73 | { 74 | swipeToRefresh.height = bufHeight; 75 | } 76 | } 77 | else 78 | { 79 | swipeToRefresh.height = bufHeight; 80 | } 81 | 82 | swipePercentage = swipeToRefresh.height / (targetHeight * 0.6); 83 | progressCircle.setValue(swipePercentage); 84 | 85 | if (swipePercentage >= 1) 86 | { 87 | swipePercentage = 1; 88 | 89 | if (!refreshing && !finishing && onRefreshCallback) 90 | { 91 | onRefreshCallback(); 92 | } 93 | } 94 | 95 | base.y = 0; 96 | } 97 | else if (base.y < 0) 98 | { 99 | if (refreshing) 100 | { 101 | base.y = 0; 102 | } 103 | 104 | swipePercentage = 0; 105 | } 106 | } 107 | } 108 | 109 | PropertyAnimation { 110 | id: animation 111 | target: button 112 | properties: "scale" 113 | easing.type: Easing.OutQuad 114 | to: 0 115 | duration: 250 116 | 117 | onStopped: { 118 | swipeToRefresh.height = 0; 119 | button.scale = 1; 120 | finishing = false; 121 | } 122 | } 123 | 124 | MaterialActionButton { 125 | id: button 126 | anchors.bottom: parent.bottom 127 | anchors.bottomMargin: buttonBottomMargin 128 | anchors.horizontalCenter: parent.horizontalCenter 129 | width: 40 130 | height: 40 131 | backgroundColor: "#fafafa" 132 | 133 | MaterialProgressCircle { 134 | id: progressCircle 135 | width: 25 136 | height: 25 137 | anchors.centerIn: parent 138 | circleColor: "#a0a0a0" 139 | indeterminate: refreshing || finishing 140 | 141 | function setValue(value_) { 142 | if (value_ < 0.25) 143 | { 144 | value = 0; 145 | } 146 | value = value_ * (4 / 3) - (1 / 3); 147 | } 148 | } 149 | 150 | MouseArea { 151 | anchors.fill: parent 152 | 153 | onClicked: { 154 | if (onCancelCallback) 155 | { 156 | onCancelCallback(); 157 | } 158 | } 159 | } 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialSwitch.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.5 2 | import QtQuick.Controls 1.4 as Controls 3 | import QtQuick.Controls.Styles 1.4 as ControlStyles 4 | import "../Element" 5 | 6 | Controls.Switch { 7 | id: control 8 | 9 | /*! 10 | The switch color. By default this is the app's accent color 11 | */ 12 | property color color: "#2196f3" 13 | 14 | /*! 15 | Set to \c true if the switch is on a dark background 16 | */ 17 | property bool darkBackground 18 | 19 | style: ControlStyles.SwitchStyle { 20 | handle: View { 21 | width: (22) 22 | height: (22) 23 | radius: height / 2 24 | elevation: 2 25 | backgroundColor: control.enabled ? control.checked ? control.color 26 | : darkBackground ? "#BDBDBD" 27 | : "#FAFAFA" 28 | : darkBackground ? "#424242" 29 | : "#BDBDBD" 30 | } 31 | 32 | groove: Item { 33 | width: (40) 34 | height: (22) 35 | 36 | Rectangle { 37 | anchors.centerIn: parent 38 | width: parent.width - (2) 39 | height: (16) 40 | radius: height / 2 41 | color: control.enabled ? control.checked ? alpha(control.color, 0.5) 42 | : darkBackground ? Qt.rgba(1, 1, 1, 0.26) 43 | : Qt.rgba(0, 0, 0, 0.26) 44 | : darkBackground ? Qt.rgba(1, 1, 1, 0.12) 45 | : Qt.rgba(0, 0, 0, 0.12) 46 | 47 | function alpha(color, alpha) { 48 | var realColor = Qt.darker(color, 1) 49 | realColor.a = alpha 50 | return realColor 51 | } 52 | 53 | Behavior on color { 54 | ColorAnimation { 55 | duration: 200 56 | } 57 | } 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialTabbed.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.5 2 | import QtQuick.Layouts 1.1 3 | import "qrc:/MaterialUI/Element/" 4 | 5 | Item { 6 | id: materialTabbed 7 | width: 40 8 | height: 40 9 | 10 | property int itemWidth: 100 11 | 12 | property alias model: listView.model 13 | property var iconDatas 14 | 15 | property alias textColor: button.textColor 16 | property alias backgroundColor: button.backgroundColor 17 | 18 | readonly property string selectedText: (listView.currentItem) ? (listView.currentItem.text) : ("") 19 | property alias selectedIndex: listView.currentIndex 20 | property int maxVisibleItems: 4 21 | 22 | signal itemSelected(int index, string text); 23 | 24 | MaterialActionButton { 25 | id: button 26 | anchors.fill: parent 27 | elevation: 0 28 | textFontFamily: "Material-Design-Iconic-Font" 29 | text: "\uF2A3" 30 | textSize: 22 31 | 32 | onClicked: { 33 | dropdown.open(this, -8, 8); 34 | } 35 | 36 | Dropdown { 37 | id: dropdown 38 | width: itemWidth 39 | height: Math.min(maxVisibleItems * (48) + (24), listView.height) 40 | 41 | ListView { 42 | id: listView 43 | 44 | width: dropdown.width 45 | height: Math.min(count > 0 ? contentHeight : 0, 4.5 * (48)); 46 | 47 | interactive: true 48 | 49 | delegate: Standard { 50 | id: delegateItem 51 | text: modelData 52 | 53 | onClicked: { 54 | listView.currentIndex = index; 55 | dropdown.close(); 56 | itemSelected(index, listView.currentItem.text); 57 | } 58 | 59 | Text { 60 | id: labelForIcon 61 | anchors.verticalCenter: parent.verticalCenter 62 | color: "#000000" 63 | visible: text !== "" 64 | font.pixelSize: 20 65 | 66 | Component.onCompleted: { 67 | if (materialTabbed.iconDatas && (materialTabbed.iconDatas.length >= index) && materialTabbed.iconDatas[index]) 68 | { 69 | labelForIcon.text = materialTabbed.iconDatas[index]["text"]; 70 | labelForIcon.font.family = materialTabbed.iconDatas[index]["fontFamily"]; 71 | } 72 | } 73 | } 74 | } 75 | } 76 | 77 | Scrollbar { 78 | flickableItem: listView 79 | } 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialTableView.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.5 2 | import QtQuick.Controls 1.4 as Controls 3 | import QtGraphicalEffects 1.0 4 | import "../Element" 5 | 6 | Controls.TableView { 7 | id: tableView 8 | width: 400 9 | height: 400 10 | enabled: modelForTableView.count > -1 11 | 12 | alternatingRowColors: false 13 | backgroundVisible: false 14 | headerVisible: true 15 | sortIndicatorVisible: true 16 | frameVisible: false 17 | 18 | horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff 19 | verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff 20 | 21 | property real headerHeight: 40 22 | property real itemHeight: 35 23 | 24 | property real rectangularGlowCornerRadius: 3 25 | 26 | model: ListModel { 27 | id: modelForTableView 28 | } 29 | 30 | headerDelegate: Rectangle { 31 | width: 80 32 | height: headerHeight 33 | color: "#ffffff" 34 | radius: 3 35 | 36 | Rectangle { 37 | anchors.bottom: parent.bottom 38 | width: parent.width 39 | height: 1 40 | color: "#00000000" 41 | border.width: 1 42 | border.color: "#e1e1e1" 43 | } 44 | 45 | Controls.Label { 46 | anchors.fill: parent 47 | text: styleData.value 48 | font.pixelSize: 15 49 | verticalAlignment: Text.AlignVCenter 50 | horizontalAlignment: Text.AlignHCenter 51 | color: "#606060" 52 | elide: Text.ElideRight 53 | 54 | font.family: { 55 | switch (Qt.platform.os) 56 | { 57 | case "windows": return "微软雅黑"; 58 | default: return "Roboto"; 59 | } 60 | } 61 | } 62 | } 63 | 64 | itemDelegate: Rectangle { 65 | id: itemForTableView 66 | color: (styleData.selected) ? ("#f3f3f3") : ("#00000000") 67 | 68 | Rectangle { 69 | anchors.bottom: parent.bottom 70 | width: parent.width 71 | height: 1 72 | color: "#00000000" 73 | border.width: 1 74 | border.color: "#e1e1e1" 75 | } 76 | 77 | Controls.Label { 78 | anchors.fill: parent 79 | text: styleData.value 80 | verticalAlignment: Text.AlignVCenter 81 | horizontalAlignment: Text.AlignHCenter 82 | color: "#000000" 83 | font.pixelSize: 13 84 | elide: Text.ElideRight 85 | 86 | font.family: { 87 | switch (Qt.platform.os) 88 | { 89 | case "windows": return "微软雅黑"; 90 | default: return "Roboto"; 91 | } 92 | } 93 | } 94 | } 95 | 96 | rowDelegate: Item { 97 | height: itemHeight 98 | } 99 | 100 | function appendText(texts) { 101 | var buf = new Object; 102 | for (var index = 0; index < texts.length; index++) 103 | { 104 | buf["text" + index] = texts[index]; 105 | } 106 | modelForTableView.append(buf) 107 | } 108 | 109 | function setText(row, texts) { 110 | if (modelForTableView.count <= row) 111 | { 112 | appendText(texts); 113 | } 114 | else 115 | { 116 | for (var index = 0; index < texts.length; index++) 117 | { 118 | modelForTableView.get(row)["text" + index] = texts[index]; 119 | } 120 | } 121 | } 122 | 123 | function clear() { 124 | modelForTableView.clear(); 125 | } 126 | 127 | RectangularGlow { 128 | x: 0 129 | y: 1 130 | z: -1 131 | width: parent.width 132 | height: parent.height 133 | glowRadius: 2 134 | spread: 0.22 135 | color: "#30000000" 136 | } 137 | 138 | Rectangle { 139 | z: -1 140 | id: rectangleForBacaground 141 | anchors.fill: parent 142 | color: "#ffffff" 143 | radius: tableView.rectangularGlowCornerRadius 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialTabs.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.5 2 | import QtQuick.Controls 1.4 as Controls 3 | import QtQuick.Controls.Styles 1.4 as ControlStyles 4 | import QtGraphicalEffects 1.0 5 | 6 | Item { 7 | id: tabs 8 | 9 | signal indexRefreshed(); 10 | 11 | property var tabSource 12 | property var iconDatas 13 | 14 | property int currentItemX 15 | property int currentItemWidth 16 | 17 | property int tabHeight: 48 18 | property int tabsAlignment: Qt.AlignHCenter 19 | 20 | property alias currentIndex: tabView.currentIndex 21 | property alias tabPosition: tabView.tabPosition 22 | 23 | property bool hideTopShadow: false 24 | property bool hideTopBackground: false 25 | 26 | property alias tabView: tabView 27 | 28 | property alias needleColor: needle.color 29 | 30 | property alias backgroundColor: tabBackground.color 31 | 32 | Component.onCompleted: { 33 | for (var index = 0; index < tabSource.length; index++) 34 | { 35 | var tab = tabView.addTab(tabSource[index]["title"], tabSource[index]["source"]); 36 | 37 | if ("objectName" in tabSource[index]) 38 | { 39 | tab.children[0].item.objectName = tabSource[index]["objectName"]; 40 | } 41 | } 42 | indexRefreshed(); 43 | } 44 | 45 | Controls.TabView { 46 | id: tabView 47 | anchors.fill: parent 48 | clip: false 49 | 50 | style: ControlStyles.TabViewStyle { 51 | frameOverlap: 0 52 | tabOverlap: 0 53 | tabsAlignment: tabs.tabsAlignment 54 | 55 | tab: MaterialButton { 56 | height: tabs.tabHeight 57 | text: styleData.title 58 | textColor: (styleData.selected) ? ("#ffffff") : ("#a2ffffff") 59 | implicitWidth: Math.min(Math.max(labelWidth + 40, 80), tabView.width / tabView.count) 60 | elevation: 0 61 | 62 | Component.onCompleted: { 63 | if (tabs.iconDatas && (tabs.iconDatas.length >= styleData.index) && tabs.iconDatas[styleData.index]) 64 | { 65 | iconVisible = true; 66 | iconFontFamily = tabs.iconDatas[styleData.index]["fontFamily"]; 67 | iconText = tabs.iconDatas[styleData.index]["text"]; 68 | iconSize = textSize * 1.5; 69 | } 70 | 71 | if ( "implicitWidth" in tabs.tabSource[ styleData.index ] ) 72 | { 73 | implicitWidth = tabs.tabSource[ styleData.index ][ "implicitWidth" ]; 74 | } 75 | } 76 | 77 | function refreshPosition() { 78 | if (tabView.currentIndex === styleData.index) 79 | { 80 | needle.x = parent.parent.x + parent.parent.parent.parent.x 81 | needle.width = width 82 | } 83 | } 84 | 85 | onClicked: { 86 | tabView.currentIndex = styleData.index; 87 | } 88 | 89 | Connections { 90 | target: parent.parent.parent.parent 91 | 92 | onXChanged: { 93 | refreshPosition(); 94 | } 95 | } 96 | 97 | Connections { 98 | target: tabs 99 | 100 | onWidthChanged: { 101 | refreshPosition(); 102 | } 103 | 104 | onCurrentIndexChanged: { 105 | refreshPosition(); 106 | } 107 | 108 | onIndexRefreshed: { 109 | refreshPosition(); 110 | } 111 | } 112 | 113 | Behavior on textColor { 114 | ColorAnimation { duration: 200; } 115 | } 116 | } 117 | 118 | frame: Rectangle { 119 | color: "#00000000" 120 | } 121 | } 122 | 123 | RectangularGlow { 124 | z: 1 125 | anchors.fill: tabBackground 126 | glowRadius: 6 127 | spread: 0.22 128 | color: "#40000000" 129 | visible: !hideTopShadow 130 | } 131 | 132 | Rectangle { 133 | id: tabBackground 134 | x: 0 135 | y: -1 * (tabs.tabHeight) 136 | z: 1 137 | width: tabView.width 138 | height: (tabs.tabHeight) 139 | color: "#07bdd3" 140 | visible: !hideTopBackground 141 | } 142 | } 143 | 144 | Rectangle { 145 | id: needle 146 | x: 0 147 | y: (tabs.tabPosition === Qt.TopEdge) ? (tabs.tabHeight - 2) : (parent.height - tabs.tabHeight) 148 | width: 20 149 | height: (2) 150 | color: "#ffff95" 151 | 152 | Behavior on x { 153 | NumberAnimation { duration: 200; easing.type: Easing.OutCubic } 154 | } 155 | 156 | Behavior on width { 157 | NumberAnimation { duration: 200; } 158 | } 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialTextField.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * QML Material - An application framework implementing Material Design. 3 | * Copyright (C) 2014 Bogdan Cuza 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | import QtQuick 2.5 19 | import QtQuick.Controls 1.4 20 | import "../Element" 21 | 22 | /* 23 | * Note that this is a FocusScope, not a TextInput. If you need to read or 24 | * write properties of the input itself, use the input property. 25 | */ 26 | FocusScope { 27 | id: field 28 | 29 | property color accentColor: "#2196f3" 30 | property color errorColor: "#F44336" 31 | 32 | property alias readOnly: textInput.readOnly 33 | 34 | property alias text: textInput.text 35 | property alias echoMode: textInput.echoMode 36 | 37 | property alias validator: textInput.validator 38 | 39 | property alias placeholderText: fieldPlaceholder.text 40 | property alias helperText: helperTextLabel.text 41 | 42 | readonly property int characterCount: text.length 43 | 44 | property bool floatingLabel: true 45 | property bool hasError: false 46 | property int characterLimit: -1 47 | property bool characterLimitVisible: true 48 | 49 | readonly property rect inputRect: Qt.rect(textInput.x, textInput.y, textInput.width, textInput.height) 50 | 51 | readonly property alias input: textInput 52 | 53 | signal accepted() 54 | signal editingFinished() 55 | 56 | implicitHeight: __internal.showHelperText ? helperTextLabel.y + helperTextLabel.height + (4) 57 | : underline.y + (8) 58 | width: (200) 59 | height: (56) 60 | 61 | QtObject { 62 | id: __internal 63 | 64 | property bool showHelperText: helperText.length > 0 65 | property bool showCharacterCounter: (characterLimit > 0) && characterLimitVisible 66 | } 67 | 68 | MouseArea { 69 | anchors.fill: parent 70 | onClicked: field.forceActiveFocus(Qt.MouseFocusReason) 71 | } 72 | 73 | TextInput { 74 | id: textInput 75 | 76 | focus: true 77 | 78 | color: "#d8000000" 79 | selectedTextColor: "white" 80 | selectionColor: Qt.darker(field.accentColor, 1) 81 | 82 | // selectByMouse: Device.type === Device.desktop 83 | selectByMouse: true 84 | 85 | activeFocusOnTab: true 86 | 87 | maximumLength: (characterLimit !== -1) ? (characterLimit) : (32767) 88 | width: parent.width 89 | 90 | clip: true 91 | 92 | y: { 93 | if ( !floatingLabel ) 94 | return (16) 95 | if ( floatingLabel && !__internal.showHelperText ) 96 | return (40) 97 | return (28) 98 | } 99 | 100 | font { 101 | family: { 102 | if ((echoMode == TextInput.Password) && (field.text.length > 0)) 103 | { 104 | return ""; 105 | } 106 | 107 | switch (Qt.platform.os) 108 | { 109 | case "windows": return "微软雅黑"; 110 | default: return "Roboto"; 111 | } 112 | } 113 | 114 | pixelSize: (16) 115 | } 116 | 117 | onAccepted: field.accepted() 118 | onEditingFinished: field.editingFinished() 119 | 120 | MouseArea { 121 | anchors.fill: parent 122 | cursorShape: Qt.IBeamCursor 123 | acceptedButtons: Qt.NoButton 124 | } 125 | } 126 | 127 | MaterialLabel { 128 | id: fieldPlaceholder 129 | 130 | text: field.placeholderText 131 | 132 | font.pixelSize: (16) 133 | 134 | anchors.baseline: textInput.baseline 135 | anchors.bottomMargin: (8) 136 | 137 | color: "#42000000" 138 | 139 | states: [ 140 | State { 141 | name: "floating" 142 | when: textInput.displayText.length > 0 && floatingLabel 143 | AnchorChanges { 144 | target: fieldPlaceholder 145 | anchors.baseline: undefined 146 | anchors.bottom: textInput.top 147 | } 148 | PropertyChanges { 149 | target: fieldPlaceholder 150 | font.pixelSize: (12) 151 | } 152 | }, 153 | State { 154 | name: "hidden" 155 | when: textInput.displayText.length > 0 && !floatingLabel 156 | PropertyChanges { 157 | target: fieldPlaceholder 158 | visible: false 159 | } 160 | } 161 | ] 162 | 163 | transitions: [ 164 | Transition { 165 | id: floatingTransition 166 | enabled: false 167 | AnchorAnimation { 168 | duration: 200 169 | } 170 | NumberAnimation { 171 | duration: 200 172 | property: "font.pixelSize" 173 | } 174 | } 175 | ] 176 | 177 | Component.onCompleted: floatingTransition.enabled = true 178 | } 179 | 180 | Rectangle { 181 | id: underline 182 | color: field.hasError || (__internal.showCharacterCounter && field.characterCount > field.characterLimit) 183 | ? field.errorColor : field.activeFocus ? field.accentColor : "#42000000" 184 | 185 | height: field.activeFocus ? (2) : (1) 186 | 187 | anchors { 188 | left: parent.left 189 | right: parent.right 190 | top: textInput.bottom 191 | topMargin: (8) 192 | } 193 | 194 | Behavior on height { 195 | NumberAnimation { duration: 200 } 196 | } 197 | 198 | Behavior on color { 199 | ColorAnimation { duration: 200 } 200 | } 201 | } 202 | 203 | MaterialLabel { 204 | id: helperTextLabel 205 | visible: __internal.showHelperText 206 | font.pixelSize: (12) 207 | color: field.hasError ? field.errorColor : Qt.darker("#42000000") 208 | anchors { 209 | left: parent.left 210 | right: parent.right 211 | top: underline.top 212 | topMargin: (4) 213 | } 214 | 215 | Behavior on color { 216 | ColorAnimation { duration: 200 } 217 | } 218 | } 219 | 220 | MaterialLabel { 221 | id: characterCounterLabel 222 | visible: __internal.showCharacterCounter 223 | font.pixelSize: (12) 224 | font.weight: Font.Light 225 | color: field.characterCount <= field.characterLimit ? Qt.darker("#42000000") : field.errorColor 226 | text: field.characterCount + " / " + field.characterLimit 227 | anchors { 228 | right: parent.right 229 | top: underline.top 230 | topMargin: (8) 231 | } 232 | 233 | Behavior on color { 234 | ColorAnimation { duration: 200 } 235 | } 236 | } 237 | } 238 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Interface/MaterialTreeView.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.5 2 | import QtQuick.Controls 1.4 3 | import QtQuick.Controls.Styles 1.4 4 | import QtGraphicalEffects 1.0 5 | import "../Element" 6 | 7 | TreeView { 8 | id: tableView 9 | width: 400 10 | height: 400 11 | enabled: modelForTableView.count > -1 12 | 13 | alternatingRowColors: false 14 | backgroundVisible: false 15 | headerVisible: true 16 | sortIndicatorVisible: true 17 | frameVisible: false 18 | 19 | horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff 20 | verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff 21 | 22 | property real itemHeight: 35 23 | property real headerHeight: 40 24 | 25 | property bool branchEnabled: true 26 | 27 | model: ListModel { 28 | id: modelForTableView 29 | } 30 | 31 | style: TreeViewStyle { 32 | 33 | branchDelegate: Label { 34 | x: 3 35 | width: 16 36 | height: 16 37 | visible: styleData.column === 0 && styleData.hasChildren 38 | text: styleData.isExpanded ? "\uF1B4" : "\uF1B6" 39 | color: "#000000" 40 | font.family: "Material-Design-Iconic-Font" 41 | font.pixelSize: 18 42 | renderType: Text.NativeRendering 43 | 44 | MouseArea { 45 | anchors.fill: parent 46 | visible: !branchEnabled 47 | } 48 | } 49 | } 50 | 51 | headerDelegate: Rectangle { 52 | width: 80 53 | height: headerHeight 54 | color: "#ffffff" 55 | radius: 3 56 | 57 | Rectangle { 58 | anchors.bottom: parent.bottom 59 | width: parent.width 60 | height: 1 61 | color: "#00000000" 62 | border.width: 1 63 | border.color: "#e1e1e1" 64 | } 65 | 66 | Label { 67 | anchors.fill: parent 68 | text: styleData.value 69 | font.pixelSize: 15 70 | verticalAlignment: Text.AlignVCenter 71 | horizontalAlignment: Text.AlignHCenter 72 | color: "#606060" 73 | 74 | font.family: { 75 | switch (Qt.platform.os) 76 | { 77 | case "windows": return "微软雅黑"; 78 | default: return "Roboto"; 79 | } 80 | } 81 | } 82 | } 83 | 84 | itemDelegate: Rectangle { 85 | color: (styleData.selected) ? ("#f3f3f3") : ("#00000000") 86 | 87 | Rectangle { 88 | anchors.bottom: parent.bottom 89 | width: parent.width 90 | height: 1 91 | color: "#00000000" 92 | border.width: 1 93 | border.color: "#e1e1e1" 94 | } 95 | 96 | Label { 97 | id: label 98 | anchors.fill: parent 99 | clip: true 100 | verticalAlignment: Text.AlignVCenter 101 | horizontalAlignment: Text.AlignHCenter 102 | color: "#000000" 103 | font.pixelSize: 14 104 | elide: Text.ElideRight 105 | 106 | font.family: { 107 | switch (Qt.platform.os) 108 | { 109 | case "windows": return "微软雅黑"; 110 | default: return "Roboto"; 111 | } 112 | } 113 | } 114 | 115 | Connections { 116 | target: styleData 117 | 118 | onValueChanged: { 119 | if (((typeof styleData.value) !== "string") && ((typeof styleData.value) !== "number")) { return; } 120 | 121 | label.text = styleData.value; 122 | } 123 | } 124 | } 125 | 126 | rowDelegate: Item { 127 | height: itemHeight 128 | } 129 | 130 | function appendText(texts) { 131 | var buf = new Object; 132 | for (var index = 0; index < texts.length; index++) 133 | { 134 | buf["text" + index] = texts[index]; 135 | } 136 | model.append(buf) 137 | } 138 | 139 | RectangularGlow { 140 | x: 0 141 | y: 1 142 | z: -1 143 | width: parent.width 144 | height: parent.height 145 | glowRadius: 2 146 | spread: 0.22 147 | color: "#30000000" 148 | cornerRadius: 3 149 | } 150 | 151 | Rectangle { 152 | z: -1 153 | id: rectangleForBacaground 154 | anchors.fill: parent 155 | color: "#ffffff" 156 | radius: 3 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/Material-Design-Iconic-Font.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TLMichael/Perceptron/a76dc4b88771b0179f150d6e3964dfb9e88f869a/HardhatSystem/library/MaterialUI/Material-Design-Iconic-Font.ttf -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/MaterialUI.pri: -------------------------------------------------------------------------------- 1 | RESOURCES *= \ 2 | $$PWD/MaterialUI.qrc 3 | -------------------------------------------------------------------------------- /HardhatSystem/library/MaterialUI/MaterialUI.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Element/BaseListItem.qml 4 | Element/BottomSheet.qml 5 | Element/CircleMask.qml 6 | Element/Divider.qml 7 | Element/Dropdown.qml 8 | Element/Ink.qml 9 | Element/PopupBase.qml 10 | Element/Scrollbar.qml 11 | Element/Standard.qml 12 | Element/Subheader.qml 13 | Element/ThemePalette.qml 14 | Element/ThinDivider.qml 15 | Element/View.qml 16 | Interface/MaterialActionButton.qml 17 | Interface/MaterialBottomActionSheet.qml 18 | Interface/MaterialButton.qml 19 | Interface/MaterialCheckBox.qml 20 | Interface/MaterialDialog.qml 21 | Interface/MaterialDialogAlert.qml 22 | Interface/MaterialDialogConfirm.qml 23 | Interface/MaterialDialogPrompt.qml 24 | Interface/MaterialDialogScrolling.qml 25 | Interface/MaterialLabel.qml 26 | Interface/MaterialMenuField.qml 27 | Interface/MaterialProgressBar.qml 28 | Interface/MaterialProgressCircle.qml 29 | Interface/MaterialRadioButton.qml 30 | Interface/MaterialSlider.qml 31 | Interface/MaterialSnackbar.qml 32 | Interface/MaterialSwipeToRefresh.qml 33 | Interface/MaterialSwitch.qml 34 | Interface/MaterialTabs.qml 35 | Interface/MaterialTextField.qml 36 | Interface/MaterialTabbed.qml 37 | MaterialUI.qml 38 | Material-Design-Iconic-Font.ttf 39 | Interface/MaterialPage.qml 40 | Interface/MaterialTreeView.qml 41 | Interface/MaterialTableView.qml 42 | Interface/MaterialDatePicker.qml 43 | Interface/MaterialTimePicker.qml 44 | Interface/MaterialDialogDatePicker.qml 45 | Interface/MaterialDialogTimePicker.qml 46 | Interface/MaterialDialogTextArea.qml 47 | Interface/MaterialAnimation.qml 48 | 49 | 50 | -------------------------------------------------------------------------------- /HardhatSystem/qml/qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 陶略 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Perceptron 2 | 3 | Hard hat detection system by QT5 4 | 5 | ## 界面预览 6 | 7 | ![](https://i.imgur.com/QTSsLwo.png) 8 | 9 | ## 开发计划 10 | 11 | 类别|功能|状态 12 | ---|---|--- 13 | 首页|引导界面|已完成 14 | 实时视频分析|使用摄像头|已完成 15 | 视频文件分析|导入视频文件|已完成 16 | 信息查询|MySQL数据库查询|已完成 17 | 18 | 19 | ## 安装部署 20 | 21 | ### Windows-GPU版本 22 | 23 | #### 安装Nvidia GPU驱动 24 | 25 | - 如果已经安装驱动则跳过这一步 26 | - 访问[Nvidia驱动下载](https://www.nvidia.com/Download/index.aspx?lang=cn),下载适合自己电脑环境的驱动 27 | - 双击**驱动安装程序**安装 28 | - 重启电脑 29 | 30 | #### 解压安全帽检测系统 31 | 32 | - 下载压缩包**HardhatSystem-gpu-win-x86_64-Release-2.2.0.rar**并解压 33 | 34 | #### 打开安全帽检测系统 35 | 36 | - 进入**HardhatSystem**文件夹 37 | - 双击运行**HardhatSystem.exe** 38 | - 等待3秒后,软件界面出现 39 | 40 | #### 可能出现的问题 41 | 42 | - 软件打开时弹出错误:双击运行**vc_redist.x64.exe**,安装完成后重新运行**HardhatSystem.exe 43 | 44 | ### Ubuntu-GPU版本 45 | 46 | #### 安装Nvidia GPU驱动 47 | - 在终端使用如下命令安装 48 | ```shell 49 | sudo add-apt-repository ppa:graphics-drivers/ppa 50 | sudo apt update 51 | sudo apt install nvidia-396 52 | ``` 53 | - 重启电脑后使用nvidia-smi命令检查是否安装成功 54 | 55 | #### 安装安全帽检测系统 56 | - 下载压缩包**HardhatSystem-gpu-linux-x86_64-Release-2.2.0.zip**并解压 57 | 58 | #### 打开安全帽检测系统 59 | - 进入目录打开终端执行命令 60 | ```shell 61 | cd /HardhatSystem-gpu-linux-x86_64-Release-2.2.0 62 | ./run.sh 63 | ``` 64 | 65 | ### Windows-CPU版本 66 | 67 | #### 解压安全帽检测系统 68 | 69 | - 下载压缩包**HardhatSystem-cpu-win-x86_64-Release-2.2.0.rar**并解压 70 | 71 | #### 打开安全帽检测系统 72 | 73 | - 进入**HardhatSystem**文件夹 74 | - 双击运行**HardhatSystem.exe** 75 | - 等待3秒后,软件界面出现 76 | 77 | #### 可能出现的问题 78 | 79 | - 软件打开时弹出错误:双击运行**vc_redist.x64.exe**,安装完成后重新运行**HardhatSystem.exe 80 | 81 | ### Ubuntu-CPU版本 82 | 83 | #### 安装安全帽检测系统 84 | - 下载压缩包**HardhatSystem-cpu-linux-x86_64-Release-2.2.0.zip**并解压 85 | 86 | #### 打开安全帽检测系统 87 | - 进入目录打开终端执行命令 88 | ```shell 89 | cd /HardhatSystem-cpu-linux-x86_64-Release-2.2.0 90 | ./run.sh 91 | ``` 92 | 93 | ## 使用说明 94 | 95 | ### Windows 96 | - 进入HardhatSystem文件夹 97 | - 双击HardhatSystem.exe打开 98 | 99 | ### Ubuntu 100 | - 解压HardhatSystem-linux-x86_64-Release-2.2.0.zip后进入解压后的文件夹 101 | - 在终端执行以下命令,打开**安全帽检测系统** 102 | ```shell 103 | cd /HardhatSystem-linux-x86_64-Release-2.2.0 104 | ./run.sh 105 | ``` 106 | -------------------------------------------------------------------------------- /preview/HardhatSystem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TLMichael/Perceptron/a76dc4b88771b0179f150d6e3964dfb9e88f869a/preview/HardhatSystem.png -------------------------------------------------------------------------------- /preview/camera1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TLMichael/Perceptron/a76dc4b88771b0179f150d6e3964dfb9e88f869a/preview/camera1.png -------------------------------------------------------------------------------- /preview/camera3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TLMichael/Perceptron/a76dc4b88771b0179f150d6e3964dfb9e88f869a/preview/camera3.png -------------------------------------------------------------------------------- /preview/camera5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TLMichael/Perceptron/a76dc4b88771b0179f150d6e3964dfb9e88f869a/preview/camera5.png -------------------------------------------------------------------------------- /preview/camera6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TLMichael/Perceptron/a76dc4b88771b0179f150d6e3964dfb9e88f869a/preview/camera6.png -------------------------------------------------------------------------------- /preview/camera7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TLMichael/Perceptron/a76dc4b88771b0179f150d6e3964dfb9e88f869a/preview/camera7.png -------------------------------------------------------------------------------- /preview/database.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TLMichael/Perceptron/a76dc4b88771b0179f150d6e3964dfb9e88f869a/preview/database.png -------------------------------------------------------------------------------- /preview/search1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TLMichael/Perceptron/a76dc4b88771b0179f150d6e3964dfb9e88f869a/preview/search1.png -------------------------------------------------------------------------------- /preview/search2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TLMichael/Perceptron/a76dc4b88771b0179f150d6e3964dfb9e88f869a/preview/search2.png -------------------------------------------------------------------------------- /preview/search3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TLMichael/Perceptron/a76dc4b88771b0179f150d6e3964dfb9e88f869a/preview/search3.png -------------------------------------------------------------------------------- /preview/search4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TLMichael/Perceptron/a76dc4b88771b0179f150d6e3964dfb9e88f869a/preview/search4.png -------------------------------------------------------------------------------- /preview/search5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TLMichael/Perceptron/a76dc4b88771b0179f150d6e3964dfb9e88f869a/preview/search5.png -------------------------------------------------------------------------------- /preview/video1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TLMichael/Perceptron/a76dc4b88771b0179f150d6e3964dfb9e88f869a/preview/video1.png -------------------------------------------------------------------------------- /preview/video2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TLMichael/Perceptron/a76dc4b88771b0179f150d6e3964dfb9e88f869a/preview/video2.png -------------------------------------------------------------------------------- /preview/video3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TLMichael/Perceptron/a76dc4b88771b0179f150d6e3964dfb9e88f869a/preview/video3.png -------------------------------------------------------------------------------- /preview/video4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TLMichael/Perceptron/a76dc4b88771b0179f150d6e3964dfb9e88f869a/preview/video4.png -------------------------------------------------------------------------------- /preview/video5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TLMichael/Perceptron/a76dc4b88771b0179f150d6e3964dfb9e88f869a/preview/video5.png --------------------------------------------------------------------------------