aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/core/lumina-desktop/LDesktop.cpp10
-rw-r--r--src-qt5/core/lumina-desktop/LDesktopPluginSpace.cpp33
-rw-r--r--src-qt5/core/lumina-desktop/LDesktopPluginSpace.h38
-rw-r--r--src-qt5/core/lumina-desktop/desktop-plugins/LDPlugin.h4
4 files changed, 52 insertions, 33 deletions
diff --git a/src-qt5/core/lumina-desktop/LDesktop.cpp b/src-qt5/core/lumina-desktop/LDesktop.cpp
index 78485b56..90c2f31f 100644
--- a/src-qt5/core/lumina-desktop/LDesktop.cpp
+++ b/src-qt5/core/lumina-desktop/LDesktop.cpp
@@ -99,7 +99,7 @@ void LDesktop::UpdateGeometry(){
PANELS[i]->UpdatePanel(true); //geom only updates - do this before adjusting the background
}*/
//qDebug() << " - Update Desktop Plugin Area";
- UpdateDesktopPluginArea();
+ //UpdateDesktopPluginArea();
//qDebug() << " - Done With Desktop Geom Updates";
QTimer::singleShot(0, this, SLOT(UpdatePanels()));
}
@@ -485,15 +485,15 @@ void LDesktop::UpdateDesktopPluginArea(){
//Now make sure the desktop plugin area is only the visible area
QRect rec = visReg.boundingRect();
// QRect rec = LSession::desktop()->availableGeometry(Screen());
- qDebug() << " - DPArea: Panel-Adjusted rectangle:" << rec;
- qDebug() << " - DPArea: Screen Geometry:" << LSession::desktop()->screenGeometry(Screen());
- qDebug() << " - DPArea: Current Geometry:" << bgDesktop->geometry();
+ //qDebug() << " - DPArea: Panel-Adjusted rectangle:" << rec;
+ //qDebug() << " - DPArea: Screen Geometry:" << LSession::desktop()->screenGeometry(Screen());
+ //qDebug() << " - DPArea: Current Geometry:" << bgDesktop->geometry();
//LSession::handle()->XCB->SetScreenWorkArea((unsigned int) Screen(), rec);
//Now remove the X offset to place it on the current screen (needs widget-coords, not global)
globalWorkRect = rec; //save this for later
rec.moveTopLeft( QPoint( rec.x()-LSession::desktop()->screenGeometry(Screen()).x() , rec.y()-LSession::desktop()->screenGeometry(Screen()).y() ) );
//qDebug() << "DPlug Area:" << rec << bgDesktop->geometry() << LSession::handle()->desktop()->availableGeometry(bgDesktop);
- if(rec.size().isNull() || rec == bgDesktop->geometry()){return; } //nothing changed
+ if(rec.size().isNull() ){ return; } //|| rec == bgDesktop->geometry()){return; } //nothing changed
//bgDesktop->show(); //make sure Fluxbox is aware of it *before* we start moving it
bgDesktop->setGeometry( LSession::desktop()->screenGeometry(Screen()));
//bgDesktop->resize(LSession::desktop()->screenGeometry(Screen()).size());
diff --git a/src-qt5/core/lumina-desktop/LDesktopPluginSpace.cpp b/src-qt5/core/lumina-desktop/LDesktopPluginSpace.cpp
index f233983c..f4cf2cfe 100644
--- a/src-qt5/core/lumina-desktop/LDesktopPluginSpace.cpp
+++ b/src-qt5/core/lumina-desktop/LDesktopPluginSpace.cpp
@@ -74,7 +74,9 @@ void LDesktopPluginSpace::setBackground(QPixmap pix){
}
void LDesktopPluginSpace::setDesktopArea(QRect area){
+ //qDebug() << "Setting Desktop Plugin Area:" << area;
desktopRect = area;
+
}
// ===================
@@ -85,7 +87,7 @@ void LDesktopPluginSpace::UpdateGeom(int oldgrid){
//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; i<ITEMS.length(); i++){
- QRect grid = geomToGrid(ITEMS[i]->geometry(), oldgrid);
+ QRect grid = ITEMS[i]->gridGeometry(); //geomToGrid(ITEMS[i]->geometry(), oldgrid);
if(DEBUG){ qDebug() << " - Check Plugin:" << ITEMS[i]->whatsThis() << grid; }
if( !ValidGrid(grid) ){
//This plugin is too far out of the screen - find new location for it
@@ -99,11 +101,8 @@ void LDesktopPluginSpace::UpdateGeom(int oldgrid){
i--;
}else{
//NOTE: We are not doing the ValidGeometry() checks because we are only resizing existing plugin with pre-set & valid grid positions
- grid = gridToGeom(grid); //convert to pixels before saving/sizing
- MovePlugin(ITEMS[i], grid);
- /*ITEMS[i]->setGeometry( grid );
- ITEMS[i]->setFixedSize(grid.size());
- ITEMS[i]->savePluginGeometry(grid);*/
+ ITEMS[i]->setGridGeometry(grid); //save the new grid position for later
+ MovePlugin(ITEMS[i], gridToGeom(grid)); //convert to pixels before saving/sizing (desktop canvas might have moved)
}
}
//if(reload){ QTimer::singleShot(0,this, SLOT(reloadPlugins())); }
@@ -123,9 +122,13 @@ void LDesktopPluginSpace::addDesktopPlugin(QString plugID){
if(plug==0){ return; } //invalid plugin
//plug->setAttribute(Qt::WA_TranslucentBackground);
plug->setWhatsThis(plugID);
- //Now get the geometry for the plugin
- QRect geom = plug->loadPluginGeometry(); //in pixel coords
- if(!geom.isNull()){ geom = geomToGrid(geom); } //convert to grid coordinates
+ //Now get the saved geometry for the plugin
+ QRect geom = plug->gridGeometry(); //grid coordinates
+ if(geom.isNull()){
+ geom = plug->loadPluginGeometry(); //in pixel coords
+ if(!geom.isNull()){ geom = geomToGrid(geom); } //convert to grid coordinates
+ }
+ //Now determine the position to put it
if(geom.isNull()){
//No previous location - need to calculate initial geom
QSize sz = plug->defaultPluginSize(); //in grid coordinates
@@ -143,6 +146,7 @@ void LDesktopPluginSpace::addDesktopPlugin(QString plugID){
}else{
if(DEBUG){ qDebug() << " - New Plugin Geometry (grid):" << geom; }
//Now place the item in the proper spot/size
+ plug->setGridGeometry(geom); //save for later
MovePlugin(plug, gridToGeom(geom));
//plug->setGeometry( gridToGeom(geom) );
plug->show();
@@ -170,7 +174,8 @@ QRect LDesktopPluginSpace::findOpenSpot(int gridwidth, int gridheight, int start
colCount = RoundUp(desktopRect.width()/GRIDSIZE);
if( (row+gridheight)>rowCount){ row = rowCount-gridheight; startRow = row; }
if( (col+gridwidth)>colCount){ col = colCount-gridwidth; startCol = col; }
- QRect geom(0, 0, gridwidth*GRIDSIZE, gridheight*GRIDSIZE); //origin point will be adjusted in a moment
+ QRect geom = gridToGeom( QRect(startCol, startRow, gridwidth, gridheight) );
+ //qDebug() << "Find Open Space:" <<geom << QRect(startCol, startRow, gridwidth, gridheight);
if(DEBUG){ qDebug() << "Search for plugin space:" << rowCount << colCount << gridheight << gridwidth << this->size(); }
if(TopToBottom && reversed && (startRow>0 || startCol>0) ){
//Arrange Top->Bottom (work backwards)
@@ -178,7 +183,7 @@ QRect LDesktopPluginSpace::findOpenSpot(int gridwidth, int gridheight, int start
while(col>=0 && !found){
while(row>=0 && !found){
bool ok = true;
- geom.moveTo(col*GRIDSIZE, row*GRIDSIZE);
+ geom.moveTo( gridToPos(QPoint(col,row)) ); //col*GRIDSIZE+desktopRect.x(), row*GRIDSIZE+desktopRect.y());
//qDebug() << " - Check Geom:" << geom << col << row;
//Check all the existing items to ensure no overlap
for(int i=0; i<ITEMS.length() && ok; i++){
@@ -200,7 +205,7 @@ QRect LDesktopPluginSpace::findOpenSpot(int gridwidth, int gridheight, int start
while(col<(colCount-gridwidth) && !found){
while(row<(rowCount-gridheight) && !found){
bool ok = true;
- geom.moveTo(col*GRIDSIZE, row*GRIDSIZE);
+ geom.moveTo( gridToPos(QPoint(col,row)) ); //col*GRIDSIZE+desktopRect.x(), row*GRIDSIZE+desktopRect.y());
//qDebug() << " - Check Geom:" << geom << col << row;
//Check all the existing items to ensure no overlap
for(int i=0; i<ITEMS.length() && ok; i++){
@@ -221,7 +226,7 @@ QRect LDesktopPluginSpace::findOpenSpot(int gridwidth, int gridheight, int start
while(row>=0 && !found){
while(col>=0 && !found){
bool ok = true;
- geom.moveTo(col*GRIDSIZE, row*GRIDSIZE);
+ geom.moveTo( gridToPos(QPoint(col,row)) ); //col*GRIDSIZE, row*GRIDSIZE);
//Check all the existing items to ensure no overlap
for(int i=0; i<ITEMS.length() && ok; i++){
if(ITEMS[i]->whatsThis()==plugID){ continue; } //same plugin - this is not a conflict
@@ -241,7 +246,7 @@ QRect LDesktopPluginSpace::findOpenSpot(int gridwidth, int gridheight, int start
while(row<(rowCount-gridheight) && !found){
while(col<(colCount-gridwidth) && !found){
bool ok = true;
- geom.moveTo(col*GRIDSIZE, row*GRIDSIZE);
+ geom.moveTo( gridToPos(QPoint(col,row)) ); //col*GRIDSIZE, row*GRIDSIZE);
//Check all the existing items to ensure no overlap
for(int i=0; i<ITEMS.length() && ok; i++){
if(ITEMS[i]->whatsThis()==plugID){ continue; } //same plugin - this is not a conflict
diff --git a/src-qt5/core/lumina-desktop/LDesktopPluginSpace.h b/src-qt5/core/lumina-desktop/LDesktopPluginSpace.h
index abc34878..8e768631 100644
--- a/src-qt5/core/lumina-desktop/LDesktopPluginSpace.h
+++ b/src-qt5/core/lumina-desktop/LDesktopPluginSpace.h
@@ -60,6 +60,7 @@ private:
int RoundUp(double num){
int out = num; //This will truncate the number
if(out < num){ out++; } //need to increase by 1
+ //qDebug() << "Round Up:" << num << "->" << out;
return out;
}
@@ -71,35 +72,42 @@ private:
QRect findOpenSpot(QRect grid, QString plugID, bool recursive = false);
QPoint posToGrid(QPoint pos){
- //This assumes a point in widget-relative coordinates
- pos.setX( RoundUp(pos.x()/GRIDSIZE));
- pos.setY( RoundUp(pos.y()/GRIDSIZE));
+ pos.setX( RoundUp((pos.x()-desktopRect.x())/GRIDSIZE));
+ pos.setY( RoundUp((pos.y()-desktopRect.y())/GRIDSIZE));
return pos;
}
+
+ QPoint gridToPos(QPoint grid){
+ grid.setX( (grid.x()*GRIDSIZE)+desktopRect.x() );
+ grid.setY( (grid.y()*GRIDSIZE)+desktopRect.y() );
+ return grid;
+ }
QRect geomToGrid(QRect geom, int grid = -1){
if(grid<0){
//use the current grid size
- return QRect( RoundUp(geom.x()/GRIDSIZE), RoundUp(geom.y()/GRIDSIZE), \
+ return QRect( RoundUp((geom.x()-desktopRect.x())/GRIDSIZE), RoundUp((geom.y()-desktopRect.y())/GRIDSIZE), \
RoundUp(geom.width()/GRIDSIZE), RoundUp(geom.height()/GRIDSIZE) );
+ //qDebug() << "Geom to Grid:" << geom << desktopRect << tmp << GRIDSIZE;
+ //return tmp;
}else{
//use the input grid size
- return QRect( RoundUp(geom.x()/((double) grid)), RoundUp(geom.y()/((double) grid)), \
+ return QRect( RoundUp((geom.x()-desktopRect.x())/((double) grid)), RoundUp((geom.y()-desktopRect.y())/((double) grid)), \
RoundUp(geom.width()/((double) grid)), RoundUp(geom.height()/((double) grid)) );
}
}
QRect gridToGeom(QRect grid){
//This function incorporates the bottom/right edge matchins procedures (for incomplete last grid)
- QRect geom(grid.x()*GRIDSIZE, grid.y()*GRIDSIZE, grid.width()*GRIDSIZE, grid.height()*GRIDSIZE);
+ QRect geom((grid.x()*GRIDSIZE)+desktopRect.x(), (grid.y()*GRIDSIZE)+desktopRect.y(), grid.width()*GRIDSIZE, grid.height()*GRIDSIZE);
//Now check the edge conditions (last right/bottom grid points might be smaller than GRIDSIZE)
- QSize areaSize = desktopRect.size(); //use the size of the area instead of the geometry - because we need this in child coordinates like "geom" above
+ //QSize areaSize = desktopRect.size();
//qDebug() << "GridToGeom:" << grid << geom << "Area size:" << areaSize;
- if(geom.right() > areaSize.width() && (geom.right()-areaSize.width())<GRIDSIZE ){
- geom.setRight(areaSize.width()-1); //match up with the edge
+ if(geom.right() > desktopRect.right() && (geom.right()-desktopRect.right())<GRIDSIZE ){
+ geom.setRight(desktopRect.right()); //match up with the edge
}
- if(geom.bottom() > areaSize.height() && (geom.bottom() -areaSize.height())<GRIDSIZE ){
- geom.setBottom(areaSize.height()-1); //match up with the edge
+ if(geom.bottom() > desktopRect.bottom() && (geom.bottom() -desktopRect.bottom())<GRIDSIZE ){
+ geom.setBottom(desktopRect.bottom()); //match up with the edge
}
//qDebug() << " - Adjusted:" << geom;
return geom;
@@ -124,16 +132,18 @@ private:
bool ValidGrid(QRect grid){
//qDebug() << "Check Valid Grid:" << grid << RoundUp(this->width()/GRIDSIZE) << RoundUp(this->height()/GRIDSIZE);
//This just checks that the grid coordinates are not out of bounds - should still run ValidGeometry() below with the actual pixel geom
- if(grid.x()<0 || grid.y()<0 || grid.width()<0 || grid.height()<0){ return false; }
+ if(grid.x()<0|| grid.y()<0 || grid.width()<0 || grid.height()<0){ return false; }
else if( (grid.x()+grid.width()) > RoundUp(desktopRect.width()/GRIDSIZE) ){ return false; }
else if( (grid.y()+grid.height()) > RoundUp(desktopRect.height()/GRIDSIZE) ){ return false; }
+ //Final Check - don't let 1x1 items occupy the last row/column (not full size)
+ else if(grid.width()==1 && grid.height()==1 && (grid.x()==RoundUp(desktopRect.width()/GRIDSIZE) || grid.y()==RoundUp(desktopRect.height()/GRIDSIZE)) ){ return false; }
return true;
}
bool ValidGeometry(QString id, QRect geom){
//First check that it is within the desktop area completely
// Note that "this->geometry()" is not in the same coordinate space as the geometry inputs
- if(!QRect(0,0,desktopRect.width(), desktopRect.height()).contains(geom)){ return false; }
+ if(!desktopRect.contains(geom)){ return false; }
//Now check that it does not collide with any other items
for(int i=0; i<ITEMS.length(); i++){
if(ITEMS[i]->whatsThis()==id){ continue; }
@@ -150,9 +160,9 @@ private:
}
void MovePlugin(LDPlugin* plug, QRect geom){
+ plug->savePluginGeometry(geom); //save the un-adjusted geometry
plug->setGeometry( geom );
plug->setFixedSize(geom.size()); //needed for some plugins
- plug->savePluginGeometry(geom);
}
private slots:
diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/LDPlugin.h b/src-qt5/core/lumina-desktop/desktop-plugins/LDPlugin.h
index a200ab90..815ae9da 100644
--- a/src-qt5/core/lumina-desktop/desktop-plugins/LDPlugin.h
+++ b/src-qt5/core/lumina-desktop/desktop-plugins/LDPlugin.h
@@ -35,6 +35,7 @@ private:
QSettings *settings;
QMenu *menu, *contextM;
QTimer *dragTimer;
+ //QRect gridRect; //Current Geometry in grid coordinates.
void setupMenu();
@@ -90,6 +91,9 @@ public:
}
+ void setGridGeometry(QRect grid){ settings->setValue(prefix+"geometry/gridLocation", grid); }
+ QRect gridGeometry(){ return settings->value(prefix+"geometry/gridLocation",QRect()).toRect(); }
+
public slots:
virtual void LocaleChange(){
//This needs to be re-implemented in the subclassed plugin
bgstack15