2001-05-06 19:03:20 +00:00
|
|
|
/*
|
|
|
|
'Web' kwin client
|
|
|
|
|
|
|
|
Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; see the file COPYING. If not, write to
|
|
|
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2003-09-18 14:59:47 +00:00
|
|
|
#include <qlabel.h>
|
2001-05-06 19:03:20 +00:00
|
|
|
#include <qlayout.h>
|
|
|
|
#include <qpainter.h>
|
|
|
|
|
|
|
|
#include <kconfig.h>
|
|
|
|
|
|
|
|
#include "Web.h"
|
|
|
|
#include "WebButton.h"
|
|
|
|
#include "WebButtonHelp.h"
|
2003-09-18 14:59:47 +00:00
|
|
|
#include "WebButtonIconify.h" // minimize button
|
2001-05-06 19:03:20 +00:00
|
|
|
#include "WebButtonClose.h"
|
2003-09-18 14:59:47 +00:00
|
|
|
#include "WebButtonSticky.h" // onAllDesktops button
|
2001-05-06 19:03:20 +00:00
|
|
|
#include "WebButtonMaximize.h"
|
|
|
|
#include "WebButtonLower.h"
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
2003-09-18 14:59:47 +00:00
|
|
|
KDecorationFactory *create_factory()
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
2003-09-18 14:59:47 +00:00
|
|
|
return new Web::WebFactory();
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-27 18:08:20 +00:00
|
|
|
namespace Web {
|
2003-09-18 14:59:47 +00:00
|
|
|
|
|
|
|
WebClient::WebClient(KDecorationBridge* bridge, KDecorationFactory* factory)
|
|
|
|
: KDecoration(bridge, factory),
|
2001-05-19 01:58:07 +00:00
|
|
|
mainLayout_ (0),
|
|
|
|
titleSpacer_ (0)
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
2003-09-18 14:59:47 +00:00
|
|
|
// Empty.
|
|
|
|
}
|
|
|
|
|
|
|
|
WebClient::~WebClient()
|
|
|
|
{
|
|
|
|
// Empty.
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
WebClient::init()
|
|
|
|
{
|
|
|
|
createMainWidget(WNoAutoErase);
|
|
|
|
widget()->installEventFilter( this );
|
|
|
|
widget()->setBackgroundMode(NoBackground);
|
|
|
|
|
|
|
|
// title height
|
2003-11-20 09:05:00 +00:00
|
|
|
const int textVMargin = 2;
|
2003-09-18 14:59:47 +00:00
|
|
|
QFontMetrics fm(options()->font(isActive(), isTool()));
|
|
|
|
|
|
|
|
// border size
|
2003-09-24 12:41:56 +00:00
|
|
|
switch(options()->preferredBorderSize( factory())) {
|
2003-09-18 14:59:47 +00:00
|
|
|
case BorderLarge:
|
|
|
|
borderSize_ = 8;
|
|
|
|
break;
|
|
|
|
case BorderVeryLarge:
|
|
|
|
borderSize_ = 12;
|
|
|
|
break;
|
|
|
|
case BorderHuge:
|
2003-09-23 14:40:18 +00:00
|
|
|
borderSize_ = 18;
|
|
|
|
break;
|
|
|
|
case BorderVeryHuge:
|
|
|
|
borderSize_ = 27;
|
|
|
|
break;
|
|
|
|
case BorderOversized:
|
|
|
|
borderSize_ = 40;
|
2003-09-18 14:59:47 +00:00
|
|
|
break;
|
|
|
|
case BorderNormal:
|
|
|
|
default:
|
|
|
|
borderSize_ = 4;
|
|
|
|
}
|
2003-09-23 14:40:18 +00:00
|
|
|
titleHeight_ = QMAX(QMAX(14, fm.height() + textVMargin * 2), borderSize_);
|
2001-05-06 19:03:20 +00:00
|
|
|
|
|
|
|
_resetLayout();
|
|
|
|
|
|
|
|
leftButtonList_ .setAutoDelete(true);
|
|
|
|
rightButtonList_ .setAutoDelete(true);
|
|
|
|
}
|
|
|
|
|
2003-09-18 14:59:47 +00:00
|
|
|
void
|
|
|
|
WebClient::reset( unsigned long changed )
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
2003-09-18 14:59:47 +00:00
|
|
|
if (changed & SettingColors)
|
|
|
|
{
|
|
|
|
// repaint the whole thing
|
|
|
|
widget()->repaint(false);
|
|
|
|
} else if (changed & SettingFont) {
|
|
|
|
// font has changed -- update title height
|
|
|
|
// title height
|
|
|
|
const uint textVMargin = 2;
|
|
|
|
QFontMetrics fm(options()->font(isActive(), isTool()));
|
|
|
|
titleHeight_ = QMAX(14, fm.height() + textVMargin * 2);
|
|
|
|
// update buttons
|
|
|
|
for (QPtrListIterator<WebButton> it(leftButtonList_); it.current(); ++it)
|
|
|
|
{
|
|
|
|
it.current()->setFixedSize(titleHeight_, titleHeight_);
|
|
|
|
}
|
|
|
|
for (QPtrListIterator<WebButton> it(rightButtonList_); it.current(); ++it)
|
|
|
|
{
|
|
|
|
it.current()->setFixedSize(titleHeight_, titleHeight_);
|
|
|
|
}
|
|
|
|
// for (int n=0; n<NumButtons; n++) {
|
|
|
|
// if (m_button[n]) m_button[n]->setSize(s_titleHeight-1);
|
|
|
|
// }
|
|
|
|
// update the spacer
|
|
|
|
titleSpacer_->changeSize(0, titleHeight_, QSizePolicy::Expanding,
|
|
|
|
QSizePolicy::Fixed);
|
|
|
|
widget()->repaint(false);
|
|
|
|
}
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-09-18 14:59:47 +00:00
|
|
|
WebClient::resizeEvent(QResizeEvent *)
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
|
|
|
doShape();
|
2003-09-18 14:59:47 +00:00
|
|
|
widget()->repaint();
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-09-18 14:59:47 +00:00
|
|
|
WebClient::captionChange()
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
2003-09-18 14:59:47 +00:00
|
|
|
widget()->repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebClient::iconChange()
|
|
|
|
{
|
|
|
|
// Empty.
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-27 18:08:20 +00:00
|
|
|
WebClient::paintEvent(QPaintEvent * pe)
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
|
|
|
QRect titleRect(titleSpacer_->geometry());
|
|
|
|
titleRect.setTop(1);
|
|
|
|
|
2003-09-18 14:59:47 +00:00
|
|
|
QPainter p(widget());
|
2001-05-06 19:03:20 +00:00
|
|
|
|
|
|
|
p.setPen(Qt::black);
|
2003-09-18 14:59:47 +00:00
|
|
|
p.setBrush(options()->colorGroup(ColorFrame, isActive()).background());
|
2001-05-06 19:03:20 +00:00
|
|
|
|
|
|
|
p.setClipRegion(pe->region() - titleRect);
|
|
|
|
|
2003-09-18 14:59:47 +00:00
|
|
|
p.drawRect(widget()->rect());
|
2001-05-06 19:03:20 +00:00
|
|
|
|
|
|
|
p.setClipRegion(pe->region());
|
|
|
|
|
2003-09-18 14:59:47 +00:00
|
|
|
p.fillRect(titleRect, options()->color(ColorTitleBar, isActive()));
|
2001-05-06 19:03:20 +00:00
|
|
|
|
|
|
|
if (shape_)
|
|
|
|
{
|
|
|
|
int r(width());
|
|
|
|
int b(height());
|
|
|
|
|
|
|
|
// Draw edge of top-left corner inside the area removed by the mask.
|
|
|
|
|
|
|
|
p.drawPoint(3, 1);
|
|
|
|
p.drawPoint(4, 1);
|
|
|
|
p.drawPoint(2, 2);
|
|
|
|
p.drawPoint(1, 3);
|
|
|
|
p.drawPoint(1, 4);
|
|
|
|
|
|
|
|
// Draw edge of top-right corner inside the area removed by the mask.
|
|
|
|
|
|
|
|
p.drawPoint(r - 5, 1);
|
|
|
|
p.drawPoint(r - 4, 1);
|
|
|
|
p.drawPoint(r - 3, 2);
|
|
|
|
p.drawPoint(r - 2, 3);
|
|
|
|
p.drawPoint(r - 2, 4);
|
|
|
|
|
|
|
|
// Draw edge of bottom-left corner inside the area removed by the mask.
|
|
|
|
|
|
|
|
p.drawPoint(1, b - 5);
|
|
|
|
p.drawPoint(1, b - 4);
|
|
|
|
p.drawPoint(2, b - 3);
|
|
|
|
p.drawPoint(3, b - 2);
|
|
|
|
p.drawPoint(4, b - 2);
|
|
|
|
|
|
|
|
// Draw edge of bottom-right corner inside the area removed by the mask.
|
|
|
|
|
|
|
|
p.drawPoint(r - 2, b - 5);
|
|
|
|
p.drawPoint(r - 2, b - 4);
|
|
|
|
p.drawPoint(r - 3, b - 3);
|
|
|
|
p.drawPoint(r - 4, b - 2);
|
|
|
|
p.drawPoint(r - 5, b - 2);
|
|
|
|
}
|
|
|
|
|
2003-09-18 14:59:47 +00:00
|
|
|
p.setFont(options()->font(isActive(), isTool()));
|
2001-05-19 01:58:07 +00:00
|
|
|
|
2003-09-18 14:59:47 +00:00
|
|
|
p.setPen(options()->color(ColorFont, isActive()));
|
2001-05-19 01:58:07 +00:00
|
|
|
|
2001-05-06 19:03:20 +00:00
|
|
|
p.drawText(titleSpacer_->geometry(), AlignCenter, caption());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-27 18:08:20 +00:00
|
|
|
WebClient::doShape()
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
|
|
|
if (!shape_)
|
|
|
|
return;
|
2001-09-11 06:53:46 +00:00
|
|
|
|
2001-05-06 19:03:20 +00:00
|
|
|
QRegion mask(0, 0, width(), height());
|
|
|
|
|
|
|
|
int r(width());
|
|
|
|
int b(height());
|
|
|
|
|
|
|
|
// Remove top-left corner.
|
|
|
|
|
|
|
|
mask -= QRegion(0, 0, 5, 1);
|
|
|
|
mask -= QRegion(0, 1, 3, 1);
|
|
|
|
mask -= QRegion(0, 2, 2, 1);
|
|
|
|
mask -= QRegion(0, 3, 1, 2);
|
|
|
|
|
|
|
|
// Remove top-right corner.
|
|
|
|
|
|
|
|
mask -= QRegion(r - 5, 0, 5, 1);
|
|
|
|
mask -= QRegion(r - 3, 1, 3, 1);
|
|
|
|
mask -= QRegion(r - 2, 2, 2, 1);
|
|
|
|
mask -= QRegion(r - 1, 3, 1, 2);
|
|
|
|
|
|
|
|
// Remove bottom-left corner.
|
|
|
|
|
|
|
|
mask -= QRegion(0, b - 5, 1, 3);
|
|
|
|
mask -= QRegion(0, b - 3, 2, 1);
|
|
|
|
mask -= QRegion(0, b - 2, 3, 1);
|
|
|
|
mask -= QRegion(0, b - 1, 5, 1);
|
|
|
|
|
|
|
|
// Remove bottom-right corner.
|
|
|
|
|
|
|
|
mask -= QRegion(r - 5, b - 1, 5, 1);
|
|
|
|
mask -= QRegion(r - 3, b - 2, 3, 1);
|
|
|
|
mask -= QRegion(r - 2, b - 3, 2, 1);
|
|
|
|
mask -= QRegion(r - 1, b - 5, 1, 2);
|
|
|
|
|
|
|
|
setMask(mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-27 18:08:20 +00:00
|
|
|
WebClient::showEvent(QShowEvent *)
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
|
|
|
doShape();
|
2003-09-18 14:59:47 +00:00
|
|
|
widget()->repaint();
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-27 18:08:20 +00:00
|
|
|
WebClient::windowWrapperShowEvent(QShowEvent *)
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
|
|
|
doShape();
|
2003-09-18 14:59:47 +00:00
|
|
|
widget()->repaint();
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-27 18:08:20 +00:00
|
|
|
WebClient::mouseDoubleClickEvent(QMouseEvent * e)
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
|
|
|
if (titleSpacer_->geometry().contains(e->pos()))
|
|
|
|
{
|
2003-09-18 14:59:47 +00:00
|
|
|
titlebarDblClickOperation();
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-09-18 14:59:47 +00:00
|
|
|
WebClient::desktopChange()
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
2003-09-18 14:59:47 +00:00
|
|
|
emit(oadChange(isOnAllDesktops()));
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-09-18 14:59:47 +00:00
|
|
|
WebClient::maximizeChange()
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
2003-09-18 14:59:47 +00:00
|
|
|
emit(maxChange(maximizeMode()==MaximizeFull));
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-09-18 14:59:47 +00:00
|
|
|
WebClient::activeChange()
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
2003-09-18 14:59:47 +00:00
|
|
|
widget()->repaint();
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
|
2003-09-18 14:59:47 +00:00
|
|
|
WebClient::MousePosition
|
2002-08-27 18:08:20 +00:00
|
|
|
WebClient::mousePosition(const QPoint & p) const
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
|
|
|
int x = p.x();
|
|
|
|
int y = p.y();
|
2003-09-23 14:40:18 +00:00
|
|
|
int corner = 14 + 3*borderSize_/2;
|
2001-05-06 19:03:20 +00:00
|
|
|
|
|
|
|
if (y < titleSpacer_->geometry().height())
|
|
|
|
{
|
2001-05-19 02:05:58 +00:00
|
|
|
// rikkus: this style is not designed to be resizable at the top edge.
|
|
|
|
|
|
|
|
#if 0
|
2003-09-23 14:40:18 +00:00
|
|
|
if ((y < 4 && x < corner) || x < 4)
|
2001-05-13 06:58:29 +00:00
|
|
|
return Client::TopLeft;
|
2003-09-23 14:40:18 +00:00
|
|
|
else if ((y < 4 && x > width() - corner) || x > width() - 4)
|
2001-05-13 06:58:29 +00:00
|
|
|
return Client::TopRight;
|
|
|
|
else if (y < 4)
|
|
|
|
return Client::Top;
|
|
|
|
else
|
2001-05-19 02:05:58 +00:00
|
|
|
#endif
|
2003-09-18 14:59:47 +00:00
|
|
|
return KDecoration::Center;
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
2003-09-18 14:59:47 +00:00
|
|
|
else if (y < height() - borderSize_)
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
2003-09-18 14:59:47 +00:00
|
|
|
if (x < borderSize_)
|
|
|
|
return KDecoration::Left;
|
2001-05-06 19:03:20 +00:00
|
|
|
else
|
2003-09-18 14:59:47 +00:00
|
|
|
if (x > width() - borderSize_)
|
|
|
|
return KDecoration::Right;
|
2003-02-12 10:06:57 +00:00
|
|
|
else
|
2003-09-18 14:59:47 +00:00
|
|
|
return KDecoration::Center;
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-09-23 14:40:18 +00:00
|
|
|
if (x < 12 + corner)
|
2003-09-18 14:59:47 +00:00
|
|
|
return KDecoration::BottomLeft2;
|
2001-05-06 19:03:20 +00:00
|
|
|
else
|
2003-09-23 14:40:18 +00:00
|
|
|
if (x > width() - corner)
|
2003-09-18 14:59:47 +00:00
|
|
|
return KDecoration::BottomRight2;
|
2001-05-06 19:03:20 +00:00
|
|
|
else
|
2003-09-18 14:59:47 +00:00
|
|
|
return KDecoration::Bottom;
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
|
2003-09-18 14:59:47 +00:00
|
|
|
return KDecoration::mousePosition(p);
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-27 18:08:20 +00:00
|
|
|
WebClient::slotMaximize(int button)
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
|
|
|
switch (button)
|
|
|
|
{
|
|
|
|
case MidButton:
|
2003-09-18 14:59:47 +00:00
|
|
|
maximize(maximizeMode() ^ MaximizeVertical);
|
2001-05-06 19:03:20 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RightButton:
|
2003-09-18 14:59:47 +00:00
|
|
|
maximize(maximizeMode() ^ MaximizeHorizontal);
|
2001-05-06 19:03:20 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LeftButton:
|
|
|
|
default:
|
2003-09-18 14:59:47 +00:00
|
|
|
maximize(maximizeMode() == MaximizeFull ? MaximizeRestore : MaximizeFull);
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WebButton *
|
2002-08-27 18:08:20 +00:00
|
|
|
WebClient::_createButton(const QString & s, QWidget * parent)
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
|
|
|
WebButton * b = 0;
|
|
|
|
|
|
|
|
if (("Help" == s) && providesContextHelp())
|
|
|
|
{
|
|
|
|
b = new WebButtonHelp(parent);
|
2003-09-18 14:59:47 +00:00
|
|
|
connect(b, SIGNAL(help()), this, SLOT(showContextHelp()));
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
|
2003-09-18 14:59:47 +00:00
|
|
|
else if ("OnAllDesktops" == s)
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
2003-09-18 14:59:47 +00:00
|
|
|
b = new WebButtonSticky(isOnAllDesktops(), parent);
|
|
|
|
connect(b, SIGNAL(toggleSticky()), this, SLOT(toggleOnAllDesktops()));
|
|
|
|
connect(this, SIGNAL(oadChange(bool)), b, SLOT(slotOnAllDesktopsChange(bool)));
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
|
2003-09-18 14:59:47 +00:00
|
|
|
else if ("Minimize" == s && isMinimizable())
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
|
|
|
b = new WebButtonIconify(parent);
|
2003-09-18 14:59:47 +00:00
|
|
|
connect(b, SIGNAL(minimize()), this, SLOT(minimize()));
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
else if ("Maximize" == s && isMaximizable())
|
|
|
|
{
|
2003-09-18 14:59:47 +00:00
|
|
|
b = new WebButtonMaximize((maximizeMode()==MaximizeFull), parent);
|
2001-05-06 19:03:20 +00:00
|
|
|
connect(b, SIGNAL(maximize(int)), this, SLOT(slotMaximize(int)));
|
|
|
|
connect(this, SIGNAL(maxChange(bool)), b, SLOT(slotMaximizeChange(bool)));
|
|
|
|
}
|
|
|
|
|
2002-08-28 15:17:31 +00:00
|
|
|
else if ("Close" == s && isCloseable())
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
|
|
|
b = new WebButtonClose(parent);
|
|
|
|
connect(b, SIGNAL(closeWindow()), this, SLOT(closeWindow()));
|
|
|
|
}
|
|
|
|
|
|
|
|
else if ("Lower" == s)
|
|
|
|
{
|
|
|
|
b = new WebButtonLower(parent);
|
|
|
|
connect(b, SIGNAL(lowerWindow()), this, SLOT(slotLowerWindow()));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 != b)
|
|
|
|
{
|
|
|
|
b->setShape(shape_);
|
|
|
|
}
|
|
|
|
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-27 18:08:20 +00:00
|
|
|
WebClient::_createButtons()
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
|
|
|
leftButtonList_ .clear();
|
|
|
|
rightButtonList_ .clear();
|
|
|
|
|
2003-09-18 14:59:47 +00:00
|
|
|
QString buttons = options()->titleButtonsLeft() + "|" + options()->titleButtonsRight();
|
2001-09-11 06:53:46 +00:00
|
|
|
QPtrList<WebButton> *buttonList = &leftButtonList_;
|
2001-05-13 05:19:20 +00:00
|
|
|
for (unsigned int i = 0; i < buttons.length(); ++i)
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
2001-05-13 05:19:20 +00:00
|
|
|
WebButton * tb = 0;
|
|
|
|
switch (buttons[i].latin1())
|
|
|
|
{
|
2003-09-18 14:59:47 +00:00
|
|
|
case 'S': // OnAllDesktops
|
|
|
|
tb = _createButton("OnAllDesktops", widget());
|
2001-05-13 05:19:20 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'H': // Help
|
2003-09-18 14:59:47 +00:00
|
|
|
tb = _createButton("Help", widget());
|
2001-05-13 05:19:20 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'I': // Minimize
|
2003-09-18 14:59:47 +00:00
|
|
|
tb = _createButton("Minimize", widget());
|
2001-05-13 05:19:20 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'A': // Maximize
|
2003-09-18 14:59:47 +00:00
|
|
|
tb = _createButton("Maximize", widget());
|
2001-05-13 05:19:20 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'X': // Close
|
2003-09-18 14:59:47 +00:00
|
|
|
tb = _createButton("Close", widget());
|
2001-05-13 05:19:20 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case '|':
|
|
|
|
buttonList = &rightButtonList_;
|
|
|
|
break;
|
|
|
|
}
|
2001-05-06 19:03:20 +00:00
|
|
|
if (0 != tb)
|
2001-05-13 05:19:20 +00:00
|
|
|
buttonList->append(tb);
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!leftButtonList_.isEmpty())
|
|
|
|
leftButtonList_.first()->setPosition(WebButton::Left);
|
|
|
|
|
|
|
|
if (!rightButtonList_.isEmpty())
|
|
|
|
rightButtonList_.last()->setPosition(WebButton::Right);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-27 18:08:20 +00:00
|
|
|
WebClient::_resetLayout()
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
2003-09-18 14:59:47 +00:00
|
|
|
KConfig c("kwinwebrc");
|
2001-05-19 01:58:07 +00:00
|
|
|
c.setGroup("General");
|
|
|
|
shape_ = c.readBoolEntry("Shape", true);
|
|
|
|
|
2001-05-06 19:03:20 +00:00
|
|
|
// ____________________________________
|
|
|
|
// | | | |
|
|
|
|
// |Xo| titleSpacer |v^| <--- topLayout
|
|
|
|
// |__|______________________________|__|
|
|
|
|
// | | | |
|
|
|
|
// | | | |
|
2003-09-18 14:59:47 +00:00
|
|
|
// | | fake window | |
|
2001-05-06 19:03:20 +00:00
|
|
|
// | | | | <--- midLayout
|
|
|
|
// | | | |
|
|
|
|
// | | | |
|
|
|
|
// | |________________________________| |
|
|
|
|
// |____________________________________|
|
|
|
|
|
2003-09-18 14:59:47 +00:00
|
|
|
const uint sideMargin = borderSize_;
|
|
|
|
const uint bottomMargin = borderSize_;
|
2001-05-06 19:03:20 +00:00
|
|
|
|
2003-09-18 14:59:47 +00:00
|
|
|
if (0 != titleHeight_ % 2)
|
|
|
|
titleHeight_ += 1;
|
2001-05-06 19:03:20 +00:00
|
|
|
|
|
|
|
delete mainLayout_;
|
|
|
|
|
2003-09-18 14:59:47 +00:00
|
|
|
mainLayout_ = new QVBoxLayout(widget(), 0, 0);
|
2001-05-06 19:03:20 +00:00
|
|
|
|
2003-09-18 14:59:47 +00:00
|
|
|
titleSpacer_ = new QSpacerItem ( 0, titleHeight_, QSizePolicy::Expanding,
|
2002-08-27 15:12:14 +00:00
|
|
|
QSizePolicy::Fixed);
|
|
|
|
|
|
|
|
QBoxLayout * topLayout = new QBoxLayout(mainLayout_, QBoxLayout::LeftToRight, 0, 0);
|
2001-05-06 19:03:20 +00:00
|
|
|
|
|
|
|
_createButtons();
|
|
|
|
|
|
|
|
// Add left-side buttons.
|
|
|
|
|
2001-09-11 06:53:46 +00:00
|
|
|
for (QPtrListIterator<WebButton> it(leftButtonList_); it.current(); ++it)
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
|
|
|
topLayout->addWidget(it.current(), Qt::AlignVCenter);
|
|
|
|
topLayout->setStretchFactor(it.current(), 0);
|
2003-09-18 14:59:47 +00:00
|
|
|
it.current()->setFixedSize(titleHeight_, titleHeight_);
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
topLayout->addItem(titleSpacer_);
|
|
|
|
|
|
|
|
// Add right-side buttons.
|
|
|
|
|
2001-09-11 06:53:46 +00:00
|
|
|
for (QPtrListIterator<WebButton> it(rightButtonList_); it.current(); ++it)
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
|
|
|
topLayout->addWidget(it.current(), Qt::AlignVCenter);
|
2003-09-18 14:59:47 +00:00
|
|
|
it.current()->setFixedSize(titleHeight_, titleHeight_);
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
QHBoxLayout * midLayout = new QHBoxLayout(mainLayout_, 0, 0);
|
2001-09-11 06:53:46 +00:00
|
|
|
|
2001-05-06 19:03:20 +00:00
|
|
|
midLayout->addSpacing(sideMargin);
|
2003-10-30 18:01:43 +00:00
|
|
|
if( isPreview())
|
|
|
|
midLayout->addWidget(new QLabel( i18n( "<center><b>Web</b></center>" ), widget()));
|
|
|
|
else
|
|
|
|
midLayout->addItem( new QSpacerItem( 0, 0 )); // no widget in the middle
|
2001-05-06 19:03:20 +00:00
|
|
|
midLayout->addSpacing(sideMargin);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
mainLayout_->addSpacing(bottomMargin);
|
|
|
|
|
|
|
|
// Make sure that topLayout doesn't stretch - midLayout should take
|
|
|
|
// all spare space.
|
|
|
|
|
|
|
|
mainLayout_->setStretchFactor(topLayout, 0);
|
|
|
|
mainLayout_->setStretchFactor(midLayout, 1);
|
|
|
|
}
|
|
|
|
|
2003-09-18 14:59:47 +00:00
|
|
|
void WebClient::borders(int& left, int& right, int& top, int& bottom) const
|
|
|
|
{
|
|
|
|
left = borderSize_;
|
|
|
|
right = borderSize_;
|
|
|
|
top = titleHeight_;
|
|
|
|
bottom = borderSize_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebClient::resize( const QSize& s )
|
|
|
|
{
|
|
|
|
widget()->resize( s );
|
|
|
|
}
|
|
|
|
|
|
|
|
QSize WebClient::minimumSize() const
|
|
|
|
{
|
|
|
|
return QSize( 200, 50 );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WebClient::isTool()
|
|
|
|
{
|
|
|
|
NET::WindowType type = windowType(NET::NormalMask|NET::ToolbarMask|NET::UtilityMask|NET::MenuMask);
|
|
|
|
return ((type==NET::Toolbar)||(type==NET::NET::Utility)||(type==NET::Menu));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WebClient::eventFilter( QObject* o, QEvent* e )
|
|
|
|
{
|
|
|
|
if( o != widget())
|
|
|
|
return false;
|
|
|
|
switch( e->type())
|
|
|
|
{
|
|
|
|
case QEvent::Resize:
|
|
|
|
resizeEvent(static_cast< QResizeEvent* >( e ) );
|
|
|
|
return true;
|
|
|
|
case QEvent::Paint:
|
|
|
|
paintEvent(static_cast< QPaintEvent* >( e ) );
|
|
|
|
return true;
|
|
|
|
case QEvent::MouseButtonDblClick:
|
|
|
|
mouseDoubleClickEvent(static_cast< QMouseEvent* >( e ) );
|
|
|
|
return true;
|
|
|
|
case QEvent::MouseButtonPress:
|
|
|
|
processMousePressEvent(static_cast< QMouseEvent* >( e ) );
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KDecoration* WebFactory::createDecoration( KDecorationBridge* b )
|
|
|
|
{
|
|
|
|
return(new WebClient(b, this));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WebFactory::reset(unsigned long changed)
|
2001-05-06 19:03:20 +00:00
|
|
|
{
|
2003-09-18 14:59:47 +00:00
|
|
|
// Do we need to "hit the wooden hammer" ?
|
|
|
|
bool needHardReset = true;
|
|
|
|
if (changed & SettingColors || changed & SettingFont)
|
|
|
|
{
|
|
|
|
needHardReset = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (needHardReset) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
resetDecorations(changed);
|
|
|
|
return false;
|
|
|
|
}
|
2001-05-06 19:03:20 +00:00
|
|
|
}
|
|
|
|
|
2003-09-24 12:41:56 +00:00
|
|
|
QValueList< WebFactory::BorderSize > WebFactory::borderSizes() const
|
|
|
|
{ // the list must be sorted
|
|
|
|
return QValueList< BorderSize >() << BorderNormal << BorderLarge <<
|
|
|
|
BorderVeryLarge << BorderHuge << BorderVeryHuge << BorderOversized;
|
|
|
|
}
|
|
|
|
|
2003-07-26 10:41:28 +00:00
|
|
|
}
|
2002-08-27 18:08:20 +00:00
|
|
|
|
2001-05-06 19:03:20 +00:00
|
|
|
#include "Web.moc"
|
|
|
|
// vim:ts=2:sw=2:tw=78:set et:
|