Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions Common/Qt/NoWheelComboBox.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* ComboBox without mouse wheel scrolling.
/* ComboBox without mouse wheel scrolling. Also, the height has been set to be more compact.
*
* From: https://github.com/PokemonAutomation/
*
Expand All @@ -8,15 +8,39 @@
#define PokemonAutomation_NoWheelComboBox_H

#include <QComboBox>
#include <QAbstractItemView>
#include <QStyledItemDelegate>

//#define PA_ENABLE_SIZE_CACHING

namespace PokemonAutomation{


class NoWheelComboBox : public QComboBox{
class HeightDelegate : public QStyledItemDelegate {
public:
using QComboBox::QComboBox;
using QStyledItemDelegate::QStyledItemDelegate;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override {
QSize s = QStyledItemDelegate::sizeHint(option, index);
int vertical_padding = 8;
s.setHeight(option.fontMetrics.height() + vertical_padding);
return s;
}
};


class NoWheelCompactComboBox : public QComboBox{
public:
explicit NoWheelCompactComboBox(QWidget* parent = nullptr) : QComboBox(parent) {
// Set the height for every line in the dropdown
this->view()->setItemDelegate(new HeightDelegate(this));

// this->setStyleSheet("QAbstractItemView::item { height: 100px; }");

// Optional: Force a standard list view to ensure the stylesheet
// is respected on all platforms (like Windows/macOS)
// #include <QListView>
// this->setView(new QListView());
}

void update_size_cache(){
#ifdef PA_ENABLE_SIZE_CACHING
Expand Down
2 changes: 1 addition & 1 deletion Common/Qt/Options/EnumDropdownWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ EnumDropdownCellWidget::~EnumDropdownCellWidget(){
m_value.remove_listener(*this);
}
EnumDropdownCellWidget::EnumDropdownCellWidget(QWidget& parent, IntegerEnumDropdownCell& value)
: NoWheelComboBox(&parent)
: NoWheelCompactComboBox(&parent)
, ConfigWidget(value, *this)
, m_value(value)
{
Expand Down
2 changes: 1 addition & 1 deletion Common/Qt/Options/EnumDropdownWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace PokemonAutomation{


class EnumDropdownCellWidget : public NoWheelComboBox, public ConfigWidget{
class EnumDropdownCellWidget : public NoWheelCompactComboBox, public ConfigWidget{
public:
using ParentOption = IntegerEnumDropdownCell;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ AudioSelectorWidget::AudioSelectorWidget(QWidget& parent, AudioSession& session)
layout1->addLayout(input_layout, CONSOLE_SETTINGS_STRETCH_L1_BODY);
layout1->addSpacing(5);

m_audio_input_box = new NoWheelComboBox(this);
m_audio_input_box = new NoWheelCompactComboBox(this);
m_audio_input_box->setMaxVisibleItems(20);
input_layout->addWidget(m_audio_input_box);

m_audio_format_box = new NoWheelComboBox(this);
m_audio_format_box = new NoWheelCompactComboBox(this);
layout1->addWidget(m_audio_format_box, CONSOLE_SETTINGS_STRETCH_L1_RIGHT);
layout1->addSpacing(5);

Expand All @@ -80,7 +80,7 @@ AudioSelectorWidget::AudioSelectorWidget(QWidget& parent, AudioSession& session)
layout1->addLayout(output_layout, CONSOLE_SETTINGS_STRETCH_L1_BODY);
layout1->addSpacing(5);

m_audio_output_box = new NoWheelComboBox(this);
m_audio_output_box = new NoWheelCompactComboBox(this);
m_audio_output_box->setMaxVisibleItems(20);
if (GlobalSettings::instance().AUDIO_PIPELINE->SHOW_RECORD_FREQUENCIES){
output_layout->addWidget(m_audio_output_box, 7);
Expand All @@ -98,7 +98,7 @@ AudioSelectorWidget::AudioSelectorWidget(QWidget& parent, AudioSession& session)
layout1->addWidget(m_volume_slider, 2);
layout1->addSpacing(5);

m_audio_vis_box = new NoWheelComboBox(this);
m_audio_vis_box = new NoWheelCompactComboBox(this);
m_audio_vis_box->addItem("No Display");
m_audio_vis_box->addItem("Spectrum");
m_audio_vis_box->addItem("Spectrogram");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,27 @@ PanelListWidget::PanelListWidget(
, m_panel_holder(holder)
{
// QFontMetrics fm(this->font());
// this->setStyleSheet(
// "QListWidget::item {"
// " margin: 0px;"
// " padding: 0px;" // Removes internal padding
// " border: none;"
// " height: 20px;" // FORCE a specific height (adjust this number)
// "}"
// );

int vertical_padding = 4;
int row_height = this->fontMetrics().height() + vertical_padding;
for (PanelEntry& item : list){
const std::string& display_name = item.display_name;
PanelDescriptor* descriptor = item.descriptor.get();

addItem(QString::fromStdString(display_name));
QListWidgetItem* list_item = this->item(this->count() - 1);
list_item->setData(Qt::SizeHintRole, QSize(0, row_height));

// Label/divider
if (descriptor == nullptr){
addItem(QString::fromStdString(display_name));
QListWidgetItem* list_item = this->item(this->count() - 1);
QFont font = list_item->font();
font.setBold(true);
list_item->setFont(font);
Expand All @@ -55,9 +68,7 @@ PanelListWidget::PanelListWidget(
throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "Duplicate program name: " + display_name);
}

addItem(QString::fromStdString(display_name));
// addItem(QString::fromStdString("DM Elvis for FREE SHINIES!!!"));
QListWidgetItem* list_item = this->item(this->count() - 1);
Color color = descriptor->color();
if (color){
QColor qcolor = QColor((uint32_t)color);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ VideoSourceSelectorWidget::VideoSourceSelectorWidget(Logger& logger, VideoSessio
layout0->addLayout(layout1, CONSOLE_SETTINGS_STRETCH_L0_RIGHT);
layout1->setContentsMargins(0, 0, 0, 0);

m_sources_box = new NoWheelComboBox(this);
m_sources_box = new NoWheelCompactComboBox(this);
m_sources_box->setMaxVisibleItems(20);
layout1->addWidget(m_sources_box, CONSOLE_SETTINGS_STRETCH_L1_BODY);
layout1->addSpacing(5);

m_resolution_box = new NoWheelComboBox(this);
m_resolution_box = new NoWheelCompactComboBox(this);
m_resolution_box->setMaxVisibleItems(20);
layout1->addWidget(m_resolution_box, CONSOLE_SETTINGS_STRETCH_L1_RIGHT);
layout1->addSpacing(5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ MainWindow::MainWindow(QWidget* parent)
QVBoxLayout* program_layout = new QVBoxLayout(program_box);
program_layout->setAlignment(Qt::AlignTop);

// NoWheelComboBox* program_dropdown = new NoWheelComboBox(this);
// NoWheelCompactComboBox* program_dropdown = new NoWheelCompactComboBox(this);
// program_layout->addWidget(program_dropdown);

m_program_list = new ProgramTabs(*this, *this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ LanguageOCRCellWidget::LanguageOCRCellWidget(QWidget& parent, LanguageOCRCell& v
{
QVBoxLayout* vbox = new QVBoxLayout(this);
vbox->setContentsMargins(0, 0, 0, 0);
m_box = new NoWheelComboBox(&parent);
m_box = new NoWheelCompactComboBox(&parent);

for (const auto& item : m_value.m_case_list){
// m_enum_to_index[item.first] = (int)m_index_to_enum.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ StringSelectCellWidget::~StringSelectCellWidget(){
m_value.remove_listener(*this);
}
StringSelectCellWidget::StringSelectCellWidget(QWidget& parent, StringSelectCell& value)
: NoWheelComboBox(&parent)
: NoWheelCompactComboBox(&parent)
, ConfigWidget(value, *this)
, m_value(value)
{
Expand Down Expand Up @@ -129,7 +129,7 @@ void StringSelectCellWidget::hide_options(){

}
QSize StringSelectCellWidget::sizeHint() const{
QSize ret = NoWheelComboBox::sizeHint();
QSize ret = NoWheelCompactComboBox::sizeHint();
// cout << ret.width() << " x " << ret.height() << endl;

double width = ret.width();
Expand All @@ -143,11 +143,11 @@ QSize StringSelectCellWidget::sizeHint() const{
void StringSelectCellWidget::focusInEvent(QFocusEvent* event){
// cout << "focusInEvent()" << endl;
update_value();
NoWheelComboBox::focusInEvent(event);
NoWheelCompactComboBox::focusInEvent(event);
}
void StringSelectCellWidget::focusOutEvent(QFocusEvent* event){
// cout << "focusOutEvent()" << endl;
NoWheelComboBox::focusOutEvent(event);
NoWheelCompactComboBox::focusOutEvent(event);
// update_value();
}
void StringSelectCellWidget::update_value(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace PokemonAutomation{


class StringSelectCellWidget : public NoWheelComboBox, public ConfigWidget{
class StringSelectCellWidget : public NoWheelCompactComboBox, public ConfigWidget{
public:
using ParentOption = StringSelectCell;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ControllerSelectorWidget::ControllerSelectorWidget(QWidget& parent, ControllerSe
layout1->addLayout(m_dropdowns, CONSOLE_SETTINGS_STRETCH_L1_BODY);
layout1->addSpacing(5);

interface_dropdown = new NoWheelComboBox(this);
interface_dropdown = new NoWheelCompactComboBox(this);
m_dropdowns->addWidget(interface_dropdown);

interface_dropdown->addItem(QString::fromStdString(CONTROLLER_INTERFACE_STRINGS.get_string(ControllerInterface::SerialPABotBase)));
Expand All @@ -65,7 +65,7 @@ ControllerSelectorWidget::ControllerSelectorWidget(QWidget& parent, ControllerSe


m_dropdowns->addSpacing(5);
m_controllers_dropdown = new NoWheelComboBox(this);
m_controllers_dropdown = new NoWheelCompactComboBox(this);
m_controllers_dropdown->setSizeAdjustPolicy(QComboBox::AdjustToContents);
m_dropdowns->addWidget(m_controllers_dropdown);
refresh_controllers(session.controller_type(), session.available_controllers());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ inline bool filter_serial_port(const QSerialPortInfo& port){



class SerialPABotBase_SelectorWidget : public NoWheelComboBox{
class SerialPABotBase_SelectorWidget : public NoWheelCompactComboBox{
public:
SerialPABotBase_SelectorWidget(
ControllerSelectorWidget& parent,
const ControllerDescriptor* current
)
: NoWheelComboBox(&parent)
: NoWheelCompactComboBox(&parent)
, m_parent(parent)
{
// cout << "SerialPABotBase(): " << current << endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ MultiSwitchSystemWidget::MultiSwitchSystemWidget(
row->setContentsMargins(0, 0, 0, 0);
row->addStretch(2);
row->addWidget(new QLabel("<b>Switch Count:</b>", this), 0);
m_console_count_box = new NoWheelComboBox(this);
m_console_count_box = new NoWheelCompactComboBox(this);
row->addWidget(m_console_count_box, 1);
row->addStretch(2);

Expand Down
2 changes: 1 addition & 1 deletion SerialPrograms/Source/PanelLists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ProgramSelect::ProgramSelect(QWidget& parent, PanelHolder& holder)
{
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setAlignment(Qt::AlignTop);
m_dropdown = new NoWheelComboBox(this);
m_dropdown = new NoWheelCompactComboBox(this);
m_dropdown->setMaxVisibleItems(20);
layout->addWidget(m_dropdown);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ NameSelectWidget::NameSelectWidget(
const std::vector<std::string>* extra_name_list,
const std::map<std::string, std::string>* extra_display_name_to_slug
)
: NoWheelComboBox(&parent)
: NoWheelCompactComboBox(&parent)
, m_display_name_to_slug(display_name_to_slug)
, m_extra_display_name_to_slug(extra_display_name_to_slug)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace PokemonAutomation{
namespace Pokemon{

// A widget to select a pokemon
class NameSelectWidget : public NoWheelComboBox{
class NameSelectWidget : public NoWheelCompactComboBox{
public:
// icons: pokemon slug -> icon. This map can be larger than the list of pokemon displayed on the widget.
// slugs: a list of pokemon slugs to choose from on the widget.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ EncounterFilterWidget::EncounterFilterWidget(QWidget& parent, EncounterFilterOpt
layout->addLayout(hbox);
hbox->addWidget(new QLabel("<b>Stop on:</b>"));

m_shininess = new NoWheelComboBox(this);
m_shininess = new NoWheelCompactComboBox(this);
hbox->addWidget(m_shininess);
for (const std::string& item : ShinyFilter_NAMES){
m_shininess->addItem(QString::fromStdString(item));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ EncounterFilterWidget::EncounterFilterWidget(QWidget& parent, EncounterFilterOpt
layout->addLayout(hbox);
hbox->addWidget(new QLabel("<b>Stop on:</b>"));

m_shininess = new NoWheelComboBox(this);
m_shininess = new NoWheelCompactComboBox(this);
hbox->addWidget(m_shininess);
if (m_value.m_rare_stars){
m_shininess->addItem(QString::fromStdString(ShinyFilter_NAMES[(int)ShinyFilter::ANYTHING]));
Expand Down