aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Moore <ken@pcbsd.org>2014-10-14 16:01:39 -0400
committerKen Moore <ken@pcbsd.org>2014-10-14 16:01:39 -0400
commit6c491c85494cdcbc750491817b68396775e9b04e (patch)
tree2c3ac506fd02e73bef5240a06a648ec6f5dc03dc
parentLarge update to the Lumina project: provide full theming capabilities. (diff)
downloadlumina-6c491c85494cdcbc750491817b68396775e9b04e.tar.gz
lumina-6c491c85494cdcbc750491817b68396775e9b04e.tar.bz2
lumina-6c491c85494cdcbc750491817b68396775e9b04e.zip
Finish up the rest of the new Lumina Theme engine and the utilities for editing those themes in lumina-config. Also tag Lumina version 0.7.0 with this change.
-rw-r--r--libLumina/LuminaThemes.cpp5
-rw-r--r--libLumina/LuminaUtils.cpp4
-rw-r--r--libLumina/colors/SampleColors.qss.colors1
-rw-r--r--lumina-config/ColorDialog.cpp139
-rw-r--r--lumina-config/ColorDialog.h60
-rw-r--r--lumina-config/ColorDialog.ui145
-rw-r--r--lumina-config/LPlugins.cpp91
-rw-r--r--lumina-config/LPlugins.h10
-rw-r--r--lumina-config/ThemeDialog.cpp71
-rw-r--r--lumina-config/ThemeDialog.h58
-rw-r--r--lumina-config/ThemeDialog.ui104
-rw-r--r--lumina-config/lumina-config.pro12
-rw-r--r--lumina-config/mainUI.cpp63
-rw-r--r--lumina-config/mainUI.h4
-rw-r--r--lumina-desktop/LDesktop.cpp2
-rw-r--r--lumina-desktop/LSession.cpp2
-rw-r--r--port-files/Makefile2
17 files changed, 752 insertions, 21 deletions
diff --git a/libLumina/LuminaThemes.cpp b/libLumina/LuminaThemes.cpp
index 8548f739..0b328502 100644
--- a/libLumina/LuminaThemes.cpp
+++ b/libLumina/LuminaThemes.cpp
@@ -85,13 +85,13 @@ QStringList LTHEME::availableSystemIcons(){ //returns: [name] for each item
//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); }
+ 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); }
+ if(!QFile::exists(localdir)){ QDir dir; dir.mkpath(localdir); }
return LUtils::writeFile(localdir+name+".qss.colors", contents, true);
}
@@ -154,6 +154,7 @@ QString LTHEME::assembleStyleSheet(QString themepath, QString colorpath, QString
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);
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/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/mainUI.cpp b/lumina-config/mainUI.cpp
index b9c83f42..756fc016 100644
--- a/lumina-config/mainUI.cpp
+++ b/lumina-config/mainUI.cpp
@@ -205,7 +205,8 @@ void MainUI::setupConnections(){
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(){
@@ -1383,28 +1384,28 @@ void MainUI::loadSessionSettings(){
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(i); }
+ 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(i); }
+ 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(i); }
+ 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(i); }
+ if(tmp[i].section("::::",1,1)==current[1]){ ui->combo_session_colorfile->setCurrentIndex(ui->combo_session_colorfile->count()-1); }
}
// - icon themes
tmp = LTHEME::availableSystemIcons();
@@ -1536,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 038651d7..0031a45f 100644
--- a/lumina-config/mainUI.h
+++ b/lumina-config/mainUI.h
@@ -27,6 +27,8 @@
#include "LPlugins.h"
#include "KeyCatch.h"
#include "AppDialog.h"
+#include "ColorDialog.h"
+#include "ThemeDialog.h"
//namespace for using the *.ui file
namespace Ui{
@@ -152,6 +154,8 @@ private slots:
void sessionoptchanged();
void sessionthemechanged();
void sessionstartchanged();
+ void sessionEditColor();
+ void sessionEditTheme();
};
#endif
diff --git a/lumina-desktop/LDesktop.cpp b/lumina-desktop/LDesktop.cpp
index 9751c487..81d57cb8 100644
--- a/lumina-desktop/LDesktop.cpp
+++ b/lumina-desktop/LDesktop.cpp
@@ -48,7 +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; }" );
+ 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 055c0a69..876db93a 100644
--- a/lumina-desktop/LSession.cpp
+++ b/lumina-desktop/LSession.cpp
@@ -29,7 +29,7 @@ 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
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}
bgstack15