Removed the minimum width limit imposed by the b2 style by
making the buttons hide when neccesary. Approved by Mosfet by lack of objection :) svn path=/trunk/kdebase/kwin/; revision=66109icc-effect-5.14.5
parent
72a25cf5d9
commit
759848b7d3
|
@ -302,10 +302,12 @@ void B2Titlebar::recalcBuffer()
|
||||||
p.setPen(options->color(Options::Font, true));
|
p.setPen(options->color(Options::Font, true));
|
||||||
p.setFont(options->font(true));
|
p.setFont(options->font(true));
|
||||||
|
|
||||||
t.setX(client->providesContextHelp() ?
|
QLayoutIterator it=layout()->iterator();
|
||||||
client->button[B2Client::BtnHelp]->x()+17 :
|
++it;
|
||||||
client->button[B2Client::BtnSticky]->x()+17);
|
++it;
|
||||||
t.setRight(client->button[B2Client::BtnIconify]->x()-1);
|
++it;
|
||||||
|
t=(++it)->geometry();
|
||||||
|
|
||||||
p.drawText(t, AlignLeft | AlignVCenter, client->caption());
|
p.drawText(t, AlignLeft | AlignVCenter, client->caption());
|
||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
|
@ -344,10 +346,12 @@ void B2Titlebar::paintEvent(QPaintEvent * /*e*/)
|
||||||
p.setPen(options->color(Options::Font, false));
|
p.setPen(options->color(Options::Font, false));
|
||||||
p.setFont(options->font(false));
|
p.setFont(options->font(false));
|
||||||
|
|
||||||
t.setX(client->providesContextHelp() ?
|
QLayoutIterator it=layout()->iterator();
|
||||||
client->button[B2Client::BtnHelp]->x()+17 :
|
++it;
|
||||||
client->button[B2Client::BtnSticky]->x()+17);
|
++it;
|
||||||
t.setRight(client->button[B2Client::BtnIconify]->x()-1);
|
++it;
|
||||||
|
t=(++it)->geometry();
|
||||||
|
|
||||||
p.drawText(t, AlignLeft | AlignVCenter, client->caption());
|
p.drawText(t, AlignLeft | AlignVCenter, client->caption());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -408,7 +412,7 @@ B2Client::B2Client( Workspace *ws, WId w, QWidget *parent,
|
||||||
|
|
||||||
g->addColSpacing(0, 4);
|
g->addColSpacing(0, 4);
|
||||||
|
|
||||||
g->addColSpacing(1, providesContextHelp() ? 102 : 85);
|
g->addColSpacing(1, 16);
|
||||||
|
|
||||||
g->setColStretch(2, 1);
|
g->setColStretch(2, 1);
|
||||||
|
|
||||||
|
@ -420,18 +424,34 @@ B2Client::B2Client( Workspace *ws, WId w, QWidget *parent,
|
||||||
g->addRowSpacing(0, 20);
|
g->addRowSpacing(0, 20);
|
||||||
|
|
||||||
titlebar = new B2Titlebar(this);
|
titlebar = new B2Titlebar(this);
|
||||||
int i;
|
titlebar->setMinimumWidth(16);
|
||||||
|
titlebar->setFixedHeight(20);
|
||||||
|
|
||||||
|
int i;
|
||||||
for(i=0; i < 6; ++i){
|
for(i=0; i < 6; ++i){
|
||||||
button[i] = new B2Button(this, titlebar/*this*/);
|
button[i] = new B2Button(this, titlebar/*this*/);
|
||||||
button[i]->setFixedSize(16, 16);
|
button[i]->setFixedSize(16, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QHBoxLayout *titleLayout=new QHBoxLayout(titlebar);
|
||||||
|
titleLayout->setSpacing(1);
|
||||||
|
|
||||||
|
titleLayout->addSpacing(3);
|
||||||
|
titleLayout->addWidget(button[BtnMenu]);
|
||||||
|
titleLayout->addWidget(button[BtnSticky]);
|
||||||
|
titleLayout->addWidget(button[BtnHelp]);
|
||||||
|
titleLayout->addStretch(1);
|
||||||
|
titleLayout->addWidget(button[BtnIconify]);
|
||||||
|
titleLayout->addWidget(button[BtnMax]);
|
||||||
|
titleLayout->addWidget(button[BtnClose]);
|
||||||
|
titleLayout->addSpacing(3);
|
||||||
|
|
||||||
button[BtnSticky]->setToggle();
|
button[BtnSticky]->setToggle();
|
||||||
button[BtnSticky]->setDown(isSticky());
|
button[BtnSticky]->setDown(isSticky());
|
||||||
button[BtnMenu]->setUseMiniIcon();
|
button[BtnMenu]->setUseMiniIcon();
|
||||||
|
|
||||||
if(!providesContextHelp())
|
if(!providesContextHelp())
|
||||||
button[5]->hide();
|
button[BtnHelp]->hide();
|
||||||
|
|
||||||
button[BtnMenu]->setPixmaps(aMenuPix, aMenuPixDown, iMenuPix,
|
button[BtnMenu]->setPixmaps(aMenuPix, aMenuPixDown, iMenuPix,
|
||||||
iMenuPixDown);
|
iMenuPixDown);
|
||||||
|
@ -472,11 +492,62 @@ B2Client::B2Client( Workspace *ws, WId w, QWidget *parent,
|
||||||
void B2Client::resizeEvent( QResizeEvent* e)
|
void B2Client::resizeEvent( QResizeEvent* e)
|
||||||
{
|
{
|
||||||
Client::resizeEvent( e );
|
Client::resizeEvent( e );
|
||||||
|
|
||||||
|
int sizeProblem = 0;
|
||||||
|
|
||||||
|
if (width() < 45) sizeProblem = 3;
|
||||||
|
else if (width() < 70) sizeProblem = 2;
|
||||||
|
else if (width() < 120) sizeProblem = 1;
|
||||||
|
|
||||||
|
switch (sizeProblem) {
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
button[BtnMenu] ->show();
|
||||||
|
button[BtnClose] ->show();
|
||||||
|
button[BtnSticky] ->hide();
|
||||||
|
button[BtnIconify] ->show();
|
||||||
|
button[BtnMax] ->hide();
|
||||||
|
button[BtnHelp] ->hide();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
button[BtnMenu] ->show();
|
||||||
|
button[BtnClose] ->show();
|
||||||
|
button[BtnSticky] ->hide();
|
||||||
|
button[BtnIconify] ->hide();
|
||||||
|
button[BtnMax] ->hide();
|
||||||
|
button[BtnHelp] ->hide();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
button[BtnMenu] ->hide();
|
||||||
|
button[BtnClose] ->hide();
|
||||||
|
button[BtnSticky] ->hide();
|
||||||
|
button[BtnIconify] ->hide();
|
||||||
|
button[BtnMax] ->hide();
|
||||||
|
button[BtnHelp] ->hide();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
button[BtnMenu] ->show();
|
||||||
|
button[BtnClose] ->show();
|
||||||
|
button[BtnSticky] ->show();
|
||||||
|
button[BtnIconify] ->show();
|
||||||
|
button[BtnMax] ->show();
|
||||||
|
if(providesContextHelp())
|
||||||
|
button[BtnHelp]->show();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
titlebar->layout()->activate();
|
||||||
|
|
||||||
positionButtons();
|
positionButtons();
|
||||||
/* may be the resize cuted off some space occupied by titlebar, which
|
/* may be the resize cuted off some space occupied by titlebar, which
|
||||||
was moved, so instead of reducing it, we first try to move it */
|
was moved, so instead of reducing it, we first try to move it */
|
||||||
titleMoveAbs(bar_x_ofs);
|
titleMoveAbs(bar_x_ofs);
|
||||||
doShape();
|
doShape();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
What does this? (MM)
|
What does this? (MM)
|
||||||
if ( isVisibleToTLW() && !testWFlags( WNorthWestGravity )) {
|
if ( isVisibleToTLW() && !testWFlags( WNorthWestGravity )) {
|
||||||
|
@ -898,28 +969,16 @@ void B2Client::positionButtons()
|
||||||
QFontMetrics fm(options->font(isActive()));
|
QFontMetrics fm(options->font(isActive()));
|
||||||
|
|
||||||
int textLen = fm.width(caption());
|
int textLen = fm.width(caption());
|
||||||
//int xpos = bar_x_ofs+4;
|
QLayoutIterator it=titlebar->layout()->iterator();
|
||||||
int xpos = 4;
|
++it;
|
||||||
button[BtnMenu]->move(xpos, 2);
|
++it;
|
||||||
xpos+=17;
|
++it;
|
||||||
button[BtnSticky]->move(xpos, 2);
|
|
||||||
xpos+=17;
|
|
||||||
if(providesContextHelp()){
|
|
||||||
button[BtnHelp]->move(xpos, 2);
|
|
||||||
xpos+=17;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(xpos + textLen+52 < width()-3)
|
int titleWidth=titlebar->width()-(++it)->geometry().width()+textLen+2;
|
||||||
xpos += textLen+1;
|
|
||||||
else
|
if( titleWidth > width()) titleWidth=width();
|
||||||
xpos = width()-3-52;
|
|
||||||
|
|
||||||
button[BtnIconify]->move(xpos, 2);
|
titlebar->resize(titleWidth,20);
|
||||||
xpos+=17;
|
|
||||||
button[BtnMax]->move(xpos, 2);
|
|
||||||
xpos+=17;
|
|
||||||
button[BtnClose]->move(xpos, 2);
|
|
||||||
titlebar->setFixedSize(xpos+17+4,20);
|
|
||||||
titlebar->move(bar_x_ofs, 0);
|
titlebar->move(bar_x_ofs, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue