BUG 暂时禁用了日志与qtextedit控件的联动,有线程冲突的风险
添加 相机控制台cameraController
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
#include <backEndController.h>
|
||||
#include <triggerController.h>
|
||||
|
||||
backEndController::backEndController()
|
||||
{
|
||||
_triggerController = new triggerController();
|
||||
_triggerController->init(this);
|
||||
}
|
||||
@@ -1,12 +1,17 @@
|
||||
#include <triggerController.h>
|
||||
class backEndController
|
||||
#ifndef BACKENDCONTROLLER_H
|
||||
#define BACKENDCONTROLLER_H
|
||||
#include <qobject.h>
|
||||
#include <globalStruct.h>
|
||||
class triggerController;
|
||||
class cameraController;
|
||||
class backEndController :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
triggerController _triggerController;//触发器
|
||||
|
||||
backEndController()
|
||||
{
|
||||
_triggerController.init();
|
||||
}
|
||||
bool init = false;
|
||||
triggerController* _triggerController;//´¥·¢Æ÷
|
||||
backEndController();
|
||||
signals:
|
||||
void sendErrorToMainwindow(backEndError);
|
||||
};
|
||||
#pragma once
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
#include<base.h>
|
||||
|
||||
typedef Base* (*CreateFunction)();
|
||||
typedef void (*ReleaseFunction)(Base* animal);
|
||||
|
||||
struct correctionStruct
|
||||
{
|
||||
std::vector<double> in_X_X0Y;
|
||||
std::vector<double> in_Y_X0Y;
|
||||
std::vector<double> in_Z_X0Y;
|
||||
std::vector<double> in_Z_X0Y_Value;
|
||||
std::vector<double> in_X_X0Z;
|
||||
std::vector<double> in_Y_X0Z;;
|
||||
std::vector<double> in_Z_X0Z;
|
||||
std::vector<double> in_Y_X0Z_Value;
|
||||
std::vector<double> in_X_Y0Z;
|
||||
std::vector<double> in_Y_Y0Z;
|
||||
std::vector<double> in_Z_Y0Z;
|
||||
std::vector<double> in_X_Y0Z_Value;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
QString m_stationKy;
|
||||
QString key; // 相机名称
|
||||
QString moduleName; // 模块名称
|
||||
QString task_thread_index = "-1";// 存储当前算法属于那个任务线程
|
||||
QByteArray m_initByte; // 传递初始化参数
|
||||
Base* module_ptr = nullptr; // 存储模块指针
|
||||
ReleaseFunction destory_ptr; // 释放
|
||||
int showIndex;
|
||||
}cameraModule;
|
||||
#pragma once
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef CAMERACONTROLLER_H
|
||||
#define CAMERACONTROLLER_H
|
||||
#include <QString>
|
||||
#include <backStruct.h>
|
||||
class backEndController;
|
||||
class cameraController
|
||||
{
|
||||
public:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,31 +0,0 @@
|
||||
#include <string>
|
||||
using namespace std;
|
||||
struct onePointPos//单次坐标
|
||||
{
|
||||
//小数点默认两位
|
||||
onePointPos(int countIn,
|
||||
int xPos1, int xPos2, int xPos3,
|
||||
int yPos1, int yPos2, int yPos3,
|
||||
int zPos1, int zPos2, int zPos3)
|
||||
{
|
||||
count = countIn;
|
||||
|
||||
xPos = xPos2*100 + xPos3;
|
||||
xPos = (xPos1 == 1) ? xPos : -xPos;
|
||||
|
||||
yPos = yPos2 * 100 + yPos3;
|
||||
yPos = (yPos1 == 1) ? yPos : -yPos;
|
||||
|
||||
zPos = zPos2 * 100 + zPos3;
|
||||
zPos = (zPos1 == 1) ? zPos : -zPos;
|
||||
}
|
||||
int count;
|
||||
int xPos;
|
||||
int yPos;
|
||||
int zPos;
|
||||
};
|
||||
|
||||
class laserPositioning
|
||||
{
|
||||
|
||||
};
|
||||
@@ -381,7 +381,6 @@ int MyIoThread::getValue(int dmPos, QByteArray byte)
|
||||
/// 目前只负责检测fins信号,拍照和传递数据到等待队列
|
||||
/// </summary>
|
||||
/// <param name="byte">从reciveCommond传入,从fins(JSON->finstcp_readAllCmd)读取的数据</param>
|
||||
#include <back/laserPositioning.h>
|
||||
|
||||
correctionStruct* correctionData=nullptr;
|
||||
void MyIoThread::decodeCameraCMD(QByteArray byte)
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
#include <triggerController.h>
|
||||
#include <backEndController.h>
|
||||
#include <backStruct.h>
|
||||
void triggerController::decodeCameraCMD(QByteArray byte)
|
||||
{
|
||||
#if 0
|
||||
if (byte.isEmpty())
|
||||
return;
|
||||
double cameraData = 0;
|
||||
if (checkTrigger(1, 1, byte) == true)
|
||||
{
|
||||
correctionData = new correctionStruct();
|
||||
correctionData->in_X_X0Y = { -258.71,-447.8,-447.2 };
|
||||
correctionData->in_Y_X0Y = { -1099.67,-1133.42,-938.83 };
|
||||
correctionData->in_Z_X0Y = { 711.77,711.62,711.730000 };
|
||||
correctionData->in_Z_X0Y_Value = { 63.9795,64.5333,65.859300 };
|
||||
|
||||
correctionData->in_X_X0Z = { -402.3,-455.91,-236.75 };
|
||||
correctionData->in_Y_X0Z = { -539.46,-536.21,-536.2 };
|
||||
correctionData->in_Z_X0Z = { -418.88,425.12,425.13 };
|
||||
correctionData->in_Y_X0Z_Value = { 118.15,-228.19,-256.5 };
|
||||
|
||||
correctionData->in_X_Y0Z = { 395.250000,395.23,328.34 };
|
||||
correctionData->in_Y_Y0Z = { -1147.29,-1147.28,-940.82 };
|
||||
correctionData->in_Z_Y0Z = { 118.15,-228.19,-256.5 };
|
||||
correctionData->in_X_Y0Z_Value = { -36.652200,-36.7302,41.0436 };
|
||||
detData* data = dController.insertDetData("Camera1", "correctionDataThread", "TEST", 0);
|
||||
data->correctionData = correctionData;
|
||||
workThread->addTask(data);//添加任务
|
||||
correctionData = nullptr;
|
||||
}
|
||||
|
||||
//总流程开始,机器人发送1至寄存器259
|
||||
|
||||
//上位机确认OK之后,清零寄存器259,并发送1至寄存器260
|
||||
//如产品型号为Product_1且为正面,则上位机发送1至寄存器256,发送0至寄存器257
|
||||
//之后机器人确认之后需发送测量点位总数具体值至寄存器258
|
||||
if (checkTrigger(259, 1, byte) == true)
|
||||
{
|
||||
bridge.back.sendFinsMsg("write_short_259_0");//触发信号清零
|
||||
bridge.back.sendFinsMsg("write_short_260_1");//开始检测信号
|
||||
}
|
||||
|
||||
//机器人激光当前点位 264 1...9
|
||||
//机器人到达激光点位1时,寄存器261至1,264至1,并将机器人在激光点位1坐标XYZ按照定义规则,保存进寄存器265~270
|
||||
|
||||
//上位机确认机器人到达点位1(264)时,确认OK后,寄存器262至1,261至0,取点完成后,发送寄存器263至1
|
||||
if (checkTrigger(261, 1, byte) == true)//读取请求地址
|
||||
{
|
||||
int armPos = getValue(264, byte);
|
||||
|
||||
int xValue1 = getValue(265, byte);
|
||||
int xValue2 = getValue(266, byte);
|
||||
int xValue3 = getValue(267, byte);
|
||||
|
||||
int yValue1 = getValue(268, byte);
|
||||
int yValue2 = getValue(269, byte);
|
||||
int yValue3 = getValue(270, byte);
|
||||
|
||||
int zValue1 = getValue(271, byte);
|
||||
int zValue2 = getValue(272, byte);
|
||||
int zValue3 = getValue(273, byte);
|
||||
|
||||
double xValue = (xValue1 == 1 ? 1 : -1) * ((double)xValue2 + ((double)xValue3) / (std::pow(10, to_string(xValue3).length())));
|
||||
double yValue = (yValue1 == 1 ? 1 : -1) * ((double)yValue2 + ((double)yValue3) / (std::pow(10, to_string(yValue3).length())));
|
||||
double zValue = (zValue1 == 1 ? 1 : -1) * ((double)zValue2 + ((double)zValue3) / (std::pow(10, to_string(zValue3).length())));
|
||||
double rangeData = threadlist[0]->getValueFromCamera();
|
||||
|
||||
if (armPos == 1)//第一次
|
||||
correctionData = new correctionStruct();
|
||||
if (correctionData != nullptr)
|
||||
{
|
||||
if (armPos <= 3)
|
||||
{
|
||||
correctionData->in_X_X0Y.push_back(xValue);
|
||||
correctionData->in_Y_X0Y.push_back(yValue);
|
||||
correctionData->in_Z_X0Y.push_back(zValue);
|
||||
correctionData->in_Z_X0Y_Value.push_back(rangeData);
|
||||
}
|
||||
else if (armPos <= 6)
|
||||
{
|
||||
correctionData->in_X_X0Z.push_back(xValue);
|
||||
correctionData->in_Y_X0Z.push_back(yValue);
|
||||
correctionData->in_Z_X0Z.push_back(zValue);
|
||||
correctionData->in_Y_X0Z_Value.push_back(rangeData);
|
||||
}
|
||||
else if (armPos <= 9)
|
||||
{
|
||||
correctionData->in_X_Y0Z.push_back(xValue);
|
||||
correctionData->in_Y_Y0Z.push_back(yValue);
|
||||
correctionData->in_Z_Y0Z.push_back(zValue);
|
||||
correctionData->in_X_Y0Z_Value.push_back(rangeData);
|
||||
}
|
||||
}
|
||||
bridge.back.sendFinsMsg("write_short_261_0");//清零
|
||||
bridge.back.sendFinsMsg("write_short_262_1");
|
||||
bridge.back.sendFinsMsg("write_short_263_1");
|
||||
|
||||
//上位机校正完成,将寄存器274置为1,并将结果按照定义XYZ规则放入310~336中
|
||||
if (armPos == 9)
|
||||
{
|
||||
detData* data = dController.insertDetData("Camera1", "correctionDataThread", "TEST", 0);
|
||||
data->correctionData = correctionData;
|
||||
workThread->addTask(data);//添加任务
|
||||
correctionData = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//机器人到达激光点位9时,寄存器261至1,264至9,并将机器人在激光点位9坐标XYZ按照定义规则,保存进寄存器265~270
|
||||
|
||||
if (checkTrigger(300, 1, byte) == true)
|
||||
{
|
||||
bridge.back.sendFinsMsg("write_short_300_0");//触发信号清零
|
||||
bridge.back.sendFinsMsg("write_short_301_1");//开始检测信号
|
||||
int Pos = getValue(303, byte);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void triggerController::init(backEndController* input)
|
||||
{
|
||||
_backEndController = input;
|
||||
QLibrary* m_lib = new QLibrary(triggerFileName);
|
||||
bool flag = m_lib->load();
|
||||
if (!m_lib->isLoaded())
|
||||
{
|
||||
emit _backEndController->sendErrorToMainwindow(dllNotFound);
|
||||
return;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
CreateFunction createFun = (CreateFunction)m_lib->resolve("create");
|
||||
ReleaseFunction releaseFun = (ReleaseFunction)m_lib->resolve("destory");
|
||||
if (createFun && releaseFun)
|
||||
{
|
||||
trigger = createFun();
|
||||
destory_finstcp = releaseFun;
|
||||
QByteArray initByte = QByteArray::fromStdString("sleeptime_20_readnum_300_writetype_ushort");
|
||||
std::vector<cv::Mat> dddd;
|
||||
trigger->reciveData(dddd, QByteArray::fromStdString("init_127.0.0.1_502_1"));
|
||||
trigger->initParas(initByte);
|
||||
}
|
||||
else
|
||||
{
|
||||
emit _backEndController->sendErrorToMainwindow(triggerInitFailure);
|
||||
delete m_lib;
|
||||
m_lib = nullptr;
|
||||
return;
|
||||
}
|
||||
}
|
||||
this->start();
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
#ifndef TRIGGERCONTROLLER_H
|
||||
#define TRIGGERCONTROLLER_H
|
||||
#include <qdebug.h>
|
||||
#include <qthread.h>
|
||||
#include <base.h>
|
||||
#include <qlibrary.h>
|
||||
|
||||
typedef Base* (*CreateFunction)();
|
||||
typedef void (*ReleaseFunction)(Base* animal);
|
||||
#include <globalStruct.h>
|
||||
#include <backStruct.h>
|
||||
class backEndController;
|
||||
//防止重复触发
|
||||
class triggerLockerT
|
||||
{
|
||||
@@ -55,45 +58,14 @@ private:
|
||||
class triggerController : public QThread
|
||||
{
|
||||
public:
|
||||
backEndController* _backEndController;
|
||||
QString triggerFileName = QString("Hd_SocketModule_ModbusTcp");
|
||||
~triggerController()
|
||||
{
|
||||
runFlag = false;
|
||||
QThread::msleep(100);
|
||||
}
|
||||
void init()
|
||||
{
|
||||
QLibrary* m_lib = new QLibrary(triggerFileName);
|
||||
bool flag = m_lib->load();
|
||||
if (!m_lib->isLoaded())
|
||||
{
|
||||
|
||||
//qDebug() << "[Error] " << " Loaded error:" << m_lib->errorString();
|
||||
return ;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
CreateFunction createFun = (CreateFunction)m_lib->resolve("create");
|
||||
ReleaseFunction releaseFun = (ReleaseFunction)m_lib->resolve("destory");
|
||||
if (createFun && releaseFun)
|
||||
{
|
||||
trigger = createFun();
|
||||
destory_finstcp = releaseFun;
|
||||
QByteArray initByte = QByteArray::fromStdString("sleeptime_20_readnum_300_writetype_ushort");
|
||||
std::vector<cv::Mat> dddd;
|
||||
trigger->reciveData(dddd, QByteArray::fromStdString("init_127.0.0.1_502_1"));
|
||||
trigger->initParas(initByte);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete m_lib;
|
||||
m_lib = nullptr;
|
||||
return;
|
||||
}
|
||||
}
|
||||
this->start();
|
||||
}
|
||||
void init(backEndController* input);
|
||||
void run()
|
||||
{
|
||||
while (runFlag)
|
||||
@@ -108,7 +80,7 @@ public:
|
||||
//auto start = std::chrono::high_resolution_clock::now();
|
||||
//QByteArray byte = m_readAllCmd.toUtf8(); // 设置 从起始位开始读取的指令
|
||||
QByteArray byte = QByteArray::fromStdString("read_byte_1_500");
|
||||
if (sendFinsMsg(byte))
|
||||
if (!sendFinsMsg(byte))
|
||||
qCritical() << "[TCP] " << " finstcp_ptr reciveData error!";
|
||||
QByteArray readByte;
|
||||
if (!reciveFinsMsg(readByte))
|
||||
@@ -117,12 +89,10 @@ public:
|
||||
//auto end = std::chrono::high_resolution_clock::now();
|
||||
//auto duration = std::chrono::duration_cast<std::chrono::microseconds>(end - start);
|
||||
//std::cout << "cost: " << duration.count() << " mm" << std::endl;
|
||||
//decodeCameraCMD(readByte);
|
||||
decodeCameraCMD(readByte);
|
||||
//workThread->snDatas.checkSnFromWaittingVec(readByte);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//发送数据到
|
||||
bool sendFinsMsg(QString cmdx)
|
||||
{
|
||||
@@ -188,7 +158,8 @@ private:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//解析并触发
|
||||
void decodeCameraCMD(QByteArray byte);
|
||||
//触发器的配置
|
||||
int startPos = 1;//数据读取的起始位
|
||||
int interval = 10;//间隔
|
||||
@@ -198,6 +169,4 @@ private:
|
||||
bool runFlag = true;
|
||||
std::vector<cv::Mat> vec_mat;//没啥用,一直保持为空就好
|
||||
};
|
||||
|
||||
|
||||
#pragma once
|
||||
#endif
|
||||
@@ -0,0 +1,61 @@
|
||||
#include <qwidget.h>
|
||||
#include <qpainter.h>
|
||||
#include <Qlabel>
|
||||
#include <opencv.hpp>
|
||||
static QPixmap cvMatToQPixmap(const cv::Mat& mat) {
|
||||
QImage qImg;
|
||||
if (mat.channels() == 3) {
|
||||
//cv::cvtColor(mat, mat, cv::COLOR_BGR2RGB);
|
||||
qImg = QImage(mat.data, mat.cols, mat.rows, mat.step, QImage::Format_RGB888);
|
||||
}
|
||||
else {
|
||||
qImg = QImage((const unsigned char*)(mat.data), mat.cols, mat.rows, mat.step, QImage::Format_Grayscale8);
|
||||
}
|
||||
return QPixmap::fromImage(qImg);
|
||||
}
|
||||
class loadingWidget : public QWidget {
|
||||
public:
|
||||
QLabel* sign;
|
||||
loadingWidget(QWidget* parent = nullptr) : QWidget(parent) {
|
||||
sign = new QLabel(this);
|
||||
}
|
||||
|
||||
void setStatus(QWidget* widget) {
|
||||
screenshot_ = QPixmap::grabWindow(widget->winId());
|
||||
update(); // 更新widget以显示新的截图
|
||||
}
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent* event) override {
|
||||
if (screenshot_.isNull())
|
||||
return;
|
||||
QImage image = screenshot_.toImage();
|
||||
image = image.convertToFormat(QImage::Format_RGB888);
|
||||
cv::Mat originalMat = cv::Mat(
|
||||
image.height(),
|
||||
image.width(),
|
||||
CV_8UC3,
|
||||
image.bits(),
|
||||
image.bytesPerLine());
|
||||
cv::Mat blurredMat;
|
||||
cv::blur(originalMat, blurredMat, cv::Size(15, 15)); // 调整模糊半径以获得不同程度的模糊效果
|
||||
QPixmap blurredPixmap = cvMatToQPixmap(blurredMat);
|
||||
QPainter painter(this);
|
||||
painter.drawPixmap(0, 0, blurredPixmap);
|
||||
|
||||
// 在模糊图片上绘制文字
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::WindowText, Qt::white);
|
||||
QFont font("微软雅黑", 100, QFont::Bold);
|
||||
QFont font2("微软雅黑", 90, QFont::Bold);
|
||||
painter.setFont(font);
|
||||
painter.setPen(Qt::black);
|
||||
painter.drawText(this->rect(), Qt::AlignCenter, "WAIT");
|
||||
painter.setFont(font2);
|
||||
painter.setPen(Qt::white);
|
||||
painter.drawText(this->rect(), Qt::AlignCenter, "WAIT");
|
||||
}
|
||||
|
||||
private:
|
||||
QPixmap screenshot_;
|
||||
};
|
||||
@@ -46,10 +46,10 @@ static void MessageHandler(QtMsgType type, const QMessageLogContext& context, co
|
||||
globalQtlogFile.setDevice(&logFile);
|
||||
globalQtlogFile << logStr << endl;
|
||||
}
|
||||
if (globalQtTextEdit != nullptr) {
|
||||
globalQtTextEdit->moveCursor(QTextCursor::End);
|
||||
globalQtTextEdit->insertPlainText(logStr + "\n");
|
||||
}
|
||||
//if (globalQtTextEdit != nullptr) {
|
||||
// globalQtTextEdit->moveCursor(QTextCursor::End);
|
||||
// globalQtTextEdit->insertPlainText(logStr + "\n");
|
||||
//}
|
||||
}
|
||||
|
||||
class stdConsoleRedirector : public std::basic_streambuf<char> {
|
||||
@@ -191,7 +191,7 @@ public:
|
||||
|
||||
QLabel* toolName2 = new QLabel(u8" 正则匹配");
|
||||
toolName2->setFont(font2);
|
||||
toolName2->setPalette(palette);
|
||||
toolName2->setPalette(palette);
|
||||
toolHLayout->addWidget(toolName2);
|
||||
|
||||
QLineEdit* lineedit = new QLineEdit();
|
||||
@@ -207,6 +207,7 @@ public:
|
||||
{
|
||||
|
||||
globalQtTextEdit = textWidget;
|
||||
//globalQtTextEdit->setUpdatesEnabled(false);
|
||||
qInstallMessageHandler(MessageHandler);
|
||||
qInfo() << "This is a Qt Info message.";
|
||||
qWarning() << "This is a Qt Warning message.";
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/********************************************************************************
|
||||
** Form generated from reading UI file 'mainwindow.ui'
|
||||
**
|
||||
** Created by: Qt User Interface Compiler version 5.14.2
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef UI_MAINWINDOW_H
|
||||
#define UI_MAINWINDOW_H
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QGridLayout>
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class Ui_MainWindow
|
||||
{
|
||||
public:
|
||||
QWidget *centralwidget;
|
||||
QGridLayout *gridLayout;
|
||||
|
||||
void setupUi(QMainWindow *MainWindow)
|
||||
{
|
||||
if (MainWindow->objectName().isEmpty())
|
||||
MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
|
||||
MainWindow->resize(800, 600);
|
||||
centralwidget = new QWidget(MainWindow);
|
||||
centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
|
||||
gridLayout = new QGridLayout(centralwidget);
|
||||
gridLayout->setSpacing(0);
|
||||
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
|
||||
gridLayout->setContentsMargins(5, 5, 5, 5);
|
||||
MainWindow->setCentralWidget(centralwidget);
|
||||
|
||||
retranslateUi(MainWindow);
|
||||
|
||||
QMetaObject::connectSlotsByName(MainWindow);
|
||||
} // setupUi
|
||||
|
||||
void retranslateUi(QMainWindow *MainWindow)
|
||||
{
|
||||
MainWindow->setWindowTitle(QCoreApplication::translate("MainWindow", "MainWindow", nullptr));
|
||||
} // retranslateUi
|
||||
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow: public Ui_MainWindow {};
|
||||
} // namespace Ui
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // UI_MAINWINDOW_H
|
||||
@@ -11,4 +11,11 @@
|
||||
|
||||
#define sColor_Black "22, 22, 22"
|
||||
#define sColor_BlackWithWhite "45, 45, 45"
|
||||
enum backEndError
|
||||
{
|
||||
dllNotFound,
|
||||
triggerInitFailure,
|
||||
triggerConnectionError,
|
||||
camerInitFailure
|
||||
};
|
||||
#pragma once
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "mainwindow.h"
|
||||
#include "./ui_mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "titlebar.h"
|
||||
#include "mywidget.h"
|
||||
#include "cfgwindow.h"
|
||||
@@ -28,13 +28,13 @@ MainWindow::MainWindow(QWidget* parent)
|
||||
this->setStyleSheet(QString("QWidget#MainWidget {background-color: rgb(%1)}").arg(sColor_blue));
|
||||
this->setCentralWidget(&stackedWidgets);
|
||||
|
||||
//加载界面初始化
|
||||
|
||||
|
||||
//登录界面
|
||||
stackedWidgets.addWidget(&_loginWindow);
|
||||
connect(&_loginWindow, &loginWindow::login, this, &MainWindow::login);
|
||||
|
||||
//加载界面初始化
|
||||
stackedWidgets.addWidget(&_loadingWidget);
|
||||
|
||||
//第一层 只有顶部菜单栏和第二层layout
|
||||
mainWidget = new QWidget();
|
||||
stackedWidgets.addWidget(mainWidget);
|
||||
|
||||
@@ -21,17 +21,9 @@
|
||||
#include <pages/logPageWidget.h>
|
||||
#include <LoginWindow.h>
|
||||
#include <QPropertyAnimation>
|
||||
#include <loadingWidget.h>
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
enum DRAG_ABSOLUTE_POSITION
|
||||
{
|
||||
DRAG_KEEP=0, //保持不动
|
||||
DRAG_LOCK_LEFT=1, //锁定左边坐标
|
||||
DRAG_LOCK_TOP=2, //锁定上边坐标
|
||||
DRAG_LOCK_RIGHT=3, //锁定右边坐标
|
||||
DRAG_LOCK_BOTTOM=4 //锁定下边坐标
|
||||
};
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindow; }
|
||||
QT_END_NAMESPACE
|
||||
@@ -48,7 +40,8 @@ private:
|
||||
std::vector<toolBarButton*>pageBtns;
|
||||
QStackedWidget stackedWidgets;//一共三层,加载界面,登录界面,主要界面
|
||||
QStackedWidget pageWidgets;//主要界面中的页面
|
||||
loginWindow _loginWindow;
|
||||
loginWindow _loginWindow;//登录界面
|
||||
loadingWidget _loadingWidget;//加载 等待界面
|
||||
|
||||
//动画效果
|
||||
QGraphicsBlurEffect* blurEffect;
|
||||
@@ -100,7 +93,7 @@ public slots:
|
||||
blurEffectAnimation->setStartValue(0);
|
||||
blurEffectAnimation->setEndValue(20);
|
||||
blurEffectAnimation->start();
|
||||
stackedWidgets.setCurrentIndex(1);
|
||||
stackedWidgets.setCurrentIndex(2);
|
||||
blurEffectAnimation->setStartValue(20);
|
||||
blurEffectAnimation->setEndValue(0);
|
||||
blurEffectAnimation->start();
|
||||
@@ -108,6 +101,22 @@ public slots:
|
||||
}
|
||||
else if(input == false)stackedWidgets.setCurrentIndex(0);
|
||||
}
|
||||
void loading(bool input)
|
||||
{
|
||||
if (input == true)
|
||||
{
|
||||
blurEffectAnimation->setStartValue(0);
|
||||
blurEffectAnimation->setEndValue(20);
|
||||
blurEffectAnimation->start();
|
||||
_loadingWidget.setStatus(&stackedWidgets);
|
||||
stackedWidgets.setCurrentIndex(1);
|
||||
blurEffectAnimation->setStartValue(20);
|
||||
blurEffectAnimation->setEndValue(0);
|
||||
blurEffectAnimation->start();
|
||||
|
||||
}
|
||||
else if (input == false)stackedWidgets.setCurrentIndex(2);
|
||||
}
|
||||
signals:
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user