From 9d2f7b1bd0d9c6a726099e77d53599a4e4d99346 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 16 Oct 2015 23:07:32 -0400 Subject: Fix up the automatic re-sizing of desktop plugins along the bottom/right screen edges when the viewport size changes. If a plugin is *completely* off the screen (a full grid point or more), remove the plugin temporarily and then re-run the plugin creation/placement routine to perform the full "find-a-spot" functionality. --- lumina-desktop/LDesktopPluginSpace.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'lumina-desktop') diff --git a/lumina-desktop/LDesktopPluginSpace.cpp b/lumina-desktop/LDesktopPluginSpace.cpp index 2c9bea12..2732556e 100644 --- a/lumina-desktop/LDesktopPluginSpace.cpp +++ b/lumina-desktop/LDesktopPluginSpace.cpp @@ -33,7 +33,7 @@ LDesktopPluginSpace::~LDesktopPluginSpace(){ } void LDesktopPluginSpace::LoadItems(QStringList plugs, QStringList files){ - if(DEBUG){ qDebug() << "Loading Desktop Items:" << plugs << files; } + if(DEBUG){ qDebug() << "Loading Desktop Items:" << plugs << files << "Area:" << this->size() << GRIDSIZE; } bool changes = false; if(plugs != plugins){ plugins = plugs; changes = true; } if(files != deskitems){ deskitems = files; changes = true; } @@ -63,8 +63,25 @@ void LDesktopPluginSpace::cleanup(){ // PUBLIC SLOTS // =================== void LDesktopPluginSpace::UpdateGeom(){ - if(DEBUG){ qDebug() << "Update Desktop Geom:"; } - //Currently no special checks - might need to add validation of all current plugin geometries in the future + if(DEBUG){ qDebug() << "Updated Desktop Geom:" << this->size() << GRIDSIZE << this->size()/GRIDSIZE; } + //Go through and check the locations/sizes of all items (particularly the ones on the bottom/right edges) + bool reload = false; + for(int i=0; igeometry()); + if(DEBUG){ qDebug() << " - Check Plugin:" << grid; } + if( (grid.x()+grid.width() > this->width()/GRIDSIZE) || (grid.y()+grid.height() > this->height()/GRIDSIZE) ){ + //This plugin is too far out of the screen - remove it and reload plugins (will find new location for it) + //qDebug() << " -- Out of bounds - recreate it..."; + delete ITEMS.takeAt(i); + i--; + reload = true; + }else if( (grid.x()+grid.width() == this->width()/GRIDSIZE) || (grid.y()+grid.height() == this->height()/GRIDSIZE) ){ + //This plugin is on the bottom/right screen edge - recalculate edge matching and re-apply geometry + //qDebug() << " -- On Screen Edge - adjust to fit..."; + ITEMS[i]->setGeometry( gridToGeom(grid) ); + } + } + if(reload){ QTimer::singleShot(0,this, SLOT(reloadPlugins())); } } // =================== -- cgit