mirror of
https://github.com/YACReader/yacreader
synced 2026-03-01 10:22:58 -05:00
Add toolbar and background theming to YACReader
This commit is contained in:
@ -2,6 +2,8 @@
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "theme_manager.h"
|
||||
|
||||
PageLabelWidget::PageLabelWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
@ -25,13 +27,13 @@ PageLabelWidget::PageLabelWidget(QWidget *parent)
|
||||
|
||||
int contentMargin = 0;
|
||||
if (verticalRes <= 1024) {
|
||||
textLabel->setStyleSheet("QLabel { color : white; font-size:12px; }");
|
||||
fontSizePx = 12;
|
||||
contentMargin = 12;
|
||||
} else if (verticalRes <= 1200) {
|
||||
textLabel->setStyleSheet("QLabel { color : white; font-size:16px; }");
|
||||
fontSizePx = 16;
|
||||
contentMargin = 16;
|
||||
} else {
|
||||
textLabel->setStyleSheet("QLabel { color : white; font-size:20px; }");
|
||||
fontSizePx = 20;
|
||||
contentMargin = 20;
|
||||
}
|
||||
|
||||
@ -47,6 +49,8 @@ PageLabelWidget::PageLabelWidget(QWidget *parent)
|
||||
|
||||
if (parent != nullptr)
|
||||
move(QPoint((parent->geometry().size().width() - this->width()), -this->height()));
|
||||
|
||||
initTheme(this);
|
||||
}
|
||||
|
||||
void PageLabelWidget::show()
|
||||
@ -90,7 +94,7 @@ void PageLabelWidget::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
painter.fillRect(0, 0, width(), height(), QColor(0xBB000000));
|
||||
painter.fillRect(rect(), infoBackgroundColor);
|
||||
}
|
||||
|
||||
void PageLabelWidget::updatePosition()
|
||||
@ -106,3 +110,14 @@ void PageLabelWidget::updatePosition()
|
||||
else
|
||||
move(QPoint((parent->geometry().size().width() - this->width()), -this->height()));
|
||||
}
|
||||
|
||||
void PageLabelWidget::applyTheme()
|
||||
{
|
||||
const auto viewerTheme = ThemeManager::instance().getCurrentTheme().viewer;
|
||||
|
||||
infoBackgroundColor = viewerTheme.infoBackgroundColor;
|
||||
|
||||
textLabel->setStyleSheet(viewerTheme.infoLabelQSS.arg(fontSizePx));
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user