Refactor system page in GUI Alpha.

This commit is contained in:
sunwen
2024-04-25 14:37:38 +08:00
parent f9eb807fa3
commit 982b54b727
420 changed files with 23907 additions and 872 deletions

View File

@@ -16,13 +16,15 @@ void ListBox::paintEvent(QPaintEvent *e) {
QStylePainter painter(this);
QStyleOptionToolButton opt;
initStyleOption(&opt);
//在最后绘制按钮的时候将text清空避免绘制出左对齐的文字
opt.text.clear();
painter.drawComplexControl(QStyle::CC_ToolButton, opt);
//自行绘制居中对齐的文字
int x = (size().width() - this->iconSize().width()) / 2 - (this->text().length() * opt.font.pixelSize()) / 4;
int y = this->iconSize().height() + 2;
painter.drawText(x,y,this->text());
QFontMetrics fm(opt.font);
int textWidth = fm.horizontalAdvance(this->text());
int textHeight = fm.height();
int x = (size().width() - this->iconSize().width() - textWidth) / 2;
int y = (size().height() + textHeight) / 2 - fm.descent();
painter.drawText(x, y, this->text());
}
void ListBox::setSmallBox(bool isSmall) {