2009-08-22 08:24:06 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-09-15 07:12:54 +00:00
|
|
|
// oxygenclient.cpp
|
2009-08-22 08:24:06 +00:00
|
|
|
// -------------------
|
2009-09-09 00:55:55 +00:00
|
|
|
//
|
2009-08-24 16:14:11 +00:00
|
|
|
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
|
2009-08-25 04:15:13 +00:00
|
|
|
// Copyright (c) 2006, 2007 Casper Boemann <cbr@boemann.dk>
|
|
|
|
// Copyright (c) 2006, 2007 Riccardo Iaconelli <riccardo@kde.org>
|
2009-08-22 08:24:06 +00:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to
|
|
|
|
// deal in the Software without restriction, including without limitation the
|
|
|
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
// sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
2009-09-09 00:55:55 +00:00
|
|
|
// IN THE SOFTWARE.
|
2009-08-22 08:24:06 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2009-09-16 06:09:31 +00:00
|
|
|
#include "oxygenclient.h"
|
|
|
|
#include "oxygenclient.moc"
|
|
|
|
|
|
|
|
#include "oxygenbutton.h"
|
|
|
|
#include "oxygensizegrip.h"
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
#include <cassert>
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
#include <KLocale>
|
|
|
|
#include <KColorUtils>
|
2010-06-02 06:04:17 +00:00
|
|
|
#include <KDebug>
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2009-11-15 03:24:04 +00:00
|
|
|
#include <QtGui/QApplication>
|
2009-09-20 07:42:03 +00:00
|
|
|
#include <QtGui/QLabel>
|
|
|
|
#include <QtGui/QPainter>
|
2009-11-15 03:24:04 +00:00
|
|
|
#include <QtGui/QBitmap>
|
2010-04-25 21:34:20 +00:00
|
|
|
#include <QtCore/QObjectList>
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2009-09-15 07:12:54 +00:00
|
|
|
namespace Oxygen
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//___________________________________________
|
|
|
|
Client::Client(KDecorationBridge *b, Factory *f):
|
|
|
|
KCommonDecorationUnstable(b, f),
|
|
|
|
factory_( f ),
|
|
|
|
sizeGrip_( 0 ),
|
|
|
|
glowAnimation_( new Animation( 200, this ) ),
|
|
|
|
titleAnimationData_( new TitleAnimationData( this ) ),
|
|
|
|
glowIntensity_(0),
|
|
|
|
initialized_( false ),
|
|
|
|
forceActive_( false ),
|
|
|
|
mouseButton_( Qt::NoButton ),
|
|
|
|
itemData_( this ),
|
|
|
|
sourceItem_( -1 )
|
|
|
|
{}
|
|
|
|
|
|
|
|
//___________________________________________
|
|
|
|
Client::~Client()
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// delete sizegrip if any
|
|
|
|
if( hasSizeGrip() ) deleteSizeGrip();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//___________________________________________
|
|
|
|
QString Client::visibleName() const
|
|
|
|
{ return i18n("Oxygen"); }
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//___________________________________________
|
|
|
|
void Client::init()
|
2009-09-10 05:13:25 +00:00
|
|
|
{
|
2009-09-14 19:21:39 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
KCommonDecoration::init();
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
widget()->setAttribute(Qt::WA_NoSystemBackground );
|
|
|
|
widget()->setAutoFillBackground( false );
|
|
|
|
widget()->setAcceptDrops( true );
|
2009-12-18 15:20:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// setup glow animation
|
2010-08-31 14:24:01 +00:00
|
|
|
glowAnimation_->setStartValue( glowBias() );
|
|
|
|
glowAnimation_->setEndValue( 1.0 );
|
|
|
|
glowAnimation_->setTargetObject( this );
|
|
|
|
glowAnimation_->setPropertyName( "glowIntensity" );
|
|
|
|
glowAnimation_->setEasingCurve( QEasingCurve::InOutQuad );
|
|
|
|
connect( glowAnimation_, SIGNAL( finished( void ) ), this, SLOT( clearForceActive( void ) ) );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// title animation data
|
2010-08-31 14:30:17 +00:00
|
|
|
titleAnimationData_->initialize();
|
|
|
|
connect( titleAnimationData_, SIGNAL( pixmapsChanged() ), SLOT( updateTitleRect() ) );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// lists
|
|
|
|
connect( itemData_.animation().data(), SIGNAL( finished() ), this, SLOT( clearTargetItem() ) );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// in case of preview, one wants to make the label used
|
|
|
|
// for the central widget transparent. This allows one to have
|
|
|
|
// the correct background (with gradient) rendered
|
|
|
|
// Remark: this is minor (and safe) a hack.
|
|
|
|
// This should be moved upstream (into kwin/lib/kdecoration)
|
|
|
|
if( isPreview() )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
QList<QLabel*> children( widget()->findChildren<QLabel*>() );
|
|
|
|
foreach( QLabel* widget, children )
|
|
|
|
{ widget->setAutoFillBackground( false ); }
|
2009-09-10 05:13:25 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
initialized_ = true;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// first reset is needed to store Oxygen configuration
|
|
|
|
reset(0);
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//___________________________________________
|
|
|
|
void Client::reset( unsigned long changed )
|
|
|
|
{
|
|
|
|
KCommonDecorationUnstable::reset( changed );
|
|
|
|
|
|
|
|
// update window mask when compositing is changed
|
|
|
|
if( !initialized_ ) return;
|
|
|
|
if( changed & SettingCompositing )
|
|
|
|
{
|
|
|
|
updateWindowShape();
|
|
|
|
widget()->update();
|
|
|
|
}
|
|
|
|
|
|
|
|
configuration_ = factory_->configuration( *this );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// animations duration
|
2010-08-31 14:24:01 +00:00
|
|
|
glowAnimation_->setDuration( configuration_.animationsDuration() );
|
2010-08-31 14:30:17 +00:00
|
|
|
titleAnimationData_->setDuration( configuration_.animationsDuration() );
|
2010-05-02 18:34:08 +00:00
|
|
|
itemData_.animation().data()->setDuration( configuration_.animationsDuration() );
|
|
|
|
itemData_.setAnimationsEnabled( useAnimations() );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// reset title transitions
|
2010-08-31 14:30:17 +00:00
|
|
|
titleAnimationData_->reset();
|
2009-10-14 14:37:58 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// should also update animations for buttons
|
|
|
|
resetButtons();
|
2009-10-14 14:37:58 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// also reset tab buttons
|
|
|
|
for( int index = 0; index < itemData_.count(); index++ )
|
|
|
|
{
|
|
|
|
ClientGroupItemData& item( itemData_[index] );
|
|
|
|
if( item.closeButton_ ) { item.closeButton_.data()->reset(0); }
|
|
|
|
}
|
2009-10-14 14:37:58 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// reset tab geometry
|
|
|
|
itemData_.setDirty( true );
|
2009-10-14 14:37:58 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// handle size grip
|
|
|
|
if( configuration_.drawSizeGrip() )
|
|
|
|
{
|
2009-10-14 14:37:58 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( !hasSizeGrip() ) createSizeGrip();
|
2009-10-14 14:37:58 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else if( hasSizeGrip() ) deleteSizeGrip();
|
2009-10-14 14:37:58 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//___________________________________________
|
|
|
|
bool Client::decorationBehaviour(DecorationBehaviour behaviour) const
|
|
|
|
{
|
|
|
|
switch (behaviour)
|
|
|
|
{
|
2009-10-14 14:37:58 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
case DB_MenuClose:
|
|
|
|
return true;
|
2009-10-14 14:37:58 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
case DB_WindowMask:
|
|
|
|
return false;
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
default:
|
|
|
|
return KCommonDecoration::decorationBehaviour(behaviour);
|
|
|
|
}
|
2009-10-14 14:37:58 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
KCommonDecorationButton *Client::createButton(::ButtonType type)
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
switch (type) {
|
2009-10-14 14:37:58 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
case MenuButton:
|
|
|
|
return new Button(*this, i18n("Menu"), ButtonMenu);
|
2009-10-14 14:37:58 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
case HelpButton:
|
|
|
|
return new Button(*this, i18n("Help"), ButtonHelp);
|
2009-10-14 14:37:58 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
case MinButton:
|
|
|
|
return new Button(*this, i18n("Minimize"), ButtonMin);
|
2009-10-14 14:37:58 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
case MaxButton:
|
|
|
|
return new Button(*this, i18n("Maximize"), ButtonMax);
|
2009-10-14 14:37:58 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
case CloseButton:
|
|
|
|
return new Button(*this, i18n("Close"), ButtonClose);
|
2009-10-14 14:37:58 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
case AboveButton:
|
|
|
|
return new Button(*this, i18n("Keep Above Others"), ButtonAbove);
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
case BelowButton:
|
|
|
|
return new Button(*this, i18n("Keep Below Others"), ButtonBelow);
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
case OnAllDesktopsButton:
|
|
|
|
return new Button(*this, i18n("On All Desktops"), ButtonSticky);
|
2009-09-20 17:51:06 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
case ShadeButton:
|
|
|
|
return new Button(*this, i18n("Shade Button"), ButtonShade);
|
2009-09-20 17:51:06 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
default: break;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
return NULL;
|
2009-09-09 16:28:01 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 16:28:01 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
QRegion Client::calcMask( void ) const
|
|
|
|
{
|
2009-10-13 03:38:26 +00:00
|
|
|
|
2010-05-10 01:56:24 +00:00
|
|
|
if( isMaximized() ) { return widget()->rect(); }
|
2010-07-28 01:54:51 +00:00
|
|
|
const QRect frame( widget()->rect().adjusted(
|
2010-05-02 18:34:08 +00:00
|
|
|
layoutMetric( LM_OuterPaddingLeft ), layoutMetric( LM_OuterPaddingTop ),
|
|
|
|
-layoutMetric( LM_OuterPaddingRight ), -layoutMetric( LM_OuterPaddingBottom ) ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-06-02 06:04:17 +00:00
|
|
|
QRegion mask;
|
2010-05-10 01:56:24 +00:00
|
|
|
if( configuration().frameBorder() == Configuration::BorderNone && !isShade() )
|
|
|
|
{
|
|
|
|
|
2010-06-02 06:04:17 +00:00
|
|
|
if( configuration().hideTitleBar() ) mask = QRegion();
|
|
|
|
else if( compositingActive() ) mask = (configuration().shadowMode() == Configuration::OxygenShadows ) ? QRegion():helper().decoRoundedMask( frame, 1, 1, 1, 0 );
|
|
|
|
else mask = helper().roundedMask( frame, 1, 1, 1, 0 );
|
2010-05-10 01:56:24 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2010-06-02 06:04:17 +00:00
|
|
|
if( compositingActive() ) mask = (configuration().shadowMode() == Configuration::OxygenShadows ) ? QRegion():helper().decoRoundedMask( frame );
|
|
|
|
else mask = helper().roundedMask( frame );
|
2010-05-10 01:56:24 +00:00
|
|
|
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-06-02 06:04:17 +00:00
|
|
|
return mask;
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//___________________________________________
|
|
|
|
int Client::layoutMetric(LayoutMetric lm, bool respectWindowState, const KCommonDecorationButton *btn) const
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const bool maximized( isMaximized() );
|
|
|
|
const bool narrowSpacing( configuration().useNarrowButtonSpacing() );
|
|
|
|
const int frameBorder( configuration().frameBorder() );
|
|
|
|
const int buttonSize( configuration().hideTitleBar() ? 0 : configuration().buttonSize() );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
switch (lm)
|
2009-09-09 00:55:55 +00:00
|
|
|
{
|
2010-05-02 18:34:08 +00:00
|
|
|
case LM_BorderLeft:
|
|
|
|
case LM_BorderRight:
|
2010-08-31 05:44:19 +00:00
|
|
|
case LM_BorderBottom:
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
|
|
|
int border( 0 );
|
|
|
|
if( respectWindowState && maximized )
|
|
|
|
{
|
2009-11-07 03:33:53 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
border = 0;
|
2009-11-07 03:33:53 +00:00
|
|
|
|
2010-08-31 05:16:02 +00:00
|
|
|
} else if( lm == LM_BorderBottom && frameBorder >= Configuration::BorderNoSide ) {
|
2009-11-07 03:33:53 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// for tiny border, the convention is to have a larger bottom area in order to
|
|
|
|
// make resizing easier
|
|
|
|
border = qMax(frameBorder, 4);
|
2009-11-07 03:33:53 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else if( frameBorder < Configuration::BorderTiny ) {
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
border = 0;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else if( !compositingActive() && frameBorder == Configuration::BorderTiny ) {
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
border = qMax( frameBorder, 3 );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else {
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
border = frameBorder;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
return border;
|
|
|
|
}
|
2009-10-15 16:03:30 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
case LM_TitleEdgeTop:
|
|
|
|
{
|
|
|
|
int border = 0;
|
|
|
|
if( frameBorder == Configuration::BorderNone && configuration().hideTitleBar() )
|
|
|
|
{
|
2009-10-15 16:03:30 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
border = 0;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else if( !( respectWindowState && maximized )) {
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
border = TFRAMESIZE;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
return border;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
case LM_TitleEdgeBottom:
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
case LM_TitleEdgeLeft:
|
|
|
|
case LM_TitleEdgeRight:
|
|
|
|
{
|
|
|
|
int border = 0;
|
|
|
|
if( !(respectWindowState && maximized) )
|
|
|
|
{ border = 4; }
|
2009-11-15 07:27:49 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
return border;
|
2009-11-15 07:27:49 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 07:27:49 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
case LM_TitleBorderLeft:
|
|
|
|
case LM_TitleBorderRight:
|
|
|
|
{
|
|
|
|
int border = 5;
|
2009-11-15 07:27:49 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// if title outline is to be drawn, one adds the space needed to
|
|
|
|
// separate title and tab border. namely the same value
|
|
|
|
if( configuration().drawTitleOutline() ) border += border;
|
2009-11-15 07:27:49 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
return border;
|
|
|
|
}
|
2009-11-15 07:27:49 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
case LM_ButtonWidth:
|
|
|
|
case LM_ButtonHeight:
|
|
|
|
case LM_TitleHeight:
|
|
|
|
{
|
|
|
|
return buttonSize;
|
|
|
|
}
|
2009-11-15 07:27:49 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
case LM_ButtonSpacing:
|
|
|
|
return narrowSpacing ? 1:3;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
case LM_ButtonMarginTop:
|
|
|
|
return 0;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// outer margin for shadow/glow
|
|
|
|
case LM_OuterPaddingLeft:
|
|
|
|
case LM_OuterPaddingRight:
|
|
|
|
case LM_OuterPaddingTop:
|
|
|
|
case LM_OuterPaddingBottom:
|
|
|
|
return shadowCache().shadowSize();
|
2009-10-15 16:03:30 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
default:
|
|
|
|
return KCommonDecoration::layoutMetric(lm, respectWindowState, btn);
|
|
|
|
}
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
QRect Client::defaultTitleRect( bool active ) const
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-08-28 19:58:22 +00:00
|
|
|
QRect titleRect( this->titleRect().adjusted( 0, -layoutMetric( LM_TitleEdgeTop ), 0, 0 ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
if( active && configuration().drawTitleOutline() && isActive() )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const QRect textRect( titleBoundingRect( options()->font( true, false), titleRect, caption() ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
titleRect.setLeft( textRect.left() - layoutMetric( LM_TitleBorderLeft ) );
|
|
|
|
titleRect.setRight( textRect.right() + layoutMetric( LM_TitleBorderRight ) );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else {
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
titleRect.setLeft( widget()->rect().left() + layoutMetric( LM_OuterPaddingLeft ) );
|
|
|
|
titleRect.setRight( widget()->rect().right() - layoutMetric( LM_OuterPaddingRight ) );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
return titleRect;
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
QRect Client::titleBoundingRect( const QFont& font, QRect rect, const QString& caption ) const
|
2009-11-15 03:24:04 +00:00
|
|
|
{
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// get title bounding rect
|
2010-08-28 19:58:22 +00:00
|
|
|
QRect boundingRect( QFontMetrics( font ).boundingRect( rect, configuration().titleAlignment() | Qt::AlignVCenter, caption ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
|
|
|
|
// adjust to make sure bounding rect
|
|
|
|
// 1/ has same vertical alignment as original titleRect
|
|
|
|
// 2/ does not exceeds available horizontal space
|
|
|
|
boundingRect.setTop( rect.top() );
|
|
|
|
boundingRect.setBottom( rect.bottom() );
|
|
|
|
|
|
|
|
// check bounding rect against input rect
|
|
|
|
if( rect.left() > boundingRect.left() ) { boundingRect.setLeft( rect.left() ); }
|
|
|
|
if( rect.right() < boundingRect.right() ) { boundingRect.setRight( rect.right() ); }
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
return boundingRect;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//_________________________________________________________
|
|
|
|
void Client::clearTargetItem( void )
|
2009-11-15 03:24:04 +00:00
|
|
|
{
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( itemData_.animationType() == AnimationLeave )
|
|
|
|
{ itemData_.setDirty( true ); }
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
void Client::updateItemBoundingRects( bool alsoUpdate )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// make sure items are not animated
|
|
|
|
itemData_.animate( AnimationNone );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// maximum available space
|
2010-07-28 01:54:51 +00:00
|
|
|
const QRect titleRect( this->titleRect() );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// get tabs
|
2010-07-28 01:54:51 +00:00
|
|
|
const int items( clientGroupItems().count() );
|
2010-05-02 18:34:08 +00:00
|
|
|
|
|
|
|
// make sure item data have the correct number of items
|
|
|
|
while( itemData_.count() < items ) itemData_.push_back( ClientGroupItemData() );
|
|
|
|
while( itemData_.count() > items )
|
2009-11-15 03:24:04 +00:00
|
|
|
{
|
2010-05-02 18:34:08 +00:00
|
|
|
if( itemData_.back().closeButton_ ) delete itemData_.back().closeButton_.data();
|
|
|
|
itemData_.pop_back();
|
2009-11-15 03:24:04 +00:00
|
|
|
}
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
assert( !itemData_.isEmpty() );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// create buttons
|
|
|
|
if( itemData_.count() == 1 )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// remove button
|
|
|
|
if( itemData_.front().closeButton_ )
|
|
|
|
{ delete itemData_.front().closeButton_.data(); }
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// set active rect
|
|
|
|
itemData_.front().activeRect_ = titleRect.adjusted( 0, -layoutMetric( LM_TitleEdgeTop ), 0, 0 );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else {
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
int left( titleRect.left() );
|
2010-07-28 01:54:51 +00:00
|
|
|
const int width( titleRect.width()/items );
|
2010-05-02 18:34:08 +00:00
|
|
|
for( int index = 0; index < itemData_.count(); index++ )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
ClientGroupItemData& item(itemData_[index]);
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// make sure button exists
|
|
|
|
if( !item.closeButton_ )
|
|
|
|
{
|
|
|
|
item.closeButton_ = ClientGroupItemData::ButtonPointer( new Button( *this, "Close this tab", ButtonItemClose ) );
|
|
|
|
item.closeButton_.data()->show();
|
|
|
|
item.closeButton_.data()->installEventFilter( this );
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// set active rect
|
|
|
|
QRect local( QPoint( left, titleRect.top() ), QSize( width, titleRect.height() ) );
|
|
|
|
local.adjust( 0, -layoutMetric( LM_TitleEdgeTop ), 0, 0 );
|
|
|
|
item.activeRect_ = local;
|
|
|
|
left += width;
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( itemData_.count() == 1 )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
itemData_.front().reset( defaultTitleRect() );
|
2009-09-18 19:47:53 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else {
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
for( int index = 0; index < itemData_.count(); index++ )
|
|
|
|
{ itemData_[index].reset( itemData_[index].activeRect_ ); }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// button activity
|
|
|
|
itemData_.updateButtonActivity( visibleClientGroupItem() );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// reset buttons location
|
|
|
|
itemData_.updateButtons( alsoUpdate );
|
|
|
|
itemData_.setDirty( false );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
return;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
2010-08-28 19:58:22 +00:00
|
|
|
QColor Client::titlebarTextColor(const QPalette &palette) const
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
|
|
|
if( glowIsAnimated() ) return KColorUtils::mix(
|
|
|
|
titlebarTextColor( palette, false ),
|
|
|
|
titlebarTextColor( palette, true ),
|
|
|
|
glowIntensity() );
|
|
|
|
else return titlebarTextColor( palette, isActive() );
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
void Client::renderWindowBackground( QPainter* painter, const QRect& rect, const QWidget* widget, const QPalette& palette ) const
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( configuration().blendColor() == Configuration::NoBlending )
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-08-28 19:58:22 +00:00
|
|
|
painter->fillRect( rect, palette.color( QPalette::Window ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const int offset = layoutMetric( LM_OuterPaddingTop );
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
int height = 64 - Configuration::ButtonDefault;
|
|
|
|
if( !configuration().hideTitleBar() ) height += configuration().buttonSize();
|
2010-07-28 01:54:51 +00:00
|
|
|
|
2010-05-20 21:41:19 +00:00
|
|
|
const QWidget* window( isPreview() ? this->widget() : widget->window() );
|
2010-05-02 18:34:08 +00:00
|
|
|
helper().renderWindowBackground(painter, rect, widget, window, palette, offset, height );
|
|
|
|
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
void Client::renderWindowBorder( QPainter* painter, const QRect& clipRect, const QWidget* widget, const QPalette& palette ) const
|
2009-09-26 21:21:39 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// get coordinates relative to the client area
|
|
|
|
// this is annoying. One could use mapTo if this was taking const QWidget* and not
|
|
|
|
// const QWidget* as argument.
|
2010-05-20 21:41:19 +00:00
|
|
|
const QWidget* window = (isPreview()) ? this->widget() : widget->window();
|
2010-05-02 18:34:08 +00:00
|
|
|
const QWidget* w = widget;
|
|
|
|
QPoint position( 0, 0 );
|
|
|
|
while ( w != window && !w->isWindow() && w != w->parentWidget() )
|
|
|
|
{
|
|
|
|
position += w->geometry().topLeft();
|
|
|
|
w = w->parentWidget();
|
|
|
|
}
|
2009-10-16 20:27:43 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// save painter
|
|
|
|
if( clipRect.isValid() )
|
|
|
|
{
|
|
|
|
painter->save();
|
|
|
|
painter->setClipRegion(clipRect,Qt::IntersectClip);
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-20 21:41:19 +00:00
|
|
|
QRect r = (isPreview()) ? this->widget()->rect():window->rect();
|
2010-07-28 01:54:51 +00:00
|
|
|
|
|
|
|
const qreal shadowSize( shadowCache().shadowSize() );
|
2010-05-02 18:34:08 +00:00
|
|
|
r.adjust( shadowSize, shadowSize, -shadowSize, -shadowSize );
|
|
|
|
r.adjust(0,0, 1, 1);
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// base color
|
|
|
|
QColor color( palette.window().color() );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// title height
|
2010-07-28 01:54:51 +00:00
|
|
|
const int titleHeight( layoutMetric( LM_TitleEdgeTop ) + layoutMetric( LM_TitleEdgeBottom ) + layoutMetric( LM_TitleHeight ) );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// make titlebar background darker for tabbed, non-outline window
|
|
|
|
if( ( clientGroupItems().count() >= 2 || itemData_.isAnimated() ) && !(configuration().drawTitleOutline() && isActive() ) )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const QPoint topLeft( r.topLeft()-position );
|
|
|
|
const QRect rect( topLeft, QSize( r.width(), titleHeight ) );
|
2009-10-15 16:03:30 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
QLinearGradient lg( rect.topLeft(), rect.bottomLeft() );
|
|
|
|
lg.setColorAt( 0, helper().alphaColor( Qt::black, 0.05 ) );
|
|
|
|
lg.setColorAt( 1, helper().alphaColor( Qt::black, 0.10 ) );
|
|
|
|
painter->setBrush( lg );
|
|
|
|
painter->setPen( Qt::NoPen );
|
|
|
|
painter->drawRect( rect );
|
2009-10-15 16:03:30 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-10-15 16:03:30 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// horizontal line
|
|
|
|
{
|
2010-07-28 01:54:51 +00:00
|
|
|
const int shadowSize = 7;
|
|
|
|
const int height = shadowSize-3;
|
2009-10-15 16:03:30 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const QPoint topLeft( r.topLeft()+QPoint(0,titleHeight-height)-position );
|
2010-05-02 18:34:08 +00:00
|
|
|
QRect rect( topLeft, QSize( r.width(), height ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// adjustements to cope with shadow size and outline border.
|
|
|
|
rect.adjust( -shadowSize, 0, shadowSize-1, 0 );
|
|
|
|
if( configuration().frameBorder() > Configuration::BorderTiny && configuration().drawTitleOutline() && isActive() && !isMaximized() )
|
|
|
|
{ rect.adjust( HFRAMESIZE-1, 0, -HFRAMESIZE+1, 0 ); }
|
2009-10-09 00:19:32 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
helper().slab( color, 0, shadowSize )->render( rect, painter, TileSet::Top );
|
2009-10-09 00:19:32 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-10-09 00:19:32 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( configuration().drawTitleOutline() && isActive() )
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// save mask and frame to where
|
|
|
|
// grey window background is to be rendered
|
|
|
|
QRegion mask;
|
|
|
|
QRect frame;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// bottom line
|
2010-07-28 01:54:51 +00:00
|
|
|
const int leftOffset = qMin( layoutMetric( LM_BorderLeft ), int(HFRAMESIZE) );
|
|
|
|
const int rightOffset = qMin( layoutMetric( LM_BorderRight ), int(HFRAMESIZE) );
|
2010-05-02 18:34:08 +00:00
|
|
|
if( configuration().frameBorder() > Configuration::BorderNone )
|
|
|
|
{
|
2009-10-09 00:19:32 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const int height = qMax( 0, layoutMetric( LM_BorderBottom ) - HFRAMESIZE );
|
|
|
|
const int width = r.width() - leftOffset - rightOffset - 1;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const QRect rect( r.bottomLeft()-position + QPoint( leftOffset, -layoutMetric( LM_BorderBottom ) ), QSize( width, height ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
if( height > 0 ) { mask += rect; frame |= rect; }
|
2009-10-16 20:27:43 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const QColor shadow( helper().calcDarkColor( color ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
painter->setPen( shadow );
|
|
|
|
painter->drawLine( rect.bottomLeft()+QPoint(0,1), rect.bottomRight()+QPoint(0,1) );
|
2009-10-09 00:19:32 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-10-16 20:27:43 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// left and right
|
2010-07-28 01:54:51 +00:00
|
|
|
const int topOffset = titleHeight;
|
|
|
|
const int bottomOffset = qMin( layoutMetric( LM_BorderBottom ), int(HFRAMESIZE) );
|
|
|
|
const int height = r.height() - topOffset - bottomOffset - 1;
|
2009-10-16 20:27:43 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( configuration().frameBorder() >= Configuration::BorderTiny )
|
|
|
|
{
|
2009-10-16 20:27:43 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const QColor shadow( helper().calcLightColor( color ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
painter->setPen( shadow );
|
2009-10-16 20:27:43 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// left
|
|
|
|
int width = qMax( 0, layoutMetric( LM_BorderLeft ) - HFRAMESIZE );
|
|
|
|
QRect rect( r.topLeft()-position + QPoint( layoutMetric( LM_BorderLeft ) - width, topOffset ), QSize( width, height ) );
|
|
|
|
if( width > 0 ) { mask += rect; frame |= rect; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
painter->drawLine( rect.topLeft()-QPoint(1,0), rect.bottomLeft()-QPoint(1, 0) );
|
2009-10-16 20:27:43 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// right
|
|
|
|
width = qMax( 0, layoutMetric( LM_BorderRight ) - HFRAMESIZE );
|
|
|
|
rect = QRect(r.topRight()-position + QPoint( -layoutMetric( LM_BorderRight ), topOffset ), QSize( width, height ));
|
|
|
|
if( width > 0 ) { mask += rect; frame |= rect; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
painter->drawLine( rect.topRight()+QPoint(1,0), rect.bottomRight()+QPoint(1, 0) );
|
|
|
|
}
|
2009-09-09 17:02:07 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// in preview mode also adds center square
|
|
|
|
if( isPreview() )
|
|
|
|
{
|
2010-07-28 01:54:51 +00:00
|
|
|
const QRect rect( r.topLeft()-position + QPoint( layoutMetric( LM_BorderLeft ), topOffset ), QSize(r.width()-layoutMetric( LM_BorderLeft )-layoutMetric( LM_BorderRight ),height) );
|
2010-05-02 18:34:08 +00:00
|
|
|
mask += rect; frame |= rect;
|
|
|
|
}
|
2009-09-04 18:58:40 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// paint
|
|
|
|
if( !mask.isEmpty() )
|
|
|
|
{
|
|
|
|
painter->setClipRegion( mask, Qt::IntersectClip);
|
|
|
|
renderWindowBackground(painter, frame, widget, palette );
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-18 01:32:27 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// restore painter
|
|
|
|
if( clipRect.isValid() )
|
|
|
|
{ painter->restore(); }
|
2009-09-18 01:32:27 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
void Client::renderSeparator( QPainter* painter, const QRect& clipRect, const QWidget* widget, const QColor& color ) const
|
2009-09-26 21:21:39 +00:00
|
|
|
{
|
2009-09-18 01:32:27 +00:00
|
|
|
|
2010-05-20 21:41:19 +00:00
|
|
|
const QWidget* window = (isPreview()) ? this->widget() : widget->window();
|
2009-09-18 01:32:27 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// get coordinates relative to the client area
|
|
|
|
// this is annoying. One could use mapTo if this was taking const QWidget* and not
|
|
|
|
// const QWidget* as argument.
|
|
|
|
QPoint position( 0, 0 );
|
|
|
|
{
|
|
|
|
const QWidget* w = widget;
|
|
|
|
while ( w != window && !w->isWindow() && w != w->parentWidget() ) {
|
|
|
|
position += w->geometry().topLeft();
|
|
|
|
w = w->parentWidget();
|
|
|
|
}
|
|
|
|
}
|
2009-09-18 01:32:27 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// setup painter
|
|
|
|
if (clipRect.isValid())
|
|
|
|
{
|
|
|
|
painter->save();
|
|
|
|
painter->setClipRegion(clipRect,Qt::IntersectClip);
|
|
|
|
}
|
2009-09-26 21:21:39 +00:00
|
|
|
|
2010-05-20 21:41:19 +00:00
|
|
|
QRect r = (isPreview()) ? this->widget()->rect():window->rect();
|
2010-05-02 18:34:08 +00:00
|
|
|
qreal shadowSize( shadowCache().shadowSize() );
|
|
|
|
r.adjust( shadowSize, shadowSize, -shadowSize, -shadowSize );
|
2009-09-18 01:32:27 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// dimensions
|
|
|
|
const int titleHeight = layoutMetric(LM_TitleHeight);
|
|
|
|
const int titleTop = layoutMetric(LM_TitleEdgeTop) + r.top();
|
2009-09-18 01:32:27 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
QColor local( color );
|
|
|
|
if( glowIsAnimated() ) local = helper().alphaColor( color, glowIntensity() );
|
|
|
|
helper().drawSeparator( painter, QRect(r.top(), titleTop+titleHeight-1.5, r.width(), 2).translated( -position ), local, Qt::Horizontal);
|
|
|
|
|
|
|
|
if (clipRect.isValid()) { painter->restore(); }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-04 18:58:40 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
void Client::renderTitleOutline( QPainter* painter, const QRect& rect, const QPalette& palette ) const
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// center (for active windows only)
|
|
|
|
{
|
|
|
|
painter->save();
|
2010-08-28 19:58:22 +00:00
|
|
|
QRect adjustedRect( rect.adjusted( 1, 1, -1, 1 ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
|
|
|
|
// prepare painter mask
|
|
|
|
QRegion mask( adjustedRect.adjusted( 1, 0, -1, 0 ) );
|
|
|
|
mask += adjustedRect.adjusted( 0, 1, 0, 0 );
|
|
|
|
painter->setClipRegion( mask, Qt::IntersectClip );
|
|
|
|
|
|
|
|
// draw window background
|
|
|
|
renderWindowBackground(painter, adjustedRect, widget(), palette );
|
|
|
|
painter->restore();
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// shadow
|
2010-08-28 19:58:22 +00:00
|
|
|
const int shadowSize( 7 );
|
|
|
|
const int offset( -3 );
|
|
|
|
const int voffset( 5-shadowSize );
|
2010-07-28 01:54:51 +00:00
|
|
|
const QRect adjustedRect( rect.adjusted(offset, voffset, -offset, shadowSize) );
|
2010-05-11 05:30:08 +00:00
|
|
|
helper().slab( palette.color( widget()->backgroundRole() ), 0, shadowSize )->render( adjustedRect, painter, TileSet::Tiles(TileSet::Top|TileSet::Left|TileSet::Right) );
|
2009-10-15 16:03:30 +00:00
|
|
|
|
2009-12-18 15:20:04 +00:00
|
|
|
}
|
2009-10-02 02:52:41 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
void Client::renderTitleText( QPainter* painter, const QRect& rect, const QColor& color, const QColor& contrast ) const
|
2009-12-18 15:20:04 +00:00
|
|
|
{
|
2009-12-13 23:24:36 +00:00
|
|
|
|
2010-08-31 14:30:17 +00:00
|
|
|
if( !titleAnimationData_->isValid() )
|
2010-02-12 00:42:25 +00:00
|
|
|
{
|
2010-05-02 18:34:08 +00:00
|
|
|
// contrast pixmap
|
2010-08-31 14:30:17 +00:00
|
|
|
titleAnimationData_->reset(
|
2010-02-12 00:42:25 +00:00
|
|
|
rect,
|
|
|
|
renderTitleText( rect, caption(), color ),
|
|
|
|
renderTitleText( rect, caption(), contrast ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
|
|
|
|
2010-08-31 14:30:17 +00:00
|
|
|
if( titleAnimationData_->isDirty() )
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
// clear dirty flags
|
2010-08-31 14:30:17 +00:00
|
|
|
titleAnimationData_->setDirty( false );
|
2010-05-02 18:34:08 +00:00
|
|
|
|
|
|
|
// finish current animation if running
|
2010-08-31 14:30:17 +00:00
|
|
|
if( titleAnimationData_->isAnimated() )
|
|
|
|
{ titleAnimationData_->finishAnimation(); }
|
2010-05-02 18:34:08 +00:00
|
|
|
|
2010-08-31 14:30:17 +00:00
|
|
|
if( !titleAnimationData_->isLocked() )
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
// set pixmaps
|
2010-08-31 14:30:17 +00:00
|
|
|
titleAnimationData_->setPixmaps(
|
2010-05-02 18:34:08 +00:00
|
|
|
rect,
|
|
|
|
renderTitleText( rect, caption(), color ),
|
|
|
|
renderTitleText( rect, caption(), contrast ) );
|
|
|
|
|
2010-08-31 14:30:17 +00:00
|
|
|
titleAnimationData_->startAnimation();
|
2010-05-02 18:34:08 +00:00
|
|
|
renderTitleText( painter, rect, color, contrast );
|
|
|
|
|
|
|
|
} else if( !caption().isEmpty() ) {
|
2010-02-12 00:42:25 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
renderTitleText( painter, rect, caption(), color, contrast );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// lock animations (this must be done whether or not
|
|
|
|
// animation was actually started, in order to extend locking
|
|
|
|
// every time title get changed too rapidly
|
2010-08-31 14:30:17 +00:00
|
|
|
titleAnimationData_->lockAnimations();
|
2010-05-02 18:34:08 +00:00
|
|
|
|
2010-08-31 14:30:17 +00:00
|
|
|
} else if( titleAnimationData_->isAnimated() ) {
|
2010-05-02 18:34:08 +00:00
|
|
|
|
|
|
|
if( isMaximized() ) painter->translate( 0, 2 );
|
2010-08-31 14:30:17 +00:00
|
|
|
if( !titleAnimationData_->contrastPixmap().isNull() )
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
|
|
|
painter->translate( 0, 1 );
|
2010-08-31 14:30:17 +00:00
|
|
|
painter->drawPixmap( rect.topLeft(), titleAnimationData_->contrastPixmap() );
|
2010-05-02 18:34:08 +00:00
|
|
|
painter->translate( 0, -1 );
|
|
|
|
}
|
|
|
|
|
2010-08-31 14:30:17 +00:00
|
|
|
painter->drawPixmap( rect.topLeft(), titleAnimationData_->pixmap() );
|
2010-05-02 18:34:08 +00:00
|
|
|
|
|
|
|
if( isMaximized() ) painter->translate( 0, -2 );
|
2010-02-12 00:42:25 +00:00
|
|
|
|
|
|
|
} else if( !caption().isEmpty() ) {
|
|
|
|
|
|
|
|
renderTitleText( painter, rect, caption(), color, contrast );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//_______________________________________________________________________
|
|
|
|
void Client::renderTitleText( QPainter* painter, const QRect& rect, const QString& caption, const QColor& color, const QColor& contrast, bool elide ) const
|
|
|
|
{
|
2009-12-13 23:24:36 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const Qt::Alignment alignment( configuration().titleAlignment() | Qt::AlignVCenter );
|
|
|
|
const QString local( elide ? QFontMetrics( painter->font() ).elidedText( caption, Qt::ElideRight, rect.width() ):caption );
|
2009-12-13 23:24:36 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// translate title down in case of maximized window
|
2009-12-18 15:20:04 +00:00
|
|
|
if( isMaximized() ) painter->translate( 0, 2 );
|
2010-05-02 18:34:08 +00:00
|
|
|
|
|
|
|
if( contrast.isValid() )
|
2009-12-18 15:20:04 +00:00
|
|
|
{
|
2010-05-02 18:34:08 +00:00
|
|
|
painter->setPen( contrast );
|
2009-12-18 15:20:04 +00:00
|
|
|
painter->translate( 0, 1 );
|
2010-05-02 18:34:08 +00:00
|
|
|
painter->drawText( rect, alignment, local );
|
2009-12-18 15:20:04 +00:00
|
|
|
painter->translate( 0, -1 );
|
2009-12-13 23:24:36 +00:00
|
|
|
}
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
painter->setPen( color );
|
|
|
|
painter->drawText( rect, alignment, local );
|
2009-11-14 04:19:09 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// translate back
|
2009-12-18 15:20:04 +00:00
|
|
|
if( isMaximized() ) painter->translate( 0, -2 );
|
2009-10-02 02:52:41 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_______________________________________________________________________
|
|
|
|
QPixmap Client::renderTitleText( const QRect& rect, const QString& caption, const QColor& color, bool elide ) const
|
|
|
|
{
|
2009-10-02 02:52:41 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
QPixmap out( rect.size() );
|
|
|
|
out.fill( Qt::transparent );
|
|
|
|
if( caption.isEmpty() || !color.isValid() ) return out;
|
2009-10-15 16:03:30 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
QPainter painter( &out );
|
|
|
|
painter.setFont( options()->font(isActive(), false) );
|
2010-07-28 01:54:51 +00:00
|
|
|
const Qt::Alignment alignment( configuration().titleAlignment() | Qt::AlignVCenter );
|
|
|
|
const QString local( elide ? QFontMetrics( painter.font() ).elidedText( caption, Qt::ElideRight, rect.width() ):caption );
|
2009-11-14 04:19:09 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
painter.setPen( color );
|
|
|
|
painter.drawText( out.rect(), alignment, local );
|
|
|
|
painter.end();
|
|
|
|
return out;
|
2009-11-19 04:11:21 +00:00
|
|
|
|
2009-11-14 04:19:09 +00:00
|
|
|
}
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_______________________________________________________________________
|
|
|
|
void Client::renderItem( QPainter* painter, int index, const QPalette& palette )
|
|
|
|
{
|
2009-10-15 16:03:30 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
const ClientGroupItemData& item( itemData_[index] );
|
2009-11-19 04:11:21 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// see if tag is active
|
2010-07-28 01:54:51 +00:00
|
|
|
const int itemCount( itemData_.count() );
|
2009-10-15 16:03:30 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//
|
|
|
|
if( !item.boundingRect_.isValid() ) return;
|
2009-12-18 15:20:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// create rect in which text is to be drawn
|
|
|
|
QRect textRect( item.boundingRect_.adjusted( 0, layoutMetric( LM_TitleEdgeTop )-1, 0, -1 ) );
|
2009-12-18 15:20:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// add extra space needed for title outline
|
|
|
|
if( itemCount > 1 || itemData_.isAnimated() )
|
|
|
|
{ textRect.adjust( layoutMetric( LM_TitleBorderLeft ), 0, -layoutMetric(LM_TitleBorderRight), 0 ); }
|
2009-12-18 15:20:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// add extra space for the button
|
|
|
|
if( itemCount > 1 && item.closeButton_ && item.closeButton_.data()->isVisible() )
|
|
|
|
{ textRect.adjust( 0, 0, - configuration().buttonSize() - layoutMetric(LM_TitleEdgeRight), 0 ); }
|
2009-12-18 15:20:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// check if current item is active
|
2010-07-28 01:54:51 +00:00
|
|
|
const bool active( index == visibleClientGroupItem() );
|
2009-12-18 15:20:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// get current item caption and update text rect
|
|
|
|
const QList< ClientGroupItem >& items( clientGroupItems() );
|
2010-07-28 01:54:51 +00:00
|
|
|
const QString caption( itemCount == 1 ? this->caption() : items[index].title() );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// always make sure that titleRect never conflicts with window buttons
|
2010-05-20 21:41:19 +00:00
|
|
|
QRect titleRect( this->titleRect() );
|
2010-05-02 18:34:08 +00:00
|
|
|
if( titleRect.left() > textRect.left() ) { textRect.setLeft( titleRect.left() ); }
|
|
|
|
if( titleRect.right() < textRect.right() ) { textRect.setRight( titleRect.right() ); }
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// title outline
|
|
|
|
if( itemCount == 1 )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-06-15 00:05:08 +00:00
|
|
|
// no title outline if the window caption is empty
|
|
|
|
if( !caption.trimmed().isEmpty() )
|
|
|
|
{
|
|
|
|
if( itemData_.isAnimated() ) {
|
|
|
|
|
|
|
|
textRect = titleBoundingRect( painter->font(), textRect, caption );
|
|
|
|
renderTitleOutline( painter, item.boundingRect_, palette );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-06-15 00:05:08 +00:00
|
|
|
} else if( (isActive()||glowIsAnimated()) && configuration().drawTitleOutline() ) {
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-06-15 00:05:08 +00:00
|
|
|
// adjust textRect
|
|
|
|
textRect = titleBoundingRect( painter->font(), textRect, caption );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-06-15 00:05:08 +00:00
|
|
|
// adjusts boundingRect accordingly
|
|
|
|
QRect boundingRect( item.boundingRect_ );
|
|
|
|
boundingRect.setLeft( textRect.left() - layoutMetric( LM_TitleBorderLeft ) );
|
|
|
|
boundingRect.setRight( textRect.right() + layoutMetric( LM_TitleBorderRight ) );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-06-15 00:05:08 +00:00
|
|
|
// render bounding rect around it with extra margins
|
|
|
|
renderTitleOutline( painter, boundingRect, palette );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-06-15 00:05:08 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2010-02-09 23:07:34 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else if( active ) {
|
2010-02-09 23:07:34 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// in multiple tabs render title outline in all cases
|
|
|
|
renderTitleOutline( painter, item.boundingRect_, palette );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// render text
|
|
|
|
if( active || itemCount == 1 )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// for active tab, current caption is "merged" with old caption, if any
|
|
|
|
renderTitleText(
|
|
|
|
painter, textRect,
|
|
|
|
titlebarTextColor( palette ),
|
|
|
|
titlebarContrastColor( palette ) );
|
2010-02-09 23:07:34 +00:00
|
|
|
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else {
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
QColor background( backgroundPalette( widget(), palette ).color( widget()->window()->backgroundRole() ) );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// add extra shade (as used in renderWindowBorder
|
|
|
|
if( !( isActive() && configuration().drawTitleOutline() ) )
|
|
|
|
{ background = KColorUtils::mix( background, Qt::black, 0.10 ); }
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// otherwise current caption is rendered directly
|
|
|
|
renderTitleText(
|
|
|
|
painter, textRect, caption,
|
|
|
|
titlebarTextColor( backgroundPalette( widget(), palette ), false ),
|
|
|
|
titlebarContrastColor( background ) );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// render separators between inactive tabs
|
|
|
|
if( !( active || itemCount == 1 ) && item.closeButton_ && item.closeButton_.data()->isVisible() )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// separators
|
|
|
|
// draw Left separator
|
2010-07-28 01:54:51 +00:00
|
|
|
const QColor color( backgroundPalette( widget(), palette ).window().color() );
|
|
|
|
const bool isFirstItem( index == 0 || (index == 1 && !itemData_[0].boundingRect_.isValid() ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
if( !active && ( ( isFirstItem && buttonsLeftWidth() > 0 ) || itemData_.isTarget( index ) ) )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const QRect local( item.boundingRect_.topLeft()+QPoint(0,2), QSize( 2, item.boundingRect_.height()-3 ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
helper().drawSeparator( painter, local, color, Qt::Vertical);
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// draw right separator
|
|
|
|
if(
|
|
|
|
( index == itemCount-1 && buttonsRightWidth() > 0 ) ||
|
|
|
|
( index+1 < itemCount && ( itemData_.isTarget( index+1 ) ||
|
|
|
|
!( index+1 == visibleClientGroupItem() && itemData_[index+1].boundingRect_.isValid() ) ) ) )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const QRect local( item.boundingRect_.topRight()+QPoint(0,2), QSize( 2, item.boundingRect_.height()-3 ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
helper().drawSeparator( painter, local, color, Qt::Vertical);
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_______________________________________________________________________
|
|
|
|
void Client::renderTargetRect( QPainter* p, const QPalette& palette )
|
2009-11-15 03:24:04 +00:00
|
|
|
{
|
2010-05-02 18:34:08 +00:00
|
|
|
if( itemData_.targetRect().isNull() || itemData_.isAnimationRunning() ) return;
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
p->save();
|
2010-07-28 01:54:51 +00:00
|
|
|
const QColor color = palette.color(QPalette::Highlight);
|
2010-05-02 18:34:08 +00:00
|
|
|
p->setPen(KColorUtils::mix(color, palette.color(QPalette::Active, QPalette::WindowText)));
|
|
|
|
p->setBrush( helper().alphaColor( color, 0.5 ) );
|
|
|
|
p->drawRect( itemData_.targetRect().adjusted( 4, 2, -4, -2 ) );
|
|
|
|
p->restore();
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_______________________________________________________________________
|
|
|
|
void Client::renderFloatFrame( QPainter* painter, const QRect& frame, const QPalette& palette ) const
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// shadow and resize handles
|
|
|
|
if( !isMaximized() )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( configuration().frameBorder() >= Configuration::BorderTiny )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
helper().drawFloatFrame(
|
|
|
|
painter, frame, backgroundColor( widget(), palette ),
|
|
|
|
!compositingActive(), isActive() && configuration().useOxygenShadows(),
|
|
|
|
KDecoration::options()->color(ColorTitleBar)
|
|
|
|
);
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else {
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// for small borders, use a frame that matches the titlebar only
|
2010-07-28 01:54:51 +00:00
|
|
|
const QRect local( frame.topLeft(), QSize( frame.width(), layoutMetric(LM_TitleHeight) + layoutMetric(LM_TitleEdgeTop) ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
helper().drawFloatFrame(
|
|
|
|
painter, local, backgroundColor( widget(), palette ),
|
|
|
|
false, isActive() && configuration().useOxygenShadows(),
|
|
|
|
KDecoration::options()->color(ColorTitleBar)
|
|
|
|
);
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else if( isShade() ) {
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// for shaded maximized windows adjust frame and draw the bottom part of it
|
|
|
|
helper().drawFloatFrame(
|
|
|
|
painter, frame.adjusted( -4, 0, 4, 0 ), backgroundColor( widget(), palette ),
|
|
|
|
!( compositingActive() || configuration().frameBorder() == Configuration::BorderNone ), isActive(),
|
|
|
|
KDecoration::options()->color(ColorTitleBar),
|
|
|
|
TileSet::Bottom
|
|
|
|
);
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-10-14 14:28:37 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//____________________________________________________________________________
|
|
|
|
void Client::renderDots( QPainter* painter, const QRect& frame, const QColor& color ) const
|
2009-10-14 14:28:37 +00:00
|
|
|
{
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( configuration().frameBorder() >= Configuration::BorderTiny )
|
|
|
|
{
|
2009-10-14 14:28:37 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// dimensions
|
|
|
|
int x,y,w,h;
|
|
|
|
frame.getRect(&x, &y, &w, &h);
|
2009-10-14 14:28:37 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( isResizable() && !isShade() && !isMaximized() )
|
|
|
|
{
|
2009-10-14 14:28:37 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// Draw right side 3-dots resize handles
|
2010-08-28 01:01:59 +00:00
|
|
|
const int cenY = (h / 2 + y) ;
|
|
|
|
const int posX = (w + x - 3);
|
2009-10-14 14:28:37 +00:00
|
|
|
|
2010-08-28 01:01:59 +00:00
|
|
|
helper().renderDot( painter, QPoint(posX, cenY - 3), color);
|
|
|
|
helper().renderDot( painter, QPoint(posX, cenY), color);
|
|
|
|
helper().renderDot( painter, QPoint(posX, cenY + 3), color);
|
2009-10-14 14:28:37 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-10-14 14:28:37 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// Draw bottom-right cornet 3-dots resize handles
|
|
|
|
if( isResizable() && !isShade() && !configuration().drawSizeGrip() )
|
|
|
|
{
|
2009-10-14 14:28:37 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
painter->save();
|
|
|
|
painter->translate(x + w-9, y + h-9);
|
2010-08-28 01:01:59 +00:00
|
|
|
helper().renderDot( painter, QPoint(2, 6), color);
|
|
|
|
helper().renderDot( painter, QPoint(5, 5), color);
|
|
|
|
helper().renderDot( painter, QPoint(6, 2), color);
|
2010-05-02 18:34:08 +00:00
|
|
|
painter->restore();
|
|
|
|
}
|
2009-10-14 14:28:37 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-10-14 14:28:37 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-10-14 14:28:37 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
void Client::activeChange( void )
|
|
|
|
{
|
2009-10-14 14:28:37 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
KCommonDecorationUnstable::activeChange();
|
|
|
|
itemData_.setDirty( true );
|
2009-10-14 14:28:37 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// reset animation
|
|
|
|
if( animateActiveChange() )
|
|
|
|
{
|
2010-08-31 14:24:01 +00:00
|
|
|
glowAnimation_->setDirection( isActive() ? Animation::Forward : Animation::Backward );
|
|
|
|
if(!glowIsAnimated()) { glowAnimation_->start(); }
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-10-14 14:28:37 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// update size grip so that it gets the right color
|
|
|
|
// also make sure it is remaped to from z stack,
|
|
|
|
// unless hidden
|
|
|
|
if( hasSizeGrip() && !(isShade() || isMaximized() ))
|
|
|
|
{
|
|
|
|
sizeGrip().activeChange();
|
|
|
|
sizeGrip().update();
|
|
|
|
}
|
2009-10-14 14:28:37 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
void Client::maximizeChange( void )
|
2009-09-18 01:32:27 +00:00
|
|
|
{
|
2010-05-02 18:34:08 +00:00
|
|
|
if( hasSizeGrip() ) sizeGrip().setVisible( !( isShade() || isMaximized() ) );
|
|
|
|
KCommonDecorationUnstable::maximizeChange();
|
2009-09-18 01:32:27 +00:00
|
|
|
}
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
void Client::shadeChange( void )
|
2009-10-12 07:26:07 +00:00
|
|
|
{
|
2010-05-02 18:34:08 +00:00
|
|
|
if( hasSizeGrip() ) sizeGrip().setVisible( !( isShade() || isMaximized() ) );
|
|
|
|
KCommonDecorationUnstable::shadeChange();
|
2009-10-12 07:26:07 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
void Client::captionChange( void )
|
|
|
|
{
|
2009-08-29 20:04:24 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
KCommonDecorationUnstable::captionChange();
|
|
|
|
itemData_.setDirty( true );
|
|
|
|
if( animateTitleChange() )
|
2010-08-31 14:30:17 +00:00
|
|
|
{ titleAnimationData_->setDirty( true ); }
|
2009-09-05 17:17:57 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-08-29 20:04:24 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
QPalette Client::backgroundPalette( const QWidget* widget, QPalette palette ) const
|
|
|
|
{
|
2009-12-18 15:20:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( configuration().drawTitleOutline() )
|
|
|
|
{
|
|
|
|
if( glowIsAnimated() && !isForcedActive() )
|
|
|
|
{
|
2009-10-02 02:52:41 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const QColor inactiveColor( backgroundColor( widget, palette, false ) );
|
|
|
|
const QColor activeColor( backgroundColor( widget, palette, true ) );
|
|
|
|
const QColor mixed( KColorUtils::mix( inactiveColor, activeColor, glowIntensity() ) );
|
2010-08-28 19:58:22 +00:00
|
|
|
palette.setColor( QPalette::Window, mixed );
|
2010-05-02 18:34:08 +00:00
|
|
|
palette.setColor( QPalette::Button, mixed );
|
2009-10-02 02:52:41 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else if( isActive() || isForcedActive() ) {
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const QColor color = options()->color( KDecorationDefines::ColorTitleBar, true );
|
2010-08-28 19:58:22 +00:00
|
|
|
palette.setColor( QPalette::Window, color );
|
2010-05-02 18:34:08 +00:00
|
|
|
palette.setColor( QPalette::Button, color );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2009-09-26 04:57:27 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
return palette;
|
2009-09-26 04:57:27 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-26 04:57:27 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
2010-08-28 19:58:22 +00:00
|
|
|
QColor Client::backgroundColor( const QWidget*, QPalette palette, bool active ) const
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
2009-09-26 04:57:27 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
return ( configuration().drawTitleOutline() && active ) ?
|
|
|
|
options()->color( KDecorationDefines::ColorTitleBar, true ):
|
2010-08-28 19:58:22 +00:00
|
|
|
palette.color( QPalette::Window );
|
2009-09-26 04:57:27 +00:00
|
|
|
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
QString Client::defaultButtonsLeft() const
|
|
|
|
{ return KCommonDecoration::defaultButtonsLeft(); }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
QString Client::defaultButtonsRight() const
|
|
|
|
{ return "HIAX"; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//________________________________________________________________
|
|
|
|
void Client::updateWindowShape()
|
|
|
|
{
|
2009-09-26 04:57:27 +00:00
|
|
|
|
2010-05-10 01:56:24 +00:00
|
|
|
if(isMaximized()) clearMask();
|
2010-05-02 18:34:08 +00:00
|
|
|
else setMask( calcMask() );
|
2009-09-26 04:57:27 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-26 04:57:27 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//______________________________________________________________________________
|
|
|
|
bool Client::eventFilter( QObject* object, QEvent* event )
|
|
|
|
{
|
2010-03-11 15:24:28 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// all dedicated event filtering is here to handle multiple tabs.
|
|
|
|
// if tabs are disabled, do nothing
|
|
|
|
if( !configuration().tabsEnabled() )
|
|
|
|
{ return KCommonDecorationUnstable::eventFilter( object, event ); }
|
2009-11-10 23:11:08 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
bool state = false;
|
|
|
|
switch( event->type() )
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
case QEvent::Show:
|
|
|
|
if( widget() == object )
|
|
|
|
{ itemData_.setDirty( true ); }
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEvent::MouseButtonPress:
|
|
|
|
if( widget() == object )
|
|
|
|
{ state = mousePressEvent( static_cast< QMouseEvent* >( event ) ); }
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEvent::MouseButtonRelease:
|
|
|
|
if( widget() == object ) state = mouseReleaseEvent( static_cast< QMouseEvent* >( event ) );
|
|
|
|
else if( Button *btn = qobject_cast< Button* >( object ) )
|
|
|
|
{
|
|
|
|
QMouseEvent* mouseEvent( static_cast< QMouseEvent* >( event ) );
|
|
|
|
if( mouseEvent->button() == Qt::LeftButton && btn->rect().contains( mouseEvent->pos() ) )
|
|
|
|
{ state = closeItem( btn ); }
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEvent::MouseMove:
|
|
|
|
state = mouseMoveEvent( static_cast< QMouseEvent* >( event ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEvent::DragEnter:
|
|
|
|
if( widget() == object )
|
|
|
|
{ state = dragEnterEvent( static_cast< QDragEnterEvent* >( event ) ); }
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEvent::DragMove:
|
|
|
|
if( widget() == object )
|
|
|
|
{ state = dragMoveEvent( static_cast< QDragMoveEvent* >( event ) ); }
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEvent::DragLeave:
|
|
|
|
if( widget() == object )
|
|
|
|
{ state = dragLeaveEvent( static_cast< QDragLeaveEvent* >( event ) ); }
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QEvent::Drop:
|
|
|
|
if( widget() == object )
|
|
|
|
{ state = dropEvent( static_cast< QDropEvent* >( event ) ); }
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: break;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
|
|
|
return state || KCommonDecorationUnstable::eventFilter( object, event );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
void Client::resizeEvent( QResizeEvent* event )
|
|
|
|
{
|
|
|
|
itemData_.setDirty( true );
|
|
|
|
KCommonDecorationUnstable::resizeEvent( event );
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________
|
|
|
|
void Client::paintEvent( QPaintEvent* event )
|
2009-11-15 03:24:04 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// factory
|
|
|
|
if(!( initialized_ && factory_->initialized() ) ) return;
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// palette
|
|
|
|
QPalette palette = widget()->palette();
|
|
|
|
palette.setCurrentColorGroup( (isActive() ) ? QPalette::Active : QPalette::Inactive );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// painter
|
|
|
|
QPainter painter(widget());
|
|
|
|
painter.setClipRegion( event->region() );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// define frame
|
|
|
|
QRect frame = widget()->rect();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// base color
|
|
|
|
QColor color = palette.window().color();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// draw shadows
|
|
|
|
if( compositingActive() )
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
TileSet *tileSet( 0 );
|
2010-05-20 21:41:19 +00:00
|
|
|
ShadowCache::Key key( this->key() );
|
2010-05-02 18:34:08 +00:00
|
|
|
if( configuration().useOxygenShadows() && glowIsAnimated() && !isForcedActive() )
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-08-26 03:05:10 +00:00
|
|
|
QColor background( backgroundPalette( widget(), palette ).window().color() );
|
2010-05-12 23:34:31 +00:00
|
|
|
tileSet = shadowCache().tileSet( background, key, glowIntensity() );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-08-26 03:05:10 +00:00
|
|
|
} else {
|
|
|
|
|
|
|
|
QColor background( backgroundColor( widget(), palette ) );
|
|
|
|
tileSet = shadowCache().tileSet( background, key );
|
|
|
|
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( !isMaximized() ) tileSet->render( frame.adjusted( 4, 4, -4, -4), &painter, TileSet::Ring);
|
|
|
|
else if( isShade() ) tileSet->render( frame.adjusted( 0, 4, 0, -4), &painter, TileSet::Bottom);
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-17 22:40:06 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// adjust frame
|
|
|
|
qreal shadowSize( shadowCache().shadowSize() );
|
|
|
|
frame.adjust( shadowSize, shadowSize, -shadowSize, -shadowSize );
|
2009-10-12 07:26:07 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// adjust mask
|
|
|
|
if( compositingActive() || isPreview() )
|
|
|
|
{
|
2009-10-12 07:26:07 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( isMaximized() ) {
|
2009-09-18 01:32:27 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
painter.setClipRect( frame, Qt::IntersectClip );
|
2009-09-17 22:40:06 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else {
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// multipliers
|
2010-07-28 01:54:51 +00:00
|
|
|
const int left = 1;
|
|
|
|
const int right = 1;
|
|
|
|
const int top = 1;
|
2010-05-02 18:34:08 +00:00
|
|
|
int bottom = 1;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// disable bottom corners when border frame is too small and window is not shaded
|
|
|
|
if( configuration().frameBorder() == Configuration::BorderNone && !isShade() ) bottom = 0;
|
2010-07-20 01:39:15 +00:00
|
|
|
QRegion mask( helper().roundedMask( frame, left, right, top, bottom ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// in no-border configuration, an extra pixel is added to the mask
|
|
|
|
// in order to get the corners color right in case of title highlighting.
|
|
|
|
if( configuration().frameBorder() == Configuration::BorderNone )
|
|
|
|
{
|
|
|
|
int x, y, w, h;
|
|
|
|
frame.getRect(&x, &y, &w, &h);
|
|
|
|
mask += QRegion(x+0*left, y+4*top, w-0*(left+right), h-4*(top+bottom));
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
painter.setClipRegion( mask, Qt::IntersectClip );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// make sure ItemData and clientGroupItems are synchronized
|
|
|
|
/*
|
|
|
|
this needs to be done before calling RenderWindowBorder
|
|
|
|
since some painting in there depend on the clientGroups state
|
|
|
|
*/
|
|
|
|
if( itemData_.isDirty() || itemData_.count() != clientGroupItems().count() )
|
|
|
|
{ updateItemBoundingRects( false ); }
|
2009-09-07 06:59:38 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// window background
|
|
|
|
renderWindowBackground( &painter, frame, widget(), backgroundPalette( widget(), palette ) );
|
2010-07-28 01:07:47 +00:00
|
|
|
|
|
|
|
// window border (for title outline)
|
|
|
|
if( hasTitleOutline() ) renderWindowBorder( &painter, frame, widget(), palette );
|
2010-05-02 18:34:08 +00:00
|
|
|
|
|
|
|
// clipping
|
|
|
|
if( compositingActive() )
|
2009-10-13 03:38:26 +00:00
|
|
|
{
|
2010-05-02 18:34:08 +00:00
|
|
|
painter.setClipping(false);
|
|
|
|
frame.adjust(-1,-1, 1, 1);
|
2009-10-13 03:38:26 +00:00
|
|
|
}
|
2009-09-07 06:59:38 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// adjust frame if there are shadows
|
|
|
|
{
|
|
|
|
painter.save();
|
|
|
|
painter.setRenderHint(QPainter::Antialiasing);
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// float frame
|
|
|
|
renderFloatFrame( &painter, frame, palette );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// resize handles
|
2010-06-06 18:12:21 +00:00
|
|
|
renderDots( &painter, frame, backgroundColor( widget(), palette ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
painter.restore();
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( !configuration().hideTitleBar() )
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// title bounding rect
|
|
|
|
painter.setFont( options()->font(isActive(), false) );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// draw ClientGroupItems
|
2010-07-28 01:54:51 +00:00
|
|
|
const int itemCount( itemData_.count() );
|
2010-05-02 18:34:08 +00:00
|
|
|
for( int i = 0; i < itemCount; i++ ) renderItem( &painter, i, palette );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// draw target rect
|
|
|
|
renderTargetRect( &painter, widget()->palette() );
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// separator
|
2010-08-31 05:44:19 +00:00
|
|
|
if( itemCount == 1 && !itemData_.isAnimated() && drawSeparator() )
|
2010-05-02 18:34:08 +00:00
|
|
|
{ renderSeparator(&painter, frame, widget(), color ); }
|
2009-09-04 18:58:40 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-10-15 16:03:30 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_____________________________________________________________
|
|
|
|
bool Client::mousePressEvent( QMouseEvent* event )
|
2009-10-15 16:03:30 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const QPoint point = event->pos();
|
2010-05-02 18:34:08 +00:00
|
|
|
if( itemClicked( point ) < 0 ) return false;
|
|
|
|
dragPoint_ = point;
|
2009-11-07 03:33:53 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
mouseButton_ = event->button();
|
|
|
|
bool accepted( false );
|
|
|
|
if( buttonToWindowOperation( mouseButton_ ) == ClientGroupDragOp )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
accepted = true;
|
2009-10-07 00:54:15 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else if( buttonToWindowOperation( mouseButton_ ) == OperationsOp ) {
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
QPoint point = event->pos();
|
2010-05-20 21:41:19 +00:00
|
|
|
int itemClicked( this->itemClicked( point ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
displayClientMenu( itemClicked, widget()->mapToGlobal( event->pos() ) );
|
|
|
|
mouseButton_ = Qt::NoButton;
|
|
|
|
accepted = true; // displayClientMenu can possibly destroy the deco...
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
|
|
|
return accepted;
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_____________________________________________________________
|
|
|
|
bool Client::mouseReleaseEvent( QMouseEvent* event )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
bool accepted( false );
|
|
|
|
if( mouseButton_ == event->button() &&
|
|
|
|
buttonToWindowOperation( mouseButton_ ) != OperationsOp )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const QPoint point = event->pos();
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const int visibleItem = visibleClientGroupItem();
|
|
|
|
const int itemClicked( this->itemClicked( point ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
if( itemClicked >= 0 && visibleItem != itemClicked )
|
|
|
|
{
|
|
|
|
setVisibleClientGroupItem( itemClicked );
|
|
|
|
setForceActive( true );
|
|
|
|
accepted = true;
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
mouseButton_ = Qt::NoButton;
|
|
|
|
return accepted;
|
2009-11-07 03:33:53 +00:00
|
|
|
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_____________________________________________________________
|
|
|
|
bool Client::mouseMoveEvent( QMouseEvent* event )
|
2009-11-15 03:24:04 +00:00
|
|
|
{
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// check button and distance to drag point
|
|
|
|
if( configuration().hideTitleBar() || mouseButton_ == Qt::NoButton || ( event->pos() - dragPoint_ ).manhattanLength() <= QApplication::startDragDistance() )
|
|
|
|
{ return false; }
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
bool accepted( false );
|
|
|
|
if( buttonToWindowOperation( mouseButton_ ) == ClientGroupDragOp )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const QPoint point = event->pos();
|
|
|
|
const int itemClicked( this->itemClicked( point ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
if( itemClicked < 0 ) return false;
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-08-31 14:30:17 +00:00
|
|
|
titleAnimationData_->reset();
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
QDrag *drag = new QDrag( widget() );
|
|
|
|
QMimeData *groupData = new QMimeData();
|
|
|
|
groupData->setData( clientGroupItemDragMimeType(), QString().setNum( itemId( itemClicked )).toAscii() );
|
|
|
|
drag->setMimeData( groupData );
|
2010-05-20 21:41:19 +00:00
|
|
|
sourceItem_ = this->itemClicked( dragPoint_ );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// get tab geometry
|
2010-07-28 01:54:51 +00:00
|
|
|
QRect geometry( itemData_[itemClicked].boundingRect_ );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// remove space used for buttons
|
|
|
|
if( itemData_.count() > 1 )
|
|
|
|
{
|
2009-12-18 15:20:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
geometry.adjust( 0, 0, - configuration().buttonSize() - layoutMetric(LM_TitleEdgeRight), 0 );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else if( !( isActive() && configuration().drawTitleOutline() ) ) {
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2009-12-27 12:00:23 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
geometry.adjust(
|
|
|
|
buttonsLeftWidth() + layoutMetric( LM_TitleEdgeLeft ) , 0,
|
|
|
|
-( buttonsRightWidth() + layoutMetric( LM_TitleEdgeRight )), 0 );
|
2009-12-27 12:00:23 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-12-27 12:00:23 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
drag->setPixmap( itemDragPixmap( itemClicked, geometry ) );
|
2009-12-27 12:00:23 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// note: the pixmap is moved just above the pointer on purpose
|
|
|
|
// because overlapping pixmap and pointer slows down the pixmap a lot.
|
|
|
|
QPoint hotSpot( QPoint( event->pos().x() - geometry.left(), -1 ) );
|
2009-12-27 12:00:23 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// make sure the horizontal hotspot position is not too far away (more than 1px)
|
|
|
|
// from the pixmap
|
|
|
|
if( hotSpot.x() < -1 ) hotSpot.setX(-1);
|
|
|
|
if( hotSpot.x() > geometry.width() ) hotSpot.setX( geometry.width() );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
drag->setHotSpot( hotSpot );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
dragStartTimer_.start( 50, this );
|
|
|
|
drag->exec( Qt::MoveAction );
|
2009-12-09 04:17:09 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// detach tab from window
|
|
|
|
if( drag->target() == 0 && itemData_.count() > 1 )
|
|
|
|
{
|
|
|
|
itemData_.setDirty( true );
|
|
|
|
removeFromClientGroup( sourceItem_,
|
|
|
|
widget()->frameGeometry().adjusted(
|
|
|
|
layoutMetric( LM_OuterPaddingLeft ),
|
|
|
|
layoutMetric( LM_OuterPaddingTop ),
|
|
|
|
-layoutMetric( LM_OuterPaddingRight ),
|
|
|
|
-layoutMetric( LM_OuterPaddingBottom )
|
|
|
|
).translated( QCursor::pos() - event->pos() +
|
|
|
|
QPoint( layoutMetric( LM_OuterPaddingLeft ), layoutMetric( LM_OuterPaddingTop )))
|
|
|
|
);
|
|
|
|
}
|
2009-12-09 04:17:09 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// reset button
|
|
|
|
mouseButton_ = Qt::NoButton;
|
|
|
|
accepted = true;
|
2009-11-15 04:49:23 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
return accepted;
|
2009-11-15 03:24:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_____________________________________________________________
|
|
|
|
bool Client::dragEnterEvent( QDragEnterEvent* event )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// check if drag enter is allowed
|
|
|
|
if( !event->mimeData()->hasFormat( clientGroupItemDragMimeType() ) || configuration().hideTitleBar() ) return false;
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//
|
|
|
|
event->acceptProposedAction();
|
|
|
|
if( event->source() != widget() )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const QPoint position( event->pos() );
|
2010-05-02 18:34:08 +00:00
|
|
|
itemData_.animate( AnimationEnter, itemClicked( position, true ) );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else if( itemData_.count() > 1 ) {
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const QPoint position( event->pos() );
|
|
|
|
const int itemClicked( this->itemClicked( position, false ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
itemData_.animate( AnimationEnter|AnimationSameTarget, itemClicked );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
return true;
|
2009-11-15 03:24:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_____________________________________________________________
|
|
|
|
bool Client::dragLeaveEvent( QDragLeaveEvent* )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( itemData_.animationType() & AnimationSameTarget )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( dragStartTimer_.isActive() ) dragStartTimer_.stop();
|
|
|
|
itemData_.animate( AnimationLeave|AnimationSameTarget, sourceItem_ );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else if( itemData_.isAnimated() ) {
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
itemData_.animate( AnimationLeave );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
return true;
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_____________________________________________________________
|
|
|
|
bool Client::dragMoveEvent( QDragMoveEvent* event )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// check format
|
|
|
|
if( !event->mimeData()->hasFormat( clientGroupItemDragMimeType() ) ) return false;
|
|
|
|
if( event->source() != widget() )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const QPoint position( event->pos() );
|
2010-05-02 18:34:08 +00:00
|
|
|
itemData_.animate( AnimationMove, itemClicked( position, true ) );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else if( itemData_.count() > 1 ) {
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( dragStartTimer_.isActive() ) dragStartTimer_.stop();
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const QPoint position( event->pos() );
|
|
|
|
const int itemClicked( this->itemClicked( position, false ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
itemData_.animate( AnimationMove|AnimationSameTarget, itemClicked );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 06:28:40 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
return false;
|
2009-11-15 03:24:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_____________________________________________________________
|
|
|
|
bool Client::dropEvent( QDropEvent* event )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const QPoint point = event->pos();
|
2010-05-02 18:34:08 +00:00
|
|
|
itemData_.animate( AnimationNone );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
const QMimeData *groupData = event->mimeData();
|
|
|
|
if( !groupData->hasFormat( clientGroupItemDragMimeType() ) ) return false;
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( widget() == event->source() )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const int from = this->itemClicked( dragPoint_ );
|
2010-05-20 21:41:19 +00:00
|
|
|
int itemClicked( this->itemClicked( point, false ) );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( itemClicked > from )
|
|
|
|
{
|
|
|
|
itemClicked++;
|
|
|
|
if( itemClicked >= clientGroupItems().count() )
|
|
|
|
{ itemClicked = -1; }
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
itemData_.setDirty( true );
|
|
|
|
moveItemInClientGroup( from, itemClicked );
|
2010-07-24 21:45:25 +00:00
|
|
|
updateTitleRect();
|
2010-07-28 01:07:47 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
} else {
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
setForceActive( true );
|
2010-07-28 01:54:51 +00:00
|
|
|
const int itemClicked( this->itemClicked( point, true ) );
|
|
|
|
const long source = QString( groupData->data( clientGroupItemDragMimeType() ) ).toLong();
|
2010-05-02 18:34:08 +00:00
|
|
|
itemData_.setDirty( true );
|
|
|
|
moveItemToClientGroup( source, itemClicked );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-08-31 14:30:17 +00:00
|
|
|
titleAnimationData_->reset();
|
2010-05-02 18:34:08 +00:00
|
|
|
return true;
|
2009-11-15 03:24:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_____________________________________________________________
|
|
|
|
void Client::timerEvent( QTimerEvent* event )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( event->timerId() != dragStartTimer_.timerId() )
|
|
|
|
{ return KCommonDecorationUnstable::timerEvent( event ); }
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
dragStartTimer_.stop();
|
2009-11-15 06:28:40 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// do nothing if there is only one tab
|
|
|
|
if( itemData_.count() > 1 )
|
|
|
|
{
|
|
|
|
itemData_.animate( AnimationMove|AnimationSameTarget, sourceItem_ );
|
|
|
|
itemData_.animate( AnimationLeave|AnimationSameTarget, sourceItem_ );
|
|
|
|
}
|
2009-11-15 06:28:40 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 06:28:40 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_____________________________________________________________
|
|
|
|
bool Client::closeItem( const Button* button )
|
2009-11-15 06:32:34 +00:00
|
|
|
{
|
2009-11-15 06:28:40 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
for( int i=0; i < itemData_.count(); i++ )
|
|
|
|
{
|
|
|
|
if( button == itemData_[i].closeButton_.data() )
|
|
|
|
{
|
|
|
|
itemData_.setDirty( true );
|
|
|
|
closeClientGroupItem( i );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2009-11-15 06:28:40 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//________________________________________________________________
|
|
|
|
QPixmap Client::itemDragPixmap( int index, const QRect& geometry )
|
2009-11-15 03:24:04 +00:00
|
|
|
{
|
2010-07-28 01:54:51 +00:00
|
|
|
const bool itemValid( index >= 0 && index < clientGroupItems().count() );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
QPixmap pixmap( geometry.size() );
|
|
|
|
QPainter painter( &pixmap );
|
|
|
|
painter.setRenderHints(QPainter::SmoothPixmapTransform|QPainter::Antialiasing);
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
painter.translate( -geometry.topLeft() );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// render window background
|
|
|
|
renderWindowBackground( &painter, geometry, widget(), widget()->palette() );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// darken background if item is inactive
|
2010-07-28 01:54:51 +00:00
|
|
|
const bool itemActive = !( itemValid && index != visibleClientGroupItem() );
|
2010-05-02 18:34:08 +00:00
|
|
|
if( !itemActive )
|
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
QLinearGradient lg( geometry.topLeft(), geometry.bottomLeft() );
|
|
|
|
lg.setColorAt( 0, helper().alphaColor( Qt::black, 0.05 ) );
|
|
|
|
lg.setColorAt( 1, helper().alphaColor( Qt::black, 0.10 ) );
|
|
|
|
painter.setBrush( lg );
|
|
|
|
painter.setPen( Qt::NoPen );
|
|
|
|
painter.drawRect( geometry );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// render title text
|
|
|
|
painter.setFont( options()->font(isActive(), false) );
|
|
|
|
QRect textRect( geometry.adjusted( 0, layoutMetric( LM_TitleEdgeTop )-1, 0, -1 ) );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
if( itemValid )
|
|
|
|
{ textRect.adjust( layoutMetric( LM_TitleBorderLeft ), 0, -layoutMetric(LM_TitleBorderRight), 0 ); }
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-07-28 01:54:51 +00:00
|
|
|
const QString caption( itemValid ? clientGroupItems()[index].title() : this->caption() );
|
2010-05-11 04:59:13 +00:00
|
|
|
renderTitleText(
|
|
|
|
&painter, textRect, caption,
|
|
|
|
titlebarTextColor( widget()->palette(), isActive() && itemActive ),
|
|
|
|
titlebarContrastColor( widget()->palette() ) );
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// floating frame
|
|
|
|
helper().drawFloatFrame(
|
|
|
|
&painter, geometry, widget()->palette().window().color(),
|
|
|
|
true, false,
|
|
|
|
KDecoration::options()->color(ColorTitleBar)
|
|
|
|
);
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
painter.end();
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// create pixmap mask
|
|
|
|
QBitmap bitmap( geometry.size() );
|
|
|
|
{
|
|
|
|
bitmap.clear();
|
|
|
|
QPainter painter( &bitmap );
|
|
|
|
QPainterPath path;
|
|
|
|
path.addRegion( helper().roundedMask( geometry.translated( -geometry.topLeft() ) ) );
|
|
|
|
painter.fillPath( path, Qt::color1 );
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
pixmap.setMask( bitmap );
|
|
|
|
return pixmap;
|
2009-11-15 03:24:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________________
|
|
|
|
void Client::createSizeGrip( void )
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
assert( !hasSizeGrip() );
|
|
|
|
if( ( isResizable() && windowId() != 0 ) || isPreview() )
|
|
|
|
{
|
|
|
|
sizeGrip_ = new SizeGrip( this );
|
|
|
|
sizeGrip().setVisible( !( isMaximized() || isShade() ) );
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//_________________________________________________________________
|
|
|
|
void Client::deleteSizeGrip( void )
|
2009-09-09 00:55:55 +00:00
|
|
|
{
|
2010-05-02 18:34:08 +00:00
|
|
|
assert( hasSizeGrip() );
|
|
|
|
sizeGrip_->deleteLater();
|
|
|
|
sizeGrip_ = 0;
|
2009-09-07 17:41:42 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|