aboutsummaryrefslogtreecommitdiff
path: root/lumina-desktop
diff options
context:
space:
mode:
Diffstat (limited to 'lumina-desktop')
-rw-r--r--lumina-desktop/LDesktop.cpp10
-rw-r--r--lumina-desktop/LDesktopPluginSpace.cpp31
-rw-r--r--lumina-desktop/LDesktopPluginSpace.h23
-rw-r--r--lumina-desktop/LSession.cpp4
4 files changed, 39 insertions, 29 deletions
diff --git a/lumina-desktop/LDesktop.cpp b/lumina-desktop/LDesktop.cpp
index 241302a4..15b09b8a 100644
--- a/lumina-desktop/LDesktop.cpp
+++ b/lumina-desktop/LDesktop.cpp
@@ -224,7 +224,7 @@ void LDesktop::InitDesktop(){
connect(bgWindow, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowMenu(const QPoint&)) );
if(DEBUG){ qDebug() << "Create bgDesktop"; }
bgDesktop = new LDesktopPluginSpace(bgWindow); //new QMdiArea(bgWindow);
- bgDesktop->SetIconSize( settings->value(DPREFIX+"IconSize",64).toInt() );
+ bgDesktop->SetIconSize( settings->value(DPREFIX+"GridSize",100).toInt() );
connect(bgDesktop, SIGNAL(PluginRemovedByUser(QString)), this, SLOT(RemoveDeskPlugin(QString)) );
connect(bgDesktop, SIGNAL(IncreaseIcons()), this, SLOT(IncreaseDesktopPluginIcons()) );
connect(bgDesktop, SIGNAL(DecreaseIcons()), this, SLOT(DecreaseDesktopPluginIcons()) );
@@ -372,21 +372,21 @@ void LDesktop::RemoveDeskPlugin(QString ID){
}
void LDesktop::IncreaseDesktopPluginIcons(){
- int cur = settings->value(DPREFIX+"IconSize",64).toInt();
+ int cur = settings->value(DPREFIX+"GridSize",100).toInt();
cur+=16;
issyncing=true; //don't let the change cause a refresh
- settings->setValue(DPREFIX+"IconSize",cur);
+ settings->setValue(DPREFIX+"GridSize",cur);
settings->sync();
QTimer::singleShot(200, this, SLOT(UnlockSettings()) );
bgDesktop->SetIconSize(cur);
}
void LDesktop::DecreaseDesktopPluginIcons(){
- int cur = settings->value(DPREFIX+"IconSize",64).toInt();
+ int cur = settings->value(DPREFIX+"GridSize",100).toInt();
if(cur<32){ return; } //cannot get smaller than 16x16
cur-=16;
issyncing=true; //don't let the change cause a refresh
- settings->setValue(DPREFIX+"IconSize",cur);
+ settings->setValue(DPREFIX+"GridSize",cur);
settings->sync();
QTimer::singleShot(200, this, SLOT(UnlockSettings()) );
bgDesktop->SetIconSize(cur);
diff --git a/lumina-desktop/LDesktopPluginSpace.cpp b/lumina-desktop/LDesktopPluginSpace.cpp
index 3b1c97ba..2c9bea12 100644
--- a/lumina-desktop/LDesktopPluginSpace.cpp
+++ b/lumina-desktop/LDesktopPluginSpace.cpp
@@ -23,6 +23,7 @@ LDesktopPluginSpace::LDesktopPluginSpace(QWidget *parent) : QWidget(parent){
this->setContextMenuPolicy(Qt::NoContextMenu);
this->setMouseTracking(true);
TopToBottom = true;
+ GRIDSIZE = 100.0; //default value if not set
plugsettings = LSession::handle()->DesktopPluginSettings();
}
@@ -41,8 +42,9 @@ void LDesktopPluginSpace::LoadItems(QStringList plugs, QStringList files){
void LDesktopPluginSpace::SetIconSize(int size){
if(DEBUG){ qDebug() << "Set Desktop Icon Size:" << size; }
- QSize newsize = calculateItemSize(size);
- itemSize = newsize; //save this for all the later icons which are generated (grid size)
+ //QSize newsize = calculateItemSize(size);
+ GRIDSIZE = size; //turn the int into a float;
+ itemSize = QSize(1,1); //save this for all the later icons which are generated (grid size)
UpdateGeom();
//Now re-set the item icon size
reloadPlugins(true);
@@ -88,11 +90,12 @@ void LDesktopPluginSpace::addDesktopPlugin(QString plugID){
LDPlugin *plug = NewDP::createPlugin(plugID, this);
plug->setWhatsThis(plugID);
//Now get the geometry for the plugin
- QRect geom = plug->loadPluginGeometry(); //in grid coords
+ QRect geom = plug->loadPluginGeometry(); //in pixel coords
+ if(!geom.isNull()){ geom = geomToGrid(geom); } //convert to grid coordinates
if(geom.isNull()){
//No previous location - need to calculate initial geom
QSize sz = plug->sizeHint();
- if(plugID.startsWith("applauncher::") ){ sz = itemSize*GRIDSIZE; }
+ if(plugID.startsWith("applauncher") ){ sz = itemSize*GRIDSIZE; }
geom.setWidth( RoundUp(sz.width()/GRIDSIZE) );
geom.setHeight( RoundUp(sz.height()/GRIDSIZE) );
geom.moveTo( findOpenSpot(geom.width(), geom.height()) );
@@ -191,24 +194,22 @@ void LDesktopPluginSpace::reloadPlugins(bool ForceIconUpdate ){
QStringList plugs = plugins;
QStringList items = deskitems;
for(int i=0; i<ITEMS.length(); i++){
- if(plugs.contains(ITEMS[i]->whatsThis())){ plugs.removeAll(ITEMS[i]->whatsThis()); }
- else if(ITEMS[i]->whatsThis().contains("---dlink") && items.contains(ITEMS[i]->whatsThis().section("---",0,0).section("::",1,50)) ){
- //Account for the variation in the Plugin ID for desktop files
- if(ForceIconUpdate){
+
+ if( ITEMS[i]->whatsThis().startsWith("applauncher") && ForceIconUpdate){
//Change the size of the existing plugin - preserving the location if possible
- QRect geom = ITEMS[i]->loadPluginGeometry();
+ QRect geom = ITEMS[i]->loadPluginGeometry(); //pixel coords
if(!geom.isNull()){
+ geom = geomToGrid(geom); //convert to grid coords
geom.setSize(itemSize); //Reset back to default size (does not change location)
- ITEMS[i]->savePluginGeometry(geom);
+ ITEMS[i]->savePluginGeometry( gridToGeom(geom)); //save it back in pixel coords
}
//Now remove the plugin for the moment - run it through the re-creation routine below
delete ITEMS.takeAt(i);
i--;
- }else{
- items.removeAll(ITEMS[i]->whatsThis().section("---",0,0).section("::",1,50));
- }
-
- }else{ ITEMS[i]->removeSettings(true); delete ITEMS.takeAt(i); i--; } //this is considered a permanent removal (cleans settings)
+ }
+ else if(plugs.contains(ITEMS[i]->whatsThis())){ plugs.removeAll(ITEMS[i]->whatsThis()); }
+ else if(items.contains(ITEMS[i]->whatsThis().section("---",0,0).section("::",1,50))){ items.removeAll(ITEMS[i]->whatsThis().section("---",0,0).section("::",1,50)); }
+ else{ ITEMS[i]->removeSettings(true); delete ITEMS.takeAt(i); i--; } //this is considered a permanent removal (cleans settings)
}
//Now create any new items
diff --git a/lumina-desktop/LDesktopPluginSpace.h b/lumina-desktop/LDesktopPluginSpace.h
index 842999b3..2a0f97a3 100644
--- a/lumina-desktop/LDesktopPluginSpace.h
+++ b/lumina-desktop/LDesktopPluginSpace.h
@@ -21,7 +21,7 @@
#define MIMETYPE QString("x-special/lumina-desktop-plugin")
//#define MIMEPOS QString("x-special/lumina-desktop-plugin-pos")
-#define GRIDSIZE 16.0 //Need this to be a double/float - usually used for divisions
+//#define GRIDSIZE 64.0 //Need this to be a double/float - usually used for divisions
class LDesktopPluginSpace : public QWidget{
Q_OBJECT
@@ -50,6 +50,7 @@ private:
QStringList plugins, deskitems;
QList<LDPlugin*> ITEMS;
bool TopToBottom;
+ float GRIDSIZE;
int RoundUp(double num){
int out = num; //This will truncate the number
@@ -80,12 +81,13 @@ private:
//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);
//Now check the edge conditions (last right/bottom grid points might be smaller than GRIDSIZE)
- //qDebug() << "GridToGeom:" << grid << geom;
- if(geom.right() > this->geometry().right() && (geom.right() -this->geometry().right())<GRIDSIZE ){
- geom.setRight(this->geometry().right()); //match up with the edge
+ QSize areaSize = this->size(); //use the size of the area instead of the geometry - because we need this in child coordinates like "geom" above
+ //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.bottom() > this->geometry().bottom() && (geom.bottom() -this->geometry().bottom())<GRIDSIZE ){
- geom.setBottom(this->geometry().bottom()); //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
}
//qDebug() << " - Adjusted:" << geom;
return geom;
@@ -171,13 +173,16 @@ protected:
QPoint diff = grid - posToGrid(geom.center()); //difference in grid coords
//qDebug() << "Move Event:" << "Diff:" << diff << "Geom:" << geom << grid << ev->pos();
geom = geomToGrid(geom); //convert to grid coords
+ //qDebug() << "Move Event:" << "Old geom (grid):" << geom;
geom.moveTo( (geom.topLeft()+diff) );
+ //qDebug() << " - After Move:" << geom;
geom = gridToGeom(geom); //convert back to px coords with edge matching
- //qDebug() << " - Setting Geometry:" << geom;
+ //qDebug() << " - new Geometry:" << geom;
if(ValidGeometry(act.section("::::",1,50), geom)){
+ //qDebug() << " - Is valid";
item->setGeometry(geom);
ev->acceptProposedAction();
- item->savePluginGeometry(geomToGrid(geom));
+ item->savePluginGeometry(geom); //save in pixel coords
}else{ ev->ignore(); } //invalid location
}else{
@@ -197,7 +202,7 @@ protected:
if(ValidGeometry(act.section("::::",1,50), geom)){
item->setGeometry(geom);
ev->acceptProposedAction();
- item->savePluginGeometry(geomToGrid(geom));
+ item->savePluginGeometry(geom); //save in pixel coords
}else{ ev->ignore(); } //invalid location
}
}
diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp
index 145ac992..cd78cce2 100644
--- a/lumina-desktop/LSession.cpp
+++ b/lumina-desktop/LSession.cpp
@@ -414,6 +414,10 @@ void LSession::checkUserFiles(){
}
}
dset.sync();
+ //Due to the grid size change for desktop plugins, need to remove any old plugin geometries
+ if(QFile::exists(QDir::homePath()+"/.lumina/pluginsettings/desktopsettings.conf")){
+ QFile::remove(QDir::homePath()+"/.lumina/pluginsettings/desktopsettings.conf");
+ }
}
//Convert to the XDG autostart spec as necessary (Change occured with 0.8.5)
bgstack15