show the toolbox as an external solid-background toolbar under the
containment, don't show text on icons except add windgets and add activity show the remove activity button in the toolbox for non active ones svn path=/trunk/KDE/kdelibs/; revision=891209
This commit is contained in:
parent
258a749f36
commit
d9c14c87ba
@ -216,12 +216,13 @@ void Containment::init()
|
|||||||
|
|
||||||
if (d->type == DesktopContainment && d->toolBox) {
|
if (d->type == DesktopContainment && d->toolBox) {
|
||||||
d->toolBox->addTool(this->action("add widgets"));
|
d->toolBox->addTool(this->action("add widgets"));
|
||||||
|
d->toolBox->addTool(this->action("add sibling containment"));
|
||||||
d->toolBox->addTool(this->action("zoom in"));
|
d->toolBox->addTool(this->action("zoom in"));
|
||||||
d->toolBox->addTool(this->action("zoom out"));
|
d->toolBox->addTool(this->action("zoom out"));
|
||||||
|
|
||||||
if (immutability() != SystemImmutable) {
|
if (immutability() != SystemImmutable) {
|
||||||
d->toolBox->addTool(this->action("lock widgets"));
|
d->toolBox->addTool(this->action("lock widgets"));
|
||||||
}
|
}
|
||||||
d->toolBox->addTool(this->action("add sibling containment"));
|
|
||||||
d->toolBox->addTool(this->action("activity settings"));
|
d->toolBox->addTool(this->action("activity settings"));
|
||||||
if (hasConfigurationInterface()) {
|
if (hasConfigurationInterface()) {
|
||||||
// re-use the contianment's action.
|
// re-use the contianment's action.
|
||||||
@ -825,6 +826,8 @@ void Containment::setScreen(int screen, int desktop)
|
|||||||
if (swapScreensWith) {
|
if (swapScreensWith) {
|
||||||
swapScreensWith->setScreen(oldScreen);
|
swapScreensWith->setScreen(oldScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enableAction("remove", screen == -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Containment::screen() const
|
int Containment::screen() const
|
||||||
@ -1607,9 +1610,14 @@ void ContainmentPrivate::containmentConstraintsEvent(Plasma::Constraints constra
|
|||||||
constraints & Plasma::FormFactorConstraint ||
|
constraints & Plasma::FormFactorConstraint ||
|
||||||
constraints & Plasma::ScreenConstraint ||
|
constraints & Plasma::ScreenConstraint ||
|
||||||
constraints & Plasma::StartupCompletedConstraint)) {
|
constraints & Plasma::StartupCompletedConstraint)) {
|
||||||
kDebug() << "BWUHA!";
|
//kDebug() << "Positioning toolbox";
|
||||||
positionToolBox();
|
positionToolBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (toolBox && constraints & Plasma::StartupCompletedConstraint) {
|
||||||
|
toolBox->addTool(q->action("remove"));
|
||||||
|
q->enableAction("remove", false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Applet *ContainmentPrivate::addApplet(const QString &name, const QVariantList &args,
|
Applet *ContainmentPrivate::addApplet(const QString &name, const QVariantList &args,
|
||||||
@ -1736,6 +1744,11 @@ void ContainmentPrivate::positionContainments()
|
|||||||
qSort(containments.begin(), containments.end(), containmentSortByPosition);
|
qSort(containments.begin(), containments.end(), containmentSortByPosition);
|
||||||
it.toFront();
|
it.toFront();
|
||||||
|
|
||||||
|
int toolBoxMargin = 0;
|
||||||
|
if (toolBox) {
|
||||||
|
toolBoxMargin = TOOLBOX_MARGIN;
|
||||||
|
}
|
||||||
|
|
||||||
int column = 0;
|
int column = 0;
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
@ -1758,7 +1771,7 @@ void ContainmentPrivate::positionContainments()
|
|||||||
if (column == CONTAINMENT_COLUMNS) {
|
if (column == CONTAINMENT_COLUMNS) {
|
||||||
column = 0;
|
column = 0;
|
||||||
x = 0;
|
x = 0;
|
||||||
y += rowHeight + INTER_CONTAINMENT_MARGIN;
|
y += rowHeight + INTER_CONTAINMENT_MARGIN + toolBoxMargin;
|
||||||
rowHeight = 0;
|
rowHeight = 0;
|
||||||
} else {
|
} else {
|
||||||
x += containment->size().width() + INTER_CONTAINMENT_MARGIN;
|
x += containment->size().width() + INTER_CONTAINMENT_MARGIN;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <kmenu.h>
|
#include <kmenu.h>
|
||||||
|
|
||||||
static const int INTER_CONTAINMENT_MARGIN = 6;
|
static const int INTER_CONTAINMENT_MARGIN = 6;
|
||||||
|
static const int TOOLBOX_MARGIN = 150;
|
||||||
static const int CONTAINMENT_COLUMNS = 2;
|
static const int CONTAINMENT_COLUMNS = 2;
|
||||||
static const int VERTICAL_STACKING_OFFSET = 10000;
|
static const int VERTICAL_STACKING_OFFSET = 10000;
|
||||||
|
|
||||||
|
@ -44,16 +44,24 @@ class EmptyGraphicsItem : public QGraphicsItem
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EmptyGraphicsItem(QGraphicsItem *parent)
|
EmptyGraphicsItem(QGraphicsItem *parent)
|
||||||
: QGraphicsItem(parent)
|
: QGraphicsItem(parent),
|
||||||
|
m_toolbar(false)
|
||||||
{
|
{
|
||||||
setAcceptsHoverEvents(true);
|
setAcceptsHoverEvents(true);
|
||||||
m_background = new Plasma::FrameSvg();
|
m_background = new Plasma::FrameSvg();
|
||||||
|
m_toolbarBackground = new Plasma::FrameSvg();
|
||||||
|
|
||||||
|
m_toolbarBackground->setImagePath("widgets/background");
|
||||||
m_background->setImagePath("widgets/translucentbackground");
|
m_background->setImagePath("widgets/translucentbackground");
|
||||||
|
|
||||||
|
m_toolbarBackground->setEnabledBorders(FrameSvg::LeftBorder|FrameSvg::RightBorder|FrameSvg::BottomBorder);
|
||||||
|
m_background->setEnabledBorders(FrameSvg::AllBorders);
|
||||||
}
|
}
|
||||||
|
|
||||||
~EmptyGraphicsItem()
|
~EmptyGraphicsItem()
|
||||||
{
|
{
|
||||||
delete m_background;
|
delete m_background;
|
||||||
|
delete m_toolbarBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF boundingRect() const
|
QRectF boundingRect() const
|
||||||
@ -66,25 +74,63 @@ class EmptyGraphicsItem : public QGraphicsItem
|
|||||||
return m_rect;
|
return m_rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setIsToolbar(bool toolbar)
|
||||||
|
{
|
||||||
|
m_toolbar = toolbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isToolbar() const
|
||||||
|
{
|
||||||
|
return m_toolbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
void getContentsMargins(qreal &left, qreal &top, qreal &right, qreal &bottom)
|
||||||
|
{
|
||||||
|
if (m_toolbar) {
|
||||||
|
m_toolbarBackground->getMargins(left, top, right, bottom);
|
||||||
|
} else {
|
||||||
|
m_background->getMargins(left, top, right, bottom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF contentsRect() const
|
||||||
|
{
|
||||||
|
qreal left, top, right, bottom;
|
||||||
|
|
||||||
|
if (m_toolbar) {
|
||||||
|
m_toolbarBackground->getMargins(left, top, right, bottom);
|
||||||
|
} else {
|
||||||
|
m_background->getMargins(left, top, right, bottom);
|
||||||
|
}
|
||||||
|
return m_rect.adjusted(left, top, -right, -bottom);
|
||||||
|
}
|
||||||
|
|
||||||
void setRect(const QRectF &rect)
|
void setRect(const QRectF &rect)
|
||||||
{
|
{
|
||||||
//kDebug() << "setting rect to" << rect;
|
//kDebug() << "setting rect to" << rect;
|
||||||
qreal left, top, right, bottom;
|
|
||||||
m_background->getMargins(left, top, right, bottom);
|
|
||||||
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
m_rect = rect.adjusted(-left, -top, right, bottom);
|
m_rect = rect;
|
||||||
setPos(m_rect.topLeft());
|
setPos(m_rect.topLeft());
|
||||||
m_background->resizeFrame(m_rect.size());
|
if (m_toolbar) {
|
||||||
|
m_toolbarBackground->resizeFrame(m_rect.size());
|
||||||
|
} else {
|
||||||
|
m_background->resizeFrame(m_rect.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
|
void paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
|
||||||
{
|
{
|
||||||
m_background->paintFrame(p);
|
if (m_toolbar) {
|
||||||
|
m_toolbarBackground->paintFrame(p);
|
||||||
|
} else {
|
||||||
|
m_background->paintFrame(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool m_toolbar;
|
||||||
QRectF m_rect;
|
QRectF m_rect;
|
||||||
|
Plasma::FrameSvg *m_toolbarBackground;
|
||||||
Plasma::FrameSvg *m_background;
|
Plasma::FrameSvg *m_background;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -376,11 +422,13 @@ void DesktopToolBox::showToolBox()
|
|||||||
|
|
||||||
Plasma::IconWidget *icon = qgraphicsitem_cast<Plasma::IconWidget *>(tool);
|
Plasma::IconWidget *icon = qgraphicsitem_cast<Plasma::IconWidget *>(tool);
|
||||||
if (icon) {
|
if (icon) {
|
||||||
if (d->viewTransform.isScaling() && d->viewTransform.m11() < Plasma::scalingFactor(Plasma::GroupZoom)) {
|
if (d->viewTransform.m11() == Plasma::scalingFactor(Plasma::DesktopZoom) ||
|
||||||
icon->setText(QString());
|
icon->action() == d->containment->action("add sibling containment") ||
|
||||||
|
icon->action() == d->containment->action("add widgets")) {
|
||||||
|
icon->setText(icon->action()->text());
|
||||||
icon->resize(icon->sizeFromIconSize(22));
|
icon->resize(icon->sizeFromIconSize(22));
|
||||||
} else {
|
} else {
|
||||||
icon->setText(icon->action()->text());
|
icon->setText(QString());
|
||||||
icon->resize(icon->sizeFromIconSize(22));
|
icon->resize(icon->sizeFromIconSize(22));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -405,38 +453,49 @@ void DesktopToolBox::showToolBox()
|
|||||||
// the rect the tools back should have
|
// the rect the tools back should have
|
||||||
QRectF backerRect = QRectF(QPointF(x, startY), QSizeF(maxWidth + 10, y - startY));
|
QRectF backerRect = QRectF(QPointF(x, startY), QSizeF(maxWidth + 10, y - startY));
|
||||||
|
|
||||||
|
if (!d->toolBacker) {
|
||||||
|
d->toolBacker = new EmptyGraphicsItem(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
d->toolBacker->setIsToolbar(isToolbar());
|
||||||
|
|
||||||
if (isToolbar()) {
|
if (isToolbar()) {
|
||||||
QPointF topRight;
|
QPointF topRight;
|
||||||
|
|
||||||
//could that cast ever fail?
|
//could that cast ever fail?
|
||||||
if (d->containment) {
|
if (d->containment) {
|
||||||
topRight = d->viewTransform.map(mapFromParent(d->containment->boundingRect().topRight()));
|
topRight = d->viewTransform.map(mapFromParent(d->containment->boundingRect().bottomRight()));
|
||||||
} else {
|
} else {
|
||||||
topRight = boundingRect().topRight();
|
topRight = boundingRect().topRight();
|
||||||
}
|
}
|
||||||
|
|
||||||
backerRect.setSize(QSize(totalWidth, maxHeight));
|
qreal left, top, right, bottom;
|
||||||
|
d->toolBacker->getContentsMargins(left, top, right, bottom);
|
||||||
|
x -= left;
|
||||||
|
|
||||||
|
backerRect.setSize(QSize(totalWidth+left+right, maxHeight+top+bottom));
|
||||||
backerRect.moveTopRight(topRight);
|
backerRect.moveTopRight(topRight);
|
||||||
}
|
} else {
|
||||||
//kDebug() << "starting at" << x << startY;
|
//kDebug() << "starting at" << x << startY;
|
||||||
|
|
||||||
// now check that is actually fits within the parent's boundaries
|
// now check that is actually fits within the parent's boundaries
|
||||||
backerRect = mapToParent(backerRect).boundingRect();
|
backerRect = mapToParent(backerRect).boundingRect();
|
||||||
QSizeF parentSize = parentWidget()->size();
|
QSizeF parentSize = parentWidget()->size();
|
||||||
if (backerRect.x() < 5) {
|
if (backerRect.x() < 5) {
|
||||||
backerRect.moveLeft(5);
|
backerRect.moveLeft(5);
|
||||||
} else if (backerRect.right() > parentSize.width() - 5) {
|
} else if (backerRect.right() > parentSize.width() - 5) {
|
||||||
backerRect.moveRight(parentSize.width() - 5);
|
backerRect.moveRight(parentSize.width() - 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (backerRect.y() < 5) {
|
if (backerRect.y() < 5) {
|
||||||
backerRect.moveTop(5);
|
backerRect.moveTop(5);
|
||||||
} else if (backerRect.bottom() > parentSize.height() - 5) {
|
} else if (backerRect.bottom() > parentSize.height() - 5) {
|
||||||
backerRect.moveBottom(parentSize.height() - 5);
|
backerRect.moveBottom(parentSize.height() - 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
// re-map our starting points back to our coordinate system
|
// re-map our starting points back to our coordinate system
|
||||||
backerRect = mapFromParent(backerRect).boundingRect();
|
backerRect = mapFromParent(backerRect).boundingRect();
|
||||||
|
}
|
||||||
x = backerRect.x() + 5;
|
x = backerRect.x() + 5;
|
||||||
y = backerRect.y();
|
y = backerRect.y();
|
||||||
|
|
||||||
@ -473,9 +532,6 @@ void DesktopToolBox::showToolBox()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!d->toolBacker) {
|
|
||||||
d->toolBacker = new EmptyGraphicsItem(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
d->toolBacker->setRect(backerRect);
|
d->toolBacker->setRect(backerRect);
|
||||||
d->toolBacker->show();
|
d->toolBacker->show();
|
||||||
|
Loading…
Reference in New Issue
Block a user