diff options
author | Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> | 2013-01-10 01:07:44 +0100 |
---|---|---|
committer | Jørgen Lind <jorgen.lind@gmail.com> | 2013-01-10 09:01:00 +0100 |
commit | 1ddfb323388ff079d1e492ca8bb6ea0e08344bd5 (patch) | |
tree | 21a4e2797a0536da6c0379608c5811d38daeb270 /src | |
parent | b483b70cc6d30828b9c7cf3fa176dc593b76037a (diff) |
Draw decorations using colors from QPalette.
Use colors from QPalette to draw the client-side decorations.
Also, draw using a linear gradient which makes the title bar look
three-dimensional.
Change-Id: Ib34ebc354f4c7556051a6164323fe178be13fe27
Reviewed-by: Jørgen Lind <jorgen.lind@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platforms/wayland/qwaylanddecoration.cpp | 26 | ||||
-rw-r--r-- | src/plugins/platforms/wayland/qwaylanddecoration.h | 9 |
2 files changed, 27 insertions, 8 deletions
diff --git a/src/plugins/platforms/wayland/qwaylanddecoration.cpp b/src/plugins/platforms/wayland/qwaylanddecoration.cpp index b27c7b36f..f9a580c2a 100644 --- a/src/plugins/platforms/wayland/qwaylanddecoration.cpp +++ b/src/plugins/platforms/wayland/qwaylanddecoration.cpp @@ -48,7 +48,8 @@ #include <QtGui/QGuiApplication> #include <QtGui/QCursor> #include <QtGui/QPainter> -#include <QtGui/QRadialGradient> +#include <QtGui/QPalette> +#include <QtGui/QLinearGradient> #define BUTTON_WIDTH 25 #define BUTTON_SPACING 5 @@ -59,9 +60,13 @@ QWaylandDecoration::QWaylandDecoration(QWaylandWindow *window) , m_margins(3,30,3,3) , m_hasSetCursor(false) , m_mouseButtons(Qt::NoButton) - , m_backgroundColor(90, 90, 100) { m_wayland_window->setDecoration(this); + + QPalette palette; + m_foregroundColor = palette.color(QPalette::Active, QPalette::HighlightedText); + m_backgroundColor = palette.color(QPalette::Active, QPalette::Highlight); + QTextOption option(Qt::AlignHCenter | Qt::AlignVCenter); option.setWrapMode(QTextOption::NoWrap); m_windowTitle.setTextOption(option); @@ -90,10 +95,10 @@ void QWaylandDecoration::paint(QPaintDevice *device) // Title bar QPoint gradCenter(top.center()+ QPoint(30, 60)); - QRadialGradient grad(gradCenter, top.width() / 2, gradCenter); + QLinearGradient grad(top.topLeft(), top.bottomLeft()); QColor base(backgroundColor()); - grad.setColorAt(1, base); - grad.setColorAt(0, base.lighter(123)); + grad.setColorAt(0, base.lighter(100)); + grad.setColorAt(1, base.darker(180)); QPainterPath roundedRect; roundedRect.addRoundedRect(surfaceRect, 6, 6); for (int i = 0; i < 4; ++i) { @@ -117,7 +122,7 @@ void QWaylandDecoration::paint(QPaintDevice *device) p.save(); p.setClipRect(titleBar); - p.setPen(QColor(0xee,0xee,0xee)); + p.setPen(m_foregroundColor); QSizeF size = m_windowTitle.size(); int dx = (top.width() - size.width()) /2; int dy = (top.height()- size.height()) /2; @@ -136,7 +141,7 @@ void QWaylandDecoration::paint(QPaintDevice *device) QRectF rect; // Default pen - QPen pen(QColor(0xee, 0xee, 0xee)); + QPen pen(m_foregroundColor); p.setPen(pen); // Close button @@ -162,7 +167,7 @@ void QWaylandDecoration::paint(QPaintDevice *device) p.drawRect(rect1); p.drawRect(rect2); } else { - p.setPen(QColor(0xee, 0xee, 0xee)); + p.setPen(m_foregroundColor); p.drawRect(rect); p.drawLine(rect.left(), rect.top() + 1, rect.right(), rect.top() + 1); } @@ -321,6 +326,11 @@ QRectF QWaylandDecoration::minimizeButtonRect() const BUTTON_SPACING, BUTTON_WIDTH, margins().top() - BUTTON_SPACING * 2); } +void QWaylandDecoration::setForegroundColor(const QColor &c) +{ + m_foregroundColor = c; +} + void QWaylandDecoration::setBackgroundColor(const QColor &c) { m_backgroundColor = c; diff --git a/src/plugins/platforms/wayland/qwaylanddecoration.h b/src/plugins/platforms/wayland/qwaylanddecoration.h index b1f31ed11..91d32d561 100644 --- a/src/plugins/platforms/wayland/qwaylanddecoration.h +++ b/src/plugins/platforms/wayland/qwaylanddecoration.h @@ -78,6 +78,9 @@ public: QWindow *window() const; QWaylandWindow *waylandWindow() const; + void setForegroundColor(const QColor &c); + inline QColor foregroundColor() const; + void setBackgroundColor(const QColor &c); inline QColor backgroundColor() const; @@ -107,6 +110,7 @@ private: Qt::CursorShape m_cursorShape; Qt::MouseButtons m_mouseButtons; + QColor m_foregroundColor; QColor m_backgroundColor; QStaticText m_windowTitle; }; @@ -126,6 +130,11 @@ inline QWaylandWindow *QWaylandDecoration::waylandWindow() const return m_wayland_window; } +inline QColor QWaylandDecoration::foregroundColor() const +{ + return m_foregroundColor; +} + inline QColor QWaylandDecoration::backgroundColor() const { return m_backgroundColor; |