diff options
32 files changed, 1037 insertions, 156 deletions
diff --git a/libLumina/LuminaThemes.cpp b/libLumina/LuminaThemes.cpp index 5100a084..0b328502 100644 --- a/libLumina/LuminaThemes.cpp +++ b/libLumina/LuminaThemes.cpp @@ -9,6 +9,7 @@ #include "LuminaUtils.h" #include "LuminaOS.h" #include <QIcon> +#include <QFont> #include <QDebug> @@ -65,11 +66,15 @@ QStringList LTHEME::availableSystemIcons(){ //returns: [name] for each item } } //Now get all the icon themes in these directories - QStringList themes; + QStringList themes, tmpthemes; QDir dir; for(int i=0; i<paths.length(); i++){ if(dir.cd(paths[i])){ - themes << dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); + tmpthemes = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); + for(int j=0; j<tmpthemes.length(); j++){ + if(tmpthemes[j].startsWith("default")){ continue; } + if(QFile::exists(dir.absoluteFilePath(tmpthemes[j]+"/index.theme")) ){ themes << tmpthemes[j]; } + } } } themes.removeDuplicates(); @@ -77,36 +82,61 @@ QStringList LTHEME::availableSystemIcons(){ //returns: [name] for each item return themes; } - //Return the currently selected Theme/Colors/Icons -QStringList LTHEME::currentSettings(){ //returns [theme path, colorspath, iconsname] - QStringList out; out << "" << "" << ""; +//Save a new theme/color file +bool LTHEME::saveLocalTheme(QString name, QStringList contents){ + QString localdir = QDir::homePath()+"/.lumina/themes/"; + if(!QFile::exists(localdir)){ QDir dir; dir.mkpath(localdir); } + return LUtils::writeFile(localdir+name+".qss.template", contents, true); +} + +bool LTHEME::saveLocalColors(QString name, QStringList contents){ + QString localdir = QDir::homePath()+"/.lumina/colors/"; + if(!QFile::exists(localdir)){ QDir dir; dir.mkpath(localdir); } + return LUtils::writeFile(localdir+name+".qss.colors", contents, true); +} + +//Return the currently selected Theme/Colors/Icons +QStringList LTHEME::currentSettings(){ //returns [theme path, colorspath, iconsname, font, fontsize] + 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(); } + else if(settings[i].startsWith("ICONTHEME=")){ out[2] = settings[i].section("=",1,1).simplified(); } + else if(settings[i].startsWith("FONTFAMILY=")){ out[3] = settings[i].section("=",1,1).simplified(); } + else if(settings[i].startsWith("FONTSIZE=")){ out[4] = 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[0].isEmpty()){ out[0] = LOS::LuminaShare()+"themes/Lumina-default.qss.template"; } if(out[1].isEmpty()){ out[1] = LOS::LuminaShare()+"colors/SampleColors.qss.colors"; } - if(nofile){ setCurrentSettings(out[0], out[1], out[2]); } + if(out[3].isEmpty()){ out[3] = QFont().defaultFamily(); } + if(out[4].isEmpty()){ + int num = QFont().pointSize(); out[4] = QString::number(num)+"pt"; //Check point size first + if(num<0){ num = QFont().pixelSize(); out[4] = QString::number(num)+"px";} //Now check pixel size + if(num<0){ out[4] = "9pt"; } //Now hard-code a fallback (just in case) + } + if(nofile){ setCurrentSettings(out[0], out[1], out[2], out[3], out[4]); } return out; } //Change the current Theme/Colors/Icons -bool LTHEME::setCurrentSettings(QString themepath, QString colorpath, QString iconname){ +bool LTHEME::setCurrentSettings(QString themepath, QString colorpath, QString iconname, QString font, QString fontsize){ + QIcon::setThemeName(iconname); + //Now save the theme settings file QStringList contents; contents << "THEMEFILE="+themepath; contents << "COLORFILE="+colorpath; contents << "ICONTHEME="+iconname; + contents << "FONTFAMILY="+font; + contents << "FONTSIZE="+fontsize; 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 LTHEME::assembleStyleSheet(QString themepath, QString colorpath, QString font, QString fontsize){ QString stylesheet = LUtils::readFile(themepath).join("\n"); QStringList colors = LUtils::readFile(colorpath); //qDebug() << "Found Theme:" << themepath << stylesheet; @@ -124,8 +154,11 @@ QString LTHEME::assembleStyleSheet(QString themepath, QString colorpath){ 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("TEXTDISABLECOLOR=")){ stylesheet = stylesheet.replace("%%TEXTDISABLECOLOR%%", colors[i].section("=",1,1).simplified()); } else if(colors[i].startsWith("TEXTHIGHLIGHTCOLOR=")){ stylesheet = stylesheet.replace("%%TEXTHIGHLIGHTCOLOR%%", colors[i].section("=",1,1).simplified()); } } + stylesheet = stylesheet.replace("%%FONT%%", font); + stylesheet = stylesheet.replace("%%FONTSIZE%%", fontsize); //qDebug() << "Assembled Style Sheet:\n" << stylesheet; return stylesheet; } @@ -135,9 +168,15 @@ QString LTHEME::assembleStyleSheet(QString themepath, QString colorpath){ //================== LuminaThemeEngine::LuminaThemeEngine(QApplication *app){ application=app; //save this pointer for later + //Make sure to prefer font antialiasing on the application + QFont tmp = application->font(); + tmp.setStyleStrategy(QFont::PreferAntialias); + application->setFont(tmp); + // Now load the theme stylesheet QStringList current = LTHEME::currentSettings(); - theme = current[0]; colors=current[1]; icons=current[2]; - application->setStyleSheet( LTHEME::assembleStyleSheet(theme, colors) ); + theme = current[0]; colors=current[1]; icons=current[2]; font=current[3]; fontsize=current[4]; + application->setStyleSheet( LTHEME::assembleStyleSheet(theme, colors, font, fontsize) ); + QIcon::setThemeName(icons); //make sure this sets set within this environment watcher = new QFileSystemWatcher(this); watcher->addPath( QDir::homePath()+"/.lumina/themesettings.cfg" ); connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(watcherChange()) ); @@ -149,12 +188,13 @@ LuminaThemeEngine::~LuminaThemeEngine(){ void LuminaThemeEngine::watcherChange(){ QStringList current = LTHEME::currentSettings(); - if(theme!=current[0] || colors!=current[1]){ - application->setStyleSheet( LTHEME::assembleStyleSheet(current[0], current[1]) ); + if(theme!=current[0] || colors!=current[1] || font!=current[3] || fontsize!=current[4]){ + application->setStyleSheet( LTHEME::assembleStyleSheet(current[0], current[1], current[3], current[4]) ); } - if(icons!=current[3]){ + if(icons!=current[2]){ + QIcon::setThemeName(current[2]); //make sure this sets set within this environment emit updateIcons(); } //Now save this for later checking - theme = current[0]; colors=current[1]; icons=current[2]; + theme = current[0]; colors=current[1]; icons=current[2]; font=current[3]; fontsize=current[4]; } diff --git a/libLumina/LuminaThemes.h b/libLumina/LuminaThemes.h index 1026622b..e4bbd208 100644 --- a/libLumina/LuminaThemes.h +++ b/libLumina/LuminaThemes.h @@ -26,14 +26,18 @@ public: static QStringList availableLocalColors(); //returns: [name::::path] for each item static QStringList availableSystemIcons(); //returns: [name] for each item + //Save a new theme/color file + static bool saveLocalTheme(QString name, QStringList contents); + static bool saveLocalColors(QString name, QStringList contents); + //Return the currently selected Theme/Colors/Icons - static QStringList currentSettings(); //returns [theme path, colorspath, iconsname] + static QStringList currentSettings(); //returns [theme path, colorspath, iconsname, font, fontsize] //Change the current Theme/Colors/Icons - static bool setCurrentSettings(QString themepath, QString colorpath, QString iconname); + static bool setCurrentSettings(QString themepath, QString colorpath, QString iconname, QString font, QString fontsize); //Return the complete stylesheet for a given theme/colors - static QString assembleStyleSheet(QString themepath, QString colorpath); + static QString assembleStyleSheet(QString themepath, QString colorpath, QString font, QString fontsize); }; @@ -58,7 +62,7 @@ public: private: QApplication *application; QFileSystemWatcher *watcher; - QString theme,colors,icons; //current settings + QString theme,colors,icons, font, fontsize; //current settings private slots: void watcherChange(); diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp index 46c2e26c..6f91082c 100644 --- a/libLumina/LuminaUtils.cpp +++ b/libLumina/LuminaUtils.cpp @@ -54,9 +54,9 @@ QStringList LUtils::readFile(QString filepath){ bool LUtils::writeFile(QString filepath, QStringList contents, bool overwrite){ QFile file(filepath); - QFile::OpenMode mode = overwrite ? (QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate) : (QIODevice::WriteOnly | QIODevice::Text); + if(file.exists() && !overwrite){ return false; } bool ok = false; - if(file.open( mode ) ){ + if( file.open(QIODevice::WriteOnly | QIODevice::Truncate) ){ QTextStream out(&file); out << contents.join("\n"); file.close(); diff --git a/libLumina/colors/SampleColors.qss.colors b/libLumina/colors/SampleColors.qss.colors index fa770fa2..19f27ff5 100644 --- a/libLumina/colors/SampleColors.qss.colors +++ b/libLumina/colors/SampleColors.qss.colors @@ -9,4 +9,5 @@ ACCENTDISABLECOLOR=#f5f0e7 BASECOLOR=#f4f0e8 ALTBASECOLOR=white TEXTCOLOR=black +TEXTDISABLECOLOR=grey TEXTHIGHLIGHTCOLOR=black
\ No newline at end of file diff --git a/libLumina/libLumina.pro b/libLumina/libLumina.pro index 97ebb799..cb89e7ca 100644 --- a/libLumina/libLumina.pro +++ b/libLumina/libLumina.pro @@ -52,7 +52,7 @@ 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 +themes.files=themes/Lumina-default.qss.template INSTALLS += target include colors themes diff --git a/libLumina/themes/SampleTheme.qss.template b/libLumina/themes/SampleTheme.qss.template deleted file mode 100644 index b60fbf5a..00000000 --- a/libLumina/themes/SampleTheme.qss.template +++ /dev/null @@ -1,64 +0,0 @@ -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-config/ColorDialog.cpp b/lumina-config/ColorDialog.cpp new file mode 100644 index 00000000..23a44633 --- /dev/null +++ b/lumina-config/ColorDialog.cpp @@ -0,0 +1,139 @@ +#include "ColorDialog.h" +#include "ui_ColorDialog.h" + +#include <LuminaUtils.h> + +ColorDialog::ColorDialog(QWidget *parent, LPlugins *plugs, QString colorFilePath) : QDialog(parent), ui(new Ui::ColorDialog){ + ui->setupUi(this); //load the designer file + filepath = colorFilePath; + this->setWindowIcon( LXDG::findIcon("format-stroke-color","") ); + ui->line_name->setText( colorFilePath.section("/",-1).section(".qss",0,0) ); + //Load the icons for the window + ui->push_cancel->setIcon( LXDG::findIcon("dialog-cancel","") ); + ui->push_save->setIcon( LXDG::findIcon("document-save","") ); + ui->tool_getcolor->setIcon( LXDG::findIcon("color-picker","") ); + ui->tool_editcolor->setIcon( LXDG::findIcon("edit-rename","") ); + //Now create entries for the available colors in the database + ui->tree_color->clear(); + QStringList colors = plugs->colorItems(); + colors.sort(); + for(int i=0; i<colors.length(); i++){ + LPI info = plugs->colorInfo(colors[i]); + QTreeWidgetItem *it = new QTreeWidgetItem(QStringList() << info.name); + it->setWhatsThis(0,info.ID); + it->setToolTip(0,info.description); + ui->tree_color->addTopLevelItem(it); + } + //Now load the given file + loadColors(); +} + +void ColorDialog::loadColors(){ + QStringList contents = LUtils::readFile(filepath); + for(int i=0; i<ui->tree_color->topLevelItemCount(); i++){ + QTreeWidgetItem *it = ui->tree_color->topLevelItem(i); + //Get the current value and update the item + QStringList fil = contents.filter(it->whatsThis(0)+"="); + QString val; + for(int i=0; i<fil.length(); i++){ + if( fil[i].startsWith(it->whatsThis(0)+"=") ){ val = fil[i]; } + } + updateItem(it, val.section("=",1,1)); + } +} + +void ColorDialog::saveColors(){ + QString name = ui->line_name->text(); + QStringList contents; + for(int i=0; i<ui->tree_color->topLevelItemCount(); i++){ + QTreeWidgetItem *it = ui->tree_color->topLevelItem(i); + contents << it->whatsThis(0)+"="+it->text(1); + } + bool ok = LTHEME::saveLocalColors(name, contents); + if(!ok){ qDebug() << "Could not save colors:" << name; } +} + +QColor ColorDialog::StringToColor(QString value){ + QColor color; + if(value.startsWith("rgb(")){ + QStringList vals = value.section("(",1,1).section(")",0,0).split(","); + if(vals.length()==3){ + color = QColor(vals[0].toInt(), vals[1].toInt(), vals[2].toInt()); + } + }else if(value.startsWith("rgba(")){ + QStringList vals = value.section("(",1,1).section(")",0,0).split(","); + if(vals.length()==4){ + color = QColor(vals[0].toInt(), vals[1].toInt(), vals[2].toInt(), vals[3].toInt()); + } + }else{ + color = QColor(value); + } + if(!color.isValid()){ color = QColor(); } + return color; +} + +void ColorDialog::updateItem(QTreeWidgetItem *it, QString value){ + it->setText(1,value); + if(value.isEmpty()){ return; } + //qDebug() << "Load Color:" << it->whatsThis(0) << value; + //Now try to load the color and set the sample + QBrush brush(StringToColor(value)); + it->setBackground(2, brush); +} + +// BUTTONS +void ColorDialog::on_push_save_clicked(){ + //Now set the output values + colorname = ui->line_name->text(); + colorpath = QDir::homePath()+"/.lumina/colors/"+colorname+".qss.colors"; + //Check if that color already exists + if(QFile::exists(colorpath)){ + if( QMessageBox::Yes != QMessageBox::question(this, tr("Color Exists"), tr("This color scheme already exists.\n Overwrite it?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) ){ + colorname.clear(); + colorpath.clear(); + return; //cancelled + } + } + //save the colors and close + saveColors(); + this->close(); +} + +void ColorDialog::on_push_cancel_clicked(){ + //Now clear the output values (just in case) + colorname.clear(); + colorpath.clear(); + this->close(); +} + +void ColorDialog::on_tool_getcolor_clicked(){ + QTreeWidgetItem *it = ui->tree_color->currentItem(); + if(it==0){ return; } //no item selected + QColor ccol = StringToColor(it->text(1)); + QColor ncol; + if(it->whatsThis(0).contains("BASE")){ ncol = QColorDialog::getColor(ccol, this, tr("Select Color")); } + else{ ncol = QColorDialog::getColor(ccol, this, tr("Select Color"), QColorDialog::ShowAlphaChannel ); } + + if(ncol.isValid()){ + QString out; + if(ncol.alpha()!=255){ + //Convert to rgba + out = "rgba("+QString::number(ncol.red())+","+QString::number(ncol.green())+","+QString::number(ncol.blue())+","+QString::number(ncol.alpha())+")"; + }else{ + //Convert to rgb + out = "rgb("+QString::number(ncol.red())+","+QString::number(ncol.green())+","+QString::number(ncol.blue())+")"; + } + updateItem(it, out); + } +} + +void ColorDialog::on_tool_editcolor_clicked(){ + QTreeWidgetItem *it = ui->tree_color->currentItem(); + if(it==0){ return; } //no item selected + //Get a string from the user + bool ok = false; + QString value = QInputDialog::getText(this, tr("Color Value"), tr("Color:"), QLineEdit::Normal, it->text(1), &ok); + if(!ok || value.isEmpty()){ return; } //cancelled + updateItem(it, value); +} + diff --git a/lumina-config/ColorDialog.h b/lumina-config/ColorDialog.h new file mode 100644 index 00000000..d343df87 --- /dev/null +++ b/lumina-config/ColorDialog.h @@ -0,0 +1,60 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2014, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +// This is the dialog for editing a color scheme +//=========================================== +#ifndef _LUMINA_FILE_MANAGER_COLOR_SELECT_DIALOG_H +#define _LUMINA_FILE_MANAGER_COLOR_SELECT_DIALOG_H + +#include <QDialog> +#include <QString> +#include <QStringList> +#include <QFile> +#include <QDir> +#include <QTreeWidgetItem> +#include <QBrush> +#include <QColor> +#include <QMessageBox> +#include <QInputDialog> +#include <QColorDialog> +#include <QDebug> + +#include <LuminaXDG.h> +#include <LuminaThemes.h> + +#include "LPlugins.h" + + +namespace Ui{ + class ColorDialog; +}; + +class ColorDialog : public QDialog{ + Q_OBJECT +private: + Ui::ColorDialog *ui; + QString filepath; + + void loadColors(); + void saveColors(); + QColor StringToColor(QString); + void updateItem(QTreeWidgetItem *it, QString value); + +public: + ColorDialog(QWidget *parent, LPlugins* plugs, QString colorFilePath); + ~ColorDialog(){} + + QString colorname, colorpath; + +private slots: + void on_push_save_clicked(); + void on_push_cancel_clicked(); + void on_tool_getcolor_clicked(); + void on_tool_editcolor_clicked(); + +}; + +#endif
\ No newline at end of file diff --git a/lumina-config/ColorDialog.ui b/lumina-config/ColorDialog.ui new file mode 100644 index 00000000..d1191c67 --- /dev/null +++ b/lumina-config/ColorDialog.ui @@ -0,0 +1,145 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ColorDialog</class> + <widget class="QDialog" name="ColorDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>377</width> + <height>307</height> + </rect> + </property> + <property name="windowTitle"> + <string>Color Scheme Editor</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>Color Scheme:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="line_name"/> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QToolButton" name="tool_getcolor"> + <property name="toolTip"> + <string>Set new color for selection</string> + </property> + <property name="text"> + <string>...</string> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_editcolor"> + <property name="toolTip"> + <string>Manually set value for selection</string> + </property> + <property name="text"> + <string>...</string> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QTreeWidget" name="tree_color"> + <property name="indentation"> + <number>0</number> + </property> + <attribute name="headerVisible"> + <bool>true</bool> + </attribute> + <attribute name="headerDefaultSectionSize"> + <number>140</number> + </attribute> + <column> + <property name="text"> + <string>Color</string> + </property> + </column> + <column> + <property name="text"> + <string>Value</string> + </property> + </column> + <column> + <property name="text"> + <string>Sample</string> + </property> + </column> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QPushButton" name="push_cancel"> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="push_save"> + <property name="text"> + <string>Save</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/lumina-config/LPlugins.cpp b/lumina-config/LPlugins.cpp index 9e34994e..6b61441b 100644 --- a/lumina-config/LPlugins.cpp +++ b/lumina-config/LPlugins.cpp @@ -10,6 +10,7 @@ LPlugins::LPlugins(){ LoadPanelPlugins(); LoadDesktopPlugins(); LoadMenuPlugins(); + LoadColorItems(); } LPlugins::~LPlugins(){ @@ -25,7 +26,9 @@ QStringList LPlugins::desktopPlugins(){ QStringList LPlugins::menuPlugins(){ return MENU.keys(); } - +QStringList LPlugins::colorItems(){ + return COLORS.keys(); +} //Information on individual plugins LPI LPlugins::panelPluginInfo(QString plug){ if(PANEL.contains(plug)){ return PANEL[plug]; } @@ -39,6 +42,10 @@ LPI LPlugins::menuPluginInfo(QString plug){ if(MENU.contains(plug)){ return MENU[plug]; } else{ return LPI(); } } +LPI LPlugins::colorInfo(QString item){ + if(COLORS.contains(item)){ return COLORS[item]; } + else{ return LPI(); } +} //=================== // PLUGINS @@ -172,4 +179,86 @@ void LPlugins::LoadMenuPlugins(){ info.ID = "app"; info.icon = "application-x-desktop"; MENU.insert(info.ID, info); +} + +void LPlugins::LoadColorItems(){ + COLORS.clear(); + //Text Color + LPI info; + info.name = QObject::tr("Text"); + info.description = QObject::tr("Color to use for all visible text."); + info.ID = "TEXTCOLOR"; + COLORS.insert(info.ID, info); + //Text Color (Disabled) + info = LPI(); //clear it + info.name = QObject::tr("Text (Disabled)"); + info.description = QObject::tr("Text color for disabled or inactive items."); + info.ID = "TEXTDISABLECOLOR"; + COLORS.insert(info.ID, info); + //Text Color (Highlighted) + info = LPI(); //clear it + info.name = QObject::tr("Text (Highlighted)"); + info.description = QObject::tr("Text color when selection is highlighted."); + info.ID = "TEXTHIGHLIGHTCOLOR"; + COLORS.insert(info.ID, info); + //Base Color (Normal) + info = LPI(); //clear it + info.name = QObject::tr("Base Window Color"); + info.description = QObject::tr("Main background color for the window/dialog."); + info.ID = "BASECOLOR"; + COLORS.insert(info.ID, info); + //Base Color (Alternate) + info = LPI(); //clear it + info.name = QObject::tr("Base Window Color (Alternate)"); + info.description = QObject::tr("Main background color for widgets that list or display collections of items."); + info.ID = "ALTBASECOLOR"; + COLORS.insert(info.ID, info); + //Primary Color (Normal) + info = LPI(); //clear it + info.name = QObject::tr("Primary Color"); + info.description = QObject::tr("Dominant color for the theme."); + info.ID = "PRIMARYCOLOR"; + COLORS.insert(info.ID, info); + //Primary Color (Disabled) + info = LPI(); //clear it + info.name = QObject::tr("Primary Color (Disabled)"); + info.description = QObject::tr("Dominant color for the theme (more subdued)."); + info.ID = "PRIMARYDISABLECOLOR"; + COLORS.insert(info.ID, info); + //Secondary Color (Normal) + info = LPI(); //clear it + info.name = QObject::tr("Secondary Color"); + info.description = QObject::tr("Alternate color for the theme."); + info.ID = "SECONDARYCOLOR"; + COLORS.insert(info.ID, info); + //Secondary Color (Disabled) + info = LPI(); //clear it + info.name = QObject::tr("Secondary Color (Disabled)"); + info.description = QObject::tr("Alternate color for the theme (more subdued)."); + info.ID = "SECONDARYDISABLECOLOR"; + COLORS.insert(info.ID, info); + //Accent Color (Normal) + info = LPI(); //clear it + info.name = QObject::tr("Accent Color"); + info.description = QObject::tr("Color used for borders or other accents."); + info.ID = "ACCENTCOLOR"; + COLORS.insert(info.ID, info); + //Accent Color (Disabled) + info = LPI(); //clear it + info.name = QObject::tr("Accent Color (Disabled)"); + info.description = QObject::tr("Color used for borders or other accents (more subdued)."); + info.ID = "ACCENTDISABLECOLOR"; + COLORS.insert(info.ID, info); + //Highlight Color (Normal) + info = LPI(); //clear it + info.name = QObject::tr("Highlight Color"); + info.description = QObject::tr("Color used for highlighting an item."); + info.ID = "HIGHLIGHTCOLOR"; + COLORS.insert(info.ID, info); + //Highlight Color (Disabled) + info = LPI(); //clear it + info.name = QObject::tr("Highlight Color (Disabled)"); + info.description = QObject::tr("Color used for highlighting an item (more subdued)."); + info.ID = "HIGHLIGHTDISABLECOLOR"; + COLORS.insert(info.ID, info); }
\ No newline at end of file diff --git a/lumina-config/LPlugins.h b/lumina-config/LPlugins.h index 7077d0ad..a123f4d3 100644 --- a/lumina-config/LPlugins.h +++ b/lumina-config/LPlugins.h @@ -15,10 +15,7 @@ class LPI{ public: QString name, ID, description, icon; - int width, height; //only used for desktop plugins - LPI(){ - width=0; height=0; - } + LPI(){} ~LPI(){} }; @@ -31,15 +28,18 @@ public: QStringList panelPlugins(); QStringList desktopPlugins(); QStringList menuPlugins(); + QStringList colorItems(); //Information on individual plugins LPI panelPluginInfo(QString); LPI desktopPluginInfo(QString); LPI menuPluginInfo(QString); + LPI colorInfo(QString); private: - QHash<QString, LPI> PANEL, DESKTOP, MENU; + QHash<QString, LPI> PANEL, DESKTOP, MENU, COLORS; void LoadPanelPlugins(); void LoadDesktopPlugins(); void LoadMenuPlugins(); + void LoadColorItems(); }; #endif
\ No newline at end of file diff --git a/lumina-config/ThemeDialog.cpp b/lumina-config/ThemeDialog.cpp new file mode 100644 index 00000000..c149255e --- /dev/null +++ b/lumina-config/ThemeDialog.cpp @@ -0,0 +1,71 @@ +#include "ThemeDialog.h" +#include "ui_ThemeDialog.h" + +#include <LuminaUtils.h> + +ThemeDialog::ThemeDialog(QWidget *parent, LPlugins *plugs, QString themeFilePath) : QDialog(parent), ui(new Ui::ThemeDialog){ + ui->setupUi(this); //load the designer file + filepath = themeFilePath; + this->setWindowIcon( LXDG::findIcon("preferences-desktop-theme","") ); + ui->line_name->setText( themeFilePath.section("/",-1).section(".qss",0,0) ); + //Load the icons for the window + ui->push_cancel->setIcon( LXDG::findIcon("dialog-cancel","") ); + ui->push_save->setIcon( LXDG::findIcon("document-save","") ); + ui->tool_color->setIcon( LXDG::findIcon("color-picker","") ); + //Now create entries for the available colors in the database + QStringList colors = plugs->colorItems(); + colors.sort(); + colormenu = new QMenu(this); + for(int i=0; i<colors.length(); i++){ + LPI info = plugs->colorInfo(colors[i]); + QAction *act = new QAction(info.name, this); + act->setWhatsThis("%%"+info.ID+"%%"); + act->setToolTip(info.description); + colormenu->addAction(act); + } + ui->tool_color->setMenu(colormenu); + //Now load the given file + loadTheme(); + connect(colormenu, SIGNAL(triggered(QAction*)),this, SLOT(menuTriggered(QAction*)) ); +} + +void ThemeDialog::loadTheme(){ + QStringList contents = LUtils::readFile(filepath); + ui->text_file->setPlainText( contents.join("\n") ); +} + +void ThemeDialog::saveTheme(){ + QString name = ui->line_name->text(); + QStringList contents = ui->text_file->toPlainText().split("\n"); + LTHEME::saveLocalTheme(name, contents); +} + + +// BUTTONS +void ThemeDialog::on_push_save_clicked(){ + //Now set the output values + themename = ui->line_name->text(); + themepath = QDir::homePath()+"/.lumina/themes/"+themename+".qss.template"; + //Check if that color already exists + if(QFile::exists(themepath)){ + if( QMessageBox::Yes != QMessageBox::question(this, tr("Theme Exists"), tr("This theme already exists.\n Overwrite it?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) ){ + themename.clear(); + themepath.clear(); + return; //cancelled + } + } + //save the colors and close + saveTheme(); + this->close(); +} + +void ThemeDialog::on_push_cancel_clicked(){ + //Now clear the output values (just in case) + themename.clear(); + themepath.clear(); + this->close(); +} + +void ThemeDialog::menuTriggered(QAction *act){ + ui->text_file->insertPlainText( act->whatsThis() ); +} diff --git a/lumina-config/ThemeDialog.h b/lumina-config/ThemeDialog.h new file mode 100644 index 00000000..15299e41 --- /dev/null +++ b/lumina-config/ThemeDialog.h @@ -0,0 +1,58 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2014, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +// This is the dialog for editing a theme stylesheet +//=========================================== +#ifndef _LUMINA_CONFIG_THEME_EDIT_DIALOG_H +#define _LUMINA_CONFIG_THEME_EDIT_DIALOG_H + +#include <QDialog> +#include <QString> +#include <QStringList> +#include <QFile> +#include <QDir> +#include <QTreeWidgetItem> +#include <QBrush> +#include <QColor> +#include <QMessageBox> +#include <QInputDialog> +#include <QColorDialog> +#include <QMenu> + +#include <LuminaXDG.h> +#include <LuminaThemes.h> + +#include "LPlugins.h" + + +namespace Ui{ + class ThemeDialog; +}; + +class ThemeDialog : public QDialog{ + Q_OBJECT +private: + Ui::ThemeDialog *ui; + QString filepath; + QMenu *colormenu; + + void loadTheme(); + void saveTheme(); + +public: + ThemeDialog(QWidget *parent, LPlugins* plugs, QString themeFilePath); + ~ThemeDialog(){} + + QString themename, themepath; + +private slots: + void on_push_save_clicked(); + void on_push_cancel_clicked(); + void menuTriggered(QAction*); + +}; + +#endif
\ No newline at end of file diff --git a/lumina-config/ThemeDialog.ui b/lumina-config/ThemeDialog.ui new file mode 100644 index 00000000..f2c4b8d7 --- /dev/null +++ b/lumina-config/ThemeDialog.ui @@ -0,0 +1,104 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ThemeDialog</class> + <widget class="QDialog" name="ThemeDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Theme Editor</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>Theme Name:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="line_name"/> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QToolButton" name="tool_color"> + <property name="text"> + <string>color</string> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="popupMode"> + <enum>QToolButton::InstantPopup</enum> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QPlainTextEdit" name="text_file"/> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QPushButton" name="push_cancel"> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="push_save"> + <property name="text"> + <string>Save</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/lumina-config/lumina-config.pro b/lumina-config/lumina-config.pro index ae063bed..ff8211b3 100644 --- a/lumina-config/lumina-config.pro +++ b/lumina-config/lumina-config.pro @@ -11,16 +11,22 @@ TEMPLATE = app SOURCES += main.cpp \ mainUI.cpp \ - LPlugins.cpp + LPlugins.cpp \ + ColorDialog.cpp \ + ThemeDialog.cpp HEADERS += mainUI.h \ LPlugins.h \ KeyCatch.h \ - AppDialog.h + AppDialog.h \ + ColorDialog.h \ + ThemeDialog.h FORMS += mainUI.ui \ KeyCatch.ui \ - AppDialog.ui + AppDialog.ui \ + ColorDialog.ui \ + ThemeDialog.ui # RESOURCES+= lumina-config.qrc diff --git a/lumina-config/main.cpp b/lumina-config/main.cpp index 415a3c85..27af600d 100644 --- a/lumina-config/main.cpp +++ b/lumina-config/main.cpp @@ -9,6 +9,7 @@ #include "mainUI.h" #include <LuminaOS.h> +#include <LuminaThemes.h> int main(int argc, char ** argv) { @@ -19,6 +20,7 @@ int main(int argc, char ** argv) if( a.isRunning() ) return !(a.sendMessage("show")); #endif + LuminaThemeEngine theme(&a); QTranslator translator; QLocale mylocale; QString langCode = mylocale.name(); @@ -31,6 +33,7 @@ int main(int argc, char ** argv) MainUI w; QObject::connect(&a, SIGNAL(messageReceived(const QString&)), &w, SLOT(slotSingleInstance()) ); + QObject::connect(&theme, SIGNAL(updateIcons()), &w, SLOT(setupIcons()) ); w.show(); int retCode = a.exec(); diff --git a/lumina-config/mainUI.cpp b/lumina-config/mainUI.cpp index df4b4d11..756fc016 100644 --- a/lumina-config/mainUI.cpp +++ b/lumina-config/mainUI.cpp @@ -118,6 +118,8 @@ void MainUI::setupIcons(){ ui->tool_session_addapp->setIcon( LXDG::findIcon("system-run","") ); ui->tool_session_addbin->setIcon( LXDG::findIcon("system-search","") ); ui->tool_session_addfile->setIcon( LXDG::findIcon("run-build-file","") ); + ui->tool_session_newtheme->setIcon( LXDG::findIcon("preferences-desktop-theme","") ); + ui->tool_session_newcolor->setIcon( LXDG::findIcon("preferences-desktop-color","") ); } @@ -198,6 +200,13 @@ void MainUI::setupConnections(){ connect(ui->check_session_playlogoutaudio, SIGNAL(stateChanged(int)), this, SLOT(sessionoptchanged()) ); connect(ui->spin_session_wkspaces, SIGNAL(valueChanged(int)), this, SLOT(sessionoptchanged()) ); connect(ui->list_session_start, SIGNAL(currentRowChanged(int)), this, SLOT(sessionstartchanged()) ); + connect(ui->spin_session_fontsize, SIGNAL(valueChanged(int)), this, SLOT(sessionoptchanged()) ); + connect(ui->combo_session_themefile, SIGNAL(currentIndexChanged(int)), this, SLOT(sessionoptchanged()) ); + connect(ui->combo_session_colorfile, SIGNAL(currentIndexChanged(int)), this, SLOT(sessionoptchanged()) ); + connect(ui->combo_session_icontheme, SIGNAL(currentIndexChanged(int)), this, SLOT(sessionoptchanged()) ); + connect(ui->font_session_theme, SIGNAL(currentIndexChanged(int)), this, SLOT(sessionoptchanged()) ); + connect(ui->tool_session_newcolor, SIGNAL(clicked()), this, SLOT(sessionEditColor()) ); + connect(ui->tool_session_newtheme, SIGNAL(clicked()), this, SLOT(sessionEditTheme()) ); } void MainUI::setupMenus(){ @@ -1365,6 +1374,51 @@ void MainUI::loadSessionSettings(){ ui->check_session_playloginaudio->setChecked( sessionsettings->value("PlayStartupAudio",true).toBool() ); ui->check_session_playlogoutaudio->setChecked( sessionsettings->value("PlayLogoutAudio",true).toBool() ); + //Now do the session theme options + ui->combo_session_themefile->clear(); + ui->combo_session_colorfile->clear(); + ui->combo_session_icontheme->clear(); + QStringList current = LTHEME::currentSettings(); + // - local theme templates + QStringList tmp = LTHEME::availableLocalThemes(); + tmp.sort(); + for(int i=0; i<tmp.length(); i++){ + ui->combo_session_themefile->addItem(tmp[i].section("::::",0,0)+" ("+tr("Local")+")", tmp[i].section("::::",1,1)); + if(tmp[i].section("::::",1,1)==current[0]){ ui->combo_session_themefile->setCurrentIndex(ui->combo_session_themefile->count()-1); } + } + // - system theme templates + tmp = LTHEME::availableSystemThemes(); + tmp.sort(); + for(int i=0; i<tmp.length(); i++){ + ui->combo_session_themefile->addItem(tmp[i].section("::::",0,0)+" ("+tr("System")+")", tmp[i].section("::::",1,1)); + if(tmp[i].section("::::",1,1)==current[0]){ ui->combo_session_themefile->setCurrentIndex(ui->combo_session_themefile->count()-1); } + } + // - local color schemes + tmp = LTHEME::availableLocalColors(); + tmp.sort(); + for(int i=0; i<tmp.length(); i++){ + ui->combo_session_colorfile->addItem(tmp[i].section("::::",0,0)+" ("+tr("Local")+")", tmp[i].section("::::",1,1)); + if(tmp[i].section("::::",1,1)==current[1]){ ui->combo_session_colorfile->setCurrentIndex(ui->combo_session_colorfile->count()-1); } + } + // - system color schemes + tmp = LTHEME::availableSystemColors(); + tmp.sort(); + for(int i=0; i<tmp.length(); i++){ + ui->combo_session_colorfile->addItem(tmp[i].section("::::",0,0)+" ("+tr("System")+")", tmp[i].section("::::",1,1)); + if(tmp[i].section("::::",1,1)==current[1]){ ui->combo_session_colorfile->setCurrentIndex(ui->combo_session_colorfile->count()-1); } + } + // - icon themes + tmp = LTHEME::availableSystemIcons(); + tmp.sort(); + for(int i=0; i<tmp.length(); i++){ + ui->combo_session_icontheme->addItem(tmp[i]); + if(tmp[i]==current[2]){ ui->combo_session_icontheme->setCurrentIndex(i); } + } + // - Font + ui->font_session_theme->setCurrentFont( QFont(current[3]) ); + // - Font Size + ui->spin_session_fontsize->setValue( current[4].section("p",0,0).toInt() ); + sessionstartchanged(); //make sure to update buttons } @@ -1407,6 +1461,14 @@ void MainUI::saveSessionSettings(){ sessionsettings->setValue("EnableNumlock", ui->check_session_numlock->isChecked()); sessionsettings->setValue("PlayStartupAudio", ui->check_session_playloginaudio->isChecked()); sessionsettings->setValue("PlayLogoutAudio", ui->check_session_playlogoutaudio->isChecked()); + + //Now do the theme options + QString themefile = ui->combo_session_themefile->itemData( ui->combo_session_themefile->currentIndex() ).toString(); + QString colorfile = ui->combo_session_colorfile->itemData( ui->combo_session_colorfile->currentIndex() ).toString(); + QString iconset = ui->combo_session_icontheme->currentText(); + QString font = ui->font_session_theme->currentFont().family(); + QString fontsize = QString::number(ui->spin_session_fontsize->value())+"pt"; + LTHEME::setCurrentSettings( themefile, colorfile, iconset, font, fontsize); } void MainUI::rmsessionstartitem(){ @@ -1475,3 +1537,55 @@ void MainUI::sessionthemechanged(){ void MainUI::sessionstartchanged(){ ui->tool_session_rmapp->setEnabled( ui->list_session_start->currentRow()>=0 ); } + +void MainUI::sessionEditColor(){ + //Get the current color file + QString file = ui->combo_session_colorfile->itemData( ui->combo_session_colorfile->currentIndex() ).toString(); + //Open the color edit dialog + ColorDialog dlg(this, PINFO, file); + dlg.exec(); + //Check whether the file got saved/changed + if(dlg.colorname.isEmpty() || dlg.colorpath.isEmpty() ){ return; } //cancelled + //Reload the color list and activate the new color + // - local color schemes + ui->combo_session_colorfile->clear(); + QStringList tmp = LTHEME::availableLocalColors(); + tmp.sort(); + for(int i=0; i<tmp.length(); i++){ + ui->combo_session_colorfile->addItem(tmp[i].section("::::",0,0)+" ("+tr("Local")+")", tmp[i].section("::::",1,1)); + if(tmp[i].section("::::",1,1)==dlg.colorpath){ ui->combo_session_colorfile->setCurrentIndex(ui->combo_session_colorfile->count()-1); } + } + // - system color schemes + tmp = LTHEME::availableSystemColors(); + tmp.sort(); + for(int i=0; i<tmp.length(); i++){ + ui->combo_session_colorfile->addItem(tmp[i].section("::::",0,0)+" ("+tr("System")+")", tmp[i].section("::::",1,1)); + if(tmp[i].section("::::",1,1)==dlg.colorpath){ ui->combo_session_colorfile->setCurrentIndex(ui->combo_session_colorfile->count()-1); } + } + +} + +void MainUI::sessionEditTheme(){ + QString file = ui->combo_session_themefile->itemData( ui->combo_session_themefile->currentIndex() ).toString(); + //Open the theme editor dialog + ThemeDialog dlg(this, PINFO, file); + dlg.exec(); + //Check for file change/save + if(dlg.themename.isEmpty() || dlg.themepath.isEmpty()){ return; } //cancelled + //Reload the theme list and activate the new theme + ui->combo_session_themefile->clear(); + // - local theme templates + QStringList tmp = LTHEME::availableLocalThemes(); + tmp.sort(); + for(int i=0; i<tmp.length(); i++){ + ui->combo_session_themefile->addItem(tmp[i].section("::::",0,0)+" ("+tr("Local")+")", tmp[i].section("::::",1,1)); + if(tmp[i].section("::::",1,1)==dlg.themepath){ ui->combo_session_themefile->setCurrentIndex(ui->combo_session_themefile->count()-1); } + } + // - system theme templates + tmp = LTHEME::availableSystemThemes(); + tmp.sort(); + for(int i=0; i<tmp.length(); i++){ + ui->combo_session_themefile->addItem(tmp[i].section("::::",0,0)+" ("+tr("System")+")", tmp[i].section("::::",1,1)); + if(tmp[i].section("::::",1,1)==dlg.themepath){ ui->combo_session_themefile->setCurrentIndex(ui->combo_session_themefile->count()-1); } + } +}
\ No newline at end of file diff --git a/lumina-config/mainUI.h b/lumina-config/mainUI.h index d40438db..0031a45f 100644 --- a/lumina-config/mainUI.h +++ b/lumina-config/mainUI.h @@ -21,11 +21,14 @@ // libLumina includes #include <LuminaXDG.h> +#include <LuminaThemes.h> // local includes #include "LPlugins.h" #include "KeyCatch.h" #include "AppDialog.h" +#include "ColorDialog.h" +#include "ThemeDialog.h" //namespace for using the *.ui file namespace Ui{ @@ -52,7 +55,6 @@ private: int panelnumber; //General purpose functions (not connected to buttons) - void setupIcons(); //called during initialization void setupMenus(); //called during initialization void setupConnections(); //called during intialization @@ -73,6 +75,9 @@ private: QStringList readFile(QString path); bool overwriteFile(QString path, QStringList contents); +public slots: + void setupIcons(); //called during initialization + private slots: void slotSingleInstance(); @@ -149,6 +154,8 @@ private slots: void sessionoptchanged(); void sessionthemechanged(); void sessionstartchanged(); + void sessionEditColor(); + void sessionEditTheme(); }; #endif diff --git a/lumina-config/mainUI.ui b/lumina-config/mainUI.ui index 7dd97862..7f8f2ae8 100644 --- a/lumina-config/mainUI.ui +++ b/lumina-config/mainUI.ui @@ -87,14 +87,11 @@ <verstretch>0</verstretch> </sizepolicy> </property> - <property name="styleSheet"> - <string notr="true">QWidget#page_desktop,#page_panels,#page_menu,#page_shortcuts,#page_defaults,#page_session{background-color: rgba(255,255,255,150); }</string> - </property> <property name="frameShape"> <enum>QFrame::StyledPanel</enum> </property> <property name="currentIndex"> - <number>2</number> + <number>5</number> </property> <widget class="QWidget" name="page_desktop"> <layout class="QVBoxLayout" name="verticalLayout_3"> @@ -372,8 +369,8 @@ <rect> <x>0</x> <y>0</y> - <width>166</width> - <height>92</height> + <width>157</width> + <height>90</height> </rect> </property> <attribute name="label"> @@ -454,8 +451,8 @@ <rect> <x>0</x> <y>0</y> - <width>194</width> - <height>107</height> + <width>177</width> + <height>106</height> </rect> </property> <attribute name="label"> @@ -592,8 +589,8 @@ <rect> <x>0</x> <y>0</y> - <width>166</width> - <height>92</height> + <width>157</width> + <height>90</height> </rect> </property> <attribute name="label"> @@ -674,8 +671,8 @@ <rect> <x>0</x> <y>0</y> - <width>194</width> - <height>107</height> + <width>177</width> + <height>106</height> </rect> </property> <attribute name="label"> @@ -1107,8 +1104,115 @@ <string/> </property> <property name="currentIndex"> - <number>2</number> + <number>0</number> </property> + <widget class="QWidget" name="tab_theme"> + <attribute name="title"> + <string>Theme</string> + </attribute> + <layout class="QFormLayout" name="formLayout_3"> + <item row="0" column="0"> + <widget class="QLabel" name="label_12"> + <property name="text"> + <string>Font:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QFontComboBox" name="font_session_theme"> + <property name="editable"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_14"> + <property name="text"> + <string>Font Size:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QSpinBox" name="spin_session_fontsize"> + <property name="suffix"> + <string> point</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_16"> + <property name="text"> + <string>Theme Template:</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_12"> + <item> + <widget class="QComboBox" name="combo_session_themefile"> + <property name="sizeAdjustPolicy"> + <enum>QComboBox::AdjustToContents</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_session_newtheme"> + <property name="toolTip"> + <string>Create/Edit a theme template (Advanced)</string> + </property> + <property name="statusTip"> + <string/> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_17"> + <property name="text"> + <string>Color Scheme:</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_19"> + <item> + <widget class="QComboBox" name="combo_session_colorfile"> + <property name="sizeAdjustPolicy"> + <enum>QComboBox::AdjustToContents</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_session_newcolor"> + <property name="toolTip"> + <string>Create/Edit a color scheme</string> + </property> + <property name="statusTip"> + <string/> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + <item row="4" column="1"> + <widget class="QComboBox" name="combo_session_icontheme"/> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_18"> + <property name="text"> + <string>Icon Pack:</string> + </property> + </widget> + </item> + </layout> + </widget> <widget class="QWidget" name="tab"> <attribute name="title"> <string>General Options</string> @@ -1279,9 +1383,6 @@ <layout class="QVBoxLayout" name="verticalLayout_12"> <item> <widget class="QScrollArea" name="scrollArea"> - <property name="styleSheet"> - <string notr="true">background: grey;</string> - </property> <property name="widgetResizable"> <bool>true</bool> </property> @@ -1290,8 +1391,8 @@ <rect> <x>0</x> <y>0</y> - <width>491</width> - <height>59</height> + <width>515</width> + <height>78</height> </rect> </property> <property name="sizePolicy"> @@ -1398,7 +1499,7 @@ <x>0</x> <y>0</y> <width>579</width> - <height>19</height> + <height>20</height> </rect> </property> </widget> diff --git a/lumina-desktop/LDesktop.cpp b/lumina-desktop/LDesktop.cpp index b230d375..81d57cb8 100644 --- a/lumina-desktop/LDesktop.cpp +++ b/lumina-desktop/LDesktop.cpp @@ -48,6 +48,7 @@ LDesktop::LDesktop(int deskNum) : QObject(){ bgDesktop = new QMdiArea(bgWindow); //Make sure the desktop area is transparent to show the background bgDesktop->setBackground( QBrush(Qt::NoBrush) ); + bgDesktop->setStyleSheet( "QMdiArea{ border: none; background: transparent;}" ); //Start the update processes QTimer::singleShot(1,this, SLOT(UpdateMenu()) ); diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index 95272954..876db93a 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -29,14 +29,14 @@ static QSettings *sessionsettings; LSession::LSession(int &argc, char ** argv) : QApplication(argc, argv){ this->setApplicationName("Lumina Desktop Environment"); - this->setApplicationVersion("0.6.3"); + this->setApplicationVersion("0.7.0"); this->setOrganizationName("LuminaDesktopEnvironment"); this->setQuitOnLastWindowClosed(false); //since the LDesktop's are not necessarily "window"s //Enabled a few of the simple effects by default this->setEffectEnabled( Qt::UI_AnimateMenu, true); this->setEffectEnabled( Qt::UI_AnimateCombo, true); this->setEffectEnabled( Qt::UI_AnimateTooltip, true); - this->setStyle( new MenuProxyStyle); //QMenu icon size override + //this->setStyle( new MenuProxyStyle); //QMenu icon size override //LuminaSessionTrayID = 0; } @@ -55,8 +55,6 @@ LSession::~LSession(){ void LSession::setupSession(){ qDebug() << "Initializing Session"; - //Load the stylesheet - loadStyleSheet(); //Setup the QSettings default paths QSettings::setPath(QSettings::NativeFormat, QSettings::UserScope, QDir::homePath()+"/.lumina"); sessionsettings = new QSettings("LuminaDE", "sessionsettings"); @@ -159,8 +157,7 @@ void LSession::launchStartupApps(){ void LSession::watcherChange(QString changed){ qDebug() << "Session Watcher Change:" << changed; - if(changed.endsWith("stylesheet.qss")){ loadStyleSheet(); } - else if(changed.endsWith("fluxbox-init") || changed.endsWith("fluxbox-keys")){ refreshWindowManager(); } + if(changed.endsWith("fluxbox-init") || changed.endsWith("fluxbox-keys")){ refreshWindowManager(); } else{ emit DesktopConfigChanged(); } } @@ -199,6 +196,7 @@ void LSession::checkUserFiles(){ else if(!QFile::exists(dset+"fluxbox-keys")){fluxcopy=true; } else if(oldversion < 60){ fluxcopy=true; qDebug() << "Current fluxbox settings obsolete: Re-implementing defaults"; } if(fluxcopy){ + qDebug() << "Copying default fluxbox configuration files"; if(QFile::exists(dset+"fluxbox-init")){ QFile::remove(dset+"fluxbox-init"); } if(QFile::exists(dset+"fluxbox-keys")){ QFile::remove(dset+"fluxbox-keys"); } QFile::copy(":/fluxboxconf/fluxbox-init-rc", dset+"fluxbox-init"); @@ -217,22 +215,6 @@ void LSession::checkUserFiles(){ sessionsettings->setValue("DesktopVersion", this->applicationVersion()); } -void LSession::loadStyleSheet(){ - QString ss = QDir::homePath()+"/.lumina/stylesheet.qss"; - if(!QFile::exists(ss)){ ss = LOS::LuminaShare()+"stylesheet.qss"; } - if(!QFile::exists(ss)){ return; } //no default stylesheet on the system - //Now read/apply the custom stylesheet - QFile file(ss); - if( file.open(QIODevice::ReadOnly | QIODevice::Text) ){ - QTextStream in(&file); - QString sheet = in.readAll(); - file.close(); - //Now fix/apply the sheet - sheet.replace("\n"," "); //make sure there are no newlines - this->setStyleSheet(sheet); - } -} - void LSession::refreshWindowManager(){ WM->updateWM(); } diff --git a/lumina-desktop/LSession.h b/lumina-desktop/LSession.h index 3f3d31f9..cdf0cbd8 100644 --- a/lumina-desktop/LSession.h +++ b/lumina-desktop/LSession.h @@ -34,13 +34,13 @@ //#define SYSTEM_TRAY_BEGIN_MESSAGE 1 //#define SYSTEM_TRAY_CANCEL_MESSAGE 2 -class MenuProxyStyle : public QProxyStyle{ +/*class MenuProxyStyle : public QProxyStyle{ public: int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const{ if(metric==PM_SmallIconSize){ return 22; } //override QMenu icon size (make it larger) else{ return QProxyStyle::pixelMetric(metric, option, widget); } //use the current style for everything else } -}; +};*/ class LSession : public QApplication{ Q_OBJECT @@ -79,7 +79,6 @@ private slots: //Internal simplification functions void checkUserFiles(); - void loadStyleSheet(); void refreshWindowManager(); void updateDesktops(); diff --git a/lumina-desktop/main.cpp b/lumina-desktop/main.cpp index 690ae80d..fa23680b 100644 --- a/lumina-desktop/main.cpp +++ b/lumina-desktop/main.cpp @@ -20,6 +20,7 @@ #include "Globals.h" #include <LuminaXDG.h> //from libLuminaUtils +#include <LuminaThemes.h> QFile logfile(QDir::homePath()+"/.lumina/logs/runtime.log"); void MessageOutput(QtMsgType type, const char *msg){ @@ -62,6 +63,7 @@ int main(int argc, char ** argv) logfile.open(QIODevice::WriteOnly | QIODevice::Append); //Startup the Application LSession a(argc, argv); + LuminaThemeEngine theme(&a); //Setup Log File qInstallMsgHandler(MessageOutput); a.setupSession(); diff --git a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp index e581e1c2..ef5f271c 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp +++ b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp @@ -278,9 +278,11 @@ void UserWidget::slotOpenDir(){ void UserWidget::mouseMoveEvent( QMouseEvent *event){ QTabBar *wid = tabBar(); - qDebug() << "Mouse Move Event:"; - if(wid && wid->tabAt(event->pos()) != -1){ + if(wid==0){ return; } //invalid widget found + QPoint relpos = wid->mapFromGlobal( this->mapToGlobal(event->pos()) ); + //qDebug() << "Mouse Move Event: " << event->pos().x() << event->pos().y() << relpos.x() << relpos.y() << wid->width() << wid->height(); + if(wid && wid->tabAt(relpos) != -1){ qDebug() << " - Mouse over tab"; - this->setCurrentIndex( wid->tabAt(event->pos()) ); + this->setCurrentIndex( wid->tabAt(relpos) ); } }
\ No newline at end of file diff --git a/lumina-fm/MainUI.h b/lumina-fm/MainUI.h index 3984e109..fea56549 100644 --- a/lumina-fm/MainUI.h +++ b/lumina-fm/MainUI.h @@ -67,6 +67,9 @@ public: void OpenDirs(QStringList); //called from the main.cpp after initialization +public slots: + void setupIcons(); //used during initialization + private: Ui::MainUI *ui; //Internal non-ui widgets @@ -97,7 +100,6 @@ private: bool isUserWritable, keepFocus; //Simplification Functions - void setupIcons(); //used during initialization void setupConnections(); //used during initialization void loadSettings(); //used during initialization diff --git a/lumina-fm/main.cpp b/lumina-fm/main.cpp index 8d5a3f95..18c75223 100644 --- a/lumina-fm/main.cpp +++ b/lumina-fm/main.cpp @@ -9,7 +9,7 @@ #include "MainUI.h" #include <LuminaOS.h> -//#include <LuminaThemes.h> +#include <LuminaThemes.h> int main(int argc, char ** argv) { @@ -27,8 +27,7 @@ int main(int argc, char ** argv) QApplication a(argc, argv); #endif a.setApplicationName("Insight File Manager"); - //LuminaThemeEngine themes(&a); - //qDebug() << "StyleSheet:\n" << a.styleSheet(); + LuminaThemeEngine themes(&a); //Load current Locale QTranslator translator; QLocale mylocale; @@ -45,6 +44,7 @@ int main(int argc, char ** argv) MainUI w; QObject::connect(&a, SIGNAL(messageReceived(const QString&)), &w, SLOT(slotSingleInstance(const QString&)) ); + QObject::connect(&themes, SIGNAL(updateIcons()), &w, SLOT(setupIcons()) ); w.OpenDirs(in); w.show(); diff --git a/lumina-open/main.cpp b/lumina-open/main.cpp index c0e7be0f..f3695085 100644 --- a/lumina-open/main.cpp +++ b/lumina-open/main.cpp @@ -29,6 +29,7 @@ #include <LuminaXDG.h> #include <LuminaUtils.h> #include <LuminaOS.h> +#include <LuminaThemes.h> void printUsageInfo(){ qDebug() << "lumina-open: Application launcher for the Lumina Desktop Environment"; @@ -102,6 +103,7 @@ QString cmdFromUser(int argc, char **argv, QString inFile, QString extension, QS if(extension=="directory" && !showDLG){ return "lumina-fm"; } //No default set -- Start up the application selection dialog QApplication App(argc, argv); + LuminaThemeEngine theme(&App); QTranslator translator; QLocale mylocale; QString langCode = mylocale.name(); @@ -303,6 +305,7 @@ int main(int argc, char **argv){ qDebug() << "[lumina-open] Application Error:" << retcode; //Setup the application QApplication App(argc, argv); + LuminaThemeEngine theme(&App); QTranslator translator; QLocale mylocale; QString langCode = mylocale.name(); diff --git a/lumina-screenshot/MainUI.cpp b/lumina-screenshot/MainUI.cpp index 34fec43a..5ff698bd 100644 --- a/lumina-screenshot/MainUI.cpp +++ b/lumina-screenshot/MainUI.cpp @@ -16,11 +16,9 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ QWidget *spacer = new QWidget(); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); ui->toolBar->insertWidget(ui->actionNew, spacer); - //Setup the icons - this->setWindowIcon( LXDG::findIcon("camera-web","") ); - ui->actionSave->setIcon( LXDG::findIcon("document-save","") ); - ui->actionQuit->setIcon( LXDG::findIcon("application-exit","") ); - ui->actionNew->setIcon( LXDG::findIcon("camera-web","") ); + + setupIcons(); + //Setup the connections connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(saveScreenshot()) ); connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(closeApplication()) ); @@ -43,6 +41,14 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ MainUI::~MainUI(){} +void MainUI::setupIcons(){ + //Setup the icons + this->setWindowIcon( LXDG::findIcon("camera-web","") ); + ui->actionSave->setIcon( LXDG::findIcon("document-save","") ); + ui->actionQuit->setIcon( LXDG::findIcon("application-exit","") ); + ui->actionNew->setIcon( LXDG::findIcon("camera-web","") ); +} + //============== // PRIVATE SLOTS //============== diff --git a/lumina-screenshot/MainUI.h b/lumina-screenshot/MainUI.h index 0e60bda6..c350f366 100644 --- a/lumina-screenshot/MainUI.h +++ b/lumina-screenshot/MainUI.h @@ -30,6 +30,9 @@ public: MainUI(); ~MainUI(); +public slots: + void setupIcons(); + private: Ui::MainUI *ui; QPixmap cpic; //current picture diff --git a/lumina-screenshot/main.cpp b/lumina-screenshot/main.cpp index 0b564f71..b7112a4d 100644 --- a/lumina-screenshot/main.cpp +++ b/lumina-screenshot/main.cpp @@ -5,10 +5,12 @@ #include "MainUI.h" #include <LuminaOS.h> +#include <LuminaThemes.h> int main(int argc, char ** argv) { QApplication a(argc, argv); + LuminaThemeEngine theme(&a); a.setApplicationName("Take Screenshot"); QTranslator translator; QLocale mylocale; @@ -20,6 +22,7 @@ int main(int argc, char ** argv) qDebug() << "Locale:" << langCode; MainUI w; + QObject::connect(&theme,SIGNAL(updateIcons()), &w, SLOT(setupIcons()) ); w.show(); return a.exec(); diff --git a/port-files/Makefile b/port-files/Makefile index 249d4009..aae5603e 100644 --- a/port-files/Makefile +++ b/port-files/Makefile @@ -3,7 +3,7 @@ PORTNAME= lumina GITVERSION= CHGVERSION -PORTVERSION= 0.6.3.${GITVERSION} +PORTVERSION= 0.7.0.${GITVERSION} PORTEPOCH= 1 CATEGORIES= x11 DISTNAME= ${PORTNAME}-${GITVERSION} diff --git a/port-files/pkg-plist b/port-files/pkg-plist index 21ecd65f..615adc2b 100644 --- a/port-files/pkg-plist +++ b/port-files/pkg-plist @@ -24,7 +24,7 @@ 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/Lumina-DE/themes/Lumina-default.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 |