aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop/panel-plugins
diff options
context:
space:
mode:
authorKen Moore <ken@pcbsd.org>2016-09-22 16:41:42 -0400
committerKen Moore <ken@pcbsd.org>2016-09-22 16:41:42 -0400
commit82ebebfb8a5867b400c1df726a478bdcb9d7c005 (patch)
tree6c799a122fba9dc9068695f95e967e417f6b1636 /src-qt5/core/lumina-desktop/panel-plugins
parentMerge remote-tracking branch 'origin/master' (diff)
downloadlumina-82ebebfb8a5867b400c1df726a478bdcb9d7c005.tar.gz
lumina-82ebebfb8a5867b400c1df726a478bdcb9d7c005.tar.bz2
lumina-82ebebfb8a5867b400c1df726a478bdcb9d7c005.zip
Large update to how XDGDesktop files are created/used.
This impacts almost all tools/utilities within Lumina - please test (passed internal tests so far). This cleans up a lot of the backend XDG compliance class, moving lots of functionality into child functions of the XDGDesktop class and ensuring that they get cleaned up more regularly/properly. This *seems* to make the desktop startup a lot faster, even if the overall memory savings are slight (so far).
Diffstat (limited to 'src-qt5/core/lumina-desktop/panel-plugins')
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/applauncher/AppLaunchButton.cpp12
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp43
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp6
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp41
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.h4
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp55
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h2
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp36
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h4
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp10
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.h2
11 files changed, 105 insertions, 110 deletions
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/applauncher/AppLaunchButton.cpp b/src-qt5/core/lumina-desktop/panel-plugins/applauncher/AppLaunchButton.cpp
index 321970ed..05b7981f 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/applauncher/AppLaunchButton.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/applauncher/AppLaunchButton.cpp
@@ -31,9 +31,8 @@ void AppLaunchButtonPlugin::updateButtonVisuals(){
QIcon icon;
QString tooltip = tr("Click to assign an application");
if(appfile.endsWith(".desktop")){
- bool ok = false;
- XDGDesktop desk = LXDG::loadDesktopFile(appfile,ok);
- if(ok){
+ XDGDesktop desk(appfile);
+ if(desk.isValid()){
icon = LXDG::findIcon(desk.icon, "unknown");
tooltip = QString(tr("Launch %1")).arg(desk.name);
}else{
@@ -56,13 +55,13 @@ void AppLaunchButtonPlugin::updateButtonVisuals(){
void AppLaunchButtonPlugin::AppClicked(){
if(appfile.isEmpty()){
//No App File selected
- QList<XDGDesktop> apps = LSession::handle()->applicationMenu()->currentAppHash()->value("All");
+ QList<XDGDesktop*> apps = LSession::handle()->applicationMenu()->currentAppHash()->value("All");
QStringList names;
- for(int i=0; i<apps.length(); i++){ names << apps[i].name; }
+ for(int i=0; i<apps.length(); i++){ names << apps[i]->name; }
bool ok = false;
QString app = QInputDialog::getItem(this, tr("Select Application"), tr("Name:"), names, 0, false, &ok);
if(!ok || names.indexOf(app)<0){ return; } //cancelled
- appfile = apps[ names.indexOf(app) ].filePath;
+ appfile = apps[ names.indexOf(app) ]->filePath;
//Still need to find a way to set this value persistently
// --- perhaps replace the plugin in the desktop settings file with the new path?
// --- "applauncher::broken---<something>" -> "applauncher::fixed---<something>" ?
@@ -71,4 +70,3 @@ void AppLaunchButtonPlugin::AppClicked(){
LSession::LaunchApplication("lumina-open \""+appfile+"\"");
}
}
-
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp b/src-qt5/core/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp
index 5d20e3ec..e3be55c2 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp
@@ -62,23 +62,22 @@ void LAppMenuPlugin::LaunchItem(QAction* item){
void LAppMenuPlugin::UpdateMenu(){
mainmenu->clear();
- QHash<QString, QList<XDGDesktop> > *HASH = LSession::handle()->applicationMenu()->currentAppHash();
+ QHash<QString, QList<XDGDesktop*> > *HASH = LSession::handle()->applicationMenu()->currentAppHash();
//Now Re-create the menu (orignally copied from the AppMenu class)
- bool ok; //for checking inputs
//Add link to the file manager
QAction *tmpact = mainmenu->addAction( LXDG::findIcon("user-home", ""), tr("Browse Files") );
tmpact->setWhatsThis("\""+QDir::homePath()+"\"");
//--Look for the app store
- XDGDesktop store = LXDG::loadDesktopFile(LOS::AppStoreShortcut(), ok);
- if(ok){
+ XDGDesktop store(LOS::AppStoreShortcut());
+ if(store.isValid()){
tmpact = mainmenu->addAction( LXDG::findIcon(store.icon, ""), tr("Install Applications") );
tmpact->setWhatsThis("\""+store.filePath+"\"");
}
//--Look for the control panel
- store = LXDG::loadDesktopFile(LOS::ControlPanelShortcut(), ok);
- if(ok){
- tmpact = mainmenu->addAction( LXDG::findIcon(store.icon, ""), tr("Control Panel") );
- tmpact->setWhatsThis("\""+store.filePath+"\"");
+ XDGDesktop controlp(LOS::ControlPanelShortcut());
+ if(controlp.isValid()){
+ tmpact = mainmenu->addAction( LXDG::findIcon(controlp.icon, ""), tr("Control Panel") );
+ tmpact->setWhatsThis("\""+controlp.filePath+"\"");
}
mainmenu->addSeparator();
//--Now create the sub-menus
@@ -104,29 +103,29 @@ void LAppMenuPlugin::UpdateMenu(){
QMenu *menu = new QMenu(name, this);
menu->setIcon(LXDG::findIcon(icon,""));
- QList<XDGDesktop> appL = HASH->value(cats[i]);
+ QList<XDGDesktop*> appL = HASH->value(cats[i]);
for( int a=0; a<appL.length(); a++){
- if(appL[a].actions.isEmpty()){
+ if(appL[a]->actions.isEmpty()){
//Just a single entry point - no extra actions
- QAction *act = new QAction(LXDG::findIcon(appL[a].icon, ""), appL[a].name, menu);
- act->setToolTip(appL[a].comment);
- act->setWhatsThis("\""+appL[a].filePath+"\"");
+ QAction *act = new QAction(LXDG::findIcon(appL[a]->icon, ""), appL[a]->name, menu);
+ act->setToolTip(appL[a]->comment);
+ act->setWhatsThis("\""+appL[a]->filePath+"\"");
menu->addAction(act);
}else{
//This app has additional actions - make this a sub menu
// - first the main menu/action
- QMenu *submenu = new QMenu(appL[a].name, menu);
- submenu->setIcon( LXDG::findIcon(appL[a].icon,"") );
+ QMenu *submenu = new QMenu(appL[a]->name, menu);
+ submenu->setIcon( LXDG::findIcon(appL[a]->icon,"") );
//This is the normal behavior - not a special sub-action (although it needs to be at the top of the new menu)
- QAction *act = new QAction(LXDG::findIcon(appL[a].icon, ""), appL[a].name, submenu);
- act->setToolTip(appL[a].comment);
- act->setWhatsThis(appL[a].filePath);
+ QAction *act = new QAction(LXDG::findIcon(appL[a]->icon, ""), appL[a]->name, submenu);
+ act->setToolTip(appL[a]->comment);
+ act->setWhatsThis(appL[a]->filePath);
submenu->addAction(act);
//Now add entries for every sub-action listed
- for(int sa=0; sa<appL[a].actions.length(); sa++){
- QAction *sact = new QAction(LXDG::findIcon(appL[a].actions[sa].icon, appL[a].icon), appL[a].actions[sa].name, this);
- sact->setToolTip(appL[a].comment);
- sact->setWhatsThis("-action \""+appL[a].actions[sa].ID+"\" \""+appL[a].filePath+"\"");
+ for(int sa=0; sa<appL[a]->actions.length(); sa++){
+ QAction *sact = new QAction(LXDG::findIcon(appL[a]->actions[sa].icon, appL[a]->icon), appL[a]->actions[sa].name, this);
+ sact->setToolTip(appL[a]->comment);
+ sact->setWhatsThis("-action \""+appL[a]->actions[sa].ID+"\" \""+appL[a]->filePath+"\"");
submenu->addAction(sact);
}
menu->addMenu(submenu);
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp b/src-qt5/core/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp
index 48bbface..9903d4fd 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp
@@ -130,11 +130,9 @@ void LDeskBarPlugin::updateFiles(){
if(type=="app"){
//Add it to appM
bool ok = false;
- XDGDesktop df = LXDG::loadDesktopFile(path, ok);
- if(ok){
- if( LXDG::checkValidity(df) && !df.isHidden ){
+ XDGDesktop df(path);
+ if(df.isValid() && !df.isHidden){
appM->addAction( newAction(df.filePath, df.name, LXDG::findIcon(df.icon, ":/images/default-application.png")) );
- }
}
}else if(type=="dir"){
//Add it to dirM
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 3a0493a3..48d9623a 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp
@@ -16,8 +16,8 @@ ItemWidget::ItemWidget(QWidget *parent, QString itemPath, QString type, bool gob
bool inHome = type.endsWith("-home"); //internal code
if(inHome){ type = type.remove("-home"); }
if(itemPath.endsWith(".desktop") || type=="app"){
- XDGDesktop item = LXDG::loadDesktopFile(itemPath, gooditem);
- if(gooditem){ gooditem = LXDG::checkValidity(item); }
+ XDGDesktop item(itemPath, this);
+ gooditem = item.isValid();
//qDebug() << "Good Item:" << gooditem << itemPath;
if(gooditem){
icon->setPixmap( LXDG::findIcon(item.icon, "preferences-system-windows-actions").pixmap(32,32) );
@@ -26,7 +26,7 @@ ItemWidget::ItemWidget(QWidget *parent, QString itemPath, QString type, bool gob
if(!item.genericName.isEmpty() && item.name!=item.genericName){ text.append("<br><i> -- "+item.genericName+"</i>"); }
name->setText(text);
name->setToolTip(item.comment);
- setupActions(item);
+ setupActions(&item);
}else{
return;
}
@@ -89,13 +89,14 @@ ItemWidget::ItemWidget(QWidget *parent, QString itemPath, QString type, bool gob
}
// - Application constructor
-ItemWidget::ItemWidget(QWidget *parent, XDGDesktop item) : QFrame(parent){
+ItemWidget::ItemWidget(QWidget *parent, XDGDesktop *item) : QFrame(parent){
+ if(item==0){ return; }
createWidget();
isDirectory = false;
- if(LUtils::isFavorite(item.filePath)){
- linkPath = item.filePath;
+ if(LUtils::isFavorite(item->filePath)){
+ linkPath = item->filePath;
isShortcut=true;
- }else if( item.filePath.section("/",0,-2)==QDir::homePath()+"/Desktop" ){
+ }else if( item->filePath.section("/",0,-2)==QDir::homePath()+"/Desktop" ){
isShortcut = true;
}else{
isShortcut = false;
@@ -104,14 +105,14 @@ ItemWidget::ItemWidget(QWidget *parent, XDGDesktop item) : QFrame(parent){
name->setToolTip(icon->whatsThis()); //also allow the user to see the full shortcut path
}
//Now fill it appropriately
- icon->setPixmap( LXDG::findIcon(item.icon,"preferences-system-windows-actions").pixmap(64,64) );
- text = item.name;
- if(!item.genericName.isEmpty() && item.name!=item.genericName){ text.append("<br><i> -- "+item.genericName+"</i>"); }
+ icon->setPixmap( LXDG::findIcon(item->icon,"preferences-system-windows-actions").pixmap(64,64) );
+ text = item->name;
+ if(!item->genericName.isEmpty() && item->name!=item->genericName){ text.append("<br><i> -- "+item->genericName+"</i>"); }
name->setText(text);
- name->setToolTip(item.comment);
- this->setWhatsThis(item.name);
- icon->setWhatsThis(item.filePath);
- iconPath = item.icon;
+ name->setToolTip(item->comment);
+ this->setWhatsThis(item->name);
+ icon->setWhatsThis(item->filePath);
+ iconPath = item->icon;
//Now setup the buttons appropriately
setupContextMenu();
setupActions(item);
@@ -176,14 +177,14 @@ void ItemWidget::setupContextMenu(){
}
}
-void ItemWidget::setupActions(XDGDesktop app){
- if(app.actions.isEmpty()){ actButton->setVisible(false); return; }
+void ItemWidget::setupActions(XDGDesktop *app){
+ if(app==0 || app->actions.isEmpty()){ actButton->setVisible(false); return; }
//Actions Available - go ahead and list them all
actButton->setMenu( new QMenu(this) );
- for(int i=0; i<app.actions.length(); i++){
- QAction *act = new QAction(LXDG::findIcon(app.actions[i].icon, app.icon), app.actions[i].name, this);
- act->setToolTip(app.actions[i].ID);
- act->setWhatsThis(app.actions[i].ID);
+ for(int i=0; i<app->actions.length(); i++){
+ QAction *act = new QAction(LXDG::findIcon(app->actions[i].icon, app->icon), app->actions[i].name, this);
+ act->setToolTip(app->actions[i].ID);
+ act->setWhatsThis(app->actions[i].ID);
actButton->menu()->addAction(act);
}
connect(actButton->menu(), SIGNAL(triggered(QAction*)), this, SLOT(actionClicked(QAction*)) );
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 8190de43..365b434f 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.h
+++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.h
@@ -32,7 +32,7 @@ public:
// - Favorites (path/type)
ItemWidget(QWidget *parent=0, QString itemPath="", QString type="unknown", bool goback=false);
// - Generic Apps
- ItemWidget(QWidget *parent=0, XDGDesktop item= XDGDesktop());
+ ItemWidget(QWidget *parent=0, XDGDesktop *item= 0);
// - Categories
//ItemWidget(QWidget *parent=0, QString cat="");
@@ -53,7 +53,7 @@ private:
void createWidget();
//void setupButton(bool disable = false);
void setupContextMenu();
- void setupActions(XDGDesktop);
+ void setupActions(XDGDesktop*);
void updateItems(); //update the text/icon to match sizes
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 60a313e8..ae61760b 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp
@@ -23,7 +23,6 @@ StartMenu::StartMenu(QWidget *parent) : QWidget(parent), ui(new Ui::StartMenu){
searchTimer->setInterval(300); //~1/3 second
searchTimer->setSingleShot(true);
connect(searchTimer, SIGNAL(timeout()), this, SLOT(startSearch()) );
- sysapps = LSession::handle()->applicationMenu()->currentAppHash();
connect(LSession::handle()->applicationMenu(), SIGNAL(AppMenuUpdated()), this, SLOT(UpdateApps()) );
//Need to load the last used setting of the application list
QString state = LSession::handle()->DesktopPluginSettings()->value("panelPlugs/systemstart/showcategories", "partial").toString();
@@ -72,9 +71,8 @@ void StartMenu::UpdateAll(){
if(QFile::exists(tmp)){
ui->tool_launch_controlpanel->setWhatsThis(tmp);
//Now read the file to see which icon to use
- bool ok = false;
- XDGDesktop desk = LXDG::loadDesktopFile(tmp, ok);
- if(ok && LXDG::checkValidity(desk)){
+ XDGDesktop desk(tmp);
+ if(desk.isValid()){
ui->tool_launch_controlpanel->setIcon(LXDG::findIcon(desk.icon,"preferences-other"));
}else{ ui->tool_launch_controlpanel->setVisible(false); }
}else{ ui->tool_launch_controlpanel->setVisible(false); }
@@ -83,9 +81,8 @@ void StartMenu::UpdateAll(){
if(QFile::exists(tmp)){
ui->tool_launch_store->setWhatsThis(tmp);
//Now read the file to see which icon to use
- bool ok = false;
- XDGDesktop desk = LXDG::loadDesktopFile(tmp, ok);
- if(ok && LXDG::checkValidity(desk)){
+ XDGDesktop desk(tmp);
+ if(desk.isValid()){
ui->tool_launch_store->setIcon(LXDG::findIcon(desk.icon,"utilities-file-archiver"));
}else{ ui->tool_launch_store->setVisible(false); }
}else{ ui->tool_launch_store->setVisible(false); }
@@ -158,8 +155,14 @@ 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::ClearScrollArea(QScrollArea *area){
- area->takeWidget()->deleteLater();
+ 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;
@@ -216,18 +219,18 @@ void StartMenu::do_search(QString search, bool force){
QStringList found; //syntax: [<sorter>::::<mimetype>::::<filepath>]
QString tmp = search;
if(LUtils::isValidBinary(tmp)){ found << "0::::application/x-executable::::"+tmp; }
- QList<XDGDesktop> apps = sysapps->value("All");
+ QList<XDGDesktop*> apps = LSession::handle()->applicationMenu()->currentAppHash()->value("All");
for(int i=0; i<apps.length(); i++){
int priority = -1;
- if(apps[i].name.toLower()==search.toLower()){ priority = 10; }
- else if(apps[i].name.startsWith(search, Qt::CaseInsensitive)){ priority = 15; }
- else if(apps[i].name.contains(search, Qt::CaseInsensitive)){ priority = 19; }
- else if(apps[i].genericName.contains(search, Qt::CaseInsensitive)){ priority = 20; }
- else if(apps[i].comment.contains(search, Qt::CaseInsensitive)){ priority = 30; }
+ if(apps[i]->name.toLower()==search.toLower()){ priority = 10; }
+ else if(apps[i]->name.startsWith(search, Qt::CaseInsensitive)){ priority = 15; }
+ else if(apps[i]->name.contains(search, Qt::CaseInsensitive)){ priority = 19; }
+ else if(apps[i]->genericName.contains(search, Qt::CaseInsensitive)){ priority = 20; }
+ else if(apps[i]->comment.contains(search, Qt::CaseInsensitive)){ priority = 30; }
//Can add other filters here later
if(priority>0){
- found << QString::number(priority)+"::::app::::"+apps[i].filePath;
+ found << QString::number(priority)+"::::app::::"+apps[i]->filePath;
}
}
found.sort(Qt::CaseInsensitive); //sort by priority/type (lower numbers are higher on list)
@@ -238,10 +241,8 @@ void StartMenu::do_search(QString search, bool force){
if(topsearch.isEmpty()){ topsearch = found[i].section("::::",2,-1); }
ItemWidget *it = 0;
if( found[i].section("::::",2,-1).endsWith(".desktop")){
- bool ok = false;
- XDGDesktop item = LXDG::loadDesktopFile(found[i].section("::::",2,-1), ok);
- if(ok){ ok = LXDG::checkValidity(item); }
- if(ok){ it = new ItemWidget(ui->scroll_favs->widget(), item); }
+ XDGDesktop item(found[i].section("::::",2,-1));
+ if(item.isValid()){ it = new ItemWidget(ui->scroll_favs->widget(), &item); }
}else{
it = new ItemWidget(ui->scroll_favs->widget(), found[i].section("::::",2,-1), found[i].section("::::",1,1) );
}
@@ -308,11 +309,11 @@ void StartMenu::UpdateApps(){
//qDebug() << " - Partially Checked";
//Show a single page of apps, but still divided up by categories
CCat.clear();
- QStringList cats = sysapps->keys();
+ QStringList cats = LSession::handle()->applicationMenu()->currentAppHash()->keys();
cats.sort();
cats.removeAll("All");
for(int c=0; c<cats.length(); c++){
- QList<XDGDesktop> apps = sysapps->value(cats[c]);
+ QList<XDGDesktop*> apps = LSession::handle()->applicationMenu()->currentAppHash()->value(cats[c]);
if(apps.isEmpty()){ continue; }
//Add the category label to the scroll
QLabel *catlabel = new QLabel("<b>"+cats[c]+"</b>",ui->scroll_apps->widget());
@@ -335,7 +336,7 @@ void StartMenu::UpdateApps(){
//Only show categories to start with - and have the user click-into a cat to see apps
if(CCat.isEmpty()){
//No cat selected yet - show cats only
- QStringList cats = sysapps->keys();
+ QStringList cats = LSession::handle()->applicationMenu()->currentAppHash()->keys();
cats.sort();
cats.removeAll("All"); //This is not a "real" category
for(int c=0; c<cats.length(); c++){
@@ -352,7 +353,7 @@ void StartMenu::UpdateApps(){
ui->scroll_apps->widget()->layout()->addWidget(it);
connect(it, SIGNAL(RunItem(QString)), this, SLOT(LaunchItem(QString)) );
//Show apps for this cat
- QList<XDGDesktop> apps = sysapps->value(CCat);
+ QList<XDGDesktop*> apps = LSession::handle()->applicationMenu()->currentAppHash()->value(CCat);
for(int i=0; i<apps.length(); i++){
//qDebug() << " - App:" << apps[i].name;
ItemWidget *it = new ItemWidget(ui->scroll_apps->widget(), apps[i] );
@@ -368,7 +369,7 @@ void StartMenu::UpdateApps(){
}else{
//qDebug() << " - Not Checked";
//No categories at all - just alphabetize all the apps
- QList<XDGDesktop> apps = sysapps->value("All");
+ 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++){
@@ -431,10 +432,8 @@ void StartMenu::UpdateFavs(){
if( !QFile::exists(tmp[i].section("::::",2,-1)) ){ continue; } //invalid favorite - skip it
ItemWidget *it = 0;
if( tmp[i].section("::::",2,-1).endsWith(".desktop")){
- bool ok = false;
- XDGDesktop item = LXDG::loadDesktopFile(tmp[i].section("::::",2,-1), ok);
- if(ok){ ok = LXDG::checkValidity(item); }
- if(ok){ it = new ItemWidget(ui->scroll_favs->widget(), item); }
+ XDGDesktop item(tmp[i].section("::::",2,-1));
+ if(item.isValid()){ it = new ItemWidget(ui->scroll_favs->widget(), &item); }
}else{
it = new ItemWidget(ui->scroll_favs->widget(), tmp[i].section("::::",2,-1), tmp[i].section("::::",1,1) );
}
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 9a629cc2..af7bd136 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h
+++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h
@@ -32,12 +32,12 @@ public slots:
private:
Ui::StartMenu *ui;
- QHash<QString, QList<XDGDesktop> > *sysapps;
QStringList favs;
QString CCat, CSearch, topsearch; //current category/search
QTimer *searchTimer;
//Simple utility functions
+ void deleteChildren(QObject *obj); //recursive function
void ClearScrollArea(QScrollArea *area);
void SortScrollArea(QScrollArea *area);
void do_search(QString search, bool force);
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp b/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp
index 1d32440a..a1dfe956 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp
@@ -15,12 +15,11 @@ UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, QString type,
bool inHome = type.endsWith("-home"); //internal code
if(inHome){ type = type.remove("-home"); }
if(itemPath.endsWith(".desktop") || type=="app"){
- bool ok = false;
- XDGDesktop item = LXDG::loadDesktopFile(itemPath, ok);
- if(ok && LXDG::checkValidity(item) ){
+ XDGDesktop item(itemPath);
+ if( item.isValid() ){
icon->setPixmap( LXDG::findIcon(item.icon, "preferences-system-windows-actions").pixmap(32,32) );
name->setText( this->fontMetrics().elidedText(item.name, Qt::ElideRight, TEXTCUTOFF) );
- setupActions(item);
+ setupActions(&item);
}else{
gooditem = false;
return;
@@ -63,22 +62,23 @@ UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, QString type,
setupButton(goback);
}
-UserItemWidget::UserItemWidget(QWidget *parent, XDGDesktop item) : QFrame(parent){
+UserItemWidget::UserItemWidget(QWidget *parent, XDGDesktop *item) : QFrame(parent){
+ if(item==0){ return; }
createWidget();
isDirectory = false;
- if(LUtils::isFavorite(item.filePath)){
- linkPath = item.filePath;
+ if(LUtils::isFavorite(item->filePath)){
+ linkPath = item->filePath;
isShortcut=true;
- }else if( item.filePath.section("/",0,-2)==QDir::homePath()+"/Desktop" ){
+ }else if( item->filePath.section("/",0,-2)==QDir::homePath()+"/Desktop" ){
isShortcut = true;
}else{
isShortcut = false;
}
//Now fill it appropriately
- icon->setPixmap( LXDG::findIcon(item.icon,"preferences-system-windows-actions").pixmap(32,32) );
- name->setText( this->fontMetrics().elidedText(item.name, Qt::ElideRight, TEXTCUTOFF) );
+ icon->setPixmap( LXDG::findIcon(item->icon,"preferences-system-windows-actions").pixmap(32,32) );
+ name->setText( this->fontMetrics().elidedText(item->name, Qt::ElideRight, TEXTCUTOFF) );
this->setWhatsThis(name->text());
- icon->setWhatsThis(item.filePath);
+ icon->setWhatsThis(item->filePath);
//Now setup the buttons appropriately
setupButton();
setupActions(item);
@@ -152,14 +152,14 @@ void UserItemWidget::setupButton(bool disable){
}
}
-void UserItemWidget::setupActions(XDGDesktop app){
- if(app.actions.isEmpty()){ actButton->setVisible(false); return; }
+void UserItemWidget::setupActions(XDGDesktop *app){
+ if(app==0 || app->actions.isEmpty()){ actButton->setVisible(false); return; }
//Actions Available - go ahead and list them all
actButton->setMenu( new QMenu(this) );
- for(int i=0; i<app.actions.length(); i++){
- QAction *act = new QAction(LXDG::findIcon(app.actions[i].icon, app.icon), app.actions[i].name, this);
- act->setToolTip(app.actions[i].ID);
- act->setWhatsThis(app.actions[i].ID);
+ for(int i=0; i<app->actions.length(); i++){
+ QAction *act = new QAction(LXDG::findIcon(app->actions[i].icon, app->icon), app->actions[i].name, this);
+ act->setToolTip(app->actions[i].ID);
+ act->setWhatsThis(app->actions[i].ID);
actButton->menu()->addAction(act);
}
connect(actButton->menu(), SIGNAL(triggered(QAction*)), this, SLOT(actionClicked(QAction*)) );
@@ -201,4 +201,4 @@ void UserItemWidget::actionClicked(QAction *act){
if(!linkPath.isEmpty()){ cmd = cmd.arg(linkPath); }
else{ cmd = cmd.arg(icon->whatsThis()); }
emit RunItem(cmd);
-} \ No newline at end of file
+}
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h b/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h
index 2251344c..0b212f10 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h
+++ b/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h
@@ -28,7 +28,7 @@ class UserItemWidget : public QFrame{
Q_OBJECT
public:
UserItemWidget(QWidget *parent=0, QString itemPath="", QString type="unknown", bool goback=false);
- UserItemWidget(QWidget *parent=0, XDGDesktop item= XDGDesktop());
+ UserItemWidget(QWidget *parent=0, XDGDesktop *item= 0);
~UserItemWidget();
bool gooditem;
@@ -41,7 +41,7 @@ private:
void createWidget();
void setupButton(bool disable = false);
- void setupActions(XDGDesktop);
+ void setupActions(XDGDesktop*);
private slots:
void buttonClicked();
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp b/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp
index c7d8109c..fb58c7f6 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp
@@ -130,8 +130,8 @@ void UserWidget::UpdateAll(){
QString APPSTORE = LOS::AppStoreShortcut();
if(QFile::exists(APPSTORE) && !APPSTORE.isEmpty()){
//Now load the info
- bool ok = false;
- XDGDesktop store = LXDG::loadDesktopFile(APPSTORE, ok);
+ XDGDesktop store(APPSTORE);
+ bool ok = store.isValid();
if(ok){
ui->tool_app_store->setIcon( LXDG::findIcon(store.icon, "") );
ui->tool_app_store->setText( store.name );
@@ -143,8 +143,8 @@ void UserWidget::UpdateAll(){
QString CONTROLPANEL = LOS::ControlPanelShortcut();
if(QFile::exists(CONTROLPANEL) && !CONTROLPANEL.isEmpty()){
//Now load the info
- bool ok = false;
- XDGDesktop cpan = LXDG::loadDesktopFile(CONTROLPANEL, ok);
+ XDGDesktop cpan(CONTROLPANEL);
+ bool ok = cpan.isValid();
if(ok){
ui->tool_controlpanel->setIcon( LXDG::findIcon(cpan.icon, "") );
}
@@ -307,7 +307,7 @@ void UserWidget::updateAppCategories(){
void UserWidget::updateApps(){
if(ui->combo_app_cats->currentIndex() < 0){ return; } //no cat
QString cat = ui->combo_app_cats->itemData( ui->combo_app_cats->currentIndex() ).toString();
- QList<XDGDesktop> items = sysapps->value(cat);
+ QList<XDGDesktop*> items = sysapps->value(cat);
ClearScrollArea(ui->scroll_apps);
for(int i=0; i<items.length(); i++){
UserItemWidget *it = new UserItemWidget(ui->scroll_apps->widget(), items[i]);
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.h b/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.h
index af9408dd..8b03c489 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.h
+++ b/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.h
@@ -42,7 +42,7 @@ public slots:
private:
Ui::UserWidget *ui;
- QHash<QString, QList<XDGDesktop> > *sysapps;
+ QHash<QString, QList<XDGDesktop*> > *sysapps;
QDateTime lastUpdate, lastHomeUpdate;
QStringList favs;
QFileInfoList homefiles;
bgstack15