Ladybird/Qt: Display drown-down settings using QPushButton

The default behavior of QPushButton is much closer to what we want from
a drop-down menu, as shown in the QPushButton::setMenu documentation:
https://doc.qt.io/qt-6/qpushbutton.html#setMenu

This also results in much less of a "squished" look than before.
This commit is contained in:
Timothy Flynn 2023-10-20 10:00:41 -04:00 committed by Tim Flynn
parent 63577e8d1c
commit e7d977f58d
Notes: sideshowbarker 2024-07-17 04:09:56 +09:00
2 changed files with 6 additions and 7 deletions

View file

@ -23,14 +23,16 @@ SettingsDialog::SettingsDialog(QMainWindow* window)
m_enable_search = make<QCheckBox>(this);
m_enable_search->setChecked(Settings::the()->enable_search());
m_search_engine_dropdown = make<QToolButton>(this);
m_search_engine_dropdown = make<QPushButton>(this);
m_search_engine_dropdown->setText(qstring_from_ak_deprecated_string(Settings::the()->search_engine().name));
m_search_engine_dropdown->setMaximumWidth(200);
m_enable_autocomplete = make<QCheckBox>(this);
m_enable_autocomplete->setChecked(Settings::the()->enable_autocomplete());
m_autocomplete_engine_dropdown = make<QToolButton>(this);
m_autocomplete_engine_dropdown = make<QPushButton>(this);
m_autocomplete_engine_dropdown->setText(Settings::the()->autocomplete_engine().name);
m_autocomplete_engine_dropdown->setMaximumWidth(200);
m_new_tab_page = make<QLineEdit>(this);
m_new_tab_page->setText(Settings::the()->new_tab_page());
@ -85,7 +87,6 @@ void SettingsDialog::setup_search_engines()
search_engine_menu->addAction(action);
}
m_search_engine_dropdown->setMenu(search_engine_menu);
m_search_engine_dropdown->setPopupMode(QToolButton::InstantPopup);
m_search_engine_dropdown->setEnabled(Settings::the()->enable_search());
QMenu* autocomplete_engine_menu = new QMenu(this);
@ -98,7 +99,6 @@ void SettingsDialog::setup_search_engines()
autocomplete_engine_menu->addAction(action);
}
m_autocomplete_engine_dropdown->setMenu(autocomplete_engine_menu);
m_autocomplete_engine_dropdown->setPopupMode(QToolButton::InstantPopup);
m_autocomplete_engine_dropdown->setEnabled(Settings::the()->enable_autocomplete());
connect(m_enable_search, &QCheckBox::stateChanged, this, [&](int state) {

View file

@ -12,7 +12,6 @@
#include <QLineEdit>
#include <QMainWindow>
#include <QPushButton>
#include <QToolButton>
#pragma once
@ -30,9 +29,9 @@ private:
QMainWindow* m_window { nullptr };
OwnPtr<QLineEdit> m_new_tab_page;
OwnPtr<QCheckBox> m_enable_search;
OwnPtr<QToolButton> m_search_engine_dropdown;
OwnPtr<QPushButton> m_search_engine_dropdown;
OwnPtr<QCheckBox> m_enable_autocomplete;
OwnPtr<QToolButton> m_autocomplete_engine_dropdown;
OwnPtr<QPushButton> m_autocomplete_engine_dropdown;
};
}