DolphinQt: Add utility function for creating label text with a standard icon.
This commit is contained in:
1 parent
059282df6f
commit
a45d00d84d
6 files changed
+46
-53
No files matched your search
@@ -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
|
||||
@@ -3,11 +3,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QStyle>
|
||||
|
||||
class QDateTimeEdit;
|
||||
class QLabel;
|
||||
class QWidget;
|
||||
|
||||
namespace QtUtils
|
||||
{
|
||||
|
||||
void ShowFourDigitYear(QDateTimeEdit* widget);
|
||||
|
||||
}
|
||||
QWidget* CreateIconWarning(QWidget* parent, QStyle::StandardPixmap standard_pixmap, QLabel* label);
|
||||
|
||||
} // namespace QtUtils
|
||||
Reference in new issue
Block a user