pull/38/head
pvqf6mep3 3 years ago
commit de5e6c02f5

@ -16,10 +16,7 @@ find_package(catkin REQUIRED COMPONENTS
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES Air_Ground_CEC
# CATKIN_DEPENDS roscpp
# DEPENDS system_lib
)
###########

@ -1,32 +0,0 @@
#ifndef LOGIN_H
#define LOGIN_H
#include <QMainWindow>
#include "ui_login.h"
namespace Ui {
class Login;
}
class Login : public QMainWindow
{
Q_OBJECT
public:
explicit Login(QWidget *parent = nullptr);
~Login();
private:
Ui::Login *ui;
bool isPressedWidget;
QPoint m_lastPos;
void initWindow();
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void setWindowState();
void setBtnAndLabelState();
};
#endif // LOGIN_H

@ -0,0 +1,40 @@
#ifndef LOGINUI_H
#define LOGINUI_H
#include <QMainWindow>
#include "ui_loginui.h"
#include <iostream>
#include <cstring>
using namespace std;
namespace Ui {
class LoginUi;
}
class LoginUi : public QMainWindow
{
Q_OBJECT
public:
explicit LoginUi(QWidget *parent = nullptr);
~LoginUi();
private:
Ui::LoginUi *ui;
bool isPressedWidget;
QPoint m_lastPos;
void initWindow();
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void setWindowState();
void setBtnAndLabelState();
bool verifyAccount(string usr, string pwd);
void changetoMainwindow();
};
#endif // LOGINUI_H

@ -1,6 +1,6 @@
#include"Djitellowhite.h"
#include<iostream>
#include<opencv2/opencv.hpp>
#include "../include/Djitellowhite.h"
#include <iostream>
#include <opencv2/opencv.hpp>
#include<stdio.h>

@ -1,6 +1,7 @@
#include"Djitellowhite.h"
#include"Hardwarelistener.h"
#include<iostream>
#include "../include/Djitellowhite.h"
#include "../include/Hardwarelistener.h"
#include <iostream>
/*
using namespace std;
int main(void){
Tello T("192.168.10.1");
@ -43,3 +44,4 @@ int main(void){
listenkeyboard(T,serveraddr);
return 0;
}
*/

@ -1,6 +1,6 @@
#include <termio.h>
#include <stdio.h>
#include "Hardwarelistener.h"
#include "../include/Hardwarelistener.h"
#include <iostream>
using namespace std;

@ -1,35 +1,36 @@
#include "../include/Air_Ground_CEC/login.h"
#include "../include/Air_Ground_CEC/loginui.h"
#include "../include/Air_Ground_CEC/mainwindow.hpp"
#include <QMovie>
#include <QWidget>
#include <QMouseEvent>
Login::Login(QWidget *parent) :
LoginUi::LoginUi(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Login)
ui(new Ui::LoginUi)
{
ui->setupUi(this);
initWindow();
}
Login::~Login()
LoginUi::~LoginUi()
{
delete ui;
}
void Login::initWindow(){
void LoginUi::initWindow(){
setWindowState();
setBtnAndLabelState();
}
void Login::setWindowState(){
void LoginUi::setWindowState(){
this->setAttribute(Qt::WA_TranslucentBackground);
this->setWindowFlags(Qt::FramelessWindowHint);//隐藏边框
}
void Login::setBtnAndLabelState(){
void LoginUi::setBtnAndLabelState(){
QMovie* movie = new QMovie("://images/background.gif");
ui->label_video->setMovie(movie);
movie->start();
@ -47,14 +48,18 @@ void Login::setBtnAndLabelState(){
connect(ui->btnWinClose, &QPushButton::clicked, this, [=]() { this->close(); });
connect(ui->btnWinClose_2, &QPushButton::clicked, this, [=]() { this->close(); });
connect(ui->btnLogin, &QPushButton::clicked, this, [=]() {
changetoMainwindow();}
);
}
void Login::mousePressEvent(QMouseEvent *event) {
void LoginUi::mousePressEvent(QMouseEvent *event) {
m_lastPos = event->globalPos();
isPressedWidget = true; // 当前鼠标按下的即是QWidget而非界面上布局的其它控件
}
void Login::mouseMoveEvent(QMouseEvent *event) {
void LoginUi::mouseMoveEvent(QMouseEvent *event) {
if (isPressedWidget) {
this->move(this->x() + (event->globalX() - m_lastPos.x()),
this->y() + (event->globalY() - m_lastPos.y()));
@ -62,8 +67,30 @@ void Login::mouseMoveEvent(QMouseEvent *event) {
}
}
void Login::mouseReleaseEvent(QMouseEvent *event) {
void LoginUi::mouseReleaseEvent(QMouseEvent *event) {
// 其实这里的mouseReleaseEvent函数可以不用重写
m_lastPos = event->globalPos();
isPressedWidget = false; // 鼠标松开时置为false
}
bool LoginUi::verifyAccount(string usr, string pwd){
if (usr == "admin" && pwd == "admin"){
return true;
}
return false;
}
void LoginUi::changetoMainwindow(){
this->close();
MainWindow CEC(0,0,0);
CEC.show();
}

@ -1,5 +1,5 @@
#include "../include/Air_Ground_CEC/mainwindow.hpp"
#include "../include/Air_Ground_CEC/login.h"
#include "../include/Air_Ground_CEC/loginui.h"
#include <QApplication>
@ -13,10 +13,10 @@ int main(int argc, char** argv)
QApplication app(argc, argv);
//MainWindow CEC(0,0,0);
//CEC.show();
Login a(0);
a.show();
MainWindow CEC(0,0,0);
CEC.show();
//LoginUi a(0);
//a.show();
return app.exec();
return(0);
@ -26,6 +26,7 @@ int main(int argc, char** argv)
/*
* find . "(" -name "*.cpp" -or -name "*.h" -or -name "*.hpp" -or -name "*.qrc" ")" -print | xargs wc -l
* git fame --incl '\.[cht]' -twMC
* rosrun rqt_graph rqt_graph
* git fame
*/

@ -1,6 +1,8 @@
#include "../include/Air_Ground_CEC/qnode.hpp"
#include "sensor_msgs/image_encodings.h"
#include "sensor_msgs/CompressedImage.h"
#include <QtConcurrent/QtConcurrent>
QNode::QNode(int argc, char **argv) : init_argc(argc), init_argv(argv){
@ -47,7 +49,8 @@ void QNode::SubAndPubTopic(){
&QNode::batteryCallback, this);
image_transport::ImageTransport it(n);
image_sub = it.subscribe("camera/rgb/image_raw", 100, &QNode::imageCallback, this);
//camera/rgb/image_raw
image_sub = it.subscribe("raspicam_node/image", 10, &QNode::imageCallback, this);
//image_sub0 = n.subscribe("camera/rgb/image_raw",100,&QNode::imageCallback,this)
@ -172,12 +175,12 @@ void QNode::speedCallback(const nav_msgs::Odometry::ConstPtr& msg)
{
emit speed_x(msg->twist.twist.linear.x);
emit speed_th(msg->twist.twist.angular.z);
}
void QNode::imageCallback(const sensor_msgs::ImageConstPtr &msg)
{
ROS_INFO("i am ok");
try
{
cv_bridge::CvImageConstPtr cv_ptr =

@ -40,7 +40,7 @@ void udp_server(int sockfd)
close(sockfd);
}
/*
int main(int argc, char **argv)
{
int sockfd;
@ -54,5 +54,6 @@ int main(int argc, char **argv)
exit(0);
}
*/

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Login</class>
<widget class="QWidget" name="Login">
<class>LoginUi</class>
<widget class="QWidget" name="LoginUi">
<property name="geometry">
<rect>
<x>0</x>
@ -841,8 +841,8 @@ background-color:none</string>
<rect>
<x>0</x>
<y>0</y>
<width>579</width>
<height>196</height>
<width>205</width>
<height>104</height>
</rect>
</property>
<attribute name="label">
@ -902,8 +902,8 @@ background-color:none</string>
<rect>
<x>0</x>
<y>0</y>
<width>579</width>
<height>196</height>
<width>88</width>
<height>88</height>
</rect>
</property>
<attribute name="label">
@ -926,7 +926,7 @@ background-color:none</string>
<rect>
<x>0</x>
<y>0</y>
<width>565</width>
<width>267</width>
<height>312</height>
</rect>
</property>
@ -1251,8 +1251,8 @@ background-color:none</string>
<rect>
<x>0</x>
<y>0</y>
<width>579</width>
<height>196</height>
<width>313</width>
<height>133</height>
</rect>
</property>
<attribute name="label">
Loading…
Cancel
Save