all members belong in the dptr.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=755512
This commit is contained in:
parent
936078bbfb
commit
627cb88ccf
@ -327,7 +327,7 @@ void Icon::init()
|
|||||||
d->setVerticalMargin(Private::ItemMargin, 0, 0);
|
d->setVerticalMargin(Private::ItemMargin, 0, 0);
|
||||||
|
|
||||||
d->setActiveMargins();
|
d->setActiveMargins();
|
||||||
currentSize = QSizeF(-1,-1);
|
d->currentSize = QSizeF(-1,-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::addAction(QAction *action)
|
void Icon::addAction(QAction *action)
|
||||||
@ -390,7 +390,7 @@ void Icon::setNumDisplayLines(int numLines)
|
|||||||
|
|
||||||
QSizeF Icon::sizeHint() const
|
QSizeF Icon::sizeHint() const
|
||||||
{
|
{
|
||||||
return currentSize;
|
return d->currentSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF Icon::Private::displaySizeHint(const QStyleOptionGraphicsItem *option, const qreal width) const
|
QSizeF Icon::Private::displaySizeHint(const QStyleOptionGraphicsItem *option, const qreal width) const
|
||||||
@ -426,11 +426,11 @@ QSizeF Icon::Private::displaySizeHint(const QStyleOptionGraphicsItem *option, co
|
|||||||
|
|
||||||
void Icon::layoutIcons(const QStyleOptionGraphicsItem *option)
|
void Icon::layoutIcons(const QStyleOptionGraphicsItem *option)
|
||||||
{
|
{
|
||||||
if (size() == currentSize) {
|
if (size() == d->currentSize) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentSize = size();
|
d->currentSize = size();
|
||||||
d->setActiveMargins();
|
d->setActiveMargins();
|
||||||
|
|
||||||
//calculate icon size based on the available space
|
//calculate icon size based on the available space
|
||||||
@ -440,19 +440,19 @@ void Icon::layoutIcons(const QStyleOptionGraphicsItem *option)
|
|||||||
qreal heightAvail;
|
qreal heightAvail;
|
||||||
//if there is text resize the icon in order to make room for the text
|
//if there is text resize the icon in order to make room for the text
|
||||||
if (!d->text.isEmpty() || !d->infoText.isEmpty()) {
|
if (!d->text.isEmpty() || !d->infoText.isEmpty()) {
|
||||||
heightAvail = currentSize.height() -
|
heightAvail = d->currentSize.height() -
|
||||||
d->displaySizeHint(option, currentSize.width()).height() -
|
d->displaySizeHint(option, d->currentSize.width()).height() -
|
||||||
d->verticalMargin[Private::TextMargin].top -
|
d->verticalMargin[Private::TextMargin].top -
|
||||||
d->verticalMargin[Private::TextMargin].bottom;
|
d->verticalMargin[Private::TextMargin].bottom;
|
||||||
//never make a label higher than half the total height
|
//never make a label higher than half the total height
|
||||||
heightAvail = qMax(heightAvail, currentSize.height()/2);
|
heightAvail = qMax(heightAvail, d->currentSize.height()/2);
|
||||||
}else{
|
}else{
|
||||||
heightAvail = currentSize.height();
|
heightAvail = d->currentSize.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
//aspect ratio very "tall"
|
//aspect ratio very "tall"
|
||||||
if (currentSize.width() < heightAvail) {
|
if (d->currentSize.width() < heightAvail) {
|
||||||
iconWidth = currentSize.width() -
|
iconWidth = d->currentSize.width() -
|
||||||
d->horizontalMargin[Private::IconMargin].left -
|
d->horizontalMargin[Private::IconMargin].left -
|
||||||
d->horizontalMargin[Private::IconMargin].right;
|
d->horizontalMargin[Private::IconMargin].right;
|
||||||
}else{
|
}else{
|
||||||
@ -474,18 +474,18 @@ void Icon::layoutIcons(const QStyleOptionGraphicsItem *option)
|
|||||||
|
|
||||||
//if there is text resize the icon in order to make room for the text
|
//if there is text resize the icon in order to make room for the text
|
||||||
if (!d->text.isEmpty() || !d->infoText.isEmpty()) {
|
if (!d->text.isEmpty() || !d->infoText.isEmpty()) {
|
||||||
widthAvail = currentSize.width() -
|
widthAvail = d->currentSize.width() -
|
||||||
//FIXME: fontmetrics
|
//FIXME: fontmetrics
|
||||||
textWidth -
|
textWidth -
|
||||||
d->horizontalMargin[Private::TextMargin].left -
|
d->horizontalMargin[Private::TextMargin].left -
|
||||||
d->horizontalMargin[Private::TextMargin].right;
|
d->horizontalMargin[Private::TextMargin].right;
|
||||||
}else{
|
}else{
|
||||||
widthAvail = currentSize.width();
|
widthAvail = d->currentSize.width();
|
||||||
}
|
}
|
||||||
|
|
||||||
//aspect ratio very "wide"
|
//aspect ratio very "wide"
|
||||||
if (currentSize.height() < widthAvail) {
|
if (d->currentSize.height() < widthAvail) {
|
||||||
iconWidth = currentSize.height() -
|
iconWidth = d->currentSize.height() -
|
||||||
d->verticalMargin[Private::IconMargin].top -
|
d->verticalMargin[Private::IconMargin].top -
|
||||||
d->verticalMargin[Private::IconMargin].bottom;
|
d->verticalMargin[Private::IconMargin].bottom;
|
||||||
}else{
|
}else{
|
||||||
@ -507,13 +507,13 @@ void Icon::layoutIcons(const QStyleOptionGraphicsItem *option)
|
|||||||
//iconAction->setRect(QRectF(6, 6, 32, 32));
|
//iconAction->setRect(QRectF(6, 6, 32, 32));
|
||||||
break;
|
break;
|
||||||
case Private::TopRight:
|
case Private::TopRight:
|
||||||
iconAction->setRect(QRectF(currentSize.width() - 38, 6, 32, 32));
|
iconAction->setRect(QRectF(d->currentSize.width() - 38, 6, 32, 32));
|
||||||
break;
|
break;
|
||||||
case Private::BottomLeft:
|
case Private::BottomLeft:
|
||||||
iconAction->setRect(QRectF(6, currentSize.height() - 38, 32, 32));
|
iconAction->setRect(QRectF(6, d->currentSize.height() - 38, 32, 32));
|
||||||
break;
|
break;
|
||||||
case Private::BottomRight:
|
case Private::BottomRight:
|
||||||
iconAction->setRect(QRectF(currentSize.width() - 38, currentSize.height() - 38, 32, 32));
|
iconAction->setRect(QRectF(d->currentSize.width() - 38, d->currentSize.height() - 38, 32, 32));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,11 +222,9 @@ private:
|
|||||||
void layoutIcons(const QStyleOptionGraphicsItem *option);
|
void layoutIcons(const QStyleOptionGraphicsItem *option);
|
||||||
|
|
||||||
Private * const d;
|
Private * const d;
|
||||||
QSizeF currentSize;
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void actionDestroyed(QObject* obj);
|
void actionDestroyed(QObject* obj);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Plasma
|
} // namespace Plasma
|
||||||
|
@ -181,6 +181,7 @@ public:
|
|||||||
IconStates states;
|
IconStates states;
|
||||||
Qt::Orientation orientation;
|
Qt::Orientation orientation;
|
||||||
int numDisplayLines;
|
int numDisplayLines;
|
||||||
|
QSizeF currentSize;
|
||||||
|
|
||||||
QList<IconAction*> cornerActions;
|
QList<IconAction*> cornerActions;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user