aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libLumina/LuminaOS-FreeBSD.cpp2
-rw-r--r--libLumina/LuminaThemes.cpp94
-rw-r--r--libLumina/LuminaThemes.h19
-rw-r--r--libLumina/LuminaUtils.cpp21
-rw-r--r--libLumina/LuminaUtils.h2
-rw-r--r--libLumina/LuminaX11.cpp5
-rw-r--r--libLumina/themes/Lumina-default.qss.template4
-rw-r--r--libLumina/themes/None.qss.template4
8 files changed, 139 insertions, 12 deletions
diff --git a/libLumina/LuminaOS-FreeBSD.cpp b/libLumina/LuminaOS-FreeBSD.cpp
index 7ca6c876..21d0552d 100644
--- a/libLumina/LuminaOS-FreeBSD.cpp
+++ b/libLumina/LuminaOS-FreeBSD.cpp
@@ -185,7 +185,7 @@ bool LOS::userHasShutdownAccess(){
}
bool LOS::systemPerformingUpdates(){
- return (QProcess::execute("pgrep -F /tmp/.updateInProgress")!=0); //this is 0 if updating right now
+ return (QProcess::execute("pgrep -F /tmp/.updateInProgress")==0); //this is 0 if updating right now
}
//System Shutdown
diff --git a/libLumina/LuminaThemes.cpp b/libLumina/LuminaThemes.cpp
index 17ddc60d..b64ace0f 100644
--- a/libLumina/LuminaThemes.cpp
+++ b/libLumina/LuminaThemes.cpp
@@ -12,6 +12,8 @@
#include <QFont>
#include <QDebug>
#include <QObject>
+#include <QPainter>
+#include <QPen>
#include <unistd.h>
@@ -310,21 +312,91 @@ QString LTHEME::readCustomEnvSetting(QString var){
return "";
}
+// =========================
+// LuminaThemeStyle
+// =========================
+LuminaThemeStyle::LuminaThemeStyle() : QProxyStyle(){
+ this->update();
+}
+
+LuminaThemeStyle::~LuminaThemeStyle(){
+
+}
+
+//Function to update the style (for use by the theme engine)
+void LuminaThemeStyle::update(){
+ darkfont = true; //make this dynamic later
+}
+
+//Subclassed functions
+void LuminaThemeStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &palette, bool enabled, const QString &text, QPalette::ColorRole textRole) const{
+ /*QFont cfont = painter->font();
+ cfont.setHintingPreference(QFont::PreferFullHinting);
+ QFont outfont = cfont;
+ outfont.setStretch(101);
+ outfont.setLetterSpacing(QFont::PercentageSpacing, 99);
+ //Paint the background outline
+ if(darkfont){ painter->setPen(QPen(Qt::white)); }
+ else{ painter->setPen(QPen(Qt::black)); }
+ painter->setFont(outfont);
+ //QRect outline = QRect(rect.left()+2, rect.top()+2, rect.right()+2, rect.bottom()+2);
+ painter->drawText(rect, text);
+
+ //Paint the text itself (Make this respect the "enabled" flag later)
+ painter->setFont(cfont);
+ if(darkfont){ painter->setPen(QPen(Qt::black)); }
+ else{ painter->setPen(QPen(Qt::white)); }
+ painter->drawText(rect, text);*/
+
+ QFont font = painter->font();
+ QFont cfont = font; //save for later
+ if(font.pixelSize()>0){ font.setPixelSize( font.pixelSize()-4); }
+ else{ font.setPointSize(font.pointSize()-1); }
+ painter->setFont(font);
+ //Create the path
+ QPainterPath path;
+ //path.setFillRule(Qt::WindingFill);
+ path.addText(rect.left(), rect.center().y()+(painter->fontMetrics().xHeight()/2), painter->font(), text);
+ //Now set the border/fill colors
+ QPen pen;
+ pen.setWidth(2);
+ if(darkfont){
+ pen.setColor(Qt::white);
+ painter->fillPath(path,Qt::black);
+ }else{
+ pen.setColor(Qt::black);
+ painter->fillPath(path,Qt::white);
+ }
+ painter->setPen(pen);
+ painter->drawPath(path);
+ painter->setFont(cfont); //reset back to original font
+
+}
+
+
//==================
// THEME ENGINE CLASS
//==================
LuminaThemeEngine::LuminaThemeEngine(QApplication *app){
application=app; //save this pointer for later
+ //style = new LuminaThemeStyle();
+ //Set the application-wide style
+ //application->setStyle( style );
+
lastcheck = QDateTime::currentDateTime(); //
- //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]; font=current[3]; fontsize=current[4];
cursors = LTHEME::currentCursor();
application->setStyleSheet( LTHEME::assembleStyleSheet(theme, colors, font, fontsize) );
+ //Make sure to prefer font antialiasing on the application
+ /*QFont tmp = application->font();
+ tmp.setStyleStrategy(QFont::PreferOutline);
+ tmp.setFamily(font);
+ tmp.setHintingPreference(QFont::PreferFullHinting);
+ if(fontsize.endsWith("pt")){ tmp.setPointSize(fontsize.section("pt",0,0).toInt()); }
+ else if(fontsize.endsWith("px")){ tmp.setPixelSize(fontsize.section("px",0,0).toInt()); }
+ application->setFont(tmp);*/
QIcon::setThemeName(icons); //make sure this sets set within this environment
syncTimer = new QTimer(this);
syncTimer->setSingleShot(true);
@@ -333,6 +405,7 @@ LuminaThemeEngine::LuminaThemeEngine(QApplication *app){
LTHEME::setCursorTheme("default"); //X11 fallback (always installed?)
cursors = "default";
}
+
//setenv("XCURSOR_THEME", cursors.toLocal8Bit(),1);
watcher = new QFileSystemWatcher(this);
watcher->addPath( QDir::homePath()+"/.lumina/envsettings.conf" );
@@ -361,7 +434,17 @@ void LuminaThemeEngine::reloadFiles(){
emit updateIcons();
}
//save the settings for comparison later
- theme = current[0]; colors=current[1]; icons=current[2]; font=current[3]; fontsize=current[4];
+ theme = current[0]; colors=current[1]; icons=current[2];
+
+ if(font!=current[3] || fontsize!=current[4]){
+ font=current[3]; fontsize=current[4];
+ QFont tmp = application->font();
+ tmp.setStyleStrategy(QFont::PreferOutline);
+ tmp.setFamily(font);
+ if(fontsize.endsWith("pt")){ tmp.setPointSize(fontsize.section("pt",0,0).toInt()); }
+ else if(fontsize.endsWith("px")){ tmp.setPixelSize(fontsize.section("px",0,0).toInt()); }
+ application->setFont(tmp);
+ }
}
//Check the Cursor file/settings
if(lastcheck < QFileInfo(QDir::homePath()+"/.icons/default/index.theme").lastModified()){
@@ -394,3 +477,4 @@ void LuminaThemeEngine::reloadFiles(){
watcher->removePaths( QStringList() << theme << colors << QDir::homePath()+"/.icons/default/index.theme" << QDir::homePath()+"/.lumina/envsettings.conf");
watcher->addPaths( QStringList() << theme << colors << QDir::homePath()+"/.icons/default/index.theme" << QDir::homePath()+"/.lumina/envsettings.conf");
}
+
diff --git a/libLumina/LuminaThemes.h b/libLumina/LuminaThemes.h
index 6dcff89d..4ded0527 100644
--- a/libLumina/LuminaThemes.h
+++ b/libLumina/LuminaThemes.h
@@ -18,6 +18,8 @@
#include <QDir>
#include <QTimer>
#include <QDateTime>
+#include <QStyle>
+#include <QProxyStyle>
class LTHEME{
public:
@@ -55,6 +57,22 @@ public:
};
+// Qt Style override to allow custom themeing/colors
+class LuminaThemeStyle : public QProxyStyle{
+ Q_OBJECT
+private:
+ bool darkfont;
+
+public:
+ LuminaThemeStyle();
+ ~LuminaThemeStyle();
+
+ //Function to update the style (for use by the theme engine)
+ void update();
+ //Subclassed functions
+ void drawItemText(QPainter*, const QRect&, int, const QPalette&, bool, const QString&, QPalette::ColorRole) const;
+
+};
//Simple class to setup a utility to use the Lumina theme
//-----Example usage in "main.cpp" -------------------------------
@@ -80,6 +98,7 @@ private:
QString theme,colors,icons, font, fontsize, cursors; //current settings
QTimer *syncTimer;
QDateTime lastcheck;
+ LuminaThemeStyle *style;
private slots:
void watcherChange();
diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp
index c4091fbc..f45c3813 100644
--- a/libLumina/LuminaUtils.cpp
+++ b/libLumina/LuminaUtils.cpp
@@ -306,6 +306,27 @@ QString LUtils::BytesToDisplaySize(qint64 ibytes){
return (num+labs[c]);
}
+QString LUtils::SecondsToDisplay(int secs){
+ if(secs < 0){ return "??"; }
+ QString rem; //remaining
+ if(secs > 3600){
+ int hours = secs/3600;
+ rem.append( QString::number(hours)+"h ");
+ secs = secs - (hours*3600);
+ }
+ if(secs > 60){
+ int min = secs/60;
+ rem.append( QString::number(min)+"m ");
+ secs = secs - (min*60);
+ }
+ if(secs > 0){
+ rem.append( QString::number(secs)+"s");
+ }else{
+ rem.append( "0s" );
+ }
+ return rem;
+}
+
//Various function for finding valid QtQuick plugins on the system
bool LUtils::validQuickPlugin(QString ID){
return ( !LUtils::findQuickPluginFile(ID).isEmpty() );
diff --git a/libLumina/LuminaUtils.h b/libLumina/LuminaUtils.h
index 06552d1f..f68cf413 100644
--- a/libLumina/LuminaUtils.h
+++ b/libLumina/LuminaUtils.h
@@ -61,6 +61,8 @@ public:
static double DisplaySizeToBytes(QString num); //Turn a display size (like 50M or 50KB) into a double for calculations (bytes)
static QString BytesToDisplaySize(qint64 bytes); //convert into a readable size (like 50M or 50KB)
+ static QString SecondsToDisplay(int secs); //convert into a readable time
+
//Various function for finding valid QtQuick plugins on the system
static bool validQuickPlugin(QString ID);
static QString findQuickPluginFile(QString ID);
diff --git a/libLumina/LuminaX11.cpp b/libLumina/LuminaX11.cpp
index d16c838b..5f4afab4 100644
--- a/libLumina/LuminaX11.cpp
+++ b/libLumina/LuminaX11.cpp
@@ -815,8 +815,9 @@ uint LXCB::EmbedWindow(WId win, WId container){
//Now setup any redirects and return
//qDebug() << " - select Input";
//XSelectInput(disp, win, StructureNotifyMask); //Notify of structure changes
- uint32_t val[] = {XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY};
- xcb_change_window_attributes(QX11Info::connection(), win, XCB_CW_EVENT_MASK, val);
+ //uint32_t val[] = {XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY};
+ //xcb_change_window_attributes(QX11Info::connection(), win, XCB_CW_EVENT_MASK, val);
+ this->SelectInput(win);
//qDebug() << " - Composite Redirect";
xcb_composite_redirect_window(QX11Info::connection(), win, XCB_COMPOSITE_REDIRECT_MANUAL);
diff --git a/libLumina/themes/Lumina-default.qss.template b/libLumina/themes/Lumina-default.qss.template
index 6799f8cb..7f0f185e 100644
--- a/libLumina/themes/Lumina-default.qss.template
+++ b/libLumina/themes/Lumina-default.qss.template
@@ -63,11 +63,11 @@ LDPlugin#desktopview QListWidget::item:hover{
}
/*For the special widgets on the user button*/
-UserItemWidget{
+UserItemWidget, ItemWidget{
background: transparent;
border-radius: 3px;
}
-UserItemWidget:hover{
+UserItemWidget:hover, ItemWidget:hover{
background: %%HIGHLIGHTCOLOR%%;
color: %%TEXTHIGHLIGHTCOLOR%%;
}
diff --git a/libLumina/themes/None.qss.template b/libLumina/themes/None.qss.template
index 4b1d302d..a2c2e016 100644
--- a/libLumina/themes/None.qss.template
+++ b/libLumina/themes/None.qss.template
@@ -60,11 +60,11 @@ LDPlugin#desktopview QListWidget::item:hover{
color: %%TEXTHIGHLIGHTCOLOR%%;
}
/*For the special widgets on the user button*/
-UserItemWidget{
+UserItemWidget, ItemWidget{
background: transparent;
border-radius: 3px;
}
-UserItemWidget:hover{
+UserItemWidget:hover, ItemWidget:hover{
background: %%HIGHLIGHTCOLOR%%;
color: %%TEXTHIGHLIGHTCOLOR%%;
}
bgstack15