don't put the fullrep in the popup if not collapsed

when preloading, if the applet is not collapsed,
the full representationshouldn't be put in the popup

reviewed-by: kbroulik
This commit is contained in:
Marco Martin 2018-02-26 14:42:01 +01:00
parent 3c4f3ed1b8
commit 3c5d6a9be8
2 changed files with 34 additions and 24 deletions

View File

@ -289,6 +289,28 @@ QQuickItem *AppletQuickItemPrivate::createCompactRepresentationExpanderItem()
return compactRepresentationExpanderItem;
}
bool AppletQuickItemPrivate::appletShouldBeExpanded() const
{
if (applet->isContainment()) {
return true;
} else {
if (switchWidth > 0 && switchHeight > 0) {
return q->width() > switchWidth && q->height() > switchHeight;
//if a size to switch wasn't set, determine what representation to always chose
} else {
//preferred representation set?
if (preferredRepresentation) {
return preferredRepresentation == fullRepresentation;
//Otherwise, base on FormFactor
} else {
return (applet->formFactor() != Plasma::Types::Horizontal && applet->formFactor() != Plasma::Types::Vertical);
}
}
}
}
void AppletQuickItemPrivate::preloadForExpansion()
{
qint64 time = 0;
@ -304,7 +326,7 @@ void AppletQuickItemPrivate::preloadForExpansion()
createCompactRepresentationExpanderItem();
}
if (compactRepresentationExpanderItem) {
if (!appletShouldBeExpanded() && compactRepresentationExpanderItem) {
compactRepresentationExpanderItem->setProperty("fullRepresentation", QVariant::fromValue<QObject*>(createFullRepresentationItem()));
} else {
fullRepresentationItem->setProperty("parent", QVariant::fromValue<QObject*>(q));
@ -329,32 +351,15 @@ void AppletQuickItemPrivate::compactRepresentationCheck()
return;
}
bool full = false;
bool full = appletShouldBeExpanded();
if (applet->isContainment()) {
full = true;
} else {
if (switchWidth > 0 && switchHeight > 0) {
full = q->width() > switchWidth && q->height() > switchHeight;
//if a size to switch wasn't set, determine what representation to always chose
} else {
//preferred representation set?
if (preferredRepresentation) {
full = preferredRepresentation == fullRepresentation;
//Otherwise, base on FormFactor
} else {
full = (applet->formFactor() != Plasma::Types::Horizontal && applet->formFactor() != Plasma::Types::Vertical);
}
}
if ((full && fullRepresentationItem && fullRepresentationItem == currentRepresentationItem) ||
(!full && compactRepresentationItem && compactRepresentationItem == currentRepresentationItem)
) {
return;
}
if ((full && fullRepresentationItem && fullRepresentationItem == currentRepresentationItem) ||
(!full && compactRepresentationItem && compactRepresentationItem == currentRepresentationItem)
) {
return;
}
//Expanded
if (full) {
QQuickItem *item = createFullRepresentationItem();

View File

@ -80,6 +80,11 @@ public:
QQuickItem *createCompactRepresentationItem();
QQuickItem *createFullRepresentationItem();
QQuickItem *createCompactRepresentationExpanderItem();
//true if the applet is at a size in which it should be expanded,
//false if is too small and should be an icon
bool appletShouldBeExpanded() const;
//ensures the popup is preloaded, don't expand yet
void preloadForExpansion();
//look into item, and return the Layout attached property, if found