2
* This file is part of unity-qt
4
* Copyright 2010 Canonical Ltd.
7
* - Aurélien Gâteau <aurelien.gateau@canonical.com>
18
#include <QApplication>
20
#include <QDesktopWidget>
22
#include <QHBoxLayout>
27
#include <X11/Xatom.h>
36
QHBoxLayout* m_layout;
40
QDesktopWidget* desktop = QApplication::desktop();
41
const QRect screen = desktop->screenGeometry(q);
42
const QRect available = desktop->availableGeometry(q);
45
Atom atom = XInternAtom(QX11Info::display(), "_NET_WM_STRUT_PARTIAL", False);
50
rect = QRect(screen.left(), available.top(), q->width(), available.height());
53
available.top(), available.bottom(), 0, 0,
58
rect = QRect(screen.left(), screen.top(), screen.width(), q->height());
62
screen.left(), screen.right(), 0, 0
69
XChangeProperty(QX11Info::display(), q->effectiveWinId(), atom,
70
XA_CARDINAL, 32, PropModeReplace,
71
(unsigned char *) &struts, 12);
74
void updateLayoutDirection()
76
QBoxLayout::Direction direction;
79
direction = QApplication::isRightToLeft() ? QBoxLayout::RightToLeft : QBoxLayout::LeftToRight;
82
direction = QBoxLayout::TopToBottom;
85
m_layout->setDirection(direction);
91
updateLayoutDirection();
95
Panel::Panel(QWidget* parent)
100
d->m_edge = Panel::TopEdge;
101
d->m_layout = new QHBoxLayout(this);
102
d->m_layout->setMargin(0);
103
d->m_layout->setSpacing(0);
104
setAttribute(Qt::WA_X11NetWmWindowTypeDock);
105
setAutoFillBackground(true);
113
void Panel::setEdge(Panel::Edge edge)
121
Panel::Edge Panel::edge() const
126
void Panel::showEvent(QShowEvent* event)
128
QWidget::showEvent(event);
132
void Panel::paintEvent(QPaintEvent* event)
134
// Necessary because Oxygen thinks it knows better what to paint in the background
135
QPainter painter(this);
136
painter.setCompositionMode(QPainter::CompositionMode_Source);
137
painter.fillRect(rect(), palette().brush(QPalette::Background));
140
void Panel::addWidget(QWidget* widget)
142
d->m_layout->addWidget(widget);
145
void Panel::addSpacer()
147
d->m_layout->addStretch();