aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp45
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.h4
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp16
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.h4
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp52
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h2
6 files changed, 83 insertions, 40 deletions
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..a0624d6b 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,42 @@ 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->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 +323,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 +342,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 +361,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 +377,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 +392,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()) );
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);
bgstack15