|
57 | 57 | #include <QTextStream> |
58 | 58 | #include <QFile> |
59 | 59 | #include <QTemporaryFile> |
| 60 | +#include <QMessageBox> |
60 | 61 |
|
61 | 62 | #include "rclcpp/rclcpp.hpp" |
62 | 63 | #include "sensor_msgs/msg/image.hpp" |
@@ -117,7 +118,6 @@ vector<string> GetIPAddresses(bool ignore_lo) { |
117 | 118 | namespace ut_automata_gui { |
118 | 119 |
|
119 | 120 | CameraDisplay::CameraDisplay(QWidget* parent) : QLabel(parent) { |
120 | | - setMinimumSize(400, 300); |
121 | 121 | setScaledContents(false); // We'll handle scaling manually for better control |
122 | 122 | setAlignment(Qt::AlignCenter); |
123 | 123 | setStyleSheet("border: 2px solid black; background-color: #f0f0f0;"); |
@@ -318,6 +318,11 @@ MainWindow::MainWindow(QWidget* parent) : |
318 | 318 | disk_space_bar_(nullptr), |
319 | 319 | stop_config_button_(nullptr) { |
320 | 320 | this->setWindowTitle("UT AUTOmataGUI"); |
| 321 | + |
| 322 | + // Ensure window takes full screen space |
| 323 | + setMinimumSize(800, 480); // Set a reasonable minimum size |
| 324 | + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
| 325 | + |
321 | 326 | camera_display_ = new CameraDisplay(); |
322 | 327 |
|
323 | 328 | QPushButton* close_button = new QPushButton("Close"); |
@@ -414,27 +419,42 @@ MainWindow::MainWindow(QWidget* parent) : |
414 | 419 | steering_status_ = new RealStatus(true); |
415 | 420 |
|
416 | 421 | QGridLayout* main_layout = new QGridLayout(); |
| 422 | + main_layout->setContentsMargins(5, 5, 5, 5); // Minimal margins |
| 423 | + main_layout->setSpacing(5); // Minimal spacing |
417 | 424 | main_layout->addWidget(camera_display_, 0, 0, 4, 4); |
418 | 425 | main_layout->addWidget(imu_led_, 0, 5, 1, 1); |
419 | 426 | main_layout->addWidget(drive_led_, 0, 6, 1, 1); |
420 | 427 | main_layout->addWidget(lidar_led_, 1, 5, 1, 1); |
421 | 428 | main_layout->addWidget(joystick_led_, 1, 6, 1, 1); |
422 | 429 | main_layout->addWidget(throttle_status_, 0, 7, 3, 1); |
423 | 430 | main_layout->addWidget(steering_status_, 3, 5, 1, 3); |
| 431 | + |
| 432 | + // Set column stretch factors to ensure proper expansion |
| 433 | + main_layout->setColumnStretch(0, 4); // Camera takes most space |
| 434 | + main_layout->setColumnStretch(1, 4); |
| 435 | + main_layout->setColumnStretch(2, 4); |
| 436 | + main_layout->setColumnStretch(3, 4); |
| 437 | + main_layout->setColumnStretch(4, 0); // Control columns get minimal space |
| 438 | + main_layout->setColumnStretch(5, 1); |
| 439 | + main_layout->setColumnStretch(6, 1); |
| 440 | + main_layout->setColumnStretch(7, 1); |
| 441 | + |
424 | 442 | main_widget->setLayout(main_layout); |
425 | 443 |
|
426 | 444 | tab_widget_->addTab(main_widget, "Main"); |
427 | 445 | tab_widget_->addTab(ros_group, tr("Configurations")); |
428 | 446 | } |
429 | 447 |
|
430 | 448 | main_layout_ = new QVBoxLayout(this); |
| 449 | + main_layout_->setContentsMargins(5, 5, 5, 5); // Minimal margins |
| 450 | + main_layout_->setSpacing(5); // Minimal spacing between elements |
431 | 451 | setLayout(main_layout_); |
432 | | - main_layout_->addLayout(top_bar, Qt::AlignTop); |
433 | | - main_layout_->addWidget(tab_widget_); |
| 452 | + main_layout_->addLayout(top_bar, 0); // Top bar gets minimal space |
| 453 | + main_layout_->addWidget(tab_widget_, 1); // Tab widget gets most space (stretch factor 1) |
434 | 454 |
|
435 | 455 | // Add disk space indicator at the bottom |
436 | 456 | disk_space_bar_ = new DiskSpaceBar(); |
437 | | - main_layout_->addWidget(disk_space_bar_); |
| 457 | + main_layout_->addWidget(disk_space_bar_, 0); // Bottom bar gets minimal space |
438 | 458 |
|
439 | 459 | connect(close_button, SIGNAL(clicked()), this, SLOT(closeWindow())); |
440 | 460 |
|
@@ -497,13 +517,6 @@ void MainWindow::StartCamera() { |
497 | 517 | Exec("roslaunch astra_camera astra.launch > /dev/null &"); |
498 | 518 | } |
499 | 519 |
|
500 | | -void MainWindow::StopAll() { |
501 | | - // two seperate kills to ensure that both |
502 | | - // autostart and manual start will be stopped |
503 | | - Exec("/opt/ros/melodic/bin/rosnode kill -a"); |
504 | | - Exec("/usr/bin/pkill roslaunch"); |
505 | | -} |
506 | | - |
507 | 520 | void MainWindow::closeWindow() { |
508 | 521 | QApplication::quit(); |
509 | 522 | } |
@@ -731,9 +744,22 @@ void MainWindow::StopTmuxConfiguration() { |
731 | 744 | } |
732 | 745 |
|
733 | 746 | void MainWindow::ShutdownCar() { |
734 | | - // Stop all tmux sessions and shutdown ROS nodes |
735 | | - StopTmuxConfiguration(); |
736 | | - StopAll(); |
| 747 | + // Show confirmation dialog |
| 748 | + QMessageBox::StandardButton reply = QMessageBox::question( |
| 749 | + this, |
| 750 | + "Confirm Shutdown", |
| 751 | + "Are you sure you want to shutdown the car?\n\nThis will:\n- Stop all running configurations\n- Stop all ROS nodes\n- Power off the system", |
| 752 | + QMessageBox::Yes | QMessageBox::No, |
| 753 | + QMessageBox::No // Default to No for safety |
| 754 | + ); |
| 755 | + |
| 756 | + if (reply == QMessageBox::Yes) { |
| 757 | + // Stop all tmux sessions |
| 758 | + StopTmuxConfiguration(); |
| 759 | + |
| 760 | + // Shutdown the PC |
| 761 | + Exec("sudo shutdown -h now"); |
| 762 | + } |
737 | 763 | } |
738 | 764 |
|
739 | 765 |
|
|
0 commit comments