From 4c91f999a6df58ea0764a880a4d47ebbc0f42f05 Mon Sep 17 00:00:00 2001 From: "Satoru;1816" <81326989+Satoru-1816@users.noreply.github.com> Date: Fri, 2 Aug 2024 22:07:32 -0300 Subject: [PATCH] Start working on the Emote Menu thingy --- include/widgets/emote_menu_filter.h | 44 +++++++++++ resource/ui/emote_filter_menu.ui | 110 ++++++++++++++++++++++++++++ src/widgets/emote_menu_filter.cpp | 70 ++++++++++++++++++ 3 files changed, 224 insertions(+) create mode 100644 include/widgets/emote_menu_filter.h create mode 100644 resource/ui/emote_filter_menu.ui create mode 100644 src/widgets/emote_menu_filter.cpp diff --git a/include/widgets/emote_menu_filter.h b/include/widgets/emote_menu_filter.h new file mode 100644 index 000000000..688140647 --- /dev/null +++ b/include/widgets/emote_menu_filter.h @@ -0,0 +1,44 @@ +#ifndef EMOTE_MENU_FILTER_H +#define EMOTE_MENU_FILTER_H + +#include "aoemotebutton.h" + +#include +#include +#include +#include +#include +#include + +class AOApplication; + +QT_BEGIN_NAMESPACE +namespace Ui { class EmoteMenuFilter; } +QT_END_NAMESPACE + +class EmoteMenuFilter : public QDialog +{ + Q_OBJECT + +public: + EmoteMenuFilter(QDialog *parent = nullptr, AOApplication *p_ao_app = nullptr); + ~EmoteMenuFilter(); + +private slots: + void onCategoryChanged(); + void onSearchTextChanged(const QString &text); + +private: + AOApplication *ao_app; + Ui::EmoteMenuFilter *emote_filter_ui; + QListWidget *categoryList; + QLineEdit *searchBox; + QScrollArea *scrollArea; + QWidget *buttonContainer; + QGridLayout *gridLayout; + QPushButton *addCategory; + QPushButton *removeCategory; + +}; + +#endif // EMOTE_MENU_FILTER_H diff --git a/resource/ui/emote_filter_menu.ui b/resource/ui/emote_filter_menu.ui new file mode 100644 index 000000000..a730ad16d --- /dev/null +++ b/resource/ui/emote_filter_menu.ui @@ -0,0 +1,110 @@ + + + Dialog + + + + 0 + 0 + 480 + 300 + + + + Dialog + + + + + + + + Remove + + + + + + + + 290 + 0 + + + + true + + + + + 0 + 0 + 288 + 223 + + + + + + + + + + + + + + + + + + + + + + + + Search... + + + + + + + Add + + + + + + + + + + false + + + + Default Emotes + + + AlignCenter + + + + + Favorites + + + AlignCenter + + + + + + + + + + + diff --git a/src/widgets/emote_menu_filter.cpp b/src/widgets/emote_menu_filter.cpp new file mode 100644 index 000000000..9cebebc0b --- /dev/null +++ b/src/widgets/emote_menu_filter.cpp @@ -0,0 +1,70 @@ +#include "emote_menu_filter.h" +#include "aoemotebutton.h" +#include "aoapplication.h" +#include +#include +#include + +EmoteMenuFilter::EmoteMenuFilter(QDialog *parent, AOApplication *p_ao_app) + : QDialog(parent), ao_app(p_ao_app), emote_filter_ui(new Ui::EmoteMenuFilter) +{ + emote_filter_ui->setupUi(this); + + categoryList = new QListWidget(this); + categoryList->addItem("Default Emotes"); + categoryList->addItem("Favorites"); + + searchBox = new QLineEdit(this); + scrollArea = new QScrollArea(this); + buttonContainer = new QWidget(this); + gridLayout = new QGridLayout(buttonContainer); + addCategory = new QPushButton("Add Category", this); + removeCategory = new QPushButton("Remove Category", this); + + scrollArea->setWidget(buttonContainer); + scrollArea->setWidgetResizable(true); + + QVBoxLayout *mainLayout = new QVBoxLayout(this); + mainLayout->addWidget(searchBox); + mainLayout->addWidget(categoryList); + mainLayout->addWidget(scrollArea); + mainLayout->addWidget(addCategory); + mainLayout->addWidget(removeCategory); + setLayout(mainLayout); + + // connect(categoryList, &QListWidget::currentTextChanged, this, &EmoteMenuFilter::onCategoryChanged); + connect(addCategory, &QPushButton::clicked, this, &EmoteMenuFilter::addCategory); + connect(removeCategory, &QPushButton::clicked, this, &EmoteMenuFilter::removeCategory); + // connect(searchBox, &QLineEdit::textChanged, this, &EmoteMenuFilter::onSearchTextChanged); +} + +EmoteMenuFilter::~EmoteMenuFilter() +{ + delete emote_filter_ui; +} + +void EmoteMenuFilter::onCategoryChanged() +{ + return; +} + +void EmoteMenuFilter::addCategory() +{ + bool ok; + QString category = QInputDialog::getText(this, tr("Add Category"), + tr("Category name:"), QLineEdit::Normal, + "", &ok); + if (ok && !category.isEmpty()) { + categoryList->addItem(category); + } +} + +void EmoteMenuFilter::removeCategory() +{ + QListWidgetItem *item = categoryList->currentItem(); + if (item) { + delete item; + } else { + QMessageBox::warning(this, tr("Remove Category"), tr("No category selected")); + } +}