2007-06-15 20:48:52 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// oxygenclient.cpp
|
|
|
|
// -------------------
|
|
|
|
// Oxygen window decoration for KDE
|
|
|
|
// -------------------
|
|
|
|
// Copyright (c) 2003, 2004 David Johnson
|
|
|
|
// Copyright (c) 2006, 2007 Casper Boemann <cbr@boemann.dk>
|
|
|
|
// Copyright (c) 2006, 2007 Riccardo Iaconelli <ruphy@fsfe.org>
|
|
|
|
//
|
|
|
|
// Please see the header file for copyright and license information.
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// #ifndef OXYGENCLIENT_H
|
|
|
|
// #define OXYGENCLIENT_H
|
|
|
|
|
2007-10-18 18:09:31 +00:00
|
|
|
#include <KConfig>
|
|
|
|
#include <KGlobal>
|
|
|
|
#include <KLocale>
|
|
|
|
#include <KDebug>
|
|
|
|
#include <KColorUtils>
|
2007-06-15 20:48:52 +00:00
|
|
|
|
|
|
|
#include <qbitmap.h>
|
|
|
|
#include <qlabel.h>
|
|
|
|
#include <qlayout.h>
|
|
|
|
#include <qpainter.h>
|
|
|
|
#include <qtooltip.h>
|
|
|
|
//Added by qt3to4:
|
|
|
|
#include <QBoxLayout>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QResizeEvent>
|
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QEvent>
|
|
|
|
#include <QShowEvent>
|
|
|
|
#include <QPaintEvent>
|
|
|
|
#include <QPainterPath>
|
|
|
|
#include <QTimer>
|
2007-07-16 02:12:45 +00:00
|
|
|
#include <QCache>
|
2007-06-15 20:48:52 +00:00
|
|
|
|
2007-10-18 18:09:31 +00:00
|
|
|
#include "math.h"
|
|
|
|
|
2007-06-15 20:48:52 +00:00
|
|
|
#include "oxygenclient.h"
|
|
|
|
#include "oxygenclient.moc"
|
|
|
|
#include "oxygenbutton.h"
|
|
|
|
#include "oxygen.h"
|
|
|
|
|
|
|
|
namespace Oxygen
|
|
|
|
{
|
|
|
|
|
2007-07-19 01:32:16 +00:00
|
|
|
K_GLOBAL_STATIC_WITH_ARGS(OxygenHelper, globalHelper, ("OxygenDeco"))
|
2007-06-15 20:48:52 +00:00
|
|
|
|
|
|
|
void renderDot(QPainter *p, const QPointF &point, qreal diameter)
|
|
|
|
{
|
|
|
|
p->drawEllipse(QRectF(point.x()-diameter/2, point.y()-diameter/2, diameter, diameter));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OxygenClient::OxygenClient(KDecorationBridge *b, KDecorationFactory *f)
|
2007-10-18 19:09:41 +00:00
|
|
|
: KCommonDecoration(b, f)
|
|
|
|
, helper_(*globalHelper)
|
|
|
|
, colorCacheInvalid_(true)
|
|
|
|
{
|
|
|
|
}
|
2007-06-15 20:48:52 +00:00
|
|
|
|
|
|
|
OxygenClient::~OxygenClient()
|
|
|
|
{
|
|
|
|
}
|
2007-09-17 18:16:26 +00:00
|
|
|
QString OxygenClient::visibleName() const
|
2007-06-15 20:48:52 +00:00
|
|
|
{
|
2007-09-17 18:16:26 +00:00
|
|
|
return i18n("Oxygen");
|
2007-06-15 20:48:52 +00:00
|
|
|
}
|
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
QString OxygenClient::defaultButtonsLeft() const
|
2007-06-15 20:48:52 +00:00
|
|
|
{
|
2007-09-17 18:16:26 +00:00
|
|
|
return "M";
|
2007-06-15 20:48:52 +00:00
|
|
|
}
|
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
QString OxygenClient::defaultButtonsRight() const
|
2007-06-15 20:48:52 +00:00
|
|
|
{
|
2007-09-17 18:16:26 +00:00
|
|
|
return "HIAX";
|
2007-06-15 20:48:52 +00:00
|
|
|
}
|
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
void OxygenClient::init()
|
2007-06-15 20:48:52 +00:00
|
|
|
{
|
2007-09-17 18:16:26 +00:00
|
|
|
KCommonDecoration::init();
|
2007-06-15 20:48:52 +00:00
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
widget()->setAutoFillBackground(false);
|
|
|
|
widget()->setAttribute(Qt::WA_OpaquePaintEvent);
|
2007-10-10 00:05:24 +00:00
|
|
|
widget()->setAttribute(Qt::WA_PaintOnScreen, false);
|
2007-09-17 18:16:26 +00:00
|
|
|
}
|
2007-06-15 20:48:52 +00:00
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
bool OxygenClient::decorationBehaviour(DecorationBehaviour behaviour) const
|
2007-06-15 20:48:52 +00:00
|
|
|
{
|
2007-09-17 18:16:26 +00:00
|
|
|
switch (behaviour) {
|
|
|
|
case DB_MenuClose:
|
|
|
|
return true;//Handler()->menuClose();
|
2007-06-15 20:48:52 +00:00
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
case DB_WindowMask:
|
|
|
|
return false;
|
2007-06-15 20:48:52 +00:00
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
default:
|
|
|
|
return KCommonDecoration::decorationBehaviour(behaviour);
|
2007-06-15 20:48:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
int OxygenClient::layoutMetric(LayoutMetric lm, bool respectWindowState, const KCommonDecorationButton *btn) const
|
2007-06-15 20:48:52 +00:00
|
|
|
{
|
2007-09-17 18:16:26 +00:00
|
|
|
bool maximized = maximizeMode()==MaximizeFull && !options()->moveResizeMaximizedWindows();
|
|
|
|
|
|
|
|
switch (lm) {
|
|
|
|
case LM_BorderLeft:
|
|
|
|
case LM_BorderRight:
|
|
|
|
case LM_BorderBottom:
|
|
|
|
{
|
|
|
|
if (respectWindowState && maximized) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return BFRAMESIZE;
|
|
|
|
}
|
|
|
|
}
|
2007-06-15 20:48:52 +00:00
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
case LM_TitleEdgeTop:
|
|
|
|
{
|
|
|
|
if (respectWindowState && maximized) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return TFRAMESIZE;
|
|
|
|
}
|
|
|
|
}
|
2007-06-15 20:48:52 +00:00
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
case LM_TitleEdgeBottom:
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2007-06-15 20:48:52 +00:00
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
case LM_TitleEdgeLeft:
|
|
|
|
case LM_TitleEdgeRight:
|
|
|
|
{
|
|
|
|
if (respectWindowState && maximized) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return 6;
|
|
|
|
}
|
|
|
|
}
|
2007-06-15 20:48:52 +00:00
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
case LM_TitleBorderLeft:
|
|
|
|
case LM_TitleBorderRight:
|
|
|
|
return 5;
|
|
|
|
|
|
|
|
case LM_ButtonWidth:
|
|
|
|
case LM_ButtonHeight:
|
|
|
|
case LM_TitleHeight:
|
|
|
|
{
|
|
|
|
if (respectWindowState && isToolWindow()) {
|
2007-10-06 00:39:16 +00:00
|
|
|
return OXYGEN_BUTTONSIZE;
|
2007-09-17 18:16:26 +00:00
|
|
|
} else {
|
2007-10-06 00:39:16 +00:00
|
|
|
return OXYGEN_BUTTONSIZE;
|
2007-09-17 18:16:26 +00:00
|
|
|
}
|
|
|
|
}
|
2007-06-15 20:48:52 +00:00
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
case LM_ButtonSpacing:
|
|
|
|
return 1;
|
2007-06-15 20:48:52 +00:00
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
case LM_ButtonMarginTop:
|
|
|
|
return 0;
|
2007-06-15 20:48:52 +00:00
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
case LM_ExplicitButtonSpacer:
|
|
|
|
return 3;
|
2007-06-15 20:48:52 +00:00
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
default:
|
|
|
|
return KCommonDecoration::layoutMetric(lm, respectWindowState, btn);
|
|
|
|
}
|
2007-06-15 20:48:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
KCommonDecorationButton *OxygenClient::createButton(::ButtonType type)
|
2007-06-15 20:48:52 +00:00
|
|
|
{
|
2007-09-17 18:16:26 +00:00
|
|
|
switch (type) {
|
|
|
|
case MenuButton:
|
2007-10-10 00:05:24 +00:00
|
|
|
return new OxygenButton(*this, i18n("Menu"), ButtonMenu);
|
2007-06-15 20:48:52 +00:00
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
case HelpButton:
|
2007-10-10 00:05:24 +00:00
|
|
|
return new OxygenButton(*this, i18n("Help"), ButtonHelp);
|
2007-06-15 20:48:52 +00:00
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
case MinButton:
|
2007-10-10 00:05:24 +00:00
|
|
|
return new OxygenButton(*this, i18n("Minimize"), ButtonMin);
|
2007-06-15 20:48:52 +00:00
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
case MaxButton:
|
2007-10-10 00:05:24 +00:00
|
|
|
return new OxygenButton(*this, i18n("Minimize"), ButtonMax);
|
2007-06-15 20:48:52 +00:00
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
case CloseButton:
|
2007-10-10 00:05:24 +00:00
|
|
|
return new OxygenButton(*this, i18n("Minimize"), ButtonClose);
|
2007-06-15 20:48:52 +00:00
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
2007-06-15 20:48:52 +00:00
|
|
|
}
|
|
|
|
|
2007-09-17 18:16:26 +00:00
|
|
|
|
2007-10-18 18:09:31 +00:00
|
|
|
// c0 - background
|
|
|
|
// c1 - foreground
|
|
|
|
// t - target contrast ratio
|
|
|
|
QColor reduceContrast(const QColor &c0, const QColor &c1, double t)
|
|
|
|
{
|
|
|
|
double s = KColorUtils::contrastRatio(c0, c1);
|
|
|
|
if (s < t)
|
|
|
|
return c1;
|
|
|
|
|
|
|
|
double l = 0.0, h = 1.0;
|
|
|
|
double x = s, a;
|
|
|
|
QColor r = c1;
|
|
|
|
for (int maxiter = 16; maxiter; --maxiter) {
|
|
|
|
a = 0.5 * (l + h);
|
|
|
|
r = KColorUtils::mix(c0, c1, a);
|
|
|
|
x = KColorUtils::contrastRatio(c0, r);
|
|
|
|
if (fabs(x - t) < 0.01)
|
|
|
|
break;
|
|
|
|
if (x > t)
|
|
|
|
h = a;
|
|
|
|
else
|
|
|
|
l = a;
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QColor OxygenClient::titlebarTextColor(const QPalette &palette)
|
|
|
|
{
|
|
|
|
if (isActive())
|
|
|
|
return palette.color(QPalette::Active, QPalette::WindowText);
|
|
|
|
else {
|
2007-10-18 19:09:41 +00:00
|
|
|
if(colorCacheInvalid_) {
|
|
|
|
QColor ab = palette.color(QPalette::Active, QPalette::Window);
|
|
|
|
QColor af = palette.color(QPalette::Active, QPalette::WindowText);
|
|
|
|
QColor nb = palette.color(QPalette::Inactive, QPalette::Window);
|
|
|
|
QColor nf = palette.color(QPalette::Inactive, QPalette::WindowText);
|
|
|
|
|
|
|
|
colorCacheInvalid_ = false;
|
|
|
|
cachedTitlebarTextColor_ = reduceContrast(nb, nf, qMax(2.5, KColorUtils::contrastRatio(ab, KColorUtils::mix(ab, af, 0.4))));
|
|
|
|
}
|
|
|
|
return cachedTitlebarTextColor_;
|
2007-10-18 18:09:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-15 20:48:52 +00:00
|
|
|
void OxygenClient::paintEvent(QPaintEvent *e)
|
|
|
|
{
|
2007-07-16 02:12:45 +00:00
|
|
|
Q_UNUSED(e)
|
2007-06-15 20:48:52 +00:00
|
|
|
if (!OxygenFactory::initialized()) return;
|
|
|
|
|
|
|
|
doShape();
|
|
|
|
|
|
|
|
QPalette palette = widget()->palette();
|
|
|
|
QPainter painter(widget());
|
|
|
|
|
2007-10-10 00:25:48 +00:00
|
|
|
// Set palette to the right group. Lubos disagrees with this being a kwin
|
|
|
|
// bug, but anyway, we need the palette group to match the current window.
|
|
|
|
// Since kwin doesn't set it correctly, we have to do it ourselves.
|
2007-09-10 19:09:39 +00:00
|
|
|
if (isActive())
|
|
|
|
palette.setCurrentColorGroup(QPalette::Active);
|
|
|
|
else
|
|
|
|
palette.setCurrentColorGroup(QPalette::Inactive);
|
|
|
|
|
2007-06-15 20:48:52 +00:00
|
|
|
int x,y,w,h;
|
2007-07-16 02:12:45 +00:00
|
|
|
QRect frame = widget()->frameGeometry();
|
|
|
|
QColor color = palette.window();
|
2007-09-17 18:16:26 +00:00
|
|
|
|
|
|
|
const int titleHeight = layoutMetric(LM_TitleHeight);
|
|
|
|
const int titleTop = layoutMetric(LM_TitleEdgeTop) + frame.top();
|
|
|
|
const int titleEdgeLeft = layoutMetric(LM_TitleEdgeLeft);
|
|
|
|
const int marginLeft = layoutMetric(LM_TitleBorderLeft);
|
|
|
|
const int marginRight = layoutMetric(LM_TitleBorderRight);
|
|
|
|
|
|
|
|
const int titleLeft = frame.left() + titleEdgeLeft + buttonsLeftWidth() + marginLeft;
|
|
|
|
const int titleWidth = frame.width() -
|
|
|
|
titleEdgeLeft - layoutMetric(LM_TitleEdgeRight) -
|
|
|
|
buttonsLeftWidth() - buttonsRightWidth() -
|
|
|
|
marginLeft - marginRight;
|
|
|
|
|
2007-07-16 02:12:45 +00:00
|
|
|
|
2007-07-16 18:01:27 +00:00
|
|
|
int splitY = qMin(300, 3*frame.height()/4);
|
2007-07-16 02:12:45 +00:00
|
|
|
|
2007-10-10 00:05:24 +00:00
|
|
|
QPixmap tile = helper_.verticalGradient(color, splitY);
|
2007-09-17 18:16:26 +00:00
|
|
|
painter.drawTiledPixmap(QRect(0, 0, frame.width(), titleHeight + TFRAMESIZE), tile);
|
2007-07-16 18:01:27 +00:00
|
|
|
|
|
|
|
painter.drawTiledPixmap(QRect(0, 0, LFRAMESIZE, splitY), tile);
|
2007-10-10 00:05:24 +00:00
|
|
|
painter.fillRect(0, splitY, LFRAMESIZE, frame.height() - splitY, helper_.backgroundBottomColor(color));
|
2007-07-16 18:01:27 +00:00
|
|
|
|
2007-07-16 02:12:45 +00:00
|
|
|
painter.drawTiledPixmap(QRect(frame.width()-RFRAMESIZE, 0,
|
2007-07-16 18:01:27 +00:00
|
|
|
RFRAMESIZE, splitY), tile,
|
2007-07-16 02:12:45 +00:00
|
|
|
QPoint(frame.width()-RFRAMESIZE, 0));
|
2007-10-10 00:05:24 +00:00
|
|
|
painter.fillRect(frame.width()-RFRAMESIZE, splitY, RFRAMESIZE, frame.height() - splitY, helper_.backgroundBottomColor(color));
|
2007-07-16 18:01:27 +00:00
|
|
|
|
2007-10-10 00:05:24 +00:00
|
|
|
painter.fillRect(0, frame.height() - BFRAMESIZE, frame.width(), BFRAMESIZE, helper_.backgroundBottomColor(color));
|
2007-07-16 02:12:45 +00:00
|
|
|
|
2007-07-16 18:01:27 +00:00
|
|
|
int radialW = qMin(600, frame.width());
|
2007-10-10 00:05:24 +00:00
|
|
|
tile = helper_.radialGradient(color, radialW);
|
2007-07-16 18:01:27 +00:00
|
|
|
QRect radialRect = QRect((frame.width() - radialW) / 2, 0, radialW, 64);
|
2007-07-16 02:12:45 +00:00
|
|
|
painter.drawPixmap(radialRect, tile);
|
|
|
|
|
|
|
|
//painter.setRenderHint(QPainter::Antialiasing,true);
|
2007-06-15 20:48:52 +00:00
|
|
|
|
|
|
|
// draw title text
|
|
|
|
painter.setFont(options()->font(isActive(), false));
|
2007-10-18 18:09:31 +00:00
|
|
|
painter.setPen(titlebarTextColor(palette));
|
2007-10-19 19:56:50 +00:00
|
|
|
painter.drawText(titleLeft, titleTop-1, titleWidth, titleHeight, // -1 is to go into top resizearea
|
2007-06-15 20:48:52 +00:00
|
|
|
OxygenFactory::titleAlign() | Qt::AlignVCenter, caption());
|
2007-07-16 02:12:45 +00:00
|
|
|
|
2007-06-15 20:48:52 +00:00
|
|
|
painter.setRenderHint(QPainter::Antialiasing);
|
|
|
|
|
2007-10-18 23:56:46 +00:00
|
|
|
// Draw dividing line
|
2007-07-16 02:12:45 +00:00
|
|
|
frame = widget()->rect();
|
2007-06-15 20:48:52 +00:00
|
|
|
frame.getRect(&x, &y, &w, &h);
|
|
|
|
|
2007-10-18 23:56:46 +00:00
|
|
|
QColor light = helper_.calcLightColor(palette.window());
|
|
|
|
QColor dark = helper_.calcDarkColor(palette.window());
|
|
|
|
dark.setAlpha(120);
|
|
|
|
|
|
|
|
if(!isActive()) {
|
|
|
|
light.setAlpha(120);
|
|
|
|
dark.setAlpha(50);
|
|
|
|
}
|
|
|
|
|
|
|
|
QLinearGradient lg(x,0,x+w,0);
|
|
|
|
lg.setColorAt(0.5, dark);
|
|
|
|
dark.setAlpha(0);
|
|
|
|
lg.setColorAt(0.0, dark);
|
|
|
|
lg.setColorAt(1.0, dark);
|
|
|
|
painter.setPen(QPen(lg,1));
|
|
|
|
|
|
|
|
painter.drawLine(QPointF(x, titleTop+titleHeight-1.5),
|
|
|
|
QPointF(x+w, titleTop+titleHeight-1.5));
|
|
|
|
|
|
|
|
lg = QLinearGradient(x,0,x+w,0);
|
|
|
|
lg.setColorAt(0.5, light);
|
|
|
|
light.setAlpha(0);
|
|
|
|
lg.setColorAt(0.0, light);
|
|
|
|
lg.setColorAt(1.0, light);
|
|
|
|
painter.setPen(QPen(lg,1));
|
|
|
|
|
|
|
|
painter.drawLine(QPointF(x, titleTop+titleHeight-0.5),
|
|
|
|
QPointF(x+w, titleTop+titleHeight-0.5));
|
|
|
|
|
|
|
|
// Draw shadows of the frame
|
|
|
|
|
2007-06-15 20:48:52 +00:00
|
|
|
painter.setBrush(Qt::NoBrush);
|
2007-10-09 21:01:18 +00:00
|
|
|
painter.setPen(QColor(255,255,255, 120));
|
|
|
|
painter.drawLine(QPointF(0, 0.5), QPointF(w, 0.5));
|
2007-06-15 20:48:52 +00:00
|
|
|
painter.setPen(QColor(128,128,128, 60));
|
2007-10-09 21:01:18 +00:00
|
|
|
painter.drawLine(QPointF(0.5, 0), QPointF(0.5, h));
|
|
|
|
painter.drawLine(QPointF(w-0.5, 0), QPointF(w-0.5, h));
|
|
|
|
painter.setPen(QColor(0,0,0, 60));
|
|
|
|
painter.drawLine(QPointF(0, h-0.5), QPointF(w, h-0.5));
|
|
|
|
|
|
|
|
painter.setPen(QColor(0,0,0, 40));
|
|
|
|
painter.drawPoint(QPointF(1.5, 1.5)); // top middle point
|
|
|
|
painter.drawPoint(QPointF(w-1.5, 1.5));
|
|
|
|
painter.drawPoint(QPointF(3.5, 0.5)); // top away points
|
|
|
|
painter.drawPoint(QPointF(w-3.5, 0.5));
|
|
|
|
painter.drawPoint(QPointF(0.5, 3.5));
|
|
|
|
painter.drawPoint(QPointF(w-0.5, 3.5));
|
|
|
|
painter.drawPoint(QPointF(1.5, h-1.5)); // bottom middle point
|
|
|
|
painter.drawPoint(QPointF(w-1.5, h-1.5));
|
|
|
|
|
|
|
|
// Draw the 3-dots resize handles
|
2007-07-16 18:01:27 +00:00
|
|
|
qreal cenY = frame.height() / 2 + 0.5;
|
|
|
|
qreal posX = frame.width() - 2.5;
|
2007-06-15 20:48:52 +00:00
|
|
|
painter.setPen(Qt::NoPen);
|
|
|
|
painter.setBrush(QColor(0, 0, 0, 66));
|
2007-09-27 18:30:17 +00:00
|
|
|
renderDot(&painter, QPointF(posX, cenY - 3), 1.8);
|
|
|
|
renderDot(&painter, QPointF(posX, cenY), 1.8);
|
|
|
|
renderDot(&painter, QPointF(posX, cenY + 3), 1.8);
|
2007-06-15 20:48:52 +00:00
|
|
|
|
|
|
|
painter.translate(frame.width()-9, frame.height()-9);
|
2007-09-27 18:30:17 +00:00
|
|
|
renderDot(&painter, QPointF(2.5, 6.5), 1.8);
|
|
|
|
renderDot(&painter, QPointF(5.5, 5.5), 1.8);
|
|
|
|
renderDot(&painter, QPointF(6.5, 2.5), 1.8);
|
2007-06-15 20:48:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OxygenClient::doShape()
|
|
|
|
{
|
2007-10-17 11:50:34 +00:00
|
|
|
bool maximized = maximizeMode()==MaximizeFull && !options()->moveResizeMaximizedWindows();
|
2007-06-15 20:48:52 +00:00
|
|
|
int r=widget()->width();
|
|
|
|
int b=widget()->height();
|
|
|
|
QRegion mask(0,0,r,b);
|
2007-10-17 11:50:34 +00:00
|
|
|
|
|
|
|
if(maximized) {
|
|
|
|
setMask(mask);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-06-15 20:48:52 +00:00
|
|
|
// Remove top-left corner.
|
|
|
|
mask -= QRegion(0, 0, 3, 1);
|
2007-10-09 21:01:18 +00:00
|
|
|
mask -= QRegion(0, 1, 1, 1);
|
2007-06-15 20:48:52 +00:00
|
|
|
mask -= QRegion(0, 2, 1, 1);
|
|
|
|
|
|
|
|
// Remove top-right corner.
|
|
|
|
mask -= QRegion(r - 3, 0, 3, 1);
|
2007-10-09 21:01:18 +00:00
|
|
|
mask -= QRegion(r - 1, 1, 1, 1);
|
2007-06-15 20:48:52 +00:00
|
|
|
mask -= QRegion(r - 1, 2, 1, 1);
|
|
|
|
|
|
|
|
// Remove bottom-left corner.
|
|
|
|
mask -= QRegion(0, b-1-0, 3, b-1-1);
|
2007-10-09 21:01:18 +00:00
|
|
|
mask -= QRegion(0, b-1-1, 1, b-1-1);
|
2007-06-15 20:48:52 +00:00
|
|
|
mask -= QRegion(0, b-1-2, 1, b-1-1);
|
|
|
|
|
|
|
|
// Remove bottom-right corner.
|
|
|
|
mask -= QRegion(r - 3, b-1-0, 3, b-1-1);
|
2007-10-09 21:01:18 +00:00
|
|
|
mask -= QRegion(r - 1, b-1-1, 1, b-1-1);
|
2007-06-15 20:48:52 +00:00
|
|
|
mask -= QRegion(r - 1, b-1-2, 1, b-1-1);
|
|
|
|
|
|
|
|
setMask(mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
} //namespace Oxygen
|
|
|
|
|
|
|
|
//#include "oxygenclient.moc"
|
|
|
|
|
|
|
|
// #endif
|