aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-open
diff options
context:
space:
mode:
authorWeblate <noreply@weblate.org>2016-09-23 07:34:07 +0000
committerWeblate <noreply@weblate.org>2016-09-23 07:34:07 +0000
commitc0d2b4d8d7c7c498ecd8b01fb3da0f93b53b3e60 (patch)
tree2c8d0d6eab74377d1d6645b90db9f430472212c6 /src-qt5/core/lumina-open
parentTranslated using Weblate (lumina_DESKTOP@sv (generated)) (diff)
parentLarge update to how XDGDesktop files are created/used. (diff)
downloadlumina-c0d2b4d8d7c7c498ecd8b01fb3da0f93b53b3e60.tar.gz
lumina-c0d2b4d8d7c7c498ecd8b01fb3da0f93b53b3e60.tar.bz2
lumina-c0d2b4d8d7c7c498ecd8b01fb3da0f93b53b3e60.zip
Merge remote-tracking branch 'origin/master'
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