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; 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() void AppletQuickItemPrivate::preloadForExpansion()
{ {
qint64 time = 0; qint64 time = 0;
@ -304,7 +326,7 @@ void AppletQuickItemPrivate::preloadForExpansion()
createCompactRepresentationExpanderItem(); createCompactRepresentationExpanderItem();
} }
if (compactRepresentationExpanderItem) { if (!appletShouldBeExpanded() && compactRepresentationExpanderItem) {
compactRepresentationExpanderItem->setProperty("fullRepresentation", QVariant::fromValue<QObject*>(createFullRepresentationItem())); compactRepresentationExpanderItem->setProperty("fullRepresentation", QVariant::fromValue<QObject*>(createFullRepresentationItem()));
} else { } else {
fullRepresentationItem->setProperty("parent", QVariant::fromValue<QObject*>(q)); fullRepresentationItem->setProperty("parent", QVariant::fromValue<QObject*>(q));
@ -329,31 +351,14 @@ void AppletQuickItemPrivate::compactRepresentationCheck()
return; 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) || if ((full && fullRepresentationItem && fullRepresentationItem == currentRepresentationItem) ||
(!full && compactRepresentationItem && compactRepresentationItem == currentRepresentationItem) (!full && compactRepresentationItem && compactRepresentationItem == currentRepresentationItem)
) { ) {
return; return;
} }
}
//Expanded //Expanded
if (full) { if (full) {

View File

@ -80,6 +80,11 @@ public:
QQuickItem *createCompactRepresentationItem(); QQuickItem *createCompactRepresentationItem();
QQuickItem *createFullRepresentationItem(); QQuickItem *createFullRepresentationItem();
QQuickItem *createCompactRepresentationExpanderItem(); 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(); void preloadForExpansion();
//look into item, and return the Layout attached property, if found //look into item, and return the Layout attached property, if found