From 5f59a88e3f9104a44b6be0cfbe56063e2deb6afe Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Sat, 4 Oct 2014 15:13:12 -0400 Subject: Add the template for the new LuminaThemes library class (not integrated into build yet). This class will provide a consistant look for all Lumina utilities, while also allowing the user ways to easily modify the themes/appearance and have it take effect immediately. I also plan on extending this framework to save the completed stylesheet for *all* Qt-based system applications to use (providing an easy way to customize the feel of the system). --- libLumina/LuminaThemes.cpp | 75 ++++++++++++++++++++++++++++++++++++++++++++++ libLumina/LuminaThemes.h | 70 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 libLumina/LuminaThemes.cpp create mode 100644 libLumina/LuminaThemes.h (limited to 'libLumina') diff --git a/libLumina/LuminaThemes.cpp b/libLumina/LuminaThemes.cpp new file mode 100644 index 00000000..d1869ae4 --- /dev/null +++ b/libLumina/LuminaThemes.cpp @@ -0,0 +1,75 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2014, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "LuminaThemes.h" + +#include "LuminaUtils.h" +#include "LuminaOS.h" + +QStringList LTHEME::availableSystemThemes(){ + //returns: [name::::path] for each item + +} + +QStringList LTHEME::availableLocalThemes(){ //returns: [name::::path] for each item + +} + +QStringList LTHEME::availableSystemColors(){ //returns: [name::::path] for each item + +} + +QStringList LTHEME::availableLocalColors(){ //returns: [name::::path] for each item + +} + +QStringList LTHEME::availableSystemIcons(){ //returns: [name] for each item + +} + + //Return the currently selected Theme/Colors/Icons +QStringList LTHEME::currentSettings(){ //returns [theme path, colorspath, iconsname] + +} + + //Change the current Theme/Colors/Icons +bool LTHEME::setCurrentSettings(QString themepath, QString colorpath, QString iconname){ + +} + + //Return the complete stylesheet for a given theme/colors +QString LTHEME::assembleStyleSheet(QString themepath, QString colorpath){ + +} + +//================== +// THEME ENGINE CLASS +//================== +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) ); + watcher = new QFileSystemWatcher(this); + watcher->addPath( QDir::homePath()+"/.lumina/currenttheme.conf" ); + connect(watcher, SIGNAL(fileChanged(const &QString)), this, SLOT(watcherChange()) ); +} + +LuminaThemeEngine::~LuminaThemeEngine(){ + +} + +void LuminaThemeEngine::watcherChange(){ + QStringList current = LTHEME::currentSettings(); + if(theme!=current[0] || colors!=current[1]){ + application->setCurrentStyleSheet( LTHEME::assembleStyleSheet(current[0], current[1]) ); + } + if(icons!=current[3]){ + emit updateIcons(); + } + //Now save this for later checking + theme = current[0]; colors=current[1]; icons=current[2]; +} diff --git a/libLumina/LuminaThemes.h b/libLumina/LuminaThemes.h new file mode 100644 index 00000000..a3e558d9 --- /dev/null +++ b/libLumina/LuminaThemes.h @@ -0,0 +1,70 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2014, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +// This class governs all the stylesheet usage and interactions +// for the Lumina utilities to provide a consistant theme for the system +//=========================================== +#ifndef _LUMINA_LIBRARY_THEMES_H +#define _LUMINA_LIBRARY_THEMES_H + +#include +#include +#include +#include +#include +#include + +class LTHEME{ + //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 + static QStringList availableSystemColors(); //returns: [name::::path] for each item + static QStringList availableLocalColors(); //returns: [name::::path] for each item + static QStringList availableSystemIcons(); //returns: [name] for each item + + //Return the currently selected Theme/Colors/Icons + static QStringList currentSettings(); //returns [theme path, colorspath, iconsname] + + //Change the current Theme/Colors/Icons + static bool setCurrentSettings(QString themepath, QString colorpath, QString iconname); + + //Return the complete stylesheet for a given theme/colors + static QString assembleStyleSheet(QString themepath, QString colorpath); + +}; + + +//Simple class to setup a utility to use the Lumina theme +//-----Example usage in "main.cpp" ------------------------------- +// QApplication a(argc,argv); +// LuminaThemeEngine themes(&a) +//------------------------------------------------------------------------------------ +// Note: If you also use LuminaXDG::findIcons() in the application and you want +// to dynamically update those icons - connect to the updateIcons() signal +//------------------------------------------------------------------------------------- +// QMainWindow w; //(or whatever the main app window is) +// QObject::connect(themes,SIGNAL(updateIcons()), &w, SLOT(updateIcons()) ); +//------------------------------------------------------------------------------------ +class LuminaThemeEngine : public QObject{ + Q_OBJECT +public: + LuminaThemeEngine(QApplication *app); + ~LuminaThemeEngine(); + +private: + QApplication *application; + QFileSystemWatcher *watcher; + QString theme,colors,icons; //current settings + +private slots: + void watcherChange(); + +signals: + void updateIcons(); +}; + + +#endif -- cgit