diff options
author | Ken Moore <ken@ixsystems.com> | 2017-10-27 08:08:39 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-10-27 08:08:39 -0400 |
commit | 3fd42c40cfda85fa90c19add4e07ec1ca1c312cb (patch) | |
tree | b7de66bba57d00ae210615aaacaedd59de29a97e /src-qt5/core | |
parent | Fix a few places where /net/ files are still checked for existance (pauses/de... (diff) | |
download | lumina-3fd42c40cfda85fa90c19add4e07ec1ca1c312cb.tar.gz lumina-3fd42c40cfda85fa90c19add4e07ec1ca1c312cb.tar.bz2 lumina-3fd42c40cfda85fa90c19add4e07ec1ca1c312cb.zip |
Add the ability to use a "directory" as the target for desktop wallpapers. Will automatically open that directory and randomly pick an image from from within it for the wallpaper.
Diffstat (limited to 'src-qt5/core')
3 files changed, 50 insertions, 30 deletions
diff --git a/src-qt5/core/lumina-desktop/LDesktop.cpp b/src-qt5/core/lumina-desktop/LDesktop.cpp index f9ea1534..1fc6b11b 100644 --- a/src-qt5/core/lumina-desktop/LDesktop.cpp +++ b/src-qt5/core/lumina-desktop/LDesktop.cpp @@ -341,7 +341,7 @@ void LDesktop::UpdateMenu(bool fast){ void LDesktop::UpdateWinMenu(){ winMenu->clear(); //Get the current list of windows - QList<WId> wins = LSession::handle()->XCB->WindowList(); + QList<WId> wins = LSession::handle()->XCB->WindowList(); //Now add them to the menu for(int i=0; i<wins.length(); i++){ LWinInfo info(wins[i]); @@ -352,7 +352,7 @@ void LDesktop::UpdateWinMenu(){ } void LDesktop::winClicked(QAction* act){ - LSession::handle()->XCB->ActivateWindow( act->data().toString().toULong() ); + LSession::handle()->XCB->ActivateWindow( act->data().toString().toULong() ); } void LDesktop::UpdateDesktop(){ @@ -393,7 +393,7 @@ void LDesktop::UpdateDesktop(){ if(settings->value(DPREFIX+"generateMediaIcons",true).toBool()){ QDir media("/media"); QStringList mediadirs = media.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot, QDir::Name); - for(int i=0; i<mediadirs.length(); i++){ + for(int i=0; i<mediadirs.length(); i++){ filelist << media.absoluteFilePath(mediadirs[i]); } } @@ -406,8 +406,8 @@ void LDesktop::RemoveDeskPlugin(QString ID){ //This is called after a plugin is manually removed by the user // just need to ensure that the plugin is also removed from the settings file QStringList plugs = settings->value(DPREFIX+"pluginlist", QStringList()).toStringList(); - if(plugs.contains(ID)){ - plugs.removeAll(ID); + if(plugs.contains(ID)){ + plugs.removeAll(ID); issyncing=true; //don't let the change cause a refresh settings->setValue(DPREFIX+"pluginlist", plugs); settings->sync(); @@ -437,7 +437,7 @@ void LDesktop::DecreaseDesktopPluginIcons(){ settings->setValue(DPREFIX+"GridSize",cur); settings->sync(); QTimer::singleShot(200, this, SLOT(UnlockSettings()) ); - bgDesktop->SetIconSize(cur); + bgDesktop->SetIconSize(cur); } void LDesktop::UpdatePanels(){ @@ -484,18 +484,18 @@ void LDesktop::UpdateDesktopPluginArea(){ QRegion shifted = visReg; QString loc = settings->value(PANELS[i]->prefix()+"location","top").toString().toLower(); int vis = PANELS[i]->visibleWidth(); - if(loc=="top"){ + if(loc=="top"){ if(!shifted.contains(QRect(rawRect.x(), rawRect.y(), rawRect.width(), vis))){ continue; } - shifted.translate(0, (rawRect.top()+vis)-shifted.boundingRect().top() ); + 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.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); + 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); + shifted.translate((rawRect.right()-vis)-shifted.boundingRect().right(),0); } visReg = visReg.intersected( shifted ); } @@ -535,7 +535,7 @@ void LDesktop::UpdateBackground(){ //Get the list of background(s) to show QStringList bgL = settings->value(DPREFIX+"background/filelist-workspace-"+QString::number( LSession::handle()->XCB->CurrentWorkspace()), QStringList()).toStringList(); if(bgL.isEmpty()){ bgL = settings->value(DPREFIX+"background/filelist", QStringList()).toStringList(); } - + //qDebug() << " - List:" << bgL << CBG; //Remove any invalid files for(int i=0; i<bgL.length(); i++){ @@ -552,13 +552,32 @@ void LDesktop::UpdateBackground(){ } oldBGL = bgL; //save this for later //Determine which background to use next - int index ( qrand() % bgL.length() ); - if(index== bgL.indexOf(CBG)){ //if the current wallpaper was selected by the randomization again - //Go to the next in the list - if(index < 0 || index >= bgL.length()-1){ index = 0; } //if invalid or last item in the list - go to first - else{ index++; } //go to next + QString bgFile; + while(bgFile.isEmpty() || QFileInfo(bgFile).isDir()){ + QString prefix; + if(!bgFile.isEmpty()){ + //Got a directory - update the list of files and re-randomize the selection + QStringList imgs = LUtils::imageExtensions(); + for(int i=0; i<imgs.length(); i++){ imgs[i].prepend("*."); } + QDir tdir(bgFile); + prefix=bgFile+"/"; + bgL = tdir.entryList(imgs, QDir::Files | QDir::NoDotAndDotDot, QDir::Name); + //If directory no longer has any valid images - remove it from list and try again + if(bgL.isEmpty()){ + oldBGL.removeAll(bgFile); //invalid directory - remove it from the list for the moment + bgL = oldBGL; //reset the list back to the original list (not within a directory) + } + } + //Verify that there are files in the list - otherwise use the default + if(bgL.isEmpty()){ bgFile="default"; break; } + int index = ( qrand() % bgL.length() ); + if(index== bgL.indexOf(CBG)){ //if the current wallpaper was selected by the randomization again + //Go to the next in the list + if(index < 0 || index >= bgL.length()-1){ index = 0; } //if invalid or last item in the list - go to first + else{ index++; } //go to next + } + bgFile = prefix+bgL[index]; } - QString bgFile = bgL[index]; //Save this file as the current background CBG = bgFile; //qDebug() << " - Set Background to:" << CBG << index << bgL; @@ -570,7 +589,7 @@ void LDesktop::UpdateBackground(){ bgDesktop->setBackground(backPix); //Now reset the timer for the next change (if appropriate) if(bgtimer->isActive()){ bgtimer->stop(); } - if(bgL.length() > 1){ + if(bgL.length()>1 || oldBGL.length()>1){ //get the length of the timer (in minutes) int min = settings->value(DPREFIX+"background/minutesToChange",5).toInt(); //restart the internal timer @@ -633,9 +652,9 @@ void LDesktop::NewDesktopFile(QString name){ QDir desktop(QDir::homePath()); if(desktop.exists(tr("Desktop"))){ desktop.cd(tr("Desktop")); } //translated folder else{ desktop.cd("Desktop"); } //default/english folder - if(!desktop.exists(name)){ + if(!desktop.exists(name)){ QFile file(desktop.absoluteFilePath(name)); - if(file.open(QIODevice::WriteOnly) ){ file.close(); } + if(file.open(QIODevice::WriteOnly) ){ file.close(); } } } } diff --git a/src-qt5/core/lumina-desktop/LDesktopPluginSpace.cpp b/src-qt5/core/lumina-desktop/LDesktopPluginSpace.cpp index 025c067a..9e964f5d 100644 --- a/src-qt5/core/lumina-desktop/LDesktopPluginSpace.cpp +++ b/src-qt5/core/lumina-desktop/LDesktopPluginSpace.cpp @@ -222,7 +222,7 @@ QRect LDesktopPluginSpace::findOpenSpot(int gridwidth, int gridheight, int start //else{ row++; } } if(!found){ col++; row=0; } //go to the next column - } + } }else if(reversed && (startRow>0 || startCol>0) ){ //Arrange Left->Right (work backwards) while(row>=0 && !found){ @@ -242,7 +242,7 @@ QRect LDesktopPluginSpace::findOpenSpot(int gridwidth, int gridheight, int start //else{ col++; } } if(!found){ row--; col=colCount-gridwidth;} //go to the previous row - } + } }else{ //Arrange Left->Right while(row<(rowCount-gridheight) && !found){ @@ -296,8 +296,8 @@ void LDesktopPluginSpace::reloadPlugins(bool ForceIconUpdate ){ QStringList plugs = plugins; QStringList items = deskitems; for(int i=0; i<ITEMS.length(); i++){ - - if( ITEMS[i]->whatsThis().startsWith("applauncher") && 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(); //pixel coords if(!geom.isNull()){ @@ -306,14 +306,14 @@ void LDesktopPluginSpace::reloadPlugins(bool ForceIconUpdate ){ 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 - ITEMS.takeAt(i)->deleteLater(); + ITEMS.takeAt(i)->deleteLater(); i--; } 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); ITEMS.takeAt(i)->deleteLater(); i--; } //this is considered a permanent removal (cleans settings) } - + //Now create any new items //First load the plugins (almost always have fixed locations) for(int i=0; i<plugs.length(); i++){ diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp index 533b5997..0bf087c1 100644 --- a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp +++ b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp @@ -44,7 +44,8 @@ void AppLauncherPlugin::loadButton(){ QFileInfo info(path); this->contextMenu()->clear(); //qDebug() << "Default Application Launcher:" << def << path; - bool ok = info.canonicalPath().startsWith("/net/") || QFile::exists(path); + bool ok = info.canonicalPath().startsWith("/net/"); + if(!ok){ ok = QFile::exists(path); } //do it this way to ensure the file existance check never runs for /net/ files if(!ok){ emit RemovePlugin(this->ID()); return;} icosize = this->height()-4 - 2.2*button->fontMetrics().height(); button->setFixedSize( this->width()-4, this->height()-4); |