Client: Improve the look of bradient
[ChangeLog][QPA plugin] The window decorations have had a redesign, they now use the window background color instead of the blue gradient. Changes: - Removed the gradient - Used QPalette::Window for color instead of QPalette::Highlight - Removed the xpm buttons as they look bad on high-dpi - Redid the non-xpm buttons, removing their border - Used anti-aliasing for cross icon (diagonal lines) - Size of buttons have been increased, to be easier to click - The position of the buttons have been shifted slightly - Reduced rounding of the corners slightly - Switched to non-bold and increased the font size for the window title Task-number: QTBUG-68834 Change-Id: I17b2464c5e2518294d795512493bfe93e9a2f550 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
This commit is contained in:
parent
764a79e01d
commit
d923a19491
@ -55,72 +55,8 @@ QT_BEGIN_NAMESPACE
|
|||||||
namespace QtWaylandClient {
|
namespace QtWaylandClient {
|
||||||
|
|
||||||
#define BUTTON_SPACING 5
|
#define BUTTON_SPACING 5
|
||||||
|
#define BUTTON_WIDTH 18
|
||||||
#if QT_CONFIG(imageformat_xpm)
|
#define BUTTONS_RIGHT_MARGIN 8
|
||||||
# define BUTTON_WIDTH 10
|
|
||||||
|
|
||||||
static const char * const qt_close_xpm[] = {
|
|
||||||
"10 10 2 1",
|
|
||||||
"# c #000000",
|
|
||||||
". c None",
|
|
||||||
"..........",
|
|
||||||
".##....##.",
|
|
||||||
"..##..##..",
|
|
||||||
"...####...",
|
|
||||||
"....##....",
|
|
||||||
"...####...",
|
|
||||||
"..##..##..",
|
|
||||||
".##....##.",
|
|
||||||
"..........",
|
|
||||||
".........."};
|
|
||||||
|
|
||||||
static const char * const qt_maximize_xpm[]={
|
|
||||||
"10 10 2 1",
|
|
||||||
"# c #000000",
|
|
||||||
". c None",
|
|
||||||
"#########.",
|
|
||||||
"#########.",
|
|
||||||
"#.......#.",
|
|
||||||
"#.......#.",
|
|
||||||
"#.......#.",
|
|
||||||
"#.......#.",
|
|
||||||
"#.......#.",
|
|
||||||
"#.......#.",
|
|
||||||
"#########.",
|
|
||||||
".........."};
|
|
||||||
|
|
||||||
static const char * const qt_minimize_xpm[] = {
|
|
||||||
"10 10 2 1",
|
|
||||||
"# c #000000",
|
|
||||||
". c None",
|
|
||||||
"..........",
|
|
||||||
"..........",
|
|
||||||
"..........",
|
|
||||||
"..........",
|
|
||||||
"..........",
|
|
||||||
"..........",
|
|
||||||
"..........",
|
|
||||||
".#######..",
|
|
||||||
".#######..",
|
|
||||||
".........."};
|
|
||||||
|
|
||||||
static const char * const qt_normalizeup_xpm[] = {
|
|
||||||
"10 10 2 1",
|
|
||||||
"# c #000000",
|
|
||||||
". c None",
|
|
||||||
"...######.",
|
|
||||||
"...######.",
|
|
||||||
"...#....#.",
|
|
||||||
".######.#.",
|
|
||||||
".######.#.",
|
|
||||||
".#....###.",
|
|
||||||
".#....#...",
|
|
||||||
".#....#...",
|
|
||||||
".######...",
|
|
||||||
".........."};
|
|
||||||
#else
|
|
||||||
# define BUTTON_WIDTH 22
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum Button
|
enum Button
|
||||||
{
|
{
|
||||||
@ -161,8 +97,8 @@ private:
|
|||||||
QWaylandBradientDecoration::QWaylandBradientDecoration()
|
QWaylandBradientDecoration::QWaylandBradientDecoration()
|
||||||
{
|
{
|
||||||
QPalette palette;
|
QPalette palette;
|
||||||
m_foregroundColor = palette.color(QPalette::Active, QPalette::HighlightedText);
|
m_foregroundColor = palette.color(QPalette::Active, QPalette::WindowText);
|
||||||
m_backgroundColor = palette.color(QPalette::Active, QPalette::Highlight);
|
m_backgroundColor = palette.color(QPalette::Active, QPalette::Window);
|
||||||
|
|
||||||
QTextOption option(Qt::AlignHCenter | Qt::AlignVCenter);
|
QTextOption option(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
option.setWrapMode(QTextOption::NoWrap);
|
option.setWrapMode(QTextOption::NoWrap);
|
||||||
@ -171,19 +107,19 @@ QWaylandBradientDecoration::QWaylandBradientDecoration()
|
|||||||
|
|
||||||
QRectF QWaylandBradientDecoration::closeButtonRect() const
|
QRectF QWaylandBradientDecoration::closeButtonRect() const
|
||||||
{
|
{
|
||||||
return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH - BUTTON_SPACING * 2,
|
return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH - BUTTON_SPACING * 0 - BUTTONS_RIGHT_MARGIN,
|
||||||
(margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
|
(margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF QWaylandBradientDecoration::maximizeButtonRect() const
|
QRectF QWaylandBradientDecoration::maximizeButtonRect() const
|
||||||
{
|
{
|
||||||
return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH * 2 - BUTTON_SPACING * 3,
|
return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH * 2 - BUTTON_SPACING * 1 - BUTTONS_RIGHT_MARGIN,
|
||||||
(margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
|
(margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF QWaylandBradientDecoration::minimizeButtonRect() const
|
QRectF QWaylandBradientDecoration::minimizeButtonRect() const
|
||||||
{
|
{
|
||||||
return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH * 3 - BUTTON_SPACING * 4,
|
return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH * 3 - BUTTON_SPACING * 2 - BUTTONS_RIGHT_MARGIN,
|
||||||
(margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
|
(margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,16 +145,12 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
|
|||||||
p.setRenderHint(QPainter::Antialiasing);
|
p.setRenderHint(QPainter::Antialiasing);
|
||||||
|
|
||||||
// Title bar
|
// Title bar
|
||||||
QLinearGradient grad(top.topLeft(), top.bottomLeft());
|
|
||||||
QColor base(m_backgroundColor);
|
|
||||||
grad.setColorAt(0, base.lighter(100));
|
|
||||||
grad.setColorAt(1, base.darker(180));
|
|
||||||
QPainterPath roundedRect;
|
QPainterPath roundedRect;
|
||||||
roundedRect.addRoundedRect(surfaceRect, 6, 6);
|
roundedRect.addRoundedRect(surfaceRect, 3, 3);
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
p.save();
|
p.save();
|
||||||
p.setClipRect(clips[i]);
|
p.setClipRect(clips[i]);
|
||||||
p.fillPath(roundedRect, grad);
|
p.fillPath(roundedRect, m_backgroundColor);
|
||||||
p.restore();
|
p.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,8 +186,7 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
|
|||||||
int dx = (top.width() - size.width()) /2;
|
int dx = (top.width() - size.width()) /2;
|
||||||
int dy = (top.height()- size.height()) /2;
|
int dy = (top.height()- size.height()) /2;
|
||||||
QFont font = p.font();
|
QFont font = p.font();
|
||||||
font.setBold(true);
|
font.setPixelSize(14);
|
||||||
font.setPixelSize(12);
|
|
||||||
p.setFont(font);
|
p.setFont(font);
|
||||||
QPoint windowTitlePoint(top.topLeft().x() + dx,
|
QPoint windowTitlePoint(top.topLeft().x() + dx,
|
||||||
top.topLeft().y() + dy);
|
top.topLeft().y() + dy);
|
||||||
@ -263,26 +194,6 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
|
|||||||
p.restore();
|
p.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_CONFIG(imageformat_xpm)
|
|
||||||
p.save();
|
|
||||||
|
|
||||||
// Close button
|
|
||||||
QPixmap closePixmap(qt_close_xpm);
|
|
||||||
p.drawPixmap(closeButtonRect(), closePixmap, closePixmap.rect());
|
|
||||||
|
|
||||||
// Maximize button
|
|
||||||
QPixmap maximizePixmap((window()->windowStates() & Qt::WindowMaximized) ? qt_normalizeup_xpm : qt_maximize_xpm);
|
|
||||||
p.drawPixmap(maximizeButtonRect(), maximizePixmap, maximizePixmap.rect());
|
|
||||||
|
|
||||||
// Minimize button
|
|
||||||
QPixmap minimizePixmap(qt_minimize_xpm);
|
|
||||||
p.drawPixmap(minimizeButtonRect(), minimizePixmap, minimizePixmap.rect());
|
|
||||||
|
|
||||||
p.restore();
|
|
||||||
#else
|
|
||||||
// We don't need antialiasing from now on
|
|
||||||
p.setRenderHint(QPainter::Antialiasing, false);
|
|
||||||
|
|
||||||
QRectF rect;
|
QRectF rect;
|
||||||
|
|
||||||
// Default pen
|
// Default pen
|
||||||
@ -292,8 +203,7 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
|
|||||||
// Close button
|
// Close button
|
||||||
p.save();
|
p.save();
|
||||||
rect = closeButtonRect();
|
rect = closeButtonRect();
|
||||||
p.drawRect(rect);
|
qreal crossSize = rect.height() / 2.3;
|
||||||
qreal crossSize = rect.height() / 2;
|
|
||||||
QPointF crossCenter(rect.center());
|
QPointF crossCenter(rect.center());
|
||||||
QRectF crossRect(crossCenter.x() - crossSize / 2, crossCenter.y() - crossSize / 2, crossSize, crossSize);
|
QRectF crossRect(crossCenter.x() - crossSize / 2, crossCenter.y() - crossSize / 2, crossSize, crossSize);
|
||||||
pen.setWidth(2);
|
pen.setWidth(2);
|
||||||
@ -304,15 +214,16 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
|
|||||||
|
|
||||||
// Maximize button
|
// Maximize button
|
||||||
p.save();
|
p.save();
|
||||||
p.drawRect(maximizeButtonRect());
|
p.setRenderHint(QPainter::Antialiasing, false);
|
||||||
rect = maximizeButtonRect().adjusted(5, 5, -5, -5);
|
rect = maximizeButtonRect().adjusted(4, 5, -4, -5);
|
||||||
if ((window()->windowStates() & Qt::WindowMaximized)) {
|
if ((window()->windowStates() & Qt::WindowMaximized)) {
|
||||||
QRectF rect1 = rect.adjusted(rect.width() / 3, 0, 0, -rect.height() / 3);
|
qreal inset = 2;
|
||||||
QRectF rect2 = rect.adjusted(0, rect.height() / 4, -rect.width() / 4, 0);
|
QRectF rect1 = rect.adjusted(inset, 0, 0, -inset);
|
||||||
|
QRectF rect2 = rect.adjusted(0, inset, -inset, 0);
|
||||||
p.drawRect(rect1);
|
p.drawRect(rect1);
|
||||||
|
p.setBrush(m_backgroundColor); // need to cover up some lines from the other rect
|
||||||
p.drawRect(rect2);
|
p.drawRect(rect2);
|
||||||
} else {
|
} else {
|
||||||
p.setPen(m_foregroundColor);
|
|
||||||
p.drawRect(rect);
|
p.drawRect(rect);
|
||||||
p.drawLine(rect.left(), rect.top() + 1, rect.right(), rect.top() + 1);
|
p.drawLine(rect.left(), rect.top() + 1, rect.right(), rect.top() + 1);
|
||||||
}
|
}
|
||||||
@ -320,13 +231,12 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
|
|||||||
|
|
||||||
// Minimize button
|
// Minimize button
|
||||||
p.save();
|
p.save();
|
||||||
p.drawRect(minimizeButtonRect());
|
p.setRenderHint(QPainter::Antialiasing, false);
|
||||||
rect = minimizeButtonRect().adjusted(5, 5, -5, -5);
|
rect = minimizeButtonRect().adjusted(5, 5, -5, -5);
|
||||||
pen.setWidth(2);
|
pen.setWidth(2);
|
||||||
p.setPen(pen);
|
p.setPen(pen);
|
||||||
p.drawLine(rect.bottomLeft(), rect.bottomRight());
|
p.drawLine(rect.bottomLeft(), rect.bottomRight());
|
||||||
p.restore();
|
p.restore();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QWaylandBradientDecoration::clickButton(Qt::MouseButtons b, Button btn)
|
bool QWaylandBradientDecoration::clickButton(Qt::MouseButtons b, Button btn)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user