<commit_before>//===========================================
//  Lumina-DE source code
//  Copyright (c) 2013, <NAME>
//  Available under the 3-clause BSD license
//  See the LICENSE file for full details
//===========================================
#include "LuminaXDG.h"
#include "LuminaOS.h"
#include <QObject>
#include <QMediaPlayer>

static QStringList mimeglobs;
static qint64 mimechecktime;

//==== LXDG Functions ====
XDGDesktop LXDG::loadDesktopFile(QString filePath, bool& ok){
  //Create the outputs
  ok=false;
  XDGDesktop DF;
    DF.isHidden=false;
    DF.useTerminal=false;
    DF.startupNotify=false;
    DF.type = XDGDesktop::BAD;
    DF.filePath = filePath;
    DF.exec = DF.tryexec = "";   // just to make sure this is initialized
  //Check input file path validity
  QFile file(filePath);
  if(!file.exists()){ return DF; } //invalid file
  //Get the current localization code
  QString lang = QLocale::system().name(); //lang code
  //Open the file
  if(!file.open(QIODevice::Text | QIODevice::ReadOnly)){
    return DF;  
  }
  QTextStream os(&file);
  //Read in the File
  bool insection=false;
  while(!os.atEnd()){
    QString line = os.readLine();
    //Check that this is the entry portion of the file (not the action/other sections)
    if(line=="[Desktop Entry]"){ insection=true; continue; }
    else if(line.startsWith("[")){ insection=false; }
    if(!insection || line.startsWith("#")){ continue; }
    //Now parse out the file
    line = line.simplified();
    QString var = line.section("=",0,0).simplified();
    QString loc = var.section("[",1,1).section("]",0,0).simplified(); // localization
    var = var.section("[",0,0).simplified(); //remove the localization
    QString val = line.section("=",1,50).simplified();
    //-------------------
    if(var=="Name"){ 
      if(DF.name.isEmpty() && loc.isEmpty()){ DF.name = val; }
      else if(loc == lang){ DF.name = val; }
    }else if(var=="GenericName"){ 
      if(DF.genericName.isEmpty() && loc.isEmpty()){ DF.genericName = val; }
      else if(loc == lang){ DF.genericName = val; }
    }else if(var=="Comment"){ 
      if(DF.comment.isEmpty() && loc.isEmpty()){ DF.comment = val; }
      else if(loc == lang){ DF.comment = val; }
    }else if(var=="Icon"){ 
      if(DF.icon.isEmpty() && loc.isEmpty()){ DF.icon = val; }
      else if(loc == lang){ DF.icon = val; }
    }
    else if( (var=="TryExec") && (DF.tryexec.isEmpty()) ) { DF.tryexec = val; }
    else if( (var=="Exec") && (DF.exec.isEmpty() ) ) { DF.exec = val; }   // only take the first Exec command in the file
    else if(var=="NoDisplay" && !DF.isHidden){ DF.isHidden = (val.toLower()=="true"); }
    else if(var=="Hidden" && !DF.isHidden){ DF.isHidden = (val.toLower()=="true"); }
    else if(var=="Categories"){ DF.catList = val.split(";",QString::SkipEmptyParts); }
    else if(var=="OnlyShowIn"){ DF.showInList = val.split(";",QString::SkipEmptyParts); }
    else if(var=="NotShowIn"){ DF.notShowInList = val.split(";",QString::SkipEmptyParts); }
    else if(var=="Terminal"){ DF.useTerminal= (val.toLower()=="true"); }
    else if(var=="Actions"){ DF.actionList = val.split(";",QString::SkipEmptyParts); }
    else if(var=="MimeType"){ DF.mimeList = val.split(";",QString::SkipEmptyParts); }
    else if(var=="Keywords"){ 
      if(DF.keyList.isEmpty() && loc.isEmpty()){ DF.keyList = val.split(";",QString::SkipEmptyParts); }
      else if(loc == lang){ DF.keyList = val.split(";",QString::SkipEmptyParts); }<commit_msg>Oops, apparently I forgot the line which copies a *.desktop "Path=" value into the data structure. lumina-open was already set to use the path properly if it exists, so no other changes to use this value necessary.<commit_after>//===========================================
//  Lumina-DE source code
//  Copyright (c) 2013, <NAME>
//  Available under the 3-clause BSD license
//  See the LICENSE file for full details
//===========================================
#include "LuminaXDG.h"
#include "LuminaOS.h"
#include <QObject>
#include <QMediaPlayer>

static QStringList mimeglobs;
static qint64 mimechecktime;

//==== LXDG Functions ====
XDGDesktop LXDG::loadDesktopFile(QString filePath, bool& ok){
  //Create the outputs
  ok=false;
  XDGDesktop DF;
    DF.isHidden=false;
    DF.useTerminal=false;
    DF.startupNotify=false;
    DF.type = XDGDesktop::BAD;
    DF.filePath = filePath;
    DF.exec = DF.tryexec = "";   // just to make sure this is initialized
  //Check input file path validity
  QFile file(filePath);
  if(!file.exists()){ return DF; } //invalid file
  //Get the current localization code
  QString lang = QLocale::system().name(); //lang code
  //Open the file
  if(!file.open(QIODevice::Text | QIODevice::ReadOnly)){
    return DF;  
  }
  QTextStream os(&file);
  //Read in the File
  bool insection=false;
  while(!os.atEnd()){
    QString line = os.readLine();
    //Check that this is the entry portion of the file (not the action/other sections)
    if(line=="[Desktop Entry]"){ insection=true; continue; }
    else if(line.startsWith("[")){ insection=false; }
    if(!insection || line.startsWith("#")){ continue; }
    //Now parse out the file
    line = line.simplified();
    QString var = line.section("=",0,0).simplified();
    QString loc = var.section("[",1,1).section("]",0,0).simplified(); // localization
    var = var.section("[",0,0).simplified(); //remove the localization
    QString val = line.section("=",1,50).simplified();
    //-------------------
    if(var=="Name"){ 
      if(DF.name.isEmpty() && loc.isEmpty()){ DF.name = val; }
      else if(loc == lang){ DF.name = val; }
    }else if(var=="GenericName"){ 
      if(DF.genericName.isEmpty() && loc.isEmpty()){ DF.genericName = val; }
      else if(loc == lang){ DF.genericName = val; }
    }else if(var=="Comment"){ 
      if(DF.comment.isEmpty() && loc.isEmpty()){ DF.comment = val; }
      else if(loc == lang){ DF.comment = val; }
    }else if(var=="Icon"){ 
      if(DF.icon.isEmpty() && loc.isEmpty()){ DF.icon = val; }
      else if(loc == lang){ DF.icon = val; }
    }
    else if( (var=="TryExec") && (DF.tryexec.isEmpty()) ) { DF.tryexec = val; }
    else if( (var=="Exec") && (DF.exec.isEmpty() ) ) { DF.exec = val; }   // only take the first Exec command in the file
    else if( (var=="Path") && (DF.path.isEmpty() ) ){ DF.path = val; }
    else if(var=="NoDisplay" && !DF.isHidden){ DF.isHidden = (val.toLower()=="true"); }
    else if(var=="Hidden" && !DF.isHidden){ DF.isHidden = (val.toLower()=="true"); }
    else if(var=="Categories"){ DF.catList = val.split(";",QString::SkipEmptyParts); }
    else if(var=="OnlyShowIn"){ DF.showInList = val.split(";",QString::SkipEmptyParts); }
    else if(var=="NotShowIn"){ DF.notShowInList = val.split(";",QString::SkipEmptyParts); }
    else if(var=="Terminal"){ DF.useTerminal= (val.toLower()=="true"); }
    else if(var=="Actions"){ DF.actionList = val.split(";",QString::SkipEmptyParts); }
    else if(var=="MimeType"){ DF.mimeList = val.split(";",QString::SkipEmptyParts); }
    else if(var=="Keywords"){ 
      if(DF.keyList.isEmpty() && loc.isEmpty()){ DF.keyList = val.split(";",QString::SkipEmptyParts); }
      else if(loc == lang){ DF.keyList = val.split(";",QString::SkipEmptyParts); }
{'fraction_non_alphanumeric': 0.21598123102401326, 'fraction_numerical': 0.0049682583494341705, 'mean_word_length': 3.7335075114304375, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5735757', 'n_tokens_mistral': 2556, 'n_tokens_neox': 2400, 'n_words': 562}