* consolidate the remove action enabling check into one method
* check the remove action on immutability changes (prevents "Remove" from showing up erroniously when locking then unlocking) svn path=/trunk/KDE/kdelibs/; revision=897290
This commit is contained in:
parent
71d6e19ae8
commit
5c2927870d
@ -395,10 +395,7 @@ void Containment::setContainmentType(Containment::Type type)
|
|||||||
d->createToolBox();
|
d->createToolBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
enableAction("remove", (immutability() == Mutable &&
|
d->checkRemoveAction();
|
||||||
(screen() == -1 ||
|
|
||||||
containmentType() == Plasma::Containment::PanelContainment ||
|
|
||||||
containmentType() == Plasma::Containment::CustomPanelContainment)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Corona *Containment::corona() const
|
Corona *Containment::corona() const
|
||||||
@ -556,7 +553,6 @@ void ContainmentPrivate::appletActions(KMenu &desktopMenu, Applet *applet, bool
|
|||||||
|
|
||||||
QAction *closeApplet = applet->d->actions.action("remove");
|
QAction *closeApplet = applet->d->actions.action("remove");
|
||||||
if (!closeApplet) { //unlikely but not impossible
|
if (!closeApplet) { //unlikely but not impossible
|
||||||
kDebug() << "no remove action!!!!!!!!";
|
|
||||||
closeApplet = new QAction(i18nc("%1 is the name of the applet", "Remove this %1", applet->name()), &desktopMenu);
|
closeApplet = new QAction(i18nc("%1 is the name of the applet", "Remove this %1", applet->name()), &desktopMenu);
|
||||||
closeApplet->setIcon(KIcon("edit-delete"));
|
closeApplet->setIcon(KIcon("edit-delete"));
|
||||||
QObject::connect(closeApplet, SIGNAL(triggered(bool)), applet, SLOT(destroy()));
|
QObject::connect(closeApplet, SIGNAL(triggered(bool)), applet, SLOT(destroy()));
|
||||||
@ -847,11 +843,7 @@ void Containment::setScreen(int screen, int desktop)
|
|||||||
swapScreensWith->setScreen(oldScreen);
|
swapScreensWith->setScreen(oldScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (immutability() == Mutable) {
|
d->checkRemoveAction();
|
||||||
enableAction("remove", screen == -1 ||
|
|
||||||
containmentType() == Plasma::Containment::PanelContainment ||
|
|
||||||
containmentType() == Plasma::Containment::CustomPanelContainment);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Containment::screen() const
|
int Containment::screen() const
|
||||||
@ -1560,6 +1552,14 @@ void ContainmentPrivate::handleDisappeared(AppletHandle *handle)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContainmentPrivate::checkRemoveAction()
|
||||||
|
{
|
||||||
|
q->enableAction("remove", (q->immutability() == Mutable &&
|
||||||
|
(screen == -1 ||
|
||||||
|
type == Plasma::Containment::PanelContainment ||
|
||||||
|
type == Plasma::Containment::CustomPanelContainment)));
|
||||||
|
}
|
||||||
|
|
||||||
void ContainmentPrivate::containmentConstraintsEvent(Plasma::Constraints constraints)
|
void ContainmentPrivate::containmentConstraintsEvent(Plasma::Constraints constraints)
|
||||||
{
|
{
|
||||||
if (!q->isContainment()) {
|
if (!q->isContainment()) {
|
||||||
@ -1569,21 +1569,17 @@ void ContainmentPrivate::containmentConstraintsEvent(Plasma::Constraints constra
|
|||||||
//kDebug() << "got containmentConstraintsEvent" << constraints << (QObject*)toolBox;
|
//kDebug() << "got containmentConstraintsEvent" << constraints << (QObject*)toolBox;
|
||||||
if (constraints & Plasma::ImmutableConstraint) {
|
if (constraints & Plasma::ImmutableConstraint) {
|
||||||
//update actions
|
//update actions
|
||||||
|
checkRemoveAction();
|
||||||
bool unlocked = q->immutability() == Mutable;
|
bool unlocked = q->immutability() == Mutable;
|
||||||
q->setAcceptDrops(unlocked);
|
q->setAcceptDrops(unlocked);
|
||||||
|
q->enableAction("add widgets", unlocked);
|
||||||
QAction *action = actions().action("add widgets");
|
|
||||||
if (action) {
|
|
||||||
action->setVisible(unlocked);
|
|
||||||
action->setEnabled(unlocked);
|
|
||||||
}
|
|
||||||
//FIXME immutability changes conflict with zoom changes
|
//FIXME immutability changes conflict with zoom changes
|
||||||
/*action = actions().action("add sibling containment");
|
/*action = actions().action("add sibling containment");
|
||||||
if (action) {
|
if (action) {
|
||||||
action->setVisible(unlocked);
|
action->setVisible(unlocked);
|
||||||
action->setEnabled(unlocked);
|
action->setEnabled(unlocked);
|
||||||
}*/
|
}*/
|
||||||
action = actions().action("lock widgets");
|
QAction *action = actions().action("lock widgets");
|
||||||
if (action) {
|
if (action) {
|
||||||
action->setText(unlocked ? i18n("Lock Widgets") : i18n("Unlock Widgets"));
|
action->setText(unlocked ? i18n("Lock Widgets") : i18n("Unlock Widgets"));
|
||||||
action->setIcon(KIcon(unlocked ? "object-locked" : "object-unlocked"));
|
action->setIcon(KIcon(unlocked ? "object-locked" : "object-unlocked"));
|
||||||
@ -1640,10 +1636,7 @@ void ContainmentPrivate::containmentConstraintsEvent(Plasma::Constraints constra
|
|||||||
|
|
||||||
if (toolBox && constraints & Plasma::StartupCompletedConstraint) {
|
if (toolBox && constraints & Plasma::StartupCompletedConstraint) {
|
||||||
toolBox->addTool(q->action("remove"));
|
toolBox->addTool(q->action("remove"));
|
||||||
q->enableAction("remove", (q->immutability() == Mutable &&
|
checkRemoveAction();
|
||||||
(screen == -1 ||
|
|
||||||
q->containmentType() == Plasma::Containment::PanelContainment ||
|
|
||||||
q->containmentType() == Plasma::Containment::CustomPanelContainment)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,6 +82,7 @@ public:
|
|||||||
void containmentActions(KMenu &desktopMenu);
|
void containmentActions(KMenu &desktopMenu);
|
||||||
void appletActions(KMenu &desktopMenu, Applet *applet, bool includeApplet);
|
void appletActions(KMenu &desktopMenu, Applet *applet, bool includeApplet);
|
||||||
bool showContextMenu(const QPointF &point, const QPoint &screenPos, bool includeApplet);
|
bool showContextMenu(const QPointF &point, const QPoint &screenPos, bool includeApplet);
|
||||||
|
void checkRemoveAction();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locks or unlocks plasma's applets.
|
* Locks or unlocks plasma's applets.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user