paint close buttons if asked to
svn path=/trunk/KDE/kdelibs/; revision=916527
This commit is contained in:
parent
82fb975523
commit
e720a24966
@ -35,6 +35,8 @@
|
|||||||
// KDE
|
// KDE
|
||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
#include <kcolorutils.h>
|
#include <kcolorutils.h>
|
||||||
|
#include <KIcon>
|
||||||
|
#include <KIconLoader>
|
||||||
|
|
||||||
#include "plasma/plasma.h"
|
#include "plasma/plasma.h"
|
||||||
#include "plasma/theme.h"
|
#include "plasma/theme.h"
|
||||||
@ -54,6 +56,7 @@ public:
|
|||||||
: q(parent),
|
: q(parent),
|
||||||
backgroundSvg(0),
|
backgroundSvg(0),
|
||||||
buttonSvg(0),
|
buttonSvg(0),
|
||||||
|
closeIcon("window-close"),
|
||||||
animationId(-1)
|
animationId(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -73,6 +76,7 @@ public:
|
|||||||
qreal left, top, right, bottom;
|
qreal left, top, right, bottom;
|
||||||
FrameSvg *buttonSvg;
|
FrameSvg *buttonSvg;
|
||||||
qreal buttonLeft, buttonTop, buttonRight, buttonBottom;
|
qreal buttonLeft, buttonTop, buttonRight, buttonBottom;
|
||||||
|
KIcon closeIcon;
|
||||||
|
|
||||||
int animationId;
|
int animationId;
|
||||||
|
|
||||||
@ -259,8 +263,13 @@ void NativeTabBar::paintEvent(QPaintEvent *event)
|
|||||||
|
|
||||||
painter.setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
|
painter.setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
|
||||||
painter.drawText(textRect, Qt::AlignCenter | Qt::TextHideMnemonic, tabText(i));
|
painter.drawText(textRect, Qt::AlignCenter | Qt::TextHideMnemonic, tabText(i));
|
||||||
|
|
||||||
|
if (isCloseButtonEnabled()) {
|
||||||
|
d->closeIcon.paint(&painter, QRect(closeButtonPos(i), QSize(KIconLoader::SizeSmall, KIconLoader::SizeSmall)) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QRect scrollButtonsRect;
|
QRect scrollButtonsRect;
|
||||||
foreach (QObject *child, children()) {
|
foreach (QObject *child, children()) {
|
||||||
QToolButton *childWidget = qobject_cast<QToolButton *>(child);
|
QToolButton *childWidget = qobject_cast<QToolButton *>(child);
|
||||||
@ -398,6 +407,36 @@ QSize NativeTabBar::tabSize(int index) const
|
|||||||
return hint;
|
return hint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Unfortunately copied from KTabBar
|
||||||
|
QPoint NativeTabBar::closeButtonPos( int tabIndex ) const
|
||||||
|
{
|
||||||
|
QPoint buttonPos;
|
||||||
|
if ( tabIndex < 0 ) {
|
||||||
|
return buttonPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
int availableHeight = height();
|
||||||
|
if ( tabIndex == currentIndex() ) {
|
||||||
|
QStyleOption option;
|
||||||
|
option.initFrom(this);
|
||||||
|
availableHeight -= style()->pixelMetric( QStyle::PM_TabBarTabShiftVertical, &option, this );
|
||||||
|
}
|
||||||
|
|
||||||
|
const QRect tabBounds = tabRect( tabIndex );
|
||||||
|
const int xInc = (height() - KIconLoader::SizeSmall) / 2;
|
||||||
|
|
||||||
|
if ( layoutDirection() == Qt::RightToLeft ) {
|
||||||
|
buttonPos = tabBounds.topLeft();
|
||||||
|
buttonPos.rx() += xInc;
|
||||||
|
} else {
|
||||||
|
buttonPos = tabBounds.topRight();
|
||||||
|
buttonPos.rx() -= KIconLoader::SizeSmall + xInc;
|
||||||
|
}
|
||||||
|
buttonPos.ry() += (availableHeight - KIconLoader::SizeSmall) / 2;
|
||||||
|
|
||||||
|
return buttonPos;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Plasma
|
} // namespace Plasma
|
||||||
|
|
||||||
#include "nativetabbar_p.moc"
|
#include "nativetabbar_p.moc"
|
||||||
|
@ -64,6 +64,7 @@ Q_SIGNALS:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QSize tabSize(int index) const;
|
QSize tabSize(int index) const;
|
||||||
|
QPoint closeButtonPos( int tabIndex ) const;
|
||||||
|
|
||||||
NativeTabBarPrivate * const d;
|
NativeTabBarPrivate * const d;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user