aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libLumina/LuminaThemes.cpp120
-rw-r--r--libLumina/LuminaThemes.h17
-rw-r--r--lumina-config/main.cpp1
-rw-r--r--lumina-config/mainUI.cpp17
-rw-r--r--lumina-config/mainUI.ui66
-rw-r--r--lumina-desktop/main.cpp1
-rw-r--r--lumina-fileinfo/main.cpp1
-rw-r--r--lumina-fm/main.cpp14
-rw-r--r--lumina-info/main.cpp1
-rw-r--r--lumina-open/main.cpp1
-rw-r--r--lumina-screenshot/main.cpp9
-rw-r--r--lumina-search/main.cpp1
-rw-r--r--lumina-wm-INCOMPLETE/main.cpp1
-rw-r--r--lumina-xconfig/main.cpp2
14 files changed, 155 insertions, 97 deletions
diff --git a/libLumina/LuminaThemes.cpp b/libLumina/LuminaThemes.cpp
index cf31e5fd..17ddc60d 100644
--- a/libLumina/LuminaThemes.cpp
+++ b/libLumina/LuminaThemes.cpp
@@ -13,6 +13,8 @@
#include <QDebug>
#include <QObject>
+#include <unistd.h>
+
//Stuff necesary for Qt Cursor Reloads
//#include "qxcbcursor.h" //needed to prod Qt to refresh the mouse cursor theme
//#include <QCursor>
@@ -250,11 +252,70 @@ QStringList LTHEME::cursorInformation(QString name){
return out;
}
+QStringList LTHEME::CustomEnvSettings(){ //view all the key=value settings
+ static QStringList info = QStringList();
+ static QDateTime lastcheck = QDateTime();
+ if(lastcheck.isNull() || lastcheck < QFileInfo(QDir::homePath()+"/.lumina/envsettings.conf").lastModified()){
+ lastcheck = QDateTime::currentDateTime();
+ info = LUtils::readFile(QDir::homePath()+"/.lumina/envsettings.conf");
+ }
+ return info;
+}
+
+void LTHEME::LoadCustomEnvSettings(){
+ //will push the custom settings into the environment (recommended before loading the initial QApplication)
+ QStringList info = LTHEME::CustomEnvSettings();
+ if(info.isEmpty()){
+ //Ensure the file exists, and create it otherwise;
+ if(!QFile::exists(QDir::homePath()+"/.lumina/envsettings.conf")){
+ LUtils::writeFile(QDir::homePath()+"/.lumina/envsettings.conf", QStringList() << "", true);
+ }
+ }
+ for(int i=0; i<info.length(); i++){
+ if(info[i].isEmpty()){ continue; }
+ if(info[i].section("=",1,100).isEmpty()){
+ unsetenv(info[i].section("=",0,0).toLocal8Bit());
+ }else{
+ setenv(info[i].section("=",0,0).toLocal8Bit(), info[i].section("=",1,100).simplified().toLocal8Bit(), 1);
+ }
+ }
+
+}
+
+bool LTHEME::setCustomEnvSetting(QString var, QString val){
+ //variable/value pair (use an empty val to clear it)
+ QStringList info = LTHEME::CustomEnvSettings();
+ bool changed = false;
+ if(!info.filter(var+"=").isEmpty()){
+ for(int i=0; i<info.length(); i++){
+ //Make sure this is an exact variable match
+ if(!info[i].startsWith(var+"=")){ continue; }
+ //Found it - replace this line
+ info[i] = var+"="+val;
+ changed = true;
+ }
+ }
+ if(!changed){ info << var+"="+val; }
+ return LUtils::writeFile(QDir::homePath()+"/.lumina/envsettings.conf", info, true);
+}
+
+QString LTHEME::readCustomEnvSetting(QString var){
+ QStringList info = LTHEME::CustomEnvSettings().filter(var+"=");
+ for(int i=0; i<info.length(); i++){
+ if(info[i].startsWith(var+"=")){
+ return info[i].section("=",1,100).simplified();
+ }
+ }
+ //If it gets here, no setting found for that variable
+ return "";
+}
+
//==================
// THEME ENGINE CLASS
//==================
LuminaThemeEngine::LuminaThemeEngine(QApplication *app){
application=app; //save this pointer for later
+ lastcheck = QDateTime::currentDateTime(); //
//Make sure to prefer font antialiasing on the application
QFont tmp = application->font();
tmp.setStyleStrategy(QFont::PreferAntialias);
@@ -272,7 +333,9 @@ LuminaThemeEngine::LuminaThemeEngine(QApplication *app){
LTHEME::setCursorTheme("default"); //X11 fallback (always installed?)
cursors = "default";
}
+ //setenv("XCURSOR_THEME", cursors.toLocal8Bit(),1);
watcher = new QFileSystemWatcher(this);
+ watcher->addPath( QDir::homePath()+"/.lumina/envsettings.conf" );
watcher->addPath( QDir::homePath()+"/.lumina/themesettings.cfg" );
watcher->addPaths( QStringList() << theme << colors << QDir::homePath()+"/.icons/default/index.theme" ); //also watch these files for changes
connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(watcherChange()) );
@@ -289,28 +352,45 @@ void LuminaThemeEngine::watcherChange(){
}
void LuminaThemeEngine::reloadFiles(){
- QStringList current = LTHEME::currentSettings();
- application->setStyleSheet( LTHEME::assembleStyleSheet(current[0], current[1], current[3], current[4]) );
-
- if(icons!=current[2]){
- QIcon::setThemeName(current[2]); //make sure this sets set within this environment
- emit updateIcons();
+ //Check the Theme file/settings
+ if(lastcheck < QFileInfo(QDir::homePath()+"/.lumina/themesettings.cfg").lastModified() ){
+ QStringList current = LTHEME::currentSettings();
+ application->setStyleSheet( LTHEME::assembleStyleSheet(current[0], current[1], current[3], current[4]) );
+ if(icons!=current[2]){
+ QIcon::setThemeName(current[2]); //make sure this sets set within this environment
+ emit updateIcons();
+ }
+ //save the settings for comparison later
+ theme = current[0]; colors=current[1]; icons=current[2]; font=current[3]; fontsize=current[4];
}
- QString ccurs = LTHEME::currentCursor();
- if(cursors != ccurs){
- emit updateCursors();
- //Might be something we can do automatically here as well - since we have the QApplication handy
- // - Note: setting/unsetting an override cursor does not update the current cursor bitmap
- // Qt created a background database/hash/mapping of the theme pixmaps on startup
- // So Qt itself needs to be prodded to update that mapping
- /*QXcbCursor::cursorThemePropertyChanged( \
+ //Check the Cursor file/settings
+ if(lastcheck < QFileInfo(QDir::homePath()+"/.icons/default/index.theme").lastModified()){
+ QString ccurs = LTHEME::currentCursor();
+ if(cursors != ccurs){
+ emit updateCursors();
+ //Might be something we can do automatically here as well - since we have the QApplication handy
+ // - Note: setting/unsetting an override cursor does not update the current cursor bitmap
+ // Qt created a background database/hash/mapping of the theme pixmaps on startup
+ // So Qt itself needs to be prodded to update that mapping
+ /*QXcbCursor::cursorThemePropertyChanged( \
new QXcbVirtualDesktop(QX11Info::connection(), application->screen()->handle(), QX11Info::appScreen()),
ccurs.toData(), QVariant("Inherits"), NULL);*/
-
+ //QCursorData::cleanup();
+ //QCursorData::initialize();
+ //setenv("XCURSOR_THEME", ccurs.toLocal8Bit(),1);
+ }
+ cursors = ccurs;
}
- //Now save this for later checking
- watcher->removePaths( QStringList() << theme << colors << QDir::homePath()+"/.icons/default/index.theme");
- theme = current[0]; colors=current[1]; icons=current[2]; font=current[3]; fontsize=current[4];
- cursors = ccurs;
- watcher->addPaths( QStringList() << theme << colors << QDir::homePath()+"/.icons/default/index.theme");
+
+
+ //Environment Changes
+ if( lastcheck < QFileInfo(QDir::homePath()+"/.lumina/envsettings.conf").lastModified()){
+ LTHEME::LoadCustomEnvSettings();
+ emit EnvChanged();
+ }
+ lastcheck = QDateTime::currentDateTime();
+
+ //Now update the watched files to ensure nothing is missed
+ watcher->removePaths( QStringList() << theme << colors << QDir::homePath()+"/.icons/default/index.theme" << QDir::homePath()+"/.lumina/envsettings.conf");
+ watcher->addPaths( QStringList() << theme << colors << QDir::homePath()+"/.icons/default/index.theme" << QDir::homePath()+"/.lumina/envsettings.conf");
}
diff --git a/libLumina/LuminaThemes.h b/libLumina/LuminaThemes.h
index 3767eb7a..6dcff89d 100644
--- a/libLumina/LuminaThemes.h
+++ b/libLumina/LuminaThemes.h
@@ -17,6 +17,7 @@
#include <QFile>
#include <QDir>
#include <QTimer>
+#include <QDateTime>
class LTHEME{
public:
@@ -46,11 +47,18 @@ public:
//Additional info for a cursor theme
static QStringList cursorInformation(QString name); //returns: [Name, Comment, Sample Image File]
+ //Environment settings
+ static QStringList CustomEnvSettings(); //view all the key=value settings
+ static void LoadCustomEnvSettings(); //will push the custom settings into the environment (recommended before loading the initial QApplication)
+ static bool setCustomEnvSetting(QString var, QString val); //variable/value pair (use an empty val to clear it)
+ static QString readCustomEnvSetting(QString var);
+
};
//Simple class to setup a utility to use the Lumina theme
//-----Example usage in "main.cpp" -------------------------------
+// LTHEME::LoadCustomEnvSettings();
// QApplication a(argc,argv);
// LuminaThemeEngine themes(&a)
//------------------------------------------------------------------------------------
@@ -71,15 +79,16 @@ private:
QFileSystemWatcher *watcher;
QString theme,colors,icons, font, fontsize, cursors; //current settings
QTimer *syncTimer;
+ QDateTime lastcheck;
private slots:
void watcherChange();
void reloadFiles();
signals:
- void updateIcons();
- void updateCursors();
-};
-
+ void updateIcons(); //Icon theme changed
+ void updateCursors(); //Cursor theme changed
+ void EnvChanged(); //Some environment variable(s) changed
+};
#endif
diff --git a/lumina-config/main.cpp b/lumina-config/main.cpp
index 115e793a..12ba0cd1 100644
--- a/lumina-config/main.cpp
+++ b/lumina-config/main.cpp
@@ -12,6 +12,7 @@
int main(int argc, char ** argv)
{
+ LTHEME::LoadCustomEnvSettings();
LSingleApplication a(argc, argv, "lumina-config"); //loads translations inside constructor
if(!a.isPrimaryProcess()){ return 0; }
diff --git a/lumina-config/mainUI.cpp b/lumina-config/mainUI.cpp
index 6bd6ba07..33b17105 100644
--- a/lumina-config/mainUI.cpp
+++ b/lumina-config/mainUI.cpp
@@ -11,7 +11,7 @@
#include <QImageReader>
#include <QTime>
#include <QDate>
-#include <QTimeZone>
+//#include <QTimeZone>
#include <QScrollBar>
#include <unistd.h>
@@ -202,7 +202,6 @@ 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()) );
connect(ui->combo_session_datetimeorder, SIGNAL(currentIndexChanged(int)), this, SLOT(sessionoptchanged()) );
connect(ui->combo_locale_lang, SIGNAL(currentIndexChanged(int)), this, SLOT(sessionoptchanged()) );
connect(ui->combo_locale_collate, SIGNAL(currentIndexChanged(int)), this, SLOT(sessionoptchanged()) );
@@ -246,7 +245,7 @@ void MainUI::setupMenus(){
//if(cur>=0){ ui->combo_session_cursortheme->setCurrentIndex(cur); }
//Available Time zones
- ui->combo_session_timezone->clear();
+ /*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
@@ -256,6 +255,7 @@ void MainUI::setupMenus(){
QString name = QLocale::countryToString(TZ.country());
if(name.count() > 20){ name = name.left(20)+"..."; }
name = QString(tr("%1 (%2)")).arg(name, TZ.abbreviation(DT));
+ qDebug() << "Time Zone:" << name << TZ.id();
if(tzlist.filter(name).isEmpty()){
tzlist << name+"::::"+QString::number(i);
}
@@ -267,7 +267,7 @@ void MainUI::setupMenus(){
//ui->combo_session_timezone->sort();
//Now set the default/system value
ui->combo_session_timezone->insertItem(0,tr("System Time"));
-
+ */
//Available localizations
QStringList langs = LUtils::knownLocales();
langs.sort();
@@ -1587,14 +1587,15 @@ void MainUI::loadSessionSettings(){
ui->line_session_date->setText( sessionsettings->value("DateFormat","").toString() );
index = ui->combo_session_datetimeorder->findData( sessionsettings->value("DateTimeOrder","timeonly").toString() );
ui->combo_session_datetimeorder->setCurrentIndex(index);
- if( !sessionsettings->value("CustomTimeZone", false).toBool() ){
+
+ /*if( !sessionsettings->value("CustomTimeZone", false).toBool() ){
//System Time selected
ui->combo_session_timezone->setCurrentIndex(0);
}else{
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 localization settings
val = sessionsettings->value("InitLocale/LANG", "").toString();
@@ -1763,14 +1764,14 @@ void MainUI::saveSessionSettings(){
sessionsettings->setValue("TimeFormat", ui->line_session_time->text());
sessionsettings->setValue("DateFormat", ui->line_session_date->text());
sessionsettings->setValue("DateTimeOrder", ui->combo_session_datetimeorder->currentData().toString());
- if( ui->combo_session_timezone->currentIndex()==0){
+ /*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 locale settings
sessionsettings->setValue("InitLocale/LANG", ui->combo_locale_lang->currentData().toString() );
diff --git a/lumina-config/mainUI.ui b/lumina-config/mainUI.ui
index aa7024d3..5a4324fb 100644
--- a/lumina-config/mainUI.ui
+++ b/lumina-config/mainUI.ui
@@ -1217,6 +1217,23 @@
</item>
</layout>
</item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_28">
+ <property name="text">
+ <string>Sample:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="label_session_timesample">
+ <property name="text">
+ <string notr="true"/>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
<item row="2" column="0">
<widget class="QLabel" name="label_25">
<property name="text">
@@ -1244,13 +1261,13 @@
</item>
</layout>
</item>
- <item row="1" column="1">
- <widget class="QLabel" name="label_session_timesample">
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_29">
<property name="text">
- <string notr="true"/>
+ <string>Sample:</string>
</property>
<property name="alignment">
- <set>Qt::AlignCenter</set>
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@@ -1264,53 +1281,16 @@
</property>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_28">
- <property name="text">
- <string>Sample:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_29">
- <property name="text">
- <string>Sample:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
<item row="4" column="0">
- <widget class="QLabel" name="label_26">
+ <widget class="QLabel" name="label_27">
<property name="text">
- <string>Time Zone:</string>
+ <string>Display Format</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>
- <item row="5" column="1">
<widget class="QComboBox" name="combo_session_datetimeorder"/>
</item>
- <item row="5" column="0">
- <widget class="QLabel" name="label_27">
- <property name="text">
- <string>Display Format</string>
- </property>
- </widget>
- </item>
</layout>
</item>
<item row="1" column="0">
diff --git a/lumina-desktop/main.cpp b/lumina-desktop/main.cpp
index ba014c9e..9415bd62 100644
--- a/lumina-desktop/main.cpp
+++ b/lumina-desktop/main.cpp
@@ -65,6 +65,7 @@ int main(int argc, char ** argv)
return 1;
}
//Setup any pre-QApplication initialization values
+ LTHEME::LoadCustomEnvSettings();
LXDG::setEnvironmentVars();
setenv("DESKTOP_SESSION","Lumina",1);
setenv("XDG_CURRENT_DESKTOP","Lumina",1);
diff --git a/lumina-fileinfo/main.cpp b/lumina-fileinfo/main.cpp
index 5f6a0d57..1028bbde 100644
--- a/lumina-fileinfo/main.cpp
+++ b/lumina-fileinfo/main.cpp
@@ -9,6 +9,7 @@
int main(int argc, char ** argv)
{
+ LTHEME::LoadCustomEnvSettings();
QApplication a(argc, argv);
LUtils::LoadTranslation(&a, "lumina-fileinfo");
LuminaThemeEngine theme(&a);
diff --git a/lumina-fm/main.cpp b/lumina-fm/main.cpp
index e3b475f1..b05c4016 100644
--- a/lumina-fm/main.cpp
+++ b/lumina-fm/main.cpp
@@ -11,19 +11,7 @@
int main(int argc, char ** argv)
{
- /*QStringList in;
- for(int i=1; i<argc; i++){ //skip the first arg (app binary)
- QString path = argv[i];
- if(path=="."){
- //Insert the current working directory
- in << QDir::currentPath();
- }else{
- if(!path.startsWith("/")){ path.prepend(QDir::currentPath()+"/"); }
- in << path;
- }
- }
- if(in.isEmpty()){ in << QDir::homePath(); }*/
-
+ LTHEME::LoadCustomEnvSettings();
LSingleApplication a(argc, argv, "lumina-fm"); //loads translations inside constructor
if( !a.isPrimaryProcess()){ return 0; }
qDebug() << "Loaded QApplication";
diff --git a/lumina-info/main.cpp b/lumina-info/main.cpp
index 026c6a05..38cae2ad 100644
--- a/lumina-info/main.cpp
+++ b/lumina-info/main.cpp
@@ -12,6 +12,7 @@
int main(int argc, char ** argv)
{
//qDebug() << "Create Single Application";
+ LTHEME::LoadCustomEnvSettings();
LSingleApplication a(argc, argv, "lumina-info"); //loads translations inside constructor
if( !a.isPrimaryProcess()){ return 0; }
//qDebug() << "Set Application Name";
diff --git a/lumina-open/main.cpp b/lumina-open/main.cpp
index 9ac2181a..2b042f61 100644
--- a/lumina-open/main.cpp
+++ b/lumina-open/main.cpp
@@ -116,6 +116,7 @@ QString cmdFromUser(int argc, char **argv, QString inFile, QString extension, QS
//Final catch: directory given - no valid default found - use lumina-fm
if(extension=="directory" && !showDLG){ return "lumina-fm"; }
//No default set -- Start up the application selection dialog
+ LTHEME::LoadCustomEnvSettings();
QApplication App(argc, argv);
LuminaThemeEngine theme(&App);
LUtils::LoadTranslation(&App,"lumina-open");
diff --git a/lumina-screenshot/main.cpp b/lumina-screenshot/main.cpp
index 02f6ae79..448547ca 100644
--- a/lumina-screenshot/main.cpp
+++ b/lumina-screenshot/main.cpp
@@ -10,18 +10,11 @@
int main(int argc, char ** argv)
{
+ LTHEME::LoadCustomEnvSettings();
QApplication a(argc, argv);
LuminaThemeEngine theme(&a);
a.setApplicationName("Take Screenshot");
LUtils::LoadTranslation(&a, "lumina-screenshot");
- /*QTranslator translator;
- QLocale mylocale;
- QString langCode = mylocale.name();
-
- if ( ! QFile::exists(LOS::LuminaShare()+"i18n/lumina-screenshot_" + langCode + ".qm" ) ) langCode.truncate(langCode.indexOf("_"));
- translator.load( QString("lumina-screenshot_") + langCode, LOS::LuminaShare()+"i18n/" );
- a.installTranslator( &translator );
- qDebug() << "Locale:" << langCode;*/
MainUI w;
QObject::connect(&theme,SIGNAL(updateIcons()), &w, SLOT(setupIcons()) );
diff --git a/lumina-search/main.cpp b/lumina-search/main.cpp
index f03bf04a..5b2b0479 100644
--- a/lumina-search/main.cpp
+++ b/lumina-search/main.cpp
@@ -17,6 +17,7 @@
int main(int argc, char ** argv)
{
//qDebug() << "Init App...";
+ LTHEME::LoadCustomEnvSettings();
QApplication a(argc, argv);
//qDebug() << "Init Theme Engine...";
LuminaThemeEngine theme(&a);
diff --git a/lumina-wm-INCOMPLETE/main.cpp b/lumina-wm-INCOMPLETE/main.cpp
index 1e533c24..95771cca 100644
--- a/lumina-wm-INCOMPLETE/main.cpp
+++ b/lumina-wm-INCOMPLETE/main.cpp
@@ -23,6 +23,7 @@
int main(int argc, char ** argv)
{
+ LTHEME::LoadCustomEnvSettings();
LSingleApplication a(argc, argv, "lumina-wm");
if(!a.isPrimaryProcess()){ return 0; } //Inputs forwarded on to the primary already
LuminaThemeEngine themes(&a);
diff --git a/lumina-xconfig/main.cpp b/lumina-xconfig/main.cpp
index de8de504..699665fb 100644
--- a/lumina-xconfig/main.cpp
+++ b/lumina-xconfig/main.cpp
@@ -23,7 +23,7 @@ int main(int argc, char ** argv)
}
}
if(in.isEmpty()){ in << QDir::homePath(); }*/
-
+ LTHEME::LoadCustomEnvSettings();
LSingleApplication a(argc, argv, "lumina-xconfig"); //loads translations inside constructor
if( !a.isPrimaryProcess()){ return 0; }
//qDebug() << "Loaded QApplication";
bgstack15