aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-open
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-open
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-open')
-rw-r--r--src-qt5/core/lumina-open/LFileDialog.cpp35
-rw-r--r--src-qt5/core/lumina-open/main.cpp22
2 files changed, 30 insertions, 27 deletions
diff --git a/src-qt5/core/lumina-open/LFileDialog.cpp b/src-qt5/core/lumina-open/LFileDialog.cpp
index fbcf007f..a0fef17c 100644
--- a/src-qt5/core/lumina-open/LFileDialog.cpp
+++ b/src-qt5/core/lumina-open/LFileDialog.cpp
@@ -158,17 +158,21 @@ void LFileDialog::updateUI(){
void LFileDialog::generateAppList(bool shownetwork){
//Now load the preferred applications
+ XDGDesktopList applist;
+ applist.updateList();
PREFAPPS = getPreferredApplications();
+ //qDebug() << "Preferred Apps:" << PREFAPPS;
ui->combo_rec->clear();
//Now get the application mimetype for the file extension (if available)
QStringList mimetypes = LXDG::findAppMimeForFile(filePath, true).split("::::"); //use all mimetypes
+ mimetypes.removeDuplicates();
//Now add all the detected applications
- QHash< QString, QList<XDGDesktop> > hash = LXDG::sortDesktopCats( LXDG::systemDesktopFiles(false,true) );
+ QHash< QString, QList<XDGDesktop*> > hash = LXDG::sortDesktopCats( applist.apps(false,true) );
QStringList cat = hash.keys();
cat.sort(); //sort alphabetically
ui->combo_apps->clear();
for(int c=0; c<cat.length(); c++){
- QList<XDGDesktop> app = hash[cat[c]];
+ QList<XDGDesktop*> app = hash[cat[c]];
if(app.length()<1){ continue; }
if(ui->combo_apps->count() >1){ ui->combo_apps->insertSeparator(ui->combo_apps->count()); }
ui->combo_apps->addItem(translateCat(cat[c]));
@@ -176,17 +180,19 @@ void LFileDialog::generateAppList(bool shownetwork){
for(int a=0; a<app.length(); a++){
if(shownetwork && (cat[c].toLower()=="network" || cat[c].toLower()=="utility") ){
//Need to show preferred internet applications - look for ones that handle URL's
- if(app[a].exec.contains("%u") || app[a].exec.contains("%U")){
- PREFAPPS << app[a].filePath;
+ if(app[a]->exec.contains("%u") || app[a]->exec.contains("%U")){
+ //qDebug() << "Add to Preferred Apps:" << app[a]->filePath;
+ PREFAPPS << app[a]->filePath;
}
}
- ui->combo_apps->addItem(LXDG::findIcon(app[a].icon, "application-x-desktop"), app[a].name, app[a].filePath);
+ ui->combo_apps->addItem(LXDG::findIcon(app[a]->icon, "application-x-desktop"), app[a]->name, app[a]->filePath);
//Check to see if this app matches the mime type
if(!mimetypes.isEmpty()){
- QStringList tmp = mimetypes; tmp << app[a].mimeList;
+ QStringList tmp = mimetypes; tmp << app[a]->mimeList;
if(tmp.removeDuplicates() > 0 ){
// also put this app in the preferred list
- PREFAPPS.append(app[a].filePath);
+ //qDebug() << "Mimetype match:" << mimetypes << app[a]->mimeList;
+ PREFAPPS.append(app[a]->filePath);
//If this is the first preferred app found - select this app initially
if(ui->combo_apps->currentIndex()<=0){ ui->combo_apps->setCurrentIndex(ui->combo_apps->count()-1); }
}
@@ -197,9 +203,8 @@ void LFileDialog::generateAppList(bool shownetwork){
//Now add all the preferred applications
PREFAPPS.removeDuplicates();
for(int i=0; i<PREFAPPS.length(); i++){
- bool ok = false;
- XDGDesktop dFile = LXDG::loadDesktopFile(PREFAPPS[i], ok);
- if( LXDG::checkValidity(dFile) && ok ){
+ XDGDesktop dFile(PREFAPPS[i]);
+ if( dFile.isValid() ){
ui->combo_rec->addItem( LXDG::findIcon(dFile.icon, "application-x-desktop"), dFile.name);
if(i==0){ ui->combo_rec->setCurrentIndex(0); } //make sure the first item is selected
}else{
@@ -242,19 +247,17 @@ void LFileDialog::on_tool_ok_clicked(){
appExec = ui->line_bin->text();
}else if(ui->radio_rec->isChecked()){
//application selected
- bool ok = false;
- XDGDesktop app = LXDG::loadDesktopFile(PREFAPPS[ui->combo_rec->currentIndex()], ok);
+ XDGDesktop app(PREFAPPS[ui->combo_rec->currentIndex()]);
//Set the output variables
- appExec = LXDG::getDesktopExec(app);
+ appExec = app.getDesktopExec();
appPath = app.path;
appFile = app.filePath;
setPreferredApplication(app.filePath); //bump this to the top of the preferred list for next time
}else{
//application selected
- bool ok = false;
- XDGDesktop app = LXDG::loadDesktopFile(ui->combo_apps->currentData().toString(), ok);
+ XDGDesktop app(ui->combo_apps->currentData().toString());
//Set the output variables
- appExec = LXDG::getDesktopExec(app);
+ appExec = app.getDesktopExec();
appPath = app.path;
appFile = app.filePath;
setPreferredApplication(app.filePath); //save this app to this extension as a recommendation
diff --git a/src-qt5/core/lumina-open/main.cpp b/src-qt5/core/lumina-open/main.cpp
index 756bef25..68d2575b 100644
--- a/src-qt5/core/lumina-open/main.cpp
+++ b/src-qt5/core/lumina-open/main.cpp
@@ -80,17 +80,19 @@ void showOSD(int argc, char **argv, QString message){
}
void LaunchAutoStart(){
- QList<XDGDesktop> xdgapps = LXDG::findAutoStartFiles();
+ QList<XDGDesktop*> xdgapps = LXDG::findAutoStartFiles();
for(int i=0; i<xdgapps.length(); i++){
//Generate command and clean up any stray "Exec" field codes (should not be any here)
- QString cmd = LXDG::getDesktopExec(xdgapps[i]);
+ QString cmd = xdgapps[i]->getDesktopExec();
if(cmd.contains("%")){cmd = cmd.remove("%U").remove("%u").remove("%F").remove("%f").remove("%i").remove("%c").remove("%k").simplified(); }
//Now run the command
if(!cmd.isEmpty()){
- qDebug() << " - Auto-Starting File:" << xdgapps[i].filePath;
+ qDebug() << " - Auto-Starting File:" << xdgapps[i]->filePath;
QProcess::startDetached(cmd);
}
}
+ //make sure we clean up all the xdgapps structures
+ for(int i=0; i<xdgapps.length(); i++){ xdgapps[i]->deleteLater(); }
}
QString cmdFromUser(int argc, char **argv, QString inFile, QString extension, QString& path, bool showDLG=false){
@@ -109,11 +111,10 @@ QString cmdFromUser(int argc, char **argv, QString inFile, QString extension, QS
}else{ defApp = LFileDialog::getDefaultApp(extension); }
//qDebug() << "extension:" << extension << "defApp:" << defApp;
if( !defApp.isEmpty() && !showDLG ){
- bool ok = false;
if(defApp.endsWith(".desktop")){
- XDGDesktop DF = LXDG::loadDesktopFile(defApp, ok);
- if(ok){
- QString exec = LXDG::getDesktopExec(DF);
+ XDGDesktop DF(defApp);
+ if(DF.isValid()){
+ QString exec = DF.getDesktopExec();
if(!exec.isEmpty()){
qDebug() << "[lumina-open] Using default application:" << DF.name << "File:" << inFile;
if(!DF.path.isEmpty()){ path = DF.path; }
@@ -258,15 +259,14 @@ void getCMD(int argc, char ** argv, QString& binary, QString& args, QString& pat
QString cmd;
bool useInputFile = false;
if(extension=="desktop" && !showDLG){
- bool ok = false;
- XDGDesktop DF = LXDG::loadDesktopFile(inFile, ok);
- if(!ok){
+ XDGDesktop DF(inFile);
+ if(!DF.isValid()){
ShowErrorDialog( argc, argv, QString(QObject::tr("File could not be opened: %1")).arg(inFile) );
}
switch(DF.type){
case XDGDesktop::APP:
if(!DF.exec.isEmpty()){
- cmd = LXDG::getDesktopExec(DF,ActionID);
+ cmd = DF.getDesktopExec(ActionID);
if(!DF.path.isEmpty()){ path = DF.path; }
watch = DF.startupNotify || !DF.filePath.contains("/xdg/autostart/");
}else{
bgstack15