aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwilliam <william.os4y@gmail.com>2015-03-14 21:34:39 +0100
committerwilliam <william.os4y@gmail.com>2015-03-14 21:34:39 +0100
commit59bd42ae3da3da0181f6bbe53580fd741d17fae9 (patch)
tree258b5ac0db26d5553e1ed438cd993e0cab5ab38b
parentspelling error (diff)
parentAdd a new favoriting system to the Lumina Utils library. This should make thi... (diff)
downloadlumina-59bd42ae3da3da0181f6bbe53580fd741d17fae9.tar.gz
lumina-59bd42ae3da3da0181f6bbe53580fd741d17fae9.tar.bz2
lumina-59bd42ae3da3da0181f6bbe53580fd741d17fae9.zip
Merge remote-tracking branch 'upstream/master' into deskEditor
-rw-r--r--libLumina/LuminaOS-OpenBSD.cpp15
-rw-r--r--libLumina/LuminaUtils.cpp44
-rw-r--r--libLumina/LuminaUtils.h10
-rw-r--r--lumina-config/mainUI.cpp41
-rw-r--r--lumina-config/mainUI.ui30
-rw-r--r--lumina-desktop/panel-plugins/clock/LClock.cpp4
-rw-r--r--lumina-desktop/panel-plugins/clock/LClock.h4
-rw-r--r--lumina-desktop/panel-plugins/userbutton/UserWidget.cpp10
-rw-r--r--lumina-fm/MainUI.cpp26
9 files changed, 171 insertions, 13 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);
diff --git a/lumina-config/mainUI.cpp b/lumina-config/mainUI.cpp
index 99576376..ba254d9f 100644
--- a/lumina-config/mainUI.cpp
+++ b/lumina-config/mainUI.cpp
@@ -11,6 +11,7 @@
#include <QImageReader>
#include <QTime>
#include <QDate>
+#include <QTimeZone>
MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){
ui->setupUi(this); //load the designer file
@@ -235,6 +236,7 @@ void MainUI::setupConnections(){
connect(ui->tool_help_date, SIGNAL(clicked()), this, SLOT(sessionShowDateCodes()) );
connect(ui->line_session_time, SIGNAL(textChanged(QString)), this, SLOT(sessionLoadTimeSample()) );
connect(ui->line_session_date, SIGNAL(textChanged(QString)), this, SLOT(sessionLoadDateSample()) );
+ connect(ui->combo_session_timezone, SIGNAL(currentIndexChanged(int)), this, SLOT(sessionoptchanged()) );
}
void MainUI::setupMenus(){
@@ -273,7 +275,28 @@ void MainUI::setupMenus(){
ui->combo_session_wtheme->addItem(fbstyles[i], fbdir.absoluteFilePath(fbstyles[i]));
}
-
+ //Available Time zones
+ ui->combo_session_timezone->clear();
+ QList<QByteArray> TZList = QTimeZone::availableTimeZoneIds();
+ QDateTime DT = QDateTime::currentDateTime();
+ QStringList tzlist; //Need to create a list which can be sorted appropriately
+ for(int i=0; i<TZList.length(); i++){
+ QTimeZone TZ(TZList[i]);
+ if(TZ.country()<=0){ continue; } //skip this one
+ QString name = QLocale::countryToString(TZ.country());
+ if(name.count() > 20){ name = name.left(20)+"..."; }
+ name = QString(tr("%1 (%2)")).arg(name, TZ.abbreviation(DT));
+ if(tzlist.filter(name).isEmpty()){
+ tzlist << name+"::::"+QString::number(i);
+ }
+ }
+ tzlist.sort();
+ for(int i=0; i<tzlist.length(); i++){
+ ui->combo_session_timezone->addItem( tzlist[i].section("::::",0,0), TZList[tzlist[i].section("::::",1,1).toInt()]);
+ }
+ //ui->combo_session_timezone->sort();
+ //Now set the default/system value
+ ui->combo_session_timezone->insertItem(0,tr("System Time"));
}
int MainUI::currentDesktop(){
@@ -1734,6 +1757,14 @@ void MainUI::loadSessionSettings(){
ui->push_session_setUserIcon->setIcon( LXDG::findIcon(QDir::homePath()+"/.loginIcon.png", "user-identity") );
ui->line_session_time->setText( sessionsettings->value("TimeFormat","").toString() );
ui->line_session_date->setText( sessionsettings->value("DateFormat","").toString() );
+ if( !sessionsettings->value("CustomTimeZone", false).toBool() ){
+ //System Time selected
+ ui->combo_session_timezone->setCurrentIndex(0);
+ }else{
+ int index = ui->combo_session_timezone->findData( sessionsettings->value("TimeZoneByteCode",QByteArray()).toByteArray() );
+ if(index>0){ ui->combo_session_timezone->setCurrentIndex(index); }
+ else{ ui->combo_session_timezone->setCurrentIndex(0); }
+ }
//Now do the session theme options
ui->combo_session_themefile->clear();
@@ -1826,6 +1857,14 @@ void MainUI::saveSessionSettings(){
sessionsettings->setValue("PlayLogoutAudio", ui->check_session_playlogoutaudio->isChecked());
sessionsettings->setValue("TimeFormat", ui->line_session_time->text());
sessionsettings->setValue("DateFormat", ui->line_session_date->text());
+ if( ui->combo_session_timezone->currentIndex()==0){
+ //System Time selected
+ sessionsettings->setValue("CustomTimeZone", false);
+ sessionsettings->setValue("TimeZoneByteCode", QByteArray()); //clear the value
+ }else{
+ sessionsettings->setValue("CustomTimeZone", true);
+ sessionsettings->setValue("TimeZoneByteCode", ui->combo_session_timezone->currentData().toByteArray()); //clear the value
+ }
//Now do the theme options
QString themefile = ui->combo_session_themefile->itemData( ui->combo_session_themefile->currentIndex() ).toString();
diff --git a/lumina-config/mainUI.ui b/lumina-config/mainUI.ui
index fcebaff7..07abacab 100644
--- a/lumina-config/mainUI.ui
+++ b/lumina-config/mainUI.ui
@@ -109,7 +109,7 @@
<enum>QFrame::StyledPanel</enum>
</property>
<property name="currentIndex">
- <number>1</number>
+ <number>4</number>
</property>
<widget class="QWidget" name="page_desktop">
<layout class="QVBoxLayout" name="verticalLayout_3">
@@ -602,8 +602,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>263</width>
- <height>178</height>
+ <width>233</width>
+ <height>150</height>
</rect>
</property>
<attribute name="label">
@@ -799,8 +799,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>263</width>
- <height>178</height>
+ <width>233</width>
+ <height>150</height>
</rect>
</property>
<attribute name="label">
@@ -1634,6 +1634,26 @@
</property>
</widget>
</item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_26">
+ <property name="text">
+ <string>Time Zone:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QComboBox" name="combo_session_timezone">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="sizeAdjustPolicy">
+ <enum>QComboBox::AdjustToMinimumContentsLength</enum>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
<item row="6" column="0" colspan="2">
diff --git a/lumina-desktop/panel-plugins/clock/LClock.cpp b/lumina-desktop/panel-plugins/clock/LClock.cpp
index e91a3a71..79cae84b 100644
--- a/lumina-desktop/panel-plugins/clock/LClock.cpp
+++ b/lumina-desktop/panel-plugins/clock/LClock.cpp
@@ -35,6 +35,7 @@ LClock::~LClock(){
void LClock::updateTime(){
QDateTime CT = QDateTime::currentDateTime();
+ if(useTZ){ CT = CT.toTimeZone(TZ); }
//Now update the display
QString label;
if(deftime){ label = CT.time().toString(Qt::SystemLocaleShortDate) ; }
@@ -53,5 +54,8 @@ void LClock::updateFormats(){
datefmt = LSession::handle()->sessionSettings()->value("DateFormat","").toString();
deftime = timefmt.simplified().isEmpty();
defdate = datefmt.simplified().isEmpty();
+ useTZ = LSession::handle()->sessionSettings()->value("CustomTimeZone",false).toBool();
+ if(useTZ){ TZ = QTimeZone( LSession::handle()->sessionSettings()->value("TimeZoneByteCode", QByteArray()).toByteArray() ); }
+
}
diff --git a/lumina-desktop/panel-plugins/clock/LClock.h b/lumina-desktop/panel-plugins/clock/LClock.h
index 1e4c8294..8156e7d8 100644
--- a/lumina-desktop/panel-plugins/clock/LClock.h
+++ b/lumina-desktop/panel-plugins/clock/LClock.h
@@ -13,6 +13,7 @@
#include <QWidget>
#include <QString>
#include <QLocale>
+#include <QTimeZone>
#include "../LPPlugin.h"
@@ -26,7 +27,8 @@ private:
QTimer *timer;
QLabel *labelWidget;
QString timefmt, datefmt;
- bool deftime, defdate;
+ bool deftime, defdate, useTZ;
+ QTimeZone TZ;
private slots:
void updateTime();
diff --git a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp
index 82a06012..52d60714 100644
--- a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp
+++ b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp
@@ -194,6 +194,16 @@ void UserWidget::updateFavItems(){
connect(it, SIGNAL(RemovedShortcut()), this, SLOT(updateFavItems()) );
}
static_cast<QBoxLayout*>(ui->scroll_fav->widget()->layout())->addStretch();
+
+ //Clean up any broken sym-links in the favorites directory
+ /*items = favdir.entryInfoList(QDir::System | QDir::NoDotAndDotDot, QDir::Name);
+ for(int i=0; i<items.length(); i++){
+ if(items[i].isSymLink() && !items[i].exists()){
+ //Broken sym-link - remove it
+ QFile::remove(items[i].absoluteFilePath());
+ }
+ }*/
+
}
//Apps Tab
diff --git a/lumina-fm/MainUI.cpp b/lumina-fm/MainUI.cpp
index df5c898a..1576e65a 100644
--- a/lumina-fm/MainUI.cpp
+++ b/lumina-fm/MainUI.cpp
@@ -973,7 +973,17 @@ void MainUI::ItemSelectionChanged(){
}
QString itname;
if(sel.length()==1){ itname = sel[0].fileName(); }
- ui->tool_act_fav->setEnabled(!itname.isEmpty() && !QFile::exists(favdir+itname) );
+ bool ok = !itname.isEmpty() && (getCurrentDir()!=QDir::homePath()+"/Desktop");
+ if(ok){
+ if(QFile::exists(favdir+itname)){
+ //Make sure this favorite does not already point to the current file
+ QFileInfo info(favdir+itname);
+ if(info.isSymLink() && info.exists()){
+ ok = false; //still an active favorite - do not allow replacement
+ }
+ }
+ }
+ ui->tool_act_fav->setEnabled(ok);
}
//-------------------------------
@@ -1287,17 +1297,17 @@ void MainUI::RemoveItem(){
if(!checkUserPerms()){ return; }
//Get the selected items
QStringList paths, names;
- if(CItem.isEmpty()){
+ //if(CItem.isEmpty()){
QFileInfoList sel = getSelectedItems();
for(int i=0; i<sel.length(); i++){
paths << sel[i].absoluteFilePath();
names << sel[i].fileName();
}
if(sel.isEmpty()){ return; } //nothing selected
- }else{
+ /*}else{
paths << CItem;
names << CItem.section("/",-1);
- }
+ }*/
//Verify permanent removal of file/dir
if(QMessageBox::Yes != QMessageBox::question(this, tr("Verify Removal"), tr("WARNING: This will permanently delete the file(s) from the system!")+"\n"+tr("Are you sure you want to continue?")+"\n\n"+names.join("\n"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){
return; //cancelled
@@ -1365,6 +1375,7 @@ void MainUI::FavoriteItem(){
QString fname = CItem;
QString fullpath = fname;
fname = fname.section("/",-1); //turn this into just the file name
+ if(QFile::exists(favdir+fname)){ QFile::remove(favdir+fname); } //remove the stale link
QFile::link(fullpath, favdir+fname);
CItem.clear();
ItemSelectionChanged();
@@ -1480,8 +1491,13 @@ void MainUI::ChecksumItems(){
qDebug() << " - Info:" << info;
if(info.isEmpty() || (info.length() != files.length()) ){ return; }
for(int i=0; i<info.length(); i++){
- info[i] = QString("%2\t(%1)").arg(files[i].section("/",-1), info[i]);
+ info[i] = QString("%2 \t(%1)").arg(files[i].section("/",-1), info[i]);
}
+ /*QMessageBox dlg(this);
+ dlg.setWindowFlags( Qt::Dialog );
+ dlg.setWindowTitle( tr("File Checksums") );
+ dlg.setInformativeText(info.join("\n"));
+ dlg.exec();*/
QMessageBox::information(this, tr("File Checksums"), info.join("\n") );
}
bgstack15