remove close support, clean up code a bit while in there
This commit is contained in:
parent
4a1ed3e6aa
commit
faa9bd1eb2
@ -47,8 +47,6 @@
|
|||||||
#include "plasma/framesvg.h"
|
#include "plasma/framesvg.h"
|
||||||
#include "plasma/paintutils.h"
|
#include "plasma/paintutils.h"
|
||||||
|
|
||||||
//#include "private/style_p.h"
|
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -64,16 +62,26 @@ public:
|
|||||||
shape(NativeTabBar::RoundedNorth),
|
shape(NativeTabBar::RoundedNorth),
|
||||||
backgroundSvg(0),
|
backgroundSvg(0),
|
||||||
buttonSvg(0),
|
buttonSvg(0),
|
||||||
closeIcon("window-close"),
|
|
||||||
m_highlightSvg(0)
|
m_highlightSvg(0)
|
||||||
{
|
{
|
||||||
|
backgroundSvg = new FrameSvg(q);
|
||||||
|
backgroundSvg->setImagePath("widgets/frame");
|
||||||
|
backgroundSvg->setElementPrefix("sunken");
|
||||||
|
|
||||||
|
buttonSvg = new FrameSvg(q);
|
||||||
|
buttonSvg->setImagePath("widgets/button");
|
||||||
|
buttonSvg->setElementPrefix("normal");
|
||||||
|
|
||||||
|
syncBorders();
|
||||||
|
|
||||||
|
lastIndex[0] = -1;
|
||||||
|
lastIndex[1] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
~NativeTabBarPrivate()
|
~NativeTabBarPrivate()
|
||||||
{
|
{
|
||||||
delete backgroundSvg;
|
delete backgroundSvg;
|
||||||
delete buttonSvg;
|
delete buttonSvg;
|
||||||
delete m_highlightSvg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void syncBorders();
|
void syncBorders();
|
||||||
@ -82,7 +90,7 @@ public:
|
|||||||
FrameSvg *highlightSvg()
|
FrameSvg *highlightSvg()
|
||||||
{
|
{
|
||||||
if (!m_highlightSvg) {
|
if (!m_highlightSvg) {
|
||||||
m_highlightSvg = new Plasma::FrameSvg();
|
m_highlightSvg = new FrameSvg(q);
|
||||||
m_highlightSvg->setImagePath("widgets/button");
|
m_highlightSvg->setImagePath("widgets/button");
|
||||||
m_highlightSvg->setElementPrefix("pressed");
|
m_highlightSvg->setElementPrefix("pressed");
|
||||||
}
|
}
|
||||||
@ -96,7 +104,6 @@ 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;
|
|
||||||
|
|
||||||
QList<bool> highlightedTabs;
|
QList<bool> highlightedTabs;
|
||||||
|
|
||||||
@ -119,11 +126,13 @@ void NativeTabBarPrivate::syncBorders()
|
|||||||
|
|
||||||
void NativeTabBarPrivate::storeLastIndex()
|
void NativeTabBarPrivate::storeLastIndex()
|
||||||
{
|
{
|
||||||
// if first run
|
// if first run, or invalid previous index
|
||||||
if (lastIndex[0] == -1) {
|
if (lastIndex[1] < 0 || lastIndex[1] >= q->count()) {
|
||||||
lastIndex[1] = q->currentIndex();
|
lastIndex[0] = q->currentIndex();
|
||||||
|
} else {
|
||||||
|
lastIndex[0] = lastIndex[1];
|
||||||
}
|
}
|
||||||
lastIndex[0] = lastIndex[1];
|
|
||||||
lastIndex[1] = q->currentIndex();
|
lastIndex[1] = q->currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,19 +140,7 @@ NativeTabBar::NativeTabBar(QWidget *parent)
|
|||||||
: KTabBar(parent),
|
: KTabBar(parent),
|
||||||
d(new NativeTabBarPrivate(this))
|
d(new NativeTabBarPrivate(this))
|
||||||
{
|
{
|
||||||
d->backgroundSvg = new Plasma::FrameSvg();
|
|
||||||
d->backgroundSvg->setImagePath("widgets/frame");
|
|
||||||
d->backgroundSvg->setElementPrefix("sunken");
|
|
||||||
|
|
||||||
d->buttonSvg = new Plasma::FrameSvg();
|
|
||||||
d->buttonSvg->setImagePath("widgets/button");
|
|
||||||
d->buttonSvg->setElementPrefix("normal");
|
|
||||||
|
|
||||||
d->syncBorders();
|
|
||||||
|
|
||||||
d->lastIndex[0] = -1;
|
|
||||||
connect(this, SIGNAL(currentChanged(int)), this, SLOT(startAnimation()));
|
connect(this, SIGNAL(currentChanged(int)), this, SLOT(startAnimation()));
|
||||||
|
|
||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,14 +373,8 @@ void NativeTabBar::paintEvent(QPaintEvent *event)
|
|||||||
painter.drawText(textRect, Qt::AlignCenter | Qt::TextHideMnemonic, tabText(i));
|
painter.drawText(textRect, Qt::AlignCenter | Qt::TextHideMnemonic, tabText(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tabsClosable()) {
|
|
||||||
d->closeIcon.paint(&painter, QRect(closeButtonPos(i), QSize(KIconLoader::SizeSmall, KIconLoader::SizeSmall)) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (scrollButtonsRect.isValid()) {
|
if (scrollButtonsRect.isValid()) {
|
||||||
scrollButtonsRect.adjust(2, 4, -2, -4);
|
scrollButtonsRect.adjust(2, 4, -2, -4);
|
||||||
painter.save();
|
painter.save();
|
||||||
@ -507,13 +498,17 @@ void NativeTabBar::animationFinished()
|
|||||||
|
|
||||||
bool NativeTabBar::isVertical() const
|
bool NativeTabBar::isVertical() const
|
||||||
{
|
{
|
||||||
Shape s = shape();
|
switch (shape()) {
|
||||||
if(s == RoundedWest ||
|
case RoundedWest:
|
||||||
s == RoundedEast ||
|
case RoundedEast:
|
||||||
s == TriangularWest ||
|
case TriangularWest:
|
||||||
s == TriangularEast) {
|
case TriangularEast:
|
||||||
return true;
|
return true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,36 +536,6 @@ 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NativeTabBar::mousePressEvent(QMouseEvent *event)
|
void NativeTabBar::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (d->currentAnimRect.isNull()) {
|
if (d->currentAnimRect.isNull()) {
|
||||||
|
@ -85,7 +85,6 @@ 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…
Reference in New Issue
Block a user