summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPier Luigi Fiorini <pierluigi.fiorini@gmail.com>2013-02-12 22:38:59 +0100
committerAndy Nichols <andy.nichols@digia.com>2013-02-18 16:21:03 +0100
commit5cb159395eccb1d96fb73a78e499eef30aacb46d (patch)
tree47791182dd6d5bb12a62bceb9cd550d6d41758f3 /src
parenta9fb88427495169ee0bfdb33e5e2b7940e9ae8f4 (diff)
downloadqtwayland-5cb159395eccb1d96fb73a78e499eef30aacb46d.tar.gz
Draw client side decoration actions with pixmaps
Pixmaps are nicer than manually drawn actions. Use pixmaps from QCommonStyle if XPM support is enabled, otherwise fallback to manually drawing the actions. Change-Id: I0a73ede7cd94e59fd6b3813ef5a3964243171c84 Reviewed-by: Andy Nichols <andy.nichols@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/wayland_common/qwaylanddecoration.cpp94
1 files changed, 89 insertions, 5 deletions
diff --git a/src/plugins/platforms/wayland_common/qwaylanddecoration.cpp b/src/plugins/platforms/wayland_common/qwaylanddecoration.cpp
index a0c9534c..982c85d0 100644
--- a/src/plugins/platforms/wayland_common/qwaylanddecoration.cpp
+++ b/src/plugins/platforms/wayland_common/qwaylanddecoration.cpp
@@ -51,10 +51,75 @@
#include <QtGui/QPalette>
#include <QtGui/QLinearGradient>
-#define BUTTON_WIDTH 25
+QT_USE_NAMESPACE
+
#define BUTTON_SPACING 5
-QT_USE_NAMESPACE
+#ifndef QT_NO_IMAGEFORMAT_XPM
+# 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
QWaylandDecoration::QWaylandDecoration(QWaylandWindow *window)
: m_window(window->window())
@@ -150,6 +215,24 @@ void QWaylandDecoration::paint(QPaintDevice *device)
p.restore();
}
+#ifndef QT_NO_IMAGEFORMAT_XPM
+ p.save();
+
+ // Close button
+ QPixmap closePixmap(qt_close_xpm);
+ p.drawPixmap(closeButtonRect(), closePixmap, closePixmap.rect());
+
+ // Maximize button
+ QPixmap maximizePixmap(m_wayland_window->shellSurface()->isMaximized()
+ ? 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);
@@ -196,6 +279,7 @@ void QWaylandDecoration::paint(QPaintDevice *device)
p.setPen(pen);
p.drawLine(rect.bottomLeft(), rect.bottomRight());
p.restore();
+#endif
}
bool QWaylandDecoration::handleMouse(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
@@ -333,19 +417,19 @@ bool QWaylandDecoration::isLeftReleased(Qt::MouseButtons newMouseButtonState)
QRectF QWaylandDecoration::closeButtonRect() const
{
return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH - BUTTON_SPACING * 2,
- BUTTON_SPACING, BUTTON_WIDTH, margins().top() - BUTTON_SPACING * 2);
+ (m_margins.top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
}
QRectF QWaylandDecoration::maximizeButtonRect() const
{
return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH * 2 - BUTTON_SPACING * 3,
- BUTTON_SPACING, BUTTON_WIDTH, margins().top() - BUTTON_SPACING * 2);
+ (m_margins.top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
}
QRectF QWaylandDecoration::minimizeButtonRect() const
{
return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH * 3 - BUTTON_SPACING * 4,
- BUTTON_SPACING, BUTTON_WIDTH, margins().top() - BUTTON_SPACING * 2);
+ (m_margins.top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
}
void QWaylandDecoration::setForegroundColor(const QColor &c)