Welcome: Derive Core::Button from QAbstractButton

Enable a hover effect on macOS and remove the need for the setFlat hack.

Change-Id: Iea77ccaddcff0e9ad9299ffda8584160dca6413a
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Alessandro Portale
2024-03-06 20:04:10 +01:00
parent 0539e2a0f6
commit 9832af9701
4 changed files with 6 additions and 8 deletions

View File

@@ -134,12 +134,10 @@ static const TextFormat &buttonTF(Button::Role role, WidgetState state)
}
Button::Button(const QString &text, Role role, QWidget *parent)
: QPushButton(text, parent)
: QAbstractButton(parent)
, m_role(role)
{
// Prevent QMacStyle::subElementRect(SE_PushButtonLayoutItem) from changing our geometry
setFlat(true);
setText(text);
updateMargins();
if (m_role == SmallList)
setCheckable(true);

View File

@@ -70,7 +70,7 @@ CORE_EXPORT QWidget *createRule(Qt::Orientation orientation, QWidget *parent = n
} // namespace WelcomePageHelpers
class CORE_EXPORT Button : public QPushButton
class CORE_EXPORT Button : public QAbstractButton
{
public:
enum Role {

View File

@@ -9,10 +9,10 @@
#include <QWidget>
QT_BEGIN_NAMESPACE
class QAbstractButton;
class QItemSelectionModel;
class QLineEdit;
class QListView;
class QPushButton;
class QSortFilterProxyModel;
QT_END_NAMESPACE
@@ -58,7 +58,7 @@ private:
QScopedPointer<QStandardItemModel> m_model;
QLineEdit *m_searchBox;
QPushButton *m_updateButton;
QAbstractButton *m_updateButton;
QListView *m_extensionsView;
QItemSelectionModel *m_selectionModel = nullptr;
QSortFilterProxyModel *m_filterProxyModel;

View File

@@ -73,7 +73,7 @@ private:
TopArea *m_topArea;
SideArea *m_sideArea;
QList<IWelcomePage *> m_pluginList;
QList<QPushButton *> m_pageButtons;
QList<QAbstractButton *> m_pageButtons;
QButtonGroup *m_buttonGroup;
Id m_activePage;
Id m_defaultPage;