diff options
-rw-r--r-- | lumina-desktop/LDesktop.cpp | 52 | ||||
-rw-r--r-- | lumina-desktop/LSession.cpp | 2 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/LDPlugin.h | 2 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/LDPluginContainer.h | 17 |
4 files changed, 58 insertions, 15 deletions
diff --git a/lumina-desktop/LDesktop.cpp b/lumina-desktop/LDesktop.cpp index eed9fa9c..5e61db8a 100644 --- a/lumina-desktop/LDesktop.cpp +++ b/lumina-desktop/LDesktop.cpp @@ -64,6 +64,14 @@ void LDesktop::prepareToClose(){ for(int i=0; i<PANELS.length(); i++){ PANELS[i]->prepareToClose(); delete PANELS.takeAt(i); i--; } //Now close down any desktop plugins desktoplocked = true; //make sure that plugin settings are preserved during removal + //Remove all the current containers + QList<QMdiSubWindow*> wins = bgDesktop->subWindowList(); + for(int i=0; i<wins.length(); i++){ + wins[i]->setWhatsThis(""); //clear this so it knows it is being temporarily removed + bgDesktop->removeSubWindow(wins[i]->widget()); //unhook plugin from container + bgDesktop->removeSubWindow(wins[i]); //remove container from screen + delete wins[i]; //delete old container + } for(int i=0; i<PLUGINS.length(); i++){delete PLUGINS.takeAt(i); i--; } } @@ -416,13 +424,26 @@ void LDesktop::AlignDesktopPlugins(){ } void LDesktop::DesktopPluginRemoved(QString ID){ - //Close down that plugin instance (NOTE: the container was already closed by the user) + //Close down that plugin instance (NOTE: the container might have already closed by the user) + if(DEBUG){ qDebug() << "Desktop Plugin Removed:" << ID; } + //First look for the container (just in case) + QList<QMdiSubWindow*> wins = bgDesktop->subWindowList(); + for(int i=0; i<wins.length(); i++){ + if(wins[i]->whatsThis() == ID){ + if(DEBUG){ qDebug() << " - Removing Plugin Container"; } + //wins[i]->setWhatsThis(""); //clear this so it knows it is being temporarily removed + bgDesktop->removeSubWindow(wins[i]->widget()); //unhook plugin from container + bgDesktop->removeSubWindow(wins[i]); //remove container from screen + delete wins[i]; //delete old container + break; + } + } //qDebug() << "PLUGINS:" << PLUGINS.length() << ID; for(int i=0; i<PLUGINS.length(); i++){ if(PLUGINS[i]->ID() == ID){ //qDebug() << "- found ID"; - if(DEBUG){ qDebug() << "Deleting Desktop Plugin:" << ID; } + if(DEBUG){ qDebug() << " - Deleting Desktop Plugin:" << ID; } delete PLUGINS.takeAt(i); break; } @@ -433,9 +454,12 @@ void LDesktop::DesktopPluginRemoved(QString ID){ if(DEBUG){ qDebug() << " - Also removing plugin from future list"; } plugins.removeAll(ID); issyncing = true; + if(DEBUG){ qDebug() << " - Save modified plugins list"; } settings->setValue(DPREFIX+"pluginlist", plugins); - settings->sync(); + if(DEBUG){ qDebug() << " - Unlock settings file in 200 ms"; } + //settings->sync(); QTimer::singleShot(200, this, SLOT(UnlockSettings()) ); + if(DEBUG){ qDebug() << " - Done removing plugin"; } } void LDesktop::UpdatePanels(){ @@ -476,13 +500,24 @@ void LDesktop::UpdatePanels(){ void LDesktop::UpdateDesktopPluginArea(){ QRegion visReg( bgWindow->geometry() ); //visible region (not hidden behind a panel) + QRect rawRect = visReg.boundingRect(); //initial value (screen size) for(int i=0; i<PANELS.length(); i++){ QRegion shifted = visReg; QString loc = settings->value(PANELS[i]->prefix()+"location","top").toString().toLower(); - if(loc=="top"){ shifted.translate(0, PANELS[i]->visibleWidth()); } - else if(loc=="bottom"){ shifted.translate(0, 0-PANELS[i]->visibleWidth()); } - else if(loc=="left"){ shifted.translate(PANELS[i]->visibleWidth(),0); } - else{ shifted.translate(0-PANELS[i]->visibleWidth(),0); } + int vis = PANELS[i]->visibleWidth(); + if(loc=="top"){ + if(!shifted.contains(QRect(rawRect.x(), rawRect.y(), rawRect.width(), vis))){ continue; } + shifted.translate(0, (rawRect.top()+vis)-shifted.boundingRect().top() ); + }else if(loc=="bottom"){ + if(!shifted.contains(QRect(rawRect.x(), rawRect.bottom()-vis, rawRect.width(), vis))){ continue; } + shifted.translate(0, (rawRect.bottom()-vis)-shifted.boundingRect().bottom()); + }else if(loc=="left"){ + if( !shifted.contains(QRect(rawRect.x(), rawRect.y(), vis,rawRect.height())) ){ continue; } + shifted.translate((rawRect.left()+vis)-shifted.boundingRect().left() ,0); + }else{ //right + if(!shifted.contains(QRect(rawRect.right()-vis, rawRect.y(), vis,rawRect.height())) ){ continue; } + shifted.translate((rawRect.right()-vis)-shifted.boundingRect().right(),0); + } visReg = visReg.intersected( shifted ); } //Now make sure the desktop plugin area is only the visible area @@ -492,11 +527,14 @@ void LDesktop::UpdateDesktopPluginArea(){ globalWorkRect = rec; //save this for later rec.moveTopLeft( QPoint( rec.x()-desktop->screenGeometry(desktopnumber).x() , rec.y() ) ); //qDebug() << "DPlug Area:" << rec.x() << rec.y() << rec.width() << rec.height(); + if(rec == bgDesktop->geometry()){return; } //nothing changed bgDesktop->setGeometry( rec ); bgDesktop->setBackground( QBrush(Qt::NoBrush) ); bgDesktop->update(); //Re-paint the panels (just in case a plugin was underneath it and the panel is transparent) for(int i=0; i<PANELS.length(); i++){ PANELS[i]->update(); } + //Also need to re-arrange any desktop plugins to ensure that nothing is out of the screen area + AlignDesktopPlugins(); } void LDesktop::UpdateBackground(){ diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index 59df5c44..17434181 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -322,7 +322,7 @@ void LSession::checkUserFiles(){ QString OVS = sessionsettings->value("DesktopVersion","0").toString(); //Old Version String int oldversion = VersionStringToNumber(OVS); bool newversion = ( oldversion < VersionStringToNumber(this->applicationVersion()) ); //increasing version number - bool newrelease = ( OVS.endsWith("-devel", Qt::CaseInsensitive) && this->applicationVersion().endsWith("-release", Qt::CaseInsensitive) ); //Moving from devel to release + bool newrelease = ( OVS.contains("-devel", Qt::CaseInsensitive) && this->applicationVersion().contains("-release", Qt::CaseInsensitive) ); //Moving from devel to release //Check for the desktop settings file QString dset = QDir::homePath()+"/.lumina/LuminaDE/desktopsettings.conf"; diff --git a/lumina-desktop/desktop-plugins/LDPlugin.h b/lumina-desktop/desktop-plugins/LDPlugin.h index 38cfa433..10c0d2ea 100644 --- a/lumina-desktop/desktop-plugins/LDPlugin.h +++ b/lumina-desktop/desktop-plugins/LDPlugin.h @@ -41,7 +41,7 @@ public: } ~LDPlugin(){ - delete settings; + } QString ID(){ diff --git a/lumina-desktop/desktop-plugins/LDPluginContainer.h b/lumina-desktop/desktop-plugins/LDPluginContainer.h index 55cc9d12..14b87585 100644 --- a/lumina-desktop/desktop-plugins/LDPluginContainer.h +++ b/lumina-desktop/desktop-plugins/LDPluginContainer.h @@ -33,6 +33,7 @@ private: private slots: void saveGeometry(){ + if(settings==0){ return; } settings->setValue("location/x", this->pos().x()); settings->setValue("location/y", this->pos().y()); settings->setValue("location/width", this->size().width()); @@ -45,14 +46,15 @@ public: locked = islocked; setup=true; syncTimer = new QTimer(this); - syncTimer->setInterval(1000); //save settings 1 second after it is moved + syncTimer->setInterval(500); //save settings 1 second after it is moved syncTimer->setSingleShot(true); //no repeats connect(syncTimer, SIGNAL(timeout()), this, SLOT(saveGeometry()) ); this->setWhatsThis(plugin->ID()); if(locked){ this->setWindowFlags(Qt::FramelessWindowHint); } - else{ this->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint); } + else{ this->setWindowFlags(Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint); } settings = plugin->settings; //save this pointer for access later - if(settings->allKeys().isEmpty()){ + if(settings!=0){ + if(settings->allKeys().isEmpty()){ //Brand new plugin - no location/size info saved yet //save the initial size of the plugin - the initial location will be set automatically QSize sz = plugin->sizeHint(); @@ -60,7 +62,8 @@ public: settings->setValue("location/width", sz.width()); settings->setValue("location/height", sz.height()); settings->sync(); - } + } + } this->setContentsMargins(0,0,0,0); if(!locked){ this->setWindowTitle( plugin->ID().replace("---"," - ") ); @@ -115,14 +118,16 @@ protected: } void closeEvent(QCloseEvent *event){ - if( !this->whatsThis().isEmpty() ){ + //qDebug() << "Desktop Plugin Close Event:" << this->whatsThis(); + if( !this->whatsThis().isEmpty() && !locked){ //Plugin removed by the user - delete the settings file locked = true; //ensure that the save settings routines don't do anything during the close if(syncTimer->isActive()){ syncTimer->stop(); } //prevent save routine from running in a moment QFile::remove( settings->fileName() ); emit PluginRemoved( this->whatsThis() ); } - event->accept(); //continue closing the widget + settings = 0; //ensure we don't touch the settings file after a close event + event->accept(); } }; |