diff options
Diffstat (limited to 'src-qt5/core/lumina-desktop')
7 files changed, 96 insertions, 45 deletions
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 bd8e79db..b74bbcb3 100644 --- a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp +++ b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp @@ -58,7 +58,9 @@ void AppLauncherPlugin::loadButton(){ if(info.isDir()){ button->setIcon( LXDG::findIcon("folder","") ); }else if(LUtils::imageExtensions().contains(info.suffix().toLower()) ){ - button->setIcon( QIcon(QPixmap(path).scaled(256,256)) ); //max size for thumbnails in memory + QPixmap pix; + if(pix.load(path)){ button->setIcon( QIcon(pix.scaled(256,256)) ); } //max size for thumbnails in memory + else{ button->setIcon( LXDG::findIcon("dialog-cancel","") ); } }else{ button->setIcon( QIcon(LXDG::findMimeIcon(path).pixmap(QSize(icosize,icosize)).scaledToHeight(icosize, Qt::SmoothTransformation) ) ); } @@ -68,7 +70,7 @@ void AppLauncherPlugin::loadButton(){ }else{ //InValid File button->setWhatsThis(""); - button->setIcon( QIcon(LXDG::findIcon("quickopen","").pixmap(QSize(icosize,icosize)).scaledToHeight(icosize, Qt::SmoothTransformation) ) ); + button->setIcon( QIcon(LXDG::findIcon("quickopen","dialog-cancel").pixmap(QSize(icosize,icosize)).scaledToHeight(icosize, Qt::SmoothTransformation) ) ); button->setText( tr("Click to Set") ); if(!watcher->files().isEmpty()){ watcher->removePaths(watcher->files()); } } @@ -126,7 +128,7 @@ void AppLauncherPlugin::buttonClicked(){ QString path = button->whatsThis(); if(path.isEmpty() || !QFile::exists(path) ){ //prompt for the user to select an application - QList<XDGDesktop*> apps = LXDG::sortDesktopNames( LXDG::systemDesktopFiles() ); + QList<XDGDesktop*> apps = LSession::handle()->applicationMenu()->currentAppHash()->value("All"); //LXDG::sortDesktopNames( LXDG::systemDesktopFiles() ); QStringList names; for(int i=0; i<apps.length(); i++){ names << apps[i]->name; } bool ok = false; diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp index 48d9623a..15b9c72c 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp @@ -90,8 +90,8 @@ ItemWidget::ItemWidget(QWidget *parent, QString itemPath, QString type, bool gob // - Application constructor ItemWidget::ItemWidget(QWidget *parent, XDGDesktop *item) : QFrame(parent){ - if(item==0){ return; } createWidget(); + if(item==0){ gooditem = false; return; } isDirectory = false; if(LUtils::isFavorite(item->filePath)){ linkPath = item->filePath; @@ -118,7 +118,22 @@ ItemWidget::ItemWidget(QWidget *parent, XDGDesktop *item) : QFrame(parent){ setupActions(item); } -ItemWidget::~ItemWidget(){ +ItemWidget::~ItemWidget(){ + icon->setPixmap(QPixmap()); //make sure the pixmap is cleared from memory too + actButton->deleteLater(); + contextMenu->clear(); + contextMenu->deleteLater(); + if(actButton->menu()!=0){ + for(int i=0; i<actButton->menu()->actions().length(); i++){ + actButton->menu()->actions().at(i)->deleteLater(); + } + actButton->menu()->deleteLater(); + } + actButton->deleteLater(); + icon->deleteLater(); + name->deleteLater(); + menureset->deleteLater(); + linkPath.clear(); iconPath.clear(); text.clear(); } void ItemWidget::triggerItem(){ @@ -133,7 +148,7 @@ void ItemWidget::createWidget(){ menureset->setSingleShot(true); menureset->setInterval(1000); //1 second this->setContentsMargins(0,0,0,0); - contextMenu = new QMenu(); + contextMenu = new QMenu(this); connect(contextMenu, SIGNAL(aboutToShow()), this, SLOT(actionMenuOpen()) ); connect(contextMenu, SIGNAL(aboutToHide()), this, SLOT(actionMenuClosed()) ); actButton = new QToolButton(this); @@ -145,7 +160,7 @@ void ItemWidget::createWidget(){ name->setTextFormat(Qt::RichText); name->setTextInteractionFlags(Qt::NoTextInteraction); //Add them to the layout - this->setLayout(new QHBoxLayout()); + this->setLayout(new QHBoxLayout(this)); this->layout()->setContentsMargins(1,1,1,1); this->layout()->addWidget(icon); this->layout()->addWidget(actButton); @@ -202,19 +217,21 @@ void ItemWidget::updateItems(){ for(int i=0; i<newname.length(); i++){ newname[i] = name->fontMetrics().elidedText(newname[i], Qt::ElideRight, name->width()); } name->setText( newname.join("<br>") ); //Now reload the icon if necessary - if(icon->pixmap()->size().height() < (H-4) ){ - if(iconPath.isEmpty()){ - //Use item path (thumbnail or mimetype) - if(LUtils::imageExtensions().contains(icon->whatsThis().section("/",-1).section(".",-1).toLower()) ){ - icon->setPixmap( QIcon(icon->whatsThis()).pixmap(H-4,H-4).scaledToHeight(H-4,Qt::SmoothTransformation) ); + if(icon->pixmap()!=0){ + if(icon->pixmap()->size().height() < (H-4) ){ + if(iconPath.isEmpty()){ + //Use item path (thumbnail or mimetype) + if(LUtils::imageExtensions().contains(icon->whatsThis().section("/",-1).section(".",-1).toLower()) ){ + icon->setPixmap( QIcon(icon->whatsThis()).pixmap(H-4,H-4).scaledToHeight(H-4,Qt::SmoothTransformation) ); + }else{ + icon->setPixmap( LXDG::findMimeIcon(icon->whatsThis().section("/",-1)).pixmap(H-4,H-4).scaledToHeight(H-4,Qt::SmoothTransformation) ); + } }else{ - icon->setPixmap( LXDG::findMimeIcon(icon->whatsThis().section("/",-1)).pixmap(H-4,H-4).scaledToHeight(H-4,Qt::SmoothTransformation) ); + icon->setPixmap( LXDG::findIcon(iconPath,"preferences-system-windows-actions").pixmap(H-4,H-4).scaledToHeight(H-4,Qt::SmoothTransformation) ); } - }else{ - icon->setPixmap( LXDG::findIcon(iconPath,"preferences-system-windows-actions").pixmap(H-4,H-4).scaledToHeight(H-4,Qt::SmoothTransformation) ); + }else if(icon->pixmap()->size().height() > (H-4) ){ + icon->setPixmap( icon->pixmap()->scaled(H-4, H-4, Qt::IgnoreAspectRatio, Qt::SmoothTransformation) ); } - }else if(icon->pixmap()->size().height() > (H-4) ){ - icon->setPixmap( icon->pixmap()->scaled(H-4, H-4, Qt::IgnoreAspectRatio, Qt::SmoothTransformation) ); } } diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.h b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.h index 365b434f..11394dd6 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.h +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.h @@ -33,8 +33,6 @@ public: ItemWidget(QWidget *parent=0, QString itemPath="", QString type="unknown", bool goback=false); // - Generic Apps ItemWidget(QWidget *parent=0, XDGDesktop *item= 0); - // - Categories - //ItemWidget(QWidget *parent=0, QString cat=""); ~ItemWidget(); @@ -51,7 +49,7 @@ private: QTimer *menureset; void createWidget(); - //void setupButton(bool disable = false); + void setupContextMenu(); void setupActions(XDGDesktop*); diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp index f817e0c0..92b3c6ea 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp @@ -51,7 +51,7 @@ void LStartButtonPlugin::updateButtonVisuals(){ void LStartButtonPlugin::updateQuickLaunch(QStringList apps){ //First clear any obsolete apps QStringList old; - qDebug() << "Update QuickLaunch Buttons"; + //qDebug() << "Update QuickLaunch Buttons"; for(int i=0; i<QUICKL.length(); i++){ if( !apps.contains(QUICKL[i]->whatsThis()) ){ //App was removed @@ -82,13 +82,13 @@ void LStartButtonPlugin::updateQuickLaunch(QStringList apps){ connect(tmp, SIGNAL(Remove(QString)), this, SLOT(RemoveQuick(QString)) ); } } - qDebug() << " - Done updateing QuickLaunch Buttons"; + //qDebug() << " - Done updateing QuickLaunch Buttons"; QTimer::singleShot(0,this, SLOT(OrientationChange())); //Update icons/sizes } void LStartButtonPlugin::LaunchQuick(QString file){ //Need to get which button was clicked - qDebug() << "Quick Launch triggered:" << file; + //qDebug() << "Quick Launch triggered:" << file; if(!file.isEmpty()){ LSession::LaunchApplication("lumina-open \""+file+"\""); emit MenuClosed(); @@ -96,7 +96,7 @@ void LStartButtonPlugin::LaunchQuick(QString file){ } void LStartButtonPlugin::RemoveQuick(QString file){ - qDebug() << "Remove Quicklaunch Button:" << file; + //qDebug() << "Remove Quicklaunch Button:" << file; if(!file.isEmpty()){ startmenu->UpdateQuickLaunch(file, false); //always a removal emit MenuClosed(); @@ -113,6 +113,14 @@ void LStartButtonPlugin::SaveMenuSize(QSize sz){ // ======================== void LStartButtonPlugin::openMenu(){ if(menu->isVisible()){ return; } //don't re-show it - already open + //TESTING CODE TO SEE IF THIS MAKES IT RECOVER MEMORY + /*StartMenu *old = startmenu; + startmenu = new StartMenu(this); + connect(startmenu, SIGNAL(CloseMenu()), this, SLOT(closeMenu()) ); + connect(startmenu, SIGNAL(UpdateQuickLaunch(QStringList)), this, SLOT(updateQuickLaunch(QStringList))); + menu->setContents(startmenu); + if(old!=0){ old->deleteLater(); }*/ +//-------- startmenu->UpdateMenu(); button->showMenu(); } diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.h b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.h index a7d98353..1a17b75b 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.h +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.h @@ -100,12 +100,12 @@ public slots: void LocaleChange(){ updateButtonVisuals(); - startmenu->UpdateAll(); + if(startmenu!=0){ startmenu->UpdateAll(); } } void ThemeChange(){ updateButtonVisuals(); - startmenu->UpdateAll(); + if(startmenu!=0){ startmenu->UpdateAll(); } } }; diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp index ae61760b..bfac46c0 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp @@ -155,22 +155,45 @@ void StartMenu::UpdateQuickLaunch(QString path, bool keep){ // ========================== // PRIVATE FUNCTIONS // ========================== -void StartMenu::deleteChildren(QObject *obj){ -for(int i=0; i<obj->children().count(); i++){ obj->children().at(i)->deleteLater(); } -} +/*void StartMenu::deleteChildren(QWidget *obj){ + if(obj->layout()==0){ + for(int i=0; i<obj->children().count(); i++){ + obj->children().at(i)->deleteLater(); + } + }else{ + + } +}*/ void StartMenu::ClearScrollArea(QScrollArea *area){ - QWidget *old = area->takeWidget(); - deleteChildren(old); //make sure we *fully* delete these items to save memory - old->deleteLater(); - area->setWidget( new QWidget() ); //create a new widget in the scroll area - area->widget()->setContentsMargins(0,0,0,0); - QVBoxLayout *layout = new QVBoxLayout; + //QWidget *old = area->takeWidget(); + //qDebug() << "Clear Scroll Area:"; + //if(old->layout()!=0){ qDebug() << " - Number of items in layout:" << old->layout()->count(); } + //qDebug() << " - Number of Children:" << old->children().count(); + //deleteChildren(old); //make sure we *fully* delete these items to save memory + //old->deleteLater(); + if(area == ui->scroll_favs){ + area->takeWidget()->deleteLater(); + } + if(area->widget()==0){ + area->setWidget( new QWidget(area) ); //create a new widget in the scroll area + } + if(area->widget()->layout()==0){ + QVBoxLayout *layout = new QVBoxLayout(area->widget()); layout->setSpacing(2); layout->setContentsMargins(3,1,3,1); layout->setDirection(QBoxLayout::TopToBottom); layout->setAlignment(Qt::AlignTop); + area->widget()->setContentsMargins(0,0,0,0); area->widget()->setLayout(layout); + } + //Now clear the items in the layout + while( area->widget()->layout()->count() >0 ){ + QLayoutItem *it = area->widget()->layout()->takeAt(0); + //Need to delete both the widget and the layout item + if(it->widget()!=0){ it->widget()->deleteLater(); } + delete it; + } } void StartMenu::SortScrollArea(QScrollArea *area){ @@ -303,8 +326,8 @@ void StartMenu::ChangeCategory(QString cat){ //Listing Update routines void StartMenu::UpdateApps(){ ClearScrollArea(ui->scroll_apps); - //Now assemble the apps list (note: this normally happens in the background - not when it is visible/open) - //qDebug() << "Update Apps:" << CCat << ui->check_apps_showcats->checkState(); + //Now assemble the apps list + //qDebug() << "Update Apps:";// << CCat << ui->check_apps_showcats->checkState(); if(ui->check_apps_showcats->checkState() == Qt::PartiallyChecked){ //qDebug() << " - Partially Checked"; //Show a single page of apps, but still divided up by categories @@ -322,7 +345,7 @@ void StartMenu::UpdateApps(){ //Now add all the apps for this category for(int i=0; i<apps.length(); i++){ ItemWidget *it = new ItemWidget(ui->scroll_apps->widget(), apps[i] ); - if(!it->gooditem){ continue; } //invalid for some reason + if(!it->gooditem){ qDebug() << "Invalid Item:"; it->deleteLater(); continue; } //invalid for some reason ui->scroll_apps->widget()->layout()->addWidget(it); connect(it, SIGNAL(NewShortcut()), this, SLOT(UpdateFavs()) ); connect(it, SIGNAL(RemovedShortcut()), this, SLOT(UpdateFavs()) ); @@ -341,7 +364,7 @@ void StartMenu::UpdateApps(){ cats.removeAll("All"); //This is not a "real" category for(int c=0; c<cats.length(); c++){ ItemWidget *it = new ItemWidget(ui->scroll_apps->widget(), cats[c], "chcat::::"+cats[c] ); - if(!it->gooditem){ continue; } //invalid for some reason + if(!it->gooditem){ qDebug() << "Invalid Item:";it->deleteLater(); continue; } //invalid for some reason ui->scroll_apps->widget()->layout()->addWidget(it); connect(it, SIGNAL(RunItem(QString)), this, SLOT(LaunchItem(QString)) ); } @@ -357,7 +380,7 @@ void StartMenu::UpdateApps(){ for(int i=0; i<apps.length(); i++){ //qDebug() << " - App:" << apps[i].name; ItemWidget *it = new ItemWidget(ui->scroll_apps->widget(), apps[i] ); - if(!it->gooditem){ continue; } //invalid for some reason + if(!it->gooditem){ qDebug() << "Invalid Item:"; it->deleteLater(); continue; } //invalid for some reason ui->scroll_apps->widget()->layout()->addWidget(it); connect(it, SIGNAL(NewShortcut()), this, SLOT(UpdateFavs()) ); connect(it, SIGNAL(RemovedShortcut()), this, SLOT(UpdateFavs()) ); @@ -372,9 +395,9 @@ void StartMenu::UpdateApps(){ QList<XDGDesktop*> apps = LSession::handle()->applicationMenu()->currentAppHash()->value("All"); CCat.clear(); //Now add all the apps for this category - for(int i=0; i<apps.length(); i++){ + for(int i=0; i<apps.length(); i++){ ItemWidget *it = new ItemWidget(ui->scroll_apps->widget(), apps[i] ); - if(!it->gooditem){ continue; } //invalid for some reason + if(!it->gooditem){ it->deleteLater(); continue; } //invalid for some reason ui->scroll_apps->widget()->layout()->addWidget(it); connect(it, SIGNAL(NewShortcut()), this, SLOT(UpdateFavs()) ); connect(it, SIGNAL(RemovedShortcut()), this, SLOT(UpdateFavs()) ); @@ -401,10 +424,11 @@ void StartMenu::UpdateFavs(){ else if(type==1){ tmp = favs.filter("::::dir::::"); } //dirs next else{ tmp = rest; } //everything left over if(type==1){ + SortScrollArea(ui->scroll_favs); //Need to run a special routine for sorting the apps (already in the widget) //qDebug() << "Sort App Widgets..."; // Since each app actually might have a different name listed within the file - QLayout *lay = ui->scroll_favs->widget()->layout(); + /*QLayout *lay = ui->scroll_favs->widget()->layout(); QStringList items; for(int i=0; i<lay->count(); i++){ items << lay->itemAt(i)->widget()->whatsThis().toLower(); @@ -424,7 +448,8 @@ void StartMenu::UpdateFavs(){ break; } } - } + }*/ + }//end of special app sorting routine tmp.sort(); //Sort alphabetically by name (dirs/files) for(int i=0; i<tmp.length(); i++){ @@ -447,6 +472,7 @@ void StartMenu::UpdateFavs(){ } //QApplication::processEvents(); } //end loop over types + ui->scroll_favs->update(); //qDebug() << "End updateFavs"; } diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h index af7bd136..8ab04d94 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h @@ -37,7 +37,7 @@ private: QTimer *searchTimer; //Simple utility functions - void deleteChildren(QObject *obj); //recursive function + //void deleteChildren(QWidget *obj); //recursive function void ClearScrollArea(QScrollArea *area); void SortScrollArea(QScrollArea *area); void do_search(QString search, bool force); |