Skip to content
Closed
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
14 changes: 13 additions & 1 deletion src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,11 @@ qreal calculateIdealFontSize(int width, const QString& text, QFont font, qreal m
return font_size;
}

ThemedLabel::ThemedLabel(QWidget* parent)
{
QLabel{parent};
}

Comment on lines +797 to +800
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
QLabel{parent};
}
: QLabel{parent} {}

ThemedLabel::ThemedLabel(const PlatformStyle* platform_style, QWidget* parent)
: QLabel{parent}, m_platform_style{platform_style}
{
Expand All @@ -807,6 +812,11 @@ void ThemedLabel::setThemedPixmap(const QString& image_filename, int width, int
updateThemedPixmap();
}

void ThemedLabel::setPlatformStyle(const PlatformStyle* platform_style)
{
m_platform_style = platform_style;
assert(m_platform_style);
}
void ThemedLabel::changeEvent(QEvent* e)
Comment on lines +819 to 820
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style nit: Add an empty line as a separator?

{
#ifdef Q_OS_MACOS
Expand All @@ -819,7 +829,9 @@ void ThemedLabel::changeEvent(QEvent* e)

void ThemedLabel::updateThemedPixmap()
{
setPixmap(m_platform_style->SingleColorIcon(m_image_filename).pixmap(m_pixmap_width, m_pixmap_height));
if (m_platform_style) {
setPixmap(m_platform_style->SingleColorIcon(m_image_filename).pixmap(m_pixmap_width, m_pixmap_height));
}
}

ClickableLabel::ClickableLabel(const PlatformStyle* platform_style, QWidget* parent)
Expand Down
4 changes: 3 additions & 1 deletion src/qt/guiutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,16 @@ namespace GUIUtil
Q_OBJECT

public:
explicit ThemedLabel(QWidget* parent = nullptr);
explicit ThemedLabel(const PlatformStyle* platform_style, QWidget* parent = nullptr);
void setThemedPixmap(const QString& image_filename, int width, int height);
void setPlatformStyle(const PlatformStyle* platform_style);

protected:
void changeEvent(QEvent* e) override;

private:
const PlatformStyle* m_platform_style;
const PlatformStyle* m_platform_style = nullptr;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{nullptr}

QString m_image_filename;
int m_pixmap_width;
int m_pixmap_height;
Expand Down