aboutsummaryrefslogtreecommitdiff
path: root/libLumina
diff options
context:
space:
mode:
Diffstat (limited to 'libLumina')
-rw-r--r--libLumina/LuminaOS-OpenBSD.cpp15
-rw-r--r--libLumina/LuminaUtils.cpp44
-rw-r--r--libLumina/LuminaUtils.h10
3 files changed, 68 insertions, 1 deletions
diff --git a/libLumina/LuminaOS-OpenBSD.cpp b/libLumina/LuminaOS-OpenBSD.cpp
index 7cf6c571..b6996795 100644
--- a/libLumina/LuminaOS-OpenBSD.cpp
+++ b/libLumina/LuminaOS-OpenBSD.cpp
@@ -192,6 +192,19 @@ int LOS::batterySecondsLeft(){ //Returns: estimated number of seconds remaining
//File Checksums
QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the input file
- return QStringList();
+ //on OpenBSD md5 has the following layout
+ //>md5 LuminaThemes.o LuminaUtils.o
+ //MD5 (LuminaThemes.o) = 50006505d9d7e54e5154eeb095555055
+ //MD5 (LuminaUtils.o) = d490878ee8866e55e5af571b98b4d448
+
+ QStringList info = LUtils::getCmdOutput("md5 \""+filepaths.join("\" \"")+"\"");
+ for(int i=0; i<info.length(); i++){
+ if( !info[i].contains(" = ") ){ info.removeAt(i); i--; }
+ else{
+ //Strip out the extra information
+ info[i] = info[i].section(" = ",1,1);
+ }
+ }
+ return info;
}
#endif
diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp
index 9b8a1860..f7f5db74 100644
--- a/libLumina/LuminaUtils.cpp
+++ b/libLumina/LuminaUtils.cpp
@@ -144,6 +144,50 @@ void LUtils::LoadTranslation(QApplication *app, QString appname){
QTextCodec::setCodecForLocale( QTextCodec::codecForName(langEnc.toUtf8()) );
}
+QStringList LUtils::listFavorites(){
+ QStringList fav = LUtils::readFile(QDir::homePath()+"/.lumina/favorites/fav.list");
+ return fav;
+}
+
+bool LUtils::saveFavorites(QStringList list){
+ return LUtils::writeFile(QDir::homePath()+"/.lumina/favorites/fav.list", list, true);
+}
+
+bool LUtils::isFavorite(QString path){
+ QStringList fav = LUtils::listFavorites();
+ for(int i=0; i<fav.length(); i++){
+ if(fav[i].endsWith("::::"+path)){ return true; }
+ }
+ return false;
+}
+
+bool LUtils::addFavorite(QString path, QString name){
+ //Generate the type of favorite this is
+ QFileInfo info(path);
+ QString type = "file";
+ if(info.isDir()){ type="dir"; }
+ else if(info.suffix()=="desktop"){ type="app"; }
+ //Assign a name if none given
+ if(name.isEmpty()){ name = info.fileName(); }
+ //Now add it to the list
+ QStringList fav = LUtils::listFavorites();
+ bool found = false;
+ for(int i=0; i<fav.length(); i++){
+ if(fav[i].endsWith("::::"+path)){ fav[i] = name+"::::"+type+"::::"+path; }
+ }
+ if(!found){ fav << name+"::::"+type+"::::"+path; }
+ return LUtils::saveFavorites(fav);
+}
+
+void LUtils::removeFavorite(QString path){
+ QStringList fav = LUtils::listFavorites();
+ bool changed = false;
+ for(int i=0; i<fav.length(); i++){
+ if(fav[i].endsWith("::::"+path)){ fav.removeAt(i); i--; changed=true;}
+ }
+ if(changed){ LUtils::saveFavorites(fav); }
+}
+
void LUtils::LoadSystemDefaults(bool skipOS){
//Will create the Lumina configuration files based on the current system template (if any)
QStringList sysDefaults;
diff --git a/libLumina/LuminaUtils.h b/libLumina/LuminaUtils.h
index ee716167..d0c8b3ad 100644
--- a/libLumina/LuminaUtils.h
+++ b/libLumina/LuminaUtils.h
@@ -44,6 +44,16 @@ public:
//Load a translation file for a Lumina Project
static void LoadTranslation(QApplication *app, QString appname);
+
+ //Various functions for the favorites sub-system
+ // Formatting Note: "<name>::::[dir/file/app]::::<path>"
+ // the <name> field might not be used for "app" flagged entries
+ static QStringList listFavorites();
+ static bool saveFavorites(QStringList);
+ static bool isFavorite(QString path);
+ static bool addFavorite(QString path, QString name = "");
+ static void removeFavorite(QString path);
+
//Load the default setup for the system
static void LoadSystemDefaults(bool skipOS = false);
bgstack15