mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
DolphinQt: Add utility function for creating label text with a standard icon.
This commit is contained in:
@ -4,6 +4,8 @@
|
||||
#include "DolphinQt/QtUtils/QtUtils.h"
|
||||
|
||||
#include <QDateTimeEdit>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
namespace QtUtils
|
||||
{
|
||||
@ -19,4 +21,18 @@ void ShowFourDigitYear(QDateTimeEdit* widget)
|
||||
}
|
||||
}
|
||||
|
||||
QWidget* CreateIconWarning(QWidget* parent, QStyle::StandardPixmap standard_pixmap, QLabel* label)
|
||||
{
|
||||
const auto size = QFontMetrics(parent->font()).height() * 5 / 4;
|
||||
|
||||
auto* const icon = new QLabel{};
|
||||
icon->setPixmap(parent->style()->standardIcon(standard_pixmap).pixmap(size, size));
|
||||
|
||||
auto* const widget = new QWidget;
|
||||
auto* const layout = new QHBoxLayout{widget};
|
||||
layout->addWidget(icon);
|
||||
layout->addWidget(label, 1);
|
||||
return widget;
|
||||
}
|
||||
|
||||
} // namespace QtUtils
|
||||
|
Reference in New Issue
Block a user