pull/36/head
pvqf6mep3 3 years ago
commit a4e554efd7

@ -0,0 +1,32 @@
#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,69 @@
#include "../include/Air_Ground_CEC/login.h"
#include <QMovie>
#include <QWidget>
#include <QMouseEvent>
Login::Login(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Login)
{
ui->setupUi(this);
initWindow();
}
Login::~Login()
{
delete ui;
}
void Login::initWindow(){
setWindowState();
setBtnAndLabelState();
}
void Login::setWindowState(){
this->setAttribute(Qt::WA_TranslucentBackground);
this->setWindowFlags(Qt::FramelessWindowHint);//隐藏边框
}
void Login::setBtnAndLabelState(){
QMovie* movie = new QMovie("://images/background.gif");
ui->label_video->setMovie(movie);
movie->start();
ui->btnWinMin->setIcon(QIcon("://images/min.png"));
ui->btnWinMin_2->setIcon(QIcon("://images/min.png"));
ui->btnWinClose->setIcon(QIcon("://images/close.png"));
ui->btnWinClose_2->setIcon(QIcon("://images/close.png"));
connect(ui->btnWinMin, &QPushButton::clicked, this,
[=]() { this->showMinimized(); });
connect(ui->btnWinMin_2, &QPushButton::clicked, this,
[=]() { this->showMinimized(); });
connect(ui->btnWinClose, &QPushButton::clicked, this, [=]() { this->close(); });
connect(ui->btnWinClose_2, &QPushButton::clicked, this, [=]() { this->close(); });
}
void Login::mousePressEvent(QMouseEvent *event) {
m_lastPos = event->globalPos();
isPressedWidget = true; // 当前鼠标按下的即是QWidget而非界面上布局的其它控件
}
void Login::mouseMoveEvent(QMouseEvent *event) {
if (isPressedWidget) {
this->move(this->x() + (event->globalX() - m_lastPos.x()),
this->y() + (event->globalY() - m_lastPos.y()));
m_lastPos = event->globalPos();
}
}
void Login::mouseReleaseEvent(QMouseEvent *event) {
// 其实这里的mouseReleaseEvent函数可以不用重写
m_lastPos = event->globalPos();
isPressedWidget = false; // 鼠标松开时置为false
}

@ -1,4 +1,5 @@
#include "../include/Air_Ground_CEC/mainwindow.hpp" #include "../include/Air_Ground_CEC/mainwindow.hpp"
#include "../include/Air_Ground_CEC/login.h"
#include <QApplication> #include <QApplication>
@ -11,9 +12,11 @@ int main(int argc, char** argv)
QApplication app(argc, argv); QApplication app(argc, argv);
MainWindow CEC(0,0,0);
CEC.show(); //MainWindow CEC(0,0,0);
//CEC.show();
Login a(0);
a.show();
return app.exec(); return app.exec();
return(0); return(0);

@ -14,7 +14,11 @@ MainWindow::MainWindow(int argc, char **argv, QWidget *parent) :
ui->setupUi(this); ui->setupUi(this);
initUis(); initUis();
timer = new QTimer(this);
connections(); connections();
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -155,6 +159,9 @@ void MainWindow::connections(){
ui->stackedWidget_ros_control->setCurrentIndex(0); ui->stackedWidget_ros_control->setCurrentIndex(0);
}); });
//label -> stream
connect(timer, SIGNAL(timeout()), this, SLOT(importFrame()));
/* /*
* *
*/ */
@ -378,7 +385,7 @@ void MainWindow::importFrame()
void MainWindow::on_Open_receive_clicked() void MainWindow::on_Open_receive_clicked()
{ {
capture.open(1); capture.open(0);
//capture.open("udp://@0.0.0.0:11111"); //capture.open("udp://@0.0.0.0:11111");
timer->start(30); timer->start(30);
} }

@ -29,7 +29,7 @@ bool QNode::init() {
SubAndPubTopic(); SubAndPubTopic();
}); });
//start();
return true; return true;
} }
@ -90,7 +90,7 @@ void QNode::KeyboardMove(char key, float speed_linear, float speed_trun){
cmd_pub.publish(twist); cmd_pub.publish(twist);
ros::spinOnce(); //ros::spinOnce();
} }
void QNode::AutoMove(float speed_linear, float speed_turn, void QNode::AutoMove(float speed_linear, float speed_turn,

@ -16,5 +16,10 @@
<file>images/up_left_2.png</file> <file>images/up_left_2.png</file>
<file>images/up_right.png</file> <file>images/up_right.png</file>
<file>images/up_right_2.png</file> <file>images/up_right_2.png</file>
<file>images/close.png</file>
<file>images/min.png</file>
<file>images/power.png</file>
<file>images/power-v.png</file>
<file>images/background.gif</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save