diff options
author | bd <bdunahu@operationnull.com> | 2025-04-21 13:41:45 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-04-21 13:41:45 -0400 |
commit | 9fe7235d7c06677f152e20b9deac85e633f429a6 (patch) | |
tree | 3277706d1e8893c75872c1710bd0a375809f925e | |
parent | dbf5d3986e5fe271b072cd3d32e73e4fa26a5fae (diff) |
Add some expression
-rw-r--r-- | gui/gui.cc | 52 | ||||
-rw-r--r-- | gui/gui.h | 14 | ||||
-rw-r--r-- | gui/messages.h | 14 | ||||
-rw-r--r-- | gui/resources.qrc | 4 | ||||
-rw-r--r-- | gui/resources/angry.png | bin | 0 -> 319 bytes | |||
-rw-r--r-- | gui/resources/busy.png | bin | 0 -> 329 bytes | |||
-rw-r--r-- | gui/resources/happy.png | bin | 0 -> 322 bytes | |||
-rw-r--r-- | gui/resources/idle.png | bin | 0 -> 322 bytes | |||
-rw-r--r-- | gui/resources/styles.qss | 22 |
9 files changed, 79 insertions, 27 deletions
@@ -19,16 +19,29 @@ #include "./ui_gui.h" #include "dynamicwaysentry.h" #include "messages.h" +#include <QPixmap> +#include <QString> GUI::GUI(QWidget *parent) : QMainWindow(parent), ui(new Ui::GUI) { ui->setupUi(this); + /* setup the status bar */ + ui->statusBar->setFixedHeight(20); + + this->avatar = new QLabel(this); this->status_label = new QLabel("", this); - this->set_status(get_waiting); QLabel *risc_vector = new QLabel("RISC V[ECTOR], CS535 UMASS AMHERST", this); - status_label->setMinimumWidth(1200); + + avatar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + avatar->setObjectName("avatar_label"); + status_label->setObjectName("msg_label"); + risc_vector->setObjectName("info_label"); + ui->statusBar->setSizeGripEnabled(false); + + this->set_status(get_waiting, "idle.png"); + ui->statusBar->addWidget(avatar); ui->statusBar->addWidget(status_label); ui->statusBar->addPermanentWidget(risc_vector); @@ -252,7 +265,7 @@ void GUI::on_upload_intructions_btn_clicked() "Binary Files (*.bin *.rv);;All Files (*.*)"); QFile file(filePath); if (filePath.isEmpty() || !file.open(QIODevice::ReadOnly)) { - this->set_status(get_no_instructions); + this->set_status(get_no_instructions, "angry"); return; } @@ -270,9 +283,9 @@ void GUI::on_upload_intructions_btn_clicked() } if (this->p.empty()) - this->set_status(get_no_instructions); + this->set_status(get_no_instructions, "angry"); else - this->set_status(get_load_file); + this->set_status(get_load_file, "happy"); file.close(); } @@ -305,10 +318,10 @@ void GUI::on_step_btn_clicked() if (!this->ready) return; - this->set_status(get_running); + this->set_status(get_running, "busy"); int steps = step_values[ui->step_slider->value()]; emit sendRunSteps(steps); - this->set_status(get_waiting); + this->set_status(get_waiting, "idle"); } void GUI::on_save_program_state_btn_clicked() @@ -333,13 +346,13 @@ void GUI::on_config_clicked() if (i != -1) { ways.push_back((unsigned int)i); } else { - this->set_status(get_bad_cache); + this->set_status(get_bad_cache, "angry"); return; } } if (this->p.empty()) { - this->set_status(get_no_instructions); + this->set_status(get_no_instructions, "angry"); return; } @@ -347,17 +360,28 @@ void GUI::on_config_clicked() // say something snarky if (!is_pipelined) - this->set_status(get_no_pipeline); + this->set_status(get_no_pipeline, "angry"); else if (ways.size() == 0) - this->set_status(get_no_cache); + this->set_status(get_no_cache, "angry"); else - this->set_status(get_initialize); + this->set_status(get_initialize, "happy"); emit sendConfigure(ways, this->p, is_pipelined); } -void GUI::set_status(const std::function<std::string()> &func) +void GUI::set_status( + const std::function<std::string()> &func, const QString &img) { this->status_label->setText( - "COMPUTER SAYS: \"" + QString::fromStdString(func()) + "\""); + "-> \"" + QString::fromStdString(func()) + "\""); + + QString img_path = ":resources/" + img; + QPixmap pixmap(img_path); + + if (!pixmap) { + return; + } + + this->avatar->setPixmap(pixmap); + this->avatar->show(); } @@ -51,15 +51,16 @@ class GUI : public QMainWindow /** * Uses `func' to set the current status. * @param a function which returns a string. + * @param a path to the desired avatar */ - void set_status(const std::function<std::string()> &func); + void set_status( + const std::function<std::string()> &func, + const QString &img = "idle.png"); signals: void sendRunSteps(int steps); void sendConfigure( - std::vector<unsigned int> ways, - vector<int> program, - bool is_pipelined); + std::vector<unsigned int> ways, vector<int> program, bool is_pipelined); private slots: void on_worker_refresh_gui(int value, int pc); @@ -117,6 +118,11 @@ class GUI : public QMainWindow QLabel *status_label; /** + * The robot image displayed on the status bar. + */ + QLabel *avatar; + + /** * The currently loaded program. */ std::vector<signed int> p; diff --git a/gui/messages.h b/gui/messages.h index adae777..03c0ab3 100644 --- a/gui/messages.h +++ b/gui/messages.h @@ -9,19 +9,15 @@ #define RANDOM_MESSAGE(v) (v[std::rand() % v.size()]) const std::vector<std::string> waiting = { - "WAITING FOR USER", "READY", "BORED", "SLEEPING"}; -const std::vector<std::string> running = { - "COMPUTING", "WORKING", "BUSY"}; + "WAITING FOR USER", "IDLE", "BORED", "SLEEPING"}; +const std::vector<std::string> running = {"COMPUTING", "WORKING", "BUSY"}; const std::vector<std::string> load_file = {"FILE LOADED"}; const std::vector<std::string> no_instructions = { - "NO PROGRAM PROVIDED", "INSTRUCTIONS NOT INCLUDED", - "NOTHING TO DO, GIVING UP"}; + "NO PROGRAM PROVIDED", "NOTHING TO DO, GIVING UP"}; const std::vector<std::string> bad_cache = { "WAYS CANNOT BE BELOW 0 OR ABOVE 5"}; -const std::vector<std::string> no_pipeline = { - "SIMULATION READY: NO PIPE :(", "SIMULATION READY"}; -const std::vector<std::string> no_cache = { - "SIMULATION READY: NO WAYS", "SIMULATION READY"}; +const std::vector<std::string> no_pipeline = {"SIMULATION READY: NO PIPE"}; +const std::vector<std::string> no_cache = {"SIMULATION READY: NO CACHE"}; const std::vector<std::string> initialize = {"SIMULATION READY"}; /** diff --git a/gui/resources.qrc b/gui/resources.qrc index 59fb36f..569cc22 100644 --- a/gui/resources.qrc +++ b/gui/resources.qrc @@ -2,6 +2,10 @@ <RCC version="1.0"> <qresource> <file>resources/styles.qss</file> + <file>resources/idle.png</file> + <file>resources/angry.png</file> + <file>resources/happy.png</file> + <file>resources/busy.png</file> <file>resources/BigBlueTermPlusNerdFontMono-Regular.ttf</file> </qresource> </RCC> diff --git a/gui/resources/angry.png b/gui/resources/angry.png Binary files differnew file mode 100644 index 0000000..3299eb4 --- /dev/null +++ b/gui/resources/angry.png diff --git a/gui/resources/busy.png b/gui/resources/busy.png Binary files differnew file mode 100644 index 0000000..df1b36a --- /dev/null +++ b/gui/resources/busy.png diff --git a/gui/resources/happy.png b/gui/resources/happy.png Binary files differnew file mode 100644 index 0000000..6168e89 --- /dev/null +++ b/gui/resources/happy.png diff --git a/gui/resources/idle.png b/gui/resources/idle.png Binary files differnew file mode 100644 index 0000000..f894716 --- /dev/null +++ b/gui/resources/idle.png diff --git a/gui/resources/styles.qss b/gui/resources/styles.qss index 9562b69..dbaa623 100644 --- a/gui/resources/styles.qss +++ b/gui/resources/styles.qss @@ -6,6 +6,28 @@ border: 0px solid "#000200"; } +QStatusBar { + font-size: 12pt; + color: "#000200"; + background-color: "#00cc00"; +} + +QLabel#msg_label { + font-size: 12pt; + color: "#000200"; + background-color: "#00cc00"; +} + +QLabel#info_label { + font-size: 12pt; + color: "#000200"; + background-color: "#00cc00"; +} + +QLabel#avatar_label { + background-color: "#00cc00"; +} + /* main window */ QWidget { } |