命名规范
This commit is contained in:
@@ -15,16 +15,16 @@ void Wifi::paintEvent(QPaintEvent *event) {
|
||||
QRect window(0, 0, 20, 10);
|
||||
painter.setWindow(window);
|
||||
double w = window.width(), h = window.height();
|
||||
QRect drawRect = getMaxRect(rect(), w / h);
|
||||
QRect drawRect = get_max_rect(rect(), w / h);
|
||||
painter.setViewport(drawRect);
|
||||
double rate = 1.5; // wife宽度 : 间隙宽度
|
||||
double baseHeightRate = 0.2;
|
||||
double spaceWidth = w/(1.0 * 4 + rate * 5);
|
||||
double stripWidth = spaceWidth * rate;
|
||||
double baseHeight = h * baseHeightRate;
|
||||
double raiseHeight = h * (1.0 - baseHeightRate)/4.0;
|
||||
double raiseWidth = spaceWidth + stripWidth;
|
||||
QRect textRect = QRect(0, 0, (int)(raiseWidth * 2), (int)(baseHeight * 2));
|
||||
double base_height_rate = 0.2;
|
||||
double space_width = w/(1.0 * 4 + rate * 5);
|
||||
double strip_width = space_width * rate;
|
||||
double base_height = h * base_height_rate;
|
||||
double raise_height = h * (1.0 - base_height_rate)/4.0;
|
||||
double raise_width = space_width + strip_width;
|
||||
QRect text_rect = QRect(0, 0, (int)(raise_width * 2), (int)(base_height * 2));
|
||||
QFont font;
|
||||
font.setPixelSize(5);
|
||||
font.setBold(true);
|
||||
@@ -32,12 +32,12 @@ void Wifi::paintEvent(QPaintEvent *event) {
|
||||
QPen pen;
|
||||
pen.setColor(Qt::white);
|
||||
painter.setPen(pen);
|
||||
painter.drawText(textRect, Qt::AlignJustify | Qt::AlignVCenter, "4G");
|
||||
painter.drawText(text_rect, Qt::AlignJustify | Qt::AlignVCenter, "4G");
|
||||
for(int i = 0; i < 5; ++i){
|
||||
double curHeight = baseHeight + i * raiseHeight;
|
||||
double curX = 0 + raiseWidth * i;
|
||||
double cur_height = base_height + i * raise_height;
|
||||
double cur_x = 0 + raise_width * i;
|
||||
QColor color = i < value ? Qt::white : QColor(0, 0, 0, 50);
|
||||
painter.fillRect(QRectF(curX, h - curHeight, stripWidth, curHeight), color);
|
||||
painter.fillRect(QRectF(cur_x, h - cur_height, strip_width, cur_height), color);
|
||||
}
|
||||
painter.end();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user