aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Moore <ken@pcbsd.org>2014-10-06 17:49:31 -0400
committerKen Moore <ken@pcbsd.org>2014-10-06 17:49:31 -0400
commit9a7d82954a8e77ca72a9d0b995ec5c0160e6018c (patch)
tree0ecacf8b0510e4330bd368af86459709857eed9d
parentClean up the new global.h usage in all the Lumina subprojects. (diff)
downloadlumina-9a7d82954a8e77ca72a9d0b995ec5c0160e6018c.tar.gz
lumina-9a7d82954a8e77ca72a9d0b995ec5c0160e6018c.tar.bz2
lumina-9a7d82954a8e77ca72a9d0b995ec5c0160e6018c.zip
Get the new LuminaThemes class working with a sample color theme for Insight (for testing). The theme loading/usage appears to be working, now I just need to generalize the theme template so that it applies to all the QAbstract* widgets
-rw-r--r--libLumina/LuminaThemes.cpp84
-rw-r--r--libLumina/LuminaThemes.h1
-rw-r--r--libLumina/LuminaUtils.cpp2
-rw-r--r--libLumina/colors/SampleColors.qss.colors12
-rw-r--r--libLumina/libLumina.pro11
-rw-r--r--libLumina/themes/SampleTheme.qss.template64
-rw-r--r--lumina-fm/MainUI.ui68
-rw-r--r--lumina-fm/main.cpp3
-rw-r--r--port-files/pkg-plist5
9 files changed, 168 insertions, 82 deletions
diff --git a/libLumina/LuminaThemes.cpp b/libLumina/LuminaThemes.cpp
index 0ec46c67..5100a084 100644
--- a/libLumina/LuminaThemes.cpp
+++ b/libLumina/LuminaThemes.cpp
@@ -8,11 +8,14 @@
#include "LuminaUtils.h"
#include "LuminaOS.h"
+#include <QIcon>
+#include <QDebug>
+
QStringList LTHEME::availableSystemThemes(){
//returns: [name::::path] for each item
QDir dir(LOS::LuminaShare()+"themes");
- QStringList list = dir.entryList(QStringList() <<"*.qss.template", QDir::Files, QDir::Name());
+ QStringList list = dir.entryList(QStringList() <<"*.qss.template", QDir::Files, QDir::Name);
for(int i=0; i<list.length(); i++){
//Format the output entry [<name>::::<fullpath>]
list[i] = list[i].section(".qss.",0,0)+"::::"+dir.absoluteFilePath(list[i]);
@@ -22,7 +25,7 @@ QStringList LTHEME::availableSystemThemes(){
QStringList LTHEME::availableLocalThemes(){ //returns: [name::::path] for each item
QDir dir(QDir::homePath()+"/.lumina/themes");
- QStringList list = dir.entryList(QStringList() <<"*.qss.template", QDir::Files, QDir::Name());
+ QStringList list = dir.entryList(QStringList() <<"*.qss.template", QDir::Files, QDir::Name);
for(int i=0; i<list.length(); i++){
//Format the output entry [<name>::::<fullpath>]
list[i] = list[i].section(".qss.",0,0)+"::::"+dir.absoluteFilePath(list[i]);
@@ -33,7 +36,7 @@ QStringList LTHEME::availableLocalThemes(){ //returns: [name::::path] for each i
QStringList LTHEME::availableSystemColors(){ //returns: [name::::path] for each item
//returns: [name::::path] for each item
QDir dir(LOS::LuminaShare()+"colors");
- QStringList list = dir.entryList(QStringList() <<"*.qss.colortemplate", QDir::Files, QDir::Name());
+ QStringList list = dir.entryList(QStringList() <<"*.qss.colors", QDir::Files, QDir::Name);
for(int i=0; i<list.length(); i++){
//Format the output entry [<name>::::<fullpath>]
list[i] = list[i].section(".qss.",0,0)+"::::"+dir.absoluteFilePath(list[i]);
@@ -43,7 +46,7 @@ QStringList LTHEME::availableSystemColors(){ //returns: [name::::path] for each
QStringList LTHEME::availableLocalColors(){ //returns: [name::::path] for each item
QDir dir(QDir::homePath()+"/.lumina/colors");
- QStringList list = dir.entryList(QStringList() <<"*.qss.template", QDir::Files, QDir::Name());
+ QStringList list = dir.entryList(QStringList() <<"*.qss.colors", QDir::Files, QDir::Name);
for(int i=0; i<list.length(); i++){
//Format the output entry [<name>::::<fullpath>]
list[i] = list[i].section(".qss.",0,0)+"::::"+dir.absoluteFilePath(list[i]);
@@ -52,22 +55,79 @@ QStringList LTHEME::availableLocalColors(){ //returns: [name::::path] for each
}
QStringList LTHEME::availableSystemIcons(){ //returns: [name] for each item
- return QStringList(); //not implemented yet
+ QStringList paths;
+ paths << QDir::homePath()+"/.icons";
+ QStringList xdd = QString(getenv("XDG_DATA_HOME")).split(":");
+ xdd << QString(getenv("XDG_DATA_DIRS")).split(":");
+ for(int i=0; i<xdd.length(); i++){
+ if(QFile::exists(xdd[i]+"/icons")){
+ paths << xdd[i]+"/icons";
+ }
+ }
+ //Now get all the icon themes in these directories
+ QStringList themes;
+ QDir dir;
+ for(int i=0; i<paths.length(); i++){
+ if(dir.cd(paths[i])){
+ themes << dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
+ }
+ }
+ themes.removeDuplicates();
+ themes.sort();
+ return themes;
}
//Return the currently selected Theme/Colors/Icons
QStringList LTHEME::currentSettings(){ //returns [theme path, colorspath, iconsname]
-
+ QStringList out; out << "" << "" << "";
+ QStringList settings = LUtils::readFile(QDir::homePath()+"/.lumina/themesettings.cfg");
+ for(int i=0; i<settings.length(); i++){
+ if(settings[i].startsWith("THEMEFILE=")){ out[0] = settings[i].section("=",1,1).simplified(); }
+ else if(settings[i].startsWith("COLORFILE=")){ out[1] = settings[i].section("=",1,1).simplified(); }
+ }
+ out[2] = QIcon::themeName();
+ bool nofile = settings.isEmpty();
+ if(out[0].isEmpty()){ out[0] = LOS::LuminaShare()+"themes/SampleTheme.qss.template"; }
+ if(out[1].isEmpty()){ out[1] = LOS::LuminaShare()+"colors/SampleColors.qss.colors"; }
+ if(nofile){ setCurrentSettings(out[0], out[1], out[2]); }
+
+ return out;
}
//Change the current Theme/Colors/Icons
bool LTHEME::setCurrentSettings(QString themepath, QString colorpath, QString iconname){
-
+ QStringList contents;
+ contents << "THEMEFILE="+themepath;
+ contents << "COLORFILE="+colorpath;
+ contents << "ICONTHEME="+iconname;
+ bool ok = LUtils::writeFile(QDir::homePath()+"/.lumina/themesettings.cfg", contents, true);
+ QIcon::setThemeName(iconname);
+ return ok;
}
//Return the complete stylesheet for a given theme/colors
QString LTHEME::assembleStyleSheet(QString themepath, QString colorpath){
-
+ QString stylesheet = LUtils::readFile(themepath).join("\n");
+ QStringList colors = LUtils::readFile(colorpath);
+ //qDebug() << "Found Theme:" << themepath << stylesheet;
+ //qDebug() << "Found Colors:" << colorpath << colors;
+ for(int i=0; i<colors.length(); i++){
+ if(colors[i].isEmpty() || colors[i].startsWith("#")){ continue; }
+ else if(colors[i].startsWith("PRIMARYCOLOR=")){ stylesheet = stylesheet.replace("%%PRIMARYCOLOR%%", colors[i].section("=",1,1).simplified()); }
+ else if(colors[i].startsWith("SECONDARYCOLOR=")){ stylesheet = stylesheet.replace("%%SECONDARYCOLOR%%", colors[i].section("=",1,1).simplified()); }
+ else if(colors[i].startsWith("HIGHLIGHTCOLOR=")){ stylesheet = stylesheet.replace("%%HIGHLIGHTCOLOR%%", colors[i].section("=",1,1).simplified()); }
+ else if(colors[i].startsWith("ACCENTCOLOR=")){ stylesheet = stylesheet.replace("%%ACCENTCOLOR%%", colors[i].section("=",1,1).simplified()); }
+ else if(colors[i].startsWith("PRIMARYDISABLECOLOR=")){ stylesheet = stylesheet.replace("%%PRIMARYDISABLECOLOR%%", colors[i].section("=",1,1).simplified()); }
+ else if(colors[i].startsWith("SECONDARYDISABLECOLOR=")){ stylesheet = stylesheet.replace("%%SECONDARYDISABLECOLOR%%", colors[i].section("=",1,1).simplified()); }
+ else if(colors[i].startsWith("HIGHLIGHTDISABLECOLOR=")){ stylesheet = stylesheet.replace("%%HIGHLIGHTDISABLECOLOR%%", colors[i].section("=",1,1).simplified()); }
+ else if(colors[i].startsWith("ACCENTDISABLECOLOR=")){ stylesheet = stylesheet.replace("%%ACCENTDISABLECOLOR%%", colors[i].section("=",1,1).simplified()); }
+ else if(colors[i].startsWith("BASECOLOR=")){ stylesheet = stylesheet.replace("%%BASECOLOR%%", colors[i].section("=",1,1).simplified()); }
+ else if(colors[i].startsWith("ALTBASECOLOR=")){ stylesheet = stylesheet.replace("%%ALTBASECOLOR%%", colors[i].section("=",1,1).simplified()); }
+ else if(colors[i].startsWith("TEXTCOLOR=")){ stylesheet = stylesheet.replace("%%TEXTCOLOR%%", colors[i].section("=",1,1).simplified()); }
+ else if(colors[i].startsWith("TEXTHIGHLIGHTCOLOR=")){ stylesheet = stylesheet.replace("%%TEXTHIGHLIGHTCOLOR%%", colors[i].section("=",1,1).simplified()); }
+ }
+ //qDebug() << "Assembled Style Sheet:\n" << stylesheet;
+ return stylesheet;
}
//==================
@@ -77,10 +137,10 @@ LuminaThemeEngine::LuminaThemeEngine(QApplication *app){
application=app; //save this pointer for later
QStringList current = LTHEME::currentSettings();
theme = current[0]; colors=current[1]; icons=current[2];
- application->setCurrentStyleSheet( LTHEME::assembleStyleSheet(theme, colors) );
+ application->setStyleSheet( LTHEME::assembleStyleSheet(theme, colors) );
watcher = new QFileSystemWatcher(this);
- watcher->addPath( QDir::homePath()+"/.lumina/currenttheme.conf" );
- connect(watcher, SIGNAL(fileChanged(const &QString)), this, SLOT(watcherChange()) );
+ watcher->addPath( QDir::homePath()+"/.lumina/themesettings.cfg" );
+ connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(watcherChange()) );
}
LuminaThemeEngine::~LuminaThemeEngine(){
@@ -90,7 +150,7 @@ LuminaThemeEngine::~LuminaThemeEngine(){
void LuminaThemeEngine::watcherChange(){
QStringList current = LTHEME::currentSettings();
if(theme!=current[0] || colors!=current[1]){
- application->setCurrentStyleSheet( LTHEME::assembleStyleSheet(current[0], current[1]) );
+ application->setStyleSheet( LTHEME::assembleStyleSheet(current[0], current[1]) );
}
if(icons!=current[3]){
emit updateIcons();
diff --git a/libLumina/LuminaThemes.h b/libLumina/LuminaThemes.h
index a3e558d9..1026622b 100644
--- a/libLumina/LuminaThemes.h
+++ b/libLumina/LuminaThemes.h
@@ -18,6 +18,7 @@
#include <QDir>
class LTHEME{
+public:
//Read the Themes/Colors/Icons that are available on the system
static QStringList availableSystemThemes();//returns: [name::::path] for each item
static QStringList availableLocalThemes(); //returns: [name::::path] for each item
diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp
index 8a652e96..03b71cc9 100644
--- a/libLumina/LuminaUtils.cpp
+++ b/libLumina/LuminaUtils.cpp
@@ -58,7 +58,7 @@ bool LUtils::writeFile(QString filepath, QStringList contents, bool overwrite){
bool ok = false;
if(file.open( mode ) ){
QTextStream out(&file);
- for(int i=0; i<contents.length(); i++){ out << contents[i]; }
+ out << contents.join("\n");
file.close();
ok = true;
}
diff --git a/libLumina/colors/SampleColors.qss.colors b/libLumina/colors/SampleColors.qss.colors
new file mode 100644
index 00000000..fa770fa2
--- /dev/null
+++ b/libLumina/colors/SampleColors.qss.colors
@@ -0,0 +1,12 @@
+PRIMARYCOLOR=#7292bf
+SECONDARYCOLOR=#efeeed
+HIGHLIGHTCOLOR=#7292bf
+ACCENTCOLOR=#9abbbe
+PRIMARYDISABLECOLOR=#d0dbea
+SECONDARYDISABLECOLOR=#f5f0e7
+HIGHLIGHTDISABLECOLOR=#d0dbea
+ACCENTDISABLECOLOR=#f5f0e7
+BASECOLOR=#f4f0e8
+ALTBASECOLOR=white
+TEXTCOLOR=black
+TEXTHIGHLIGHTCOLOR=black \ No newline at end of file
diff --git a/libLumina/libLumina.pro b/libLumina/libLumina.pro
index 3bc6b516..97ebb799 100644
--- a/libLumina/libLumina.pro
+++ b/libLumina/libLumina.pro
@@ -23,11 +23,13 @@ VERSION = 1
HEADERS += LuminaXDG.h \
LuminaUtils.h \
LuminaX11.h \
+ LuminaThemes.h \
LuminaOS.h
SOURCES += LuminaXDG.cpp \
LuminaUtils.cpp \
LuminaX11.cpp \
+ LuminaThemes.cpp \
LuminaOS-FreeBSD.cpp \
LuminaOS-DragonFly.cpp \
LuminaOS-OpenBSD.cpp \
@@ -43,8 +45,15 @@ include.path=$$PREFIX/include/
include.files=LuminaXDG.h \
LuminaUtils.h \
LuminaX11.h \
+ LuminaThemes.h \
LuminaOS.h
-INSTALLS += target include
+colors.path=$$PREFIX/share/Lumina-DE/colors/
+colors.files=colors/SampleColors.qss.colors
+
+themes.path=$$PREFIX/share/Lumina-DE/themes/
+themes.files=themes/SampleTheme.qss.template
+
+INSTALLS += target include colors themes
QMAKE_LIBDIR = $$LIBPREFIX/qt4 $$LIBPREFIX
diff --git a/libLumina/themes/SampleTheme.qss.template b/libLumina/themes/SampleTheme.qss.template
new file mode 100644
index 00000000..b60fbf5a
--- /dev/null
+++ b/libLumina/themes/SampleTheme.qss.template
@@ -0,0 +1,64 @@
+QWidget{ color: %%TEXTCOLOR%%; }
+QWidget#page_browser,#page_audioPlayer,#page_zfs,#page_image_view{background:
+qradialgradient(cx: 0.5, cy: -1.8, fx: 0.5, fy: 0, radius: 2,
+stop: 0 %%ACCENTCOLOR%%,
+stop: 1 %%PRIMARYCOLOR%%);
+}
+QMainWindow, QMenu{ background: %%BASECOLOR%%; }
+QMenuBar, QMenuBar::item, QToolBar{ background: transparent; }
+QMenuBar::item:selected, QMenuBar::item:pressed, QMenu::item:selected{ background: qradialgradient(cx: 0.5, cy: -1.8, fx: 0.5, fy: 0, radius: 2,
+stop: 0 %%ACCENTCOLOR%%,
+stop: 1 %%HIGHLIGHTCOLOR%%);
+color: %%TEXTHIGHLIGHTCOLOR%%;
+}
+QMenu::item{ background: transparent; border: none; color: %%TEXTCOLOR%%; padding: 2px 25px 2px 20px;}
+QMenu::indicator{ width: 14px; height: 14px; }
+
+ QMenu::indicator:non-exclusive:unchecked {
+ image: url(:/trolltech/styles/commonstyle/images/standardbutton-no-16.png);
+ }
+
+ QMenu::indicator:non-exclusive:unchecked:selected {
+ image: url(:/trolltech/styles/commonstyle/images/standardbutton-no-16.png);
+ }
+
+ QMenu::indicator:non-exclusive:checked {
+ image: url(:/trolltech/styles/commonstyle/images/standardbutton-yes-16.png);
+ }
+
+ QMenu::indicator:non-exclusive:checked:selected {
+ image: url(:/trolltech/styles/commonstyle/images/standardbutton-yes-16.png);
+ }
+
+ QTabBar::tab {
+ background: qradialgradient(cx: 0.5, cy: -1.8, fx: 0.5, fy: 0, radius: 2,
+stop: 0 %%SECONDARYDISABLECOLOR%%,
+stop: 1 %%SECONDARYCOLOR%%);
+ border-top-left-radius: 4px;
+ border-top-right-radius: 4px;
+ min-width: 8ex;
+ padding: 2px;
+ }
+
+ QTabBar::tab:selected{
+ background: qradialgradient(cx: 0.5, cy: -1.8, fx: 0.5, fy: 0, radius: 2,
+stop: 0 %%ACCENTDISABLECOLOR%%,
+stop: 1 %%HIGHLIGHTCOLOR%%);
+ }
+QTabBar::tab:hover {
+ background: qradialgradient(cx: 0.5, cy: -1.8, fx: 0.5, fy: 0, radius: 2,
+stop: 0 %%ACCENTDISABLECOLOR%%,
+stop: 1 %%HIGHLIGHTDISABLECOLOR%%);
+ }
+
+ QTabBar::tab:!selected {
+ margin-top: 2px; /* make non-selected tabs look smaller */
+ }
+
+QToolTip{
+ background: %%BASECOLOR%%;
+ border: 1px solid %%PRIMARYDISABLECOLOR%%;
+ border-radius: 2px;
+ padding: 1px;
+ color: %%TEXTCOLOR%%;
+} \ No newline at end of file
diff --git a/lumina-fm/MainUI.ui b/lumina-fm/MainUI.ui
index 041a5ee5..160a271d 100644
--- a/lumina-fm/MainUI.ui
+++ b/lumina-fm/MainUI.ui
@@ -13,74 +13,6 @@
<property name="windowTitle">
<string>Insight</string>
</property>
- <property name="styleSheet">
- <string notr="true">QWidget{ color: black; }
-QWidget#page_browser,#page_audioPlayer,#page_zfs,#page_image_view{background:
-qradialgradient(cx: 0.5, cy: -1.8, fx: 0.5, fy: 0, radius: 2,
-stop: 0 #9abbbe,
-stop: 1 #7292bf);
-}
-QMainWindow, QMenu{ background: #f4f0e8; }
-QMenuBar, QMenuBar::item, QToolBar{ background: transparent; }
-QMenuBar::item:selected, QMenuBar::item:pressed, QMenu::item:selected{ background: qradialgradient(cx: 0.5, cy: -1.8, fx: 0.5, fy: 0, radius: 2,
-stop: 0 #f9fafc,
-stop: 1 #7292bf);
-color: black;
-}
-QMenu::item{ background: transparent; border: none; color: black; padding: 2px 25px 2px 20px;}
-QMenu::indicator{ width: 14px; height: 14px; }
-
- QMenu::indicator:non-exclusive:unchecked {
- image: url(:/trolltech/styles/commonstyle/images/standardbutton-no-16.png);
- }
-
- QMenu::indicator:non-exclusive:unchecked:selected {
- image: url(:/trolltech/styles/commonstyle/images/standardbutton-no-16.png);
- }
-
- QMenu::indicator:non-exclusive:checked {
- image: url(:/trolltech/styles/commonstyle/images/standardbutton-yes-16.png);
- }
-
- QMenu::indicator:non-exclusive:checked:selected {
- image: url(:/trolltech/styles/commonstyle/images/standardbutton-yes-16.png);
- }
-
- QTabBar::tab {
- background: qradialgradient(cx: 0.5, cy: -1.8, fx: 0.5, fy: 0, radius: 2,
-stop: 0 #f5f0e7,
-stop: 1 #efeeed);
- border-bottom: 2px solid white;
- border-bottom-color: white; /* same as the pane color */
- border-top-left-radius: 4px;
- border-top-right-radius: 4px;
- min-width: 8ex;
- padding: 2px;
- }
-
- QTabBar::tab:selected{
- background: qradialgradient(cx: 0.5, cy: -1.8, fx: 0.5, fy: 0, radius: 2,
-stop: 0 #f5f0e7,
-stop: 1 #fbf2e1);
- }
-QTabBar::tab:hover {
- background: qradialgradient(cx: 0.5, cy: -1.8, fx: 0.5, fy: 0, radius: 2,
-stop: 0 #f5f0e7,
-stop: 1 #d0dbea);
- }
-
- QTabBar::tab:!selected {
- margin-top: 2px; /* make non-selected tabs look smaller */
- }
-
-QToolTip{
- background: #f4f0e8;
- border: 1px solid #d0dbea;
- border-radius: 2px;
- padding: 1px;
- color: black;
-}</string>
- </property>
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="margin">
diff --git a/lumina-fm/main.cpp b/lumina-fm/main.cpp
index bc48d0db..29e59460 100644
--- a/lumina-fm/main.cpp
+++ b/lumina-fm/main.cpp
@@ -9,6 +9,7 @@
#include "MainUI.h"
#include <LuminaOS.h>
+#include <LuminaThemes.h>
int main(int argc, char ** argv)
{
@@ -26,6 +27,8 @@ int main(int argc, char ** argv)
QApplication a(argc, argv);
#endif
a.setApplicationName("Insight File Manager");
+ LuminaThemeEngine themes(&a);
+ //qDebug() << "StyleSheet:\n" << a.styleSheet();
//Load current Locale
QTranslator translator;
QLocale mylocale;
diff --git a/port-files/pkg-plist b/port-files/pkg-plist
index 6ad8999b..21ecd65f 100644
--- a/port-files/pkg-plist
+++ b/port-files/pkg-plist
@@ -10,6 +10,7 @@ lib/libLuminaUtils.so.1.0.0
include/LuminaXDG.h
include/LuminaUtils.h
include/LuminaX11.h
+include/LuminaTheme.h
include/LuminaOS.h
share/applications/lumina-fm.desktop
share/applications/lumina-screenshot.desktop
@@ -22,6 +23,8 @@ share/Lumina-DE/desktopsettings.conf
share/Lumina-DE/stylesheet.qss
share/Lumina-DE/Login.ogg
share/Lumina-DE/Logout.ogg
+share/Lumina-DE/colors/SampleColors.qss.colors
+share/Lumina-DE/themes/SampleTheme.qss.template
share/wallpapers/Lumina-DE/Lumina_Wispy_gold_1920x1080.jpg
share/wallpapers/Lumina-DE/Lumina_Wispy_green_1920x1080.jpg
share/wallpapers/Lumina-DE/Lumina_Wispy_purple_1920x1080.jpg
@@ -337,6 +340,8 @@ share/Lumina-DE/i18n/lumina-screenshot_zh_HK.qm
share/Lumina-DE/i18n/lumina-screenshot_zh_TW.qm
share/Lumina-DE/i18n/lumina-screenshot_zu.qm
@dirrm share/Lumina-DE/i18n
+@dirrmtry share/Lumina-DE/colors
+@dirrmtry share/Lumina-DE/themes
@dirrmtry share/Lumina-DE
@dirrmtry share/wallpapers/Lumina-DE
@dirrmtry share/xsessions
bgstack15