diff options
author | Ken Moore <moorekou@gmail.com> | 2015-10-21 16:20:30 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2015-10-21 16:20:30 -0400 |
commit | ee81bb74542b8198b35034208dca8c5ae2465528 (patch) | |
tree | 5c49f79099727fb4a4ca8f548be86e3fce6e7fc8 | |
parent | Tag version 0.8.7-Release in sources (diff) | |
download | lumina-ee81bb74542b8198b35034208dca8c5ae2465528.tar.gz lumina-ee81bb74542b8198b35034208dca8c5ae2465528.tar.bz2 lumina-ee81bb74542b8198b35034208dca8c5ae2465528.zip |
A couple quick fixes for desktop icons:
1) In the Applauncher plugin, have it send the removal signal if the file it is supposed to load does not exist.
2) Fix the loading of plugins - always go forwards when searching for a new spot - not backwards (will switch to backwards automatically as necessary).
-rw-r--r-- | lumina-desktop/LDesktopPluginSpace.cpp | 2 | ||||
-rw-r--r-- | lumina-desktop/LDesktopPluginSpace.h | 2 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp | 81 |
3 files changed, 22 insertions, 63 deletions
diff --git a/lumina-desktop/LDesktopPluginSpace.cpp b/lumina-desktop/LDesktopPluginSpace.cpp index abb16fc0..cb0cc75f 100644 --- a/lumina-desktop/LDesktopPluginSpace.cpp +++ b/lumina-desktop/LDesktopPluginSpace.cpp @@ -113,7 +113,7 @@ void LDesktopPluginSpace::addDesktopPlugin(QString plugID){ geom = findOpenSpot(geom.width(), geom.height() ); }else if(!ValidGeometry(plugID, gridToGeom(geom)) ){ //Find a new location for the plugin (saved location is invalid) - geom = findOpenSpot(geom.width(), geom.height(), geom.y(), geom.x(), true); //try to get it within the same general area (go backwards) + geom = findOpenSpot(geom.width(), geom.height(), geom.y(), geom.x(), false); //try to get it within the same general area first } if(geom.x() < 0 || geom.y() < 0){ qDebug() << "No available space for desktop plugin:" << plugID << " - IGNORING"; diff --git a/lumina-desktop/LDesktopPluginSpace.h b/lumina-desktop/LDesktopPluginSpace.h index 33c9468e..6328b4de 100644 --- a/lumina-desktop/LDesktopPluginSpace.h +++ b/lumina-desktop/LDesktopPluginSpace.h @@ -114,7 +114,7 @@ private: } bool ValidGrid(QRect grid){ - qDebug() << "Check Valid Grid:" << grid << RoundUp(this->width()/GRIDSIZE) << RoundUp(this->height()/GRIDSIZE); + //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; } else if( (grid.x()+grid.width()) > RoundUp(this->width()/GRIDSIZE) ){ return false; } diff --git a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp index 4b3210a5..40eca47e 100644 --- a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp +++ b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp @@ -2,7 +2,7 @@ #include "../../LSession.h" #include "OutlineToolButton.h" -#define OUTMARGIN 8 //special margin for fonts due to the outlining effect from the OutlineToolbutton +#define OUTMARGIN 10 //special margin for fonts due to the outlining effect from the OutlineToolbutton AppLauncherPlugin::AppLauncherPlugin(QWidget* parent, QString ID) : LDPlugin(parent, ID){ QVBoxLayout *lay = new QVBoxLayout(); @@ -24,9 +24,7 @@ AppLauncherPlugin::AppLauncherPlugin(QWidget* parent, QString ID) : LDPlugin(par void AppLauncherPlugin::Cleanup(){ //This is run only when the plugin was forcibly closed/removed - /*if(QFile::exists(button->whatsThis()) && button->whatsThis().startsWith(QDir::homePath()+"/Desktop") ){ - deleteFile(); - }*/ + } void AppLauncherPlugin::loadButton(){ @@ -34,6 +32,7 @@ void AppLauncherPlugin::loadButton(){ QString path = this->readSetting("applicationpath",def).toString(); //use the default if necessary //qDebug() << "Default Application Launcher:" << def << path; bool ok = QFile::exists(path); + if(!ok){ emit RemovePlugin(this->ID()); return;} int icosize = this->height()-4 - 2.2*button->fontMetrics().height(); button->setFixedSize( this->width()-4, this->height()-4); button->setIconSize( QSize(icosize,icosize) ); @@ -75,22 +74,23 @@ void AppLauncherPlugin::loadButton(){ //Now adjust the visible text as necessary based on font/grid sizing button->setToolTip(txt); //Double check that the visual icon size matches the requested size - otherwise upscale the icon - /*if(button->icon().actualSize(QSize(icosize,icosize)).height() < icosize){ - qDebug() << "Scale Up Icon:" << button->iconSize() << icosize << button->icon().actualSize(QSize(icosize,icosize)); - QIcon ico = button->icon(); - ico.addPixmap( ico.pixmap(QSize(icosize,icosize)).scaledToHeight(icosize, Qt::SmoothTransformation) ); - qDebug() << " - New Icon Size:" << ico.actualSize(QSize(icosize,icosize)); - button->setIcon(ico); - }*/ - //int icosize = this->readSetting("iconsize",64).toInt(); - //int bwid = qRound(1.1*icosize); - //this->setFixedSize(bwid, icosize+qRound(2.5*button->fontMetrics().height()) ); //make sure to adjust the button on first show. - //if(onchange){ this->adjustSize( bwid+4, icosize+8+qRound(2.5*button->fontMetrics().height())); } - //qDebug() << "Initial Button Text:" << txt << icosize; if(button->fontMetrics().width(txt) > (button->width()-OUTMARGIN) ){ - //int dash = this->fontMetrics().width("-"); //Text too long, try to show it on two lines - txt = txt.section(" ",0,2).replace(" ","\n"); //First take care of any natural breaks + //txt = button->fontMetrics().elidedText(txt, Qt::ElideRight, 2*(button->width()-OUTMARGIN), Qt::TextWordWrap); + txt =txt.section(" ",0,2).replace(" ","\n"); //First take care of any natural breaks + //Go through and combine any lines + if(txt.contains("\n")){ + //need to check each line + QStringList txtL = txt.split("\n"); + for(int i=0; i<txtL.length(); i++){ + if(( i+1<txtL.length()) && (button->fontMetrics().width(txtL[i]) < button->width()/2) ){ + txtL[i] = txtL[i]+" "+txtL[i+1]; + txtL.removeAt(i+1); + } + } + txt = txtL.join("\n").section("\n",0,2); + } + if(txt.contains("\n")){ //need to check each line QStringList txtL = txt.split("\n"); @@ -108,14 +108,7 @@ void AppLauncherPlugin::loadButton(){ if(!txt.contains("\n")){ txt.append("\n "); } //always use two lines //qDebug() << " - Setting Button Text:" << txt; button->setText(txt); - //Now setup the menu again - //menu->clear(); - /*menu->addAction(LXDG::findIcon("zoom-in",""), tr("Increase Size"), this, SLOT(increaseIconSize())); - menu->addAction(LXDG::findIcon("zoom-out",""), tr("Decrease Size"), this, SLOT(decreaseIconSize())); - if( !button->whatsThis().isEmpty() && button->whatsThis().startsWith(QDir::homePath()+"/Desktop") ){ - menu->addAction(LXDG::findIcon("list-remove",""), tr("Delete File"), this, SLOT(deleteFile()) ); - }*/ - + QTimer::singleShot(100, this, SLOT(update()) ); //Make sure to re-draw the image in a moment } @@ -135,38 +128,4 @@ void AppLauncherPlugin::buttonClicked(){ LSession::LaunchApplication("lumina-open \""+path+"\""); } -} - -/*void AppLauncherPlugin::openContextMenu(){ - if(button->underMouse()){ - menu->popup(QCursor::pos()); - }else{ - emit OpenDesktopMenu(); - } -}*/ - -/*void AppLauncherPlugin::increaseIconSize(){ - int icosize = this->readSetting("iconsize",64).toInt(); - icosize += 16; - button->setIconSize(QSize(icosize,icosize)); - this->saveSetting("iconsize",icosize); - this->loadButton(true); //redo size calculations - -} - -void AppLauncherPlugin::decreaseIconSize(){ - int icosize = this->readSetting("iconsize",64).toInt(); - if(icosize < 20){ return; } //cannot get smaller - icosize -= 16; - button->setIconSize(QSize(icosize,icosize)); - this->saveSetting("iconsize",icosize); - this->loadButton(true); //redo size calculations -} - -void AppLauncherPlugin::deleteFile(){ - if(QFileInfo(button->whatsThis()).isDir()){ - QProcess::startDetached("rm -r \""+button->whatsThis()+"\""); - }else{ - QFile::remove(button->whatsThis()); - } -}*/
\ No newline at end of file +}
\ No newline at end of file |