Fix the preview rendering bug, some cleanup.
svn path=/trunk/kdebase/kwin/; revision=400989
This commit is contained in:
parent
06e5b5b960
commit
7f5bb05567
2 changed files with 44 additions and 29 deletions
|
@ -354,6 +354,9 @@ void B2Client::init()
|
||||||
i18n("Resize")
|
i18n("Resize")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Check this early, otherwise the preview will be rendered badly.
|
||||||
|
resizable = isResizable();
|
||||||
|
|
||||||
createMainWidget(WResizeNoErase | WRepaintNoErase);
|
createMainWidget(WResizeNoErase | WRepaintNoErase);
|
||||||
widget()->installEventFilter(this);
|
widget()->installEventFilter(this);
|
||||||
|
|
||||||
|
@ -363,35 +366,39 @@ void B2Client::init()
|
||||||
for (int i = 0; i < BtnCount; i++)
|
for (int i = 0; i < BtnCount; i++)
|
||||||
button[i] = NULL;
|
button[i] = NULL;
|
||||||
|
|
||||||
g = new QGridLayout(widget(), 0, 0);
|
g = new QGridLayout(widget(), 3, 3);
|
||||||
if (isPreview()) {
|
|
||||||
g->addMultiCellWidget(
|
|
||||||
new QLabel(i18n("<b><center>B II preview</center></b>"),
|
|
||||||
widget()),
|
|
||||||
1, 1, 1, 2);
|
|
||||||
} else {
|
|
||||||
g->addMultiCell(new QSpacerItem(0, 0), 1, 1, 1, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Left and right border width
|
// Left and right border width
|
||||||
|
|
||||||
leftSpacer = new QSpacerItem(thickness, 16,
|
leftSpacer = new QSpacerItem(thickness, 16,
|
||||||
QSizePolicy::Fixed, QSizePolicy::Expanding);
|
QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||||
rightSpacer = new QSpacerItem(thickness, 16,
|
rightSpacer = new QSpacerItem(thickness, 16,
|
||||||
QSizePolicy::Fixed, QSizePolicy::Expanding);
|
QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||||
|
|
||||||
g->addItem(leftSpacer, 1, 0);
|
g->addItem(leftSpacer, 1, 0);
|
||||||
g->addColSpacing(1, 16);
|
g->addItem(rightSpacer, 1, 2);
|
||||||
g->setColStretch(2, 1);
|
|
||||||
g->setRowStretch(1, 1);
|
|
||||||
g->addItem(rightSpacer, 1, 3);
|
|
||||||
|
|
||||||
// Bottom border height
|
// Top border height
|
||||||
spacer = new QSpacerItem(10, thickness + (mustDrawHandle() ? 4 : 0),
|
topSpacer = new QSpacerItem(10, buttonSize + 4,
|
||||||
QSizePolicy::Expanding, QSizePolicy::Fixed);
|
QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
g->addItem(spacer, 3, 1);
|
g->addItem(topSpacer, 0, 1);
|
||||||
|
|
||||||
|
// Bottom border height.
|
||||||
|
bottomSpacer = new QSpacerItem(10,
|
||||||
|
thickness + (mustDrawHandle() ? 4 : 0),
|
||||||
|
QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
|
g->addItem(bottomSpacer, 2, 1);
|
||||||
|
if (isPreview()) {
|
||||||
|
QLabel *previewLabel = new QLabel(
|
||||||
|
i18n("<b><center>B II preview</center></b>"),
|
||||||
|
widget());
|
||||||
|
g->addWidget(previewLabel, 1, 1);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
g->addItem(new QSpacerItem(0, 0), 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
// titlebar
|
// titlebar
|
||||||
g->addRowSpacing(0, buttonSize + 4);
|
g->setRowSpacing(0, buttonSize + 4);
|
||||||
|
|
||||||
titlebar = new B2Titlebar(this);
|
titlebar = new B2Titlebar(this);
|
||||||
titlebar->setMinimumWidth(buttonSize + 4);
|
titlebar->setMinimumWidth(buttonSize + 4);
|
||||||
|
@ -425,7 +432,6 @@ void B2Client::init()
|
||||||
positionButtons();
|
positionButtons();
|
||||||
titlebar->recalcBuffer();
|
titlebar->recalcBuffer();
|
||||||
titlebar->installEventFilter(this);
|
titlebar->installEventFilter(this);
|
||||||
resizable = isResizable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void B2Client::addButtons(const QString& s, const QString tips[],
|
void B2Client::addButtons(const QString& s, const QString tips[],
|
||||||
|
@ -699,8 +705,10 @@ void B2Client::doShape()
|
||||||
QRegion mask(widget()->rect());
|
QRegion mask(widget()->rect());
|
||||||
// top to the tilebar right
|
// top to the tilebar right
|
||||||
if (bar_x_ofs) {
|
if (bar_x_ofs) {
|
||||||
mask -= QRect(0, 0, bar_x_ofs, t.height() - thickness); //left from bar
|
// left from bar
|
||||||
mask -= QRect(0, t.height() - thickness, 1, 1); //top left point
|
mask -= QRect(0, 0, bar_x_ofs, t.height() - thickness);
|
||||||
|
// top left point
|
||||||
|
mask -= QRect(0, t.height() - thickness, 1, 1);
|
||||||
}
|
}
|
||||||
if (t.right() < width() - 1) {
|
if (t.right() < width() - 1) {
|
||||||
mask -= QRect(width() - 1,
|
mask -= QRect(width() - 1,
|
||||||
|
@ -708,13 +716,18 @@ void B2Client::doShape()
|
||||||
mask -= QRect(t.right() + 1, 0,
|
mask -= QRect(t.right() + 1, 0,
|
||||||
width() - t.right() - 1, t.height() - thickness);
|
width() - t.right() - 1, t.height() - thickness);
|
||||||
}
|
}
|
||||||
mask -= QRect(width() - 1, height() - 1, 1, 1); //bottom right point
|
// bottom right point
|
||||||
|
mask -= QRect(width() - 1, height() - 1, 1, 1);
|
||||||
if (mustDrawHandle()) {
|
if (mustDrawHandle()) {
|
||||||
mask -= QRect(0, height() - 5, 1, 1); //bottom left point
|
// bottom left point
|
||||||
mask -= QRect(width() - 40, height() - 1, 1, 1); //handle left point
|
mask -= QRect(0, height() - 5, 1, 1);
|
||||||
mask -= QRect(0, height() - 4, width() - 40, 4); //bottom left
|
// handle left point
|
||||||
|
mask -= QRect(width() - 40, height() - 1, 1, 1);
|
||||||
|
// bottom left
|
||||||
|
mask -= QRect(0, height() - 4, width() - 40, 4);
|
||||||
} else {
|
} else {
|
||||||
mask -= QRect(0, height() - 1, 1, 1); // bottom left point
|
// bottom left point
|
||||||
|
mask -= QRect(0, height() - 1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
setMask(mask);
|
setMask(mask);
|
||||||
|
@ -814,7 +827,7 @@ void B2Client::maximizeChange()
|
||||||
QToolTip::add(button[BtnMax],
|
QToolTip::add(button[BtnMax],
|
||||||
m ? i18n("Restore") : i18n("Maximize"));
|
m ? i18n("Restore") : i18n("Maximize"));
|
||||||
}
|
}
|
||||||
spacer->changeSize(10, thickness + (mustDrawHandle() ? 4 : 0),
|
bottomSpacer->changeSize(10, thickness + (mustDrawHandle() ? 4 : 0),
|
||||||
QSizePolicy::Expanding, QSizePolicy::Minimum);
|
QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||||
|
|
||||||
g->activate();
|
g->activate();
|
||||||
|
@ -839,7 +852,7 @@ void B2Client::activeChange()
|
||||||
|
|
||||||
void B2Client::shadeChange()
|
void B2Client::shadeChange()
|
||||||
{
|
{
|
||||||
spacer->changeSize(10, thickness + (mustDrawHandle() ? 4 : 0),
|
bottomSpacer->changeSize(10, thickness + (mustDrawHandle() ? 4 : 0),
|
||||||
QSizePolicy::Expanding, QSizePolicy::Minimum);
|
QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||||
g->activate();
|
g->activate();
|
||||||
doShape();
|
doShape();
|
||||||
|
|
|
@ -137,7 +137,9 @@ private:
|
||||||
BtnHelp, BtnShade, BtnResize, BtnCount};
|
BtnHelp, BtnShade, BtnResize, BtnCount};
|
||||||
B2Button* button[BtnCount];
|
B2Button* button[BtnCount];
|
||||||
QGridLayout *g;
|
QGridLayout *g;
|
||||||
QSpacerItem *spacer; // Bottom border spacer
|
// Border spacers
|
||||||
|
QSpacerItem *topSpacer;
|
||||||
|
QSpacerItem *bottomSpacer;
|
||||||
QSpacerItem *leftSpacer;
|
QSpacerItem *leftSpacer;
|
||||||
QSpacerItem *rightSpacer;
|
QSpacerItem *rightSpacer;
|
||||||
B2Titlebar *titlebar;
|
B2Titlebar *titlebar;
|
||||||
|
|
Loading…
Reference in a new issue