[PC-BSD Commits] r21484 - pcbsd-projects/PCDM
svn at pcbsd.org
svn at pcbsd.org
Wed Feb 13 15:20:13 PST 2013
Author: kenmoore
Date: 2013-02-13 23:20:13 +0000 (Wed, 13 Feb 2013)
New Revision: 21484
Added:
pcbsd-projects/PCDM/themeItem.h
Modified:
pcbsd-projects/PCDM/PCDM.pro
pcbsd-projects/PCDM/loginWidget.cpp
pcbsd-projects/PCDM/loginWidget.h
pcbsd-projects/PCDM/main.cpp
pcbsd-projects/PCDM/pcdm-backend.cpp
pcbsd-projects/PCDM/pcdm-backend.h
pcbsd-projects/PCDM/pcdm-config.cpp
pcbsd-projects/PCDM/pcdm-config.h
pcbsd-projects/PCDM/pcdm-gui.cpp
pcbsd-projects/PCDM/pcdm-gui.h
pcbsd-projects/PCDM/pcdm.conf
pcbsd-projects/PCDM/themeStruct.cpp
pcbsd-projects/PCDM/themeStruct.h
Log:
Convert PCDM completely over to the new themeing structure. Now it just needs to be tested
Modified: pcbsd-projects/PCDM/PCDM.pro
===================================================================
--- pcbsd-projects/PCDM/PCDM.pro 2013-02-13 21:46:36 UTC (rev 21483)
+++ pcbsd-projects/PCDM/PCDM.pro 2013-02-13 23:20:13 UTC (rev 21484)
@@ -6,7 +6,7 @@
SOURCES += main.cpp \
pcdm-gui.cpp \
pcdm-backend.cpp \
- pcdm-themes.cpp \
+ themeStruct.cpp \
pcdm-config.cpp \
pcdm-xprocess.cpp \
fancySwitcher.cpp \
@@ -16,7 +16,8 @@
HEADERS += pcdm-gui.h \
pcdm-backend.h \
- pcdm-themes.h \
+ themeStruct.h \
+ themeItem.h \
pcdm-config.h \
pcdm-xprocess.h \
fancySwitcher.h \
Modified: pcbsd-projects/PCDM/loginWidget.cpp
===================================================================
--- pcbsd-projects/PCDM/loginWidget.cpp 2013-02-13 21:46:36 UTC (rev 21483)
+++ pcbsd-projects/PCDM/loginWidget.cpp 2013-02-13 23:20:13 UTC (rev 21484)
@@ -173,19 +173,18 @@
retranslateUi();
}
-void LoginWidget::setIconSize(int xysize){
- //Update the pushbuttons icons
- pushUserIcon->resize(QSize(xysize,xysize));
- pushLogin->setIconSize(QSize(xysize,xysize));
-
-}
-
-void LoginWidget::changeButtonIcon(QString button, QString iconFile){
+void LoginWidget::changeButtonIcon(QString button, QString iconFile, QSize iconSize){
if(!QFile::exists(iconFile)){ qDebug() << "LoginWidget: invalid image file"<<iconFile; return; }
- if(button.toLower() == "display"){ pushUserIcon->defaultAction()->setIcon(QIcon(iconFile)); }
- else if(button.toLower() == "login"){ pushLogin->defaultAction()->setIcon(QIcon(iconFile)); }
- else if(button.toLower() == "pwview"){ pushViewPassword->defaultAction()->setIcon(QIcon(iconFile)); }
- else{
+ if(button.toLower() == "display"){
+ pushUserIcon->resize(iconSize);
+ pushUserIcon->defaultAction()->setIcon(QIcon(iconFile));
+ }else if(button.toLower() == "login"){
+ pushLogin->setIconSize(iconSize);
+ pushLogin->defaultAction()->setIcon(QIcon(iconFile));
+ }else if(button.toLower() == "pwview"){
+ pushViewPassword->resize(iconSize);
+ pushViewPassword->defaultAction()->setIcon(QIcon(iconFile));
+ }else{
qDebug() << "LoginWidget: Cannot change the icon for button" << button << " - valid buttons are \"display\", \"login\", and \"pwview\"";
}
}
Modified: pcbsd-projects/PCDM/loginWidget.h
===================================================================
--- pcbsd-projects/PCDM/loginWidget.h 2013-02-13 21:46:36 UTC (rev 21483)
+++ pcbsd-projects/PCDM/loginWidget.h 2013-02-13 23:20:13 UTC (rev 21484)
@@ -33,10 +33,8 @@
void setCurrentUser(QString);
void setUsernames(QStringList);
void displayHostName(QString);
- //Set x-y size (in pixels) to scale all images (best before adding items)
- void setIconSize(int xysize);
//Manually set the "back" (up/left) and "forward" (down/right) button icons
- void changeButtonIcon(QString button, QString iconFile);
+ void changeButtonIcon(QString button, QString iconFile, QSize iconSize);
//Change the style sheet for all widget items (see QtStyle options for more)
void changeStyleSheet(QString item, QString style);
Modified: pcbsd-projects/PCDM/main.cpp
===================================================================
--- pcbsd-projects/PCDM/main.cpp 2013-02-13 21:46:36 UTC (rev 21483)
+++ pcbsd-projects/PCDM/main.cpp 2013-02-13 23:20:13 UTC (rev 21484)
@@ -6,7 +6,6 @@
#include <QSplashScreen>
#include <QDebug>
-#include "pcdm-themes.h"
#include "pcdm-gui.h"
#include "pcdm-backend.h"
#include "pcdm-config.h"
@@ -27,15 +26,15 @@
// Load the configuration file
Config::loadConfigFile("/usr/local/share/PCDM/pcdm.conf");
// Load the Desired Theme
- Theme::loadTheme(Config::themeFile());
+ //Theme::loadTheme(Config::themeFile());
// Startup the main application
QApplication a(argc,argv);
// Show our splash screen, so the user doesn't freak that that it takes a few seconds to show up
QSplashScreen splash;
- if(Theme::useSplashscreen()){
- splash.setPixmap( QPixmap(Theme::splashscreen()) ); //load the splashscreen file
+ if(!Config::splashscreen().isEmpty()){
+ splash.setPixmap( QPixmap(Config::splashscreen()) ); //load the splashscreen file
}
splash.show();
@@ -90,10 +89,10 @@
PCDMgui w;
//Set the proper size on the Application
- if(Theme::isFullScreen() ){
+ //if(Theme::isFullScreen() ){
w.setWindowFlags(w.windowFlags() ^Qt::WindowSoftkeysVisibleHint);
w.setWindowState(Qt::WindowFullScreen);
- }else{
+ /*}else{
//Get the screen and desired geometries
QRect dimensions = QApplication::desktop()->screenGeometry();
int wid = dimensions.width(); // returns desktop width
@@ -105,7 +104,7 @@
if(thWid > wid){ thWid = wid; }
// Center the Application
w.setGeometry((wid/2) - (thWid/2), (hig/2) - (thHig/2), thWid, thHig);
- }
+ }*/
//Setup the signals/slots to startup the desktop session
QObject::connect( &w,SIGNAL(xUserFound(QString)), &desktop,SLOT(setXUsername(QString)) );
QObject::connect( &w,SIGNAL(xCmdFound(QString)), &desktop,SLOT(setXCommand(QString)) );
@@ -119,20 +118,6 @@
Backend::startXSession();
} // end of PCDM GUI running
- /*
- if ( QFile::exists(TMPLANGFILE) ) {
- QFile lfile(TMPLANGFILE);
- if (!lfile.open(QIODevice::ReadOnly | QIODevice::Text))
- return 150;
- changeLang = lfile.readLine();
- lfile.close();
- Backend::log("Language switch requested for:" + changeLang);
- QFile::remove(TMPLANGFILE);
-
- } else {
- break;
- }
- */
//Wait for the desktop session to finish before exiting
desktop.waitForFinished();
Modified: pcbsd-projects/PCDM/pcdm-backend.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.cpp 2013-02-13 21:46:36 UTC (rev 21483)
+++ pcbsd-projects/PCDM/pcdm-backend.cpp 2013-02-13 23:20:13 UTC (rev 21484)
@@ -363,7 +363,6 @@
if(!tmp.isEmpty()){
//Complete file paths if necessary
if(!tmp[0].startsWith("/")){ tmp[0] = "/usr/local/bin/"+tmp[0]; }
- if(tmp[3].isEmpty()){ tmp[3] = Theme::objectIconPath("desktop"); }
if(!tmp[3].startsWith("/")&&!tmp[3].startsWith(":")){ tmp[3] = xIconDir+tmp[3]; }
if(!tmp[4].startsWith("/")){ tmp[4] = "/usr/local/bin/"+tmp[4]; }
//Check for valid DE
@@ -373,10 +372,7 @@
instXNameList << tmp[1];
instXCommentList << tmp[2];
//Check to make sure we have a valid icon
- if( !QFile::exists(tmp[3]) ){
- //Use the default Theme icon otherwise
- tmp[3] = Theme::objectIconPath("desktop");
- }
+ if( !QFile::exists(tmp[3]) ){ tmp[3] = ""; }
instXIconList << tmp[3];
Backend::log( "PCDM: Found xsession: " + tmp.join(" ") );
}
Modified: pcbsd-projects/PCDM/pcdm-backend.h
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.h 2013-02-13 21:46:36 UTC (rev 21483)
+++ pcbsd-projects/PCDM/pcdm-backend.h 2013-02-13 23:20:13 UTC (rev 21484)
@@ -13,7 +13,6 @@
#include "pcdm-config.h"
#include "pcbsd-utils.h"
-#include "pcdm-themes.h"
#define PCSYSINSTALL QString("/usr/sbin/pc-sysinstall")
Modified: pcbsd-projects/PCDM/pcdm-config.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-config.cpp 2013-02-13 21:46:36 UTC (rev 21483)
+++ pcbsd-projects/PCDM/pcdm-config.cpp 2013-02-13 23:20:13 UTC (rev 21484)
@@ -14,6 +14,7 @@
confStruct << "FALSE"; // [3] Auto-login enabled
confStruct << "no-username"; // [4] Auto-login username
confStruct << "no-desktop"; // [5] Auto-login desktop environment
+ confStruct << "/usr/local/share/PCDM/images/default-splash.png"; // [6] Splash Screen File
return;
}
@@ -41,6 +42,7 @@
else if(var=="ENABLE_AUTO_LOGIN"){ confStruct[3] = val; }
else if(var=="AUTO_LOGIN_USER"){ confStruct[4] = val; }
else if(var=="AUTO_LOGIN_DESKTOP"){ confStruct[5] = val; }
+ else if(var=="SPLASHSCREEN_FILE"){ confStruct[6] = val; }
else{}
}
@@ -84,3 +86,7 @@
if(confStruct.startsWith("/")){ return confStruct[5]; } //already an absolute path
else{ return (confStruct[1]+"/"+confStruct[5]); } //prepend the xsessions directory path
}
+
+QString Config::splashscreen(){
+ return confStruct[6];
+}
Modified: pcbsd-projects/PCDM/pcdm-config.h
===================================================================
--- pcbsd-projects/PCDM/pcdm-config.h 2013-02-13 21:46:36 UTC (rev 21483)
+++ pcbsd-projects/PCDM/pcdm-config.h 2013-02-13 23:20:13 UTC (rev 21484)
@@ -23,7 +23,7 @@
static bool useAutoLogin(); //returns whether auto-login is enabled
static QString autoLoginUsername(); //returns username to log into automatically
static QString autoLoginDesktop(); //return *.desktop file to startup automatically
-
+ static QString splashscreen(); //return the image file for the splashscreen
};
Modified: pcbsd-projects/PCDM/pcdm-gui.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-gui.cpp 2013-02-13 21:46:36 UTC (rev 21483)
+++ pcbsd-projects/PCDM/pcdm-gui.cpp 2013-02-13 23:20:13 UTC (rev 21484)
@@ -12,6 +12,9 @@
PCDMgui::PCDMgui() : QMainWindow()
{
+ //Load the Theme
+ loadTheme();
+
//Create the GUI based upon the current Theme
createGUIfromTheme();
@@ -22,21 +25,37 @@
//delete ui;
}
+void PCDMgui::loadTheme(){
+ currentTheme = new ThemeStruct();
+ currentTheme->loadThemeFile( Config::themeFile() );
+ //Check the Theme, using default values as necessary
+ QStringList invalid = currentTheme->invalidItems();
+ if( !invalid.isEmpty() ){
+ ThemeStruct* defaultTheme = new ThemeStruct();
+ defaultTheme->loadThemeFile( ":samples/pcdm.theme" );
+ for( int i=0; i<invalid.length(); i++){
+ //Replace the invalid items with the defaults
+ currentTheme->importItem( invalid[i] , defaultTheme->exportItem(invalid[i]) );
+ }
+ }
+
+}
+
void PCDMgui::createGUIfromTheme(){
QString style;
//Fill a couple global variables
kModels = Backend::keyModels();
kLayouts = Backend::keyLayouts();
//Set the background image
- if(Theme::customBackground()){
+ if( !currentTheme->itemIcon("background").isEmpty() ){
//use "border-image" instead of "background-image" to stretch rather than tile the image
QString bgstyle = "PCDMgui {border-image: url(BGIMAGE) stretch;}";
- bgstyle.replace("BGIMAGE",Theme::background() );
+ bgstyle.replace("BGIMAGE", currentTheme->itemIcon("background") );
style.append(bgstyle);
}
//Set the application style sheet
- style.append(" "+Theme::appstylesheet);
- this->setStyleSheet(style);
+ style.append(" "+ currentTheme->styleSheet() );
+ this->setStyleSheet( style.simplified() );
//get the default translation directory
translationDir = QApplication::applicationDirPath() + "/i18n/";
//Fill the translator
@@ -44,29 +63,44 @@
//Create the Toolbar
toolbar = new QToolBar();
//Add the Toolbar to the window
- this->addToolBar( Theme::toolbarLocation(), toolbar ); //use the theme location
+ //use the theme location
+ QString tarea = currentTheme->itemValue("toolbar");
+ if(tarea == "left"){
+ this->addToolBar( Qt::LeftToolBarArea, toolbar );
+ }else if( tarea=="top"){
+ this->addToolBar( Qt::TopToolBarArea, toolbar );
+ }else if(tarea=="right"){
+ this->addToolBar( Qt::RightToolBarArea, toolbar );
+ }else{ //bottom is default
+ this->addToolBar( Qt::BottomToolBarArea, toolbar );
+ }
+ //Set toolbar flags
toolbar->setVisible(TRUE);
toolbar->setMovable(FALSE);
toolbar->setFloatable(FALSE);
//Set the default style and icon sizes
- toolbar->setToolButtonStyle( Theme::toolbarStyle() ); //use the theme style
- toolbar->setIconSize( QSize(Theme::toolbarSizeWidth(),Theme::toolbarSizeHeight()) ); //use theme size
- toolbar->setStyleSheet(Theme::objectStyleSheet("toolbar"));
+ QString tstyle = currentTheme->itemIcon("toolbar").toLower(); //use the theme style
+ if(tstyle=="textonly"){ toolbar->setToolButtonStyle(Qt::ToolButtonTextOnly); }
+ else if(tstyle=="textbesideicon"){ toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); }
+ else if(tstyle=="textundericon"){ toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); }
+ else{ toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly); } //default to icon only
+ toolbar->setIconSize( currentTheme->itemIconSize("toolbar") ); //use theme size
+
//Populate the Toolbar with items (starts at leftmost/topmost)
//----Virtual Keyboard
- virtkeyboardButton = new QAction( QIcon(Theme::objectIconPath("virt-keyboard")),tr("Virtual Keyboard"),this );
+ virtkeyboardButton = new QAction( QIcon(currentTheme->itemIcon("vkeyboard")),tr("Virtual Keyboard"),this );
toolbar->addAction(virtkeyboardButton);
connect( virtkeyboardButton, SIGNAL(triggered()), this, SLOT(slotPushVirtKeyboard()) );
//----Locale Switcher
- localeButton = new QAction( QIcon(Theme::objectIconPath("locale")),tr("Locale"),this );
+ localeButton = new QAction( QIcon(currentTheme->itemIcon("locale")),tr("Locale"),this );
toolbar->addAction(localeButton);
connect( localeButton, SIGNAL(triggered()), this, SLOT(slotChangeLocale()) );
//----Keyboard Layout Switcher
- keyboardButton = new QAction( QIcon(Theme::objectIconPath("keyboard")),tr("Keyboard Layout"),this );
+ keyboardButton = new QAction( QIcon(currentTheme->itemIcon("keyboard")),tr("Keyboard Layout"),this );
toolbar->addAction(keyboardButton);
connect( keyboardButton, SIGNAL(triggered()), this, SLOT(slotChangeKeyboardLayout()) );
@@ -76,25 +110,27 @@
toolbar->addWidget(spacer);
//----System Shutdown/Restart
- systemButton = new QAction( QIcon(Theme::objectIconPath("system")),tr("System"),this );
+ QAction* act = new QAction( QIcon(currentTheme->itemIcon("system")),tr("System"),this );
+ systemButton = new QToolButton();
+ systemButton->setDefaultAction(act);
systemMenu = new QMenu();
- toolbar->addAction(systemButton);
- connect( systemButton, SIGNAL(triggered()), this, SLOT(slotShutdownComputer()) );
- systemButton->setToolTip(tr("Shutdown the computer"));
+ toolbar->addWidget(systemButton);
+ //connect( systemButton, SIGNAL(triggered()), this, SLOT(slotShutdownComputer()) );
+ systemButton->setPopupMode( QToolButton::InstantPopup );
+ //systemButton->setToolTip(tr("Shutdown the computer"));
//Create the grid layout
QGridLayout* grid = new QGridLayout;
//Populate the grid with items
//----Header Image
- QString hLayout = Theme::objectIconStyle("header");
QLabel* header = new QLabel;
- if(hLayout!="disabled"){
- QPixmap tmp( Theme::objectIconPath("header") );
- header->setPixmap( tmp.scaled(Theme::objectIconSize("header")) );
- grid->addWidget( header, Theme::objectLocationRow("header"), \
- Theme::objectLocationColumn("header"), \
- Theme::objectLocationRowSpan("header"), \
- Theme::objectLocationColumnSpan("header"), Qt::AlignCenter);
+ if( currentTheme->itemIsEnabled("header") ){
+ QPixmap tmp( currentTheme->itemIcon("header") );
+ header->setPixmap( tmp.scaled( currentTheme->itemIconSize("header") ) );
+ grid->addWidget( header, currentTheme->itemLocation("header","row"), \
+ currentTheme->itemLocation("header","col"), \
+ currentTheme->itemLocation("header","rowspan"), \
+ currentTheme->itemLocation("header","colspan"), Qt::AlignCenter);
}
//Username/Password/Login widget
@@ -102,38 +138,36 @@
loginW->setUsernames(Backend::getSystemUsers()); //add in the detected users
//loginW->setCurrentUser(); //set the previously used user
//Set Icons from theme
- loginW->changeButtonIcon("login",Theme::objectIconPath("login"));
- loginW->changeButtonIcon("display",Theme::objectIconPath("user"));
- loginW->changeButtonIcon("pwview",Theme::objectIconPath("password"));
+ loginW->changeButtonIcon("login",currentTheme->itemIcon("login"), currentTheme->itemIconSize("login"));
+ loginW->changeButtonIcon("display",currentTheme->itemIcon("user"), currentTheme->itemIconSize("user"));
+ loginW->changeButtonIcon("pwview",currentTheme->itemIcon("password"), currentTheme->itemIconSize("password"));
//Set style sheets
- loginW->changeStyleSheet("login", Theme::objectStyleSheet("login"));
- loginW->changeStyleSheet("password", Theme::objectStyleSheet("password"));
- loginW->changeStyleSheet("pwview", Theme::objectStyleSheet("password"));
- loginW->changeStyleSheet("user", Theme::objectStyleSheet("user"));
- loginW->setBackgroundFade(true,100,"blue","transparent");
+ //loginW->changeStyleSheet("login", Theme::objectStyleSheet("login"));
+ //loginW->changeStyleSheet("password", Theme::objectStyleSheet("password"));
+ //loginW->changeStyleSheet("pwview", Theme::objectStyleSheet("password"));
+ //loginW->changeStyleSheet("user", Theme::objectStyleSheet("user"));
//Add item to the grid
- grid->addWidget( loginW, Theme::objectLocationRow("login"), \
- Theme::objectLocationColumn("login"), \
- Theme::objectLocationRowSpan("login"), \
- Theme::objectLocationColumnSpan("login"), Qt::AlignCenter);
+ grid->addWidget( loginW, currentTheme->itemLocation("login","row"), \
+ currentTheme->itemLocation("login","col"), \
+ currentTheme->itemLocation("login","rowspan"), \
+ currentTheme->itemLocation("login","colspan"), Qt::AlignCenter);
//Connect the signals/slots
connect(loginW,SIGNAL(loginRequested(QString,QString)),this,SLOT(slotStartLogin(QString,QString)));
connect(loginW,SIGNAL(escapePressed()),this,SLOT(slotShutdownComputer()));
//----Desktop Environment Switcher
//Create the switcher
- bool horizontalDE = TRUE;
- if(Theme::objectIconStyle("desktop") == "vertical"){ horizontalDE = FALSE; }
- deSwitcher = new FancySwitcher(this,horizontalDE);
- QSize deSize = Theme::objectIconSize("desktop");
+ deSwitcher = new FancySwitcher(this, !currentTheme->itemIsVertical("desktop") );
+ QSize deSize = currentTheme->itemIconSize("desktop");
deSwitcher->setIconSize(deSize.height());
- QString deStyle = Theme::objectStyleSheet("desktop");
- deSwitcher->setStyleSheet(deStyle);
- if(deStyle.contains("background: transparent;")){
+ //Figure out if we need to smooth out the animation
+ //QString deStyle = currentTheme::objectStyleSheet("desktop");
+ //deSwitcher->setStyleSheet(deStyle);
+ //if(deStyle.contains("background: transparent;")){
deSwitcher->setNumberAnimationFrames("2"); // transparent widget background slows the animation to a crawl with a stretched background image
- }else{
- deSwitcher->setNumberAnimationFrames("smooth");
- }
+ //}else{
+ //deSwitcher->setNumberAnimationFrames("smooth");
+ //}
//Add the available desktops to the switcher
QStringList deList = Backend::getAvailableDesktops();
for(int i=0; i<deList.length(); i++){
@@ -142,18 +176,18 @@
//Set the switcher to the last used desktop environment
//deSwitcher->setCurrentItem("kde3");
//deSwitcher->changeButtonIcon("forward","/home/kenmoore/Downloads/kde.png");
- grid->addWidget( deSwitcher, Theme::objectLocationRow("desktop"), \
- Theme::objectLocationColumn("desktop"), \
- Theme::objectLocationRowSpan("desktop"), \
- Theme::objectLocationColumnSpan("desktop"), Qt::AlignCenter);
+ grid->addWidget( deSwitcher, currentTheme->itemLocation("desktop","row"), \
+ currentTheme->itemLocation("desktop","col"), \
+ currentTheme->itemLocation("desktop","rowspan"), \
+ currentTheme->itemLocation("desktop","colspan"), Qt::AlignCenter);
//----WINDOW SPACERS
- QStringList spacers = Theme::getSpacers();
+ QStringList spacers = currentTheme->getSpacers();
for(int i=0; i<spacers.length(); i++){
- QString type = spacers[i].section("::",0,0);
+ bool isVertical = (spacers[i].section("::",0,0) == "true");
int row = spacers[i].section("::",1,1).toInt();
int col = spacers[i].section("::",2,2).toInt();
- if(type =="vertical"){
+ if(isVertical){
grid->setRowStretch(row,1);
}else{ //horizontal
grid->setColumnStretch(col,1);
@@ -325,8 +359,8 @@
keyboardButton->setToolTip(tr("Change Keyboard Layout"));
keyboardButton->setText(tr("Keyboard Layout"));
//system button
- systemButton->setToolTip(tr("Shutdown the computer"));
- systemButton->setText(tr("System"));
+ systemButton->defaultAction()->setToolTip(tr("Shutdown the computer"));
+ systemButton->defaultAction()->setText(tr("System"));
//Menu entries for system button
systemMenu->clear();
systemMenu->addAction( tr("Restart"),this, SLOT(slotRestartComputer()) );
@@ -334,7 +368,7 @@
if(DEBUG_MODE){systemMenu->addAction( tr("Close PCDM"), this, SLOT(slotClosePCDM()) ); }
systemButton->setMenu(systemMenu);
//The main login widget
-
+ loginW->retranslateUi();
//The desktop switcher
deSwitcher->removeAllItems();
QStringList deList = Backend::getAvailableDesktops();
Modified: pcbsd-projects/PCDM/pcdm-gui.h
===================================================================
--- pcbsd-projects/PCDM/pcdm-gui.h 2013-02-13 21:46:36 UTC (rev 21483)
+++ pcbsd-projects/PCDM/pcdm-gui.h 2013-02-13 23:20:13 UTC (rev 21484)
@@ -18,7 +18,7 @@
#include <QSpacerItem>
#include "pcdm-backend.h"
-#include "pcdm-themes.h"
+#include "themeStruct.h"
#include "fancySwitcher.h"
#include "dialogKeyboard.h"
#include "dialogLocale.h"
@@ -52,20 +52,23 @@
widgetKeyboard* wKey;
widgetLocale* wLoc;
QToolBar* toolbar;
- QAction *virtkeyboardButton, *localeButton, *keyboardButton, *systemButton;
+ QAction *virtkeyboardButton, *localeButton, *keyboardButton;
+ QToolButton *systemButton;
QMenu* systemMenu;
QComboBox* unameline;
FancySwitcher* deSwitcher;
QLineEdit* pwline;
- QX11EmbedContainer* container;
+ //QX11EmbedContainer* container;
QProcess* vkbd;
QStringList kModels, kLayouts;
+ ThemeStruct* currentTheme;
QTranslator* m_translator;
QString translationDir;
//Functions
void createGUIfromTheme();
void retranslateUi();
+ void loadTheme();
signals:
void xUserFound(QString);
Modified: pcbsd-projects/PCDM/pcdm.conf
===================================================================
--- pcbsd-projects/PCDM/pcdm.conf 2013-02-13 21:46:36 UTC (rev 21483)
+++ pcbsd-projects/PCDM/pcdm.conf 2013-02-13 23:20:13 UTC (rev 21484)
@@ -3,8 +3,9 @@
# (/usr/local/share/PCDM/pcdm.conf) #
#####################################
-## SELECTED THEME ##
+## APPEARANCE SETTINGS ##
THEME_FILE=/usr/local/share/PCDM/pcdm.theme
+SPLASHSCREEN_FILE=/usr/local/share/PCDM/images/default-splash.png
## Base Directories for files ##
DE_STARTUP_DIR=/usr/local/share/xsessions #location for *.desktop entries for desktop environments(s)
Modified: pcbsd-projects/PCDM/themeStruct.cpp
===================================================================
--- pcbsd-projects/PCDM/themeStruct.cpp 2013-02-13 21:46:36 UTC (rev 21483)
+++ pcbsd-projects/PCDM/themeStruct.cpp 2013-02-13 23:20:13 UTC (rev 21484)
@@ -1,4 +1,4 @@
-#include "pcdm-themes.h"
+#include "themeStruct.h"
void ThemeStruct::loadThemeFile(QString filePath){
@@ -6,7 +6,10 @@
itemNames.clear();
itemNames << "background" << "header" << "user" << "password" << "login" << "desktop" << "system" << "locale" << "keyboard" << "vkeyboard" << "toolbar";
items.clear();
- for(int i=0; i<itemNames.length(); i++){ items << new ThemeItem(); }
+ for(int i=0; i<itemNames.length(); i++){
+ ThemeItem it;
+ items << it;
+ }
QString iconFileDir;
int numspacers = 0;
@@ -42,12 +45,13 @@
if(!val.endsWith("/")){val.append("/");}
iconFileDir = val;
}else if( prop == "ADDSPACER" ){ //create a spacer item
- indexNames << "spacer"+QString::number(numspacers);
+ itemNames << "spacer"+QString::number(numspacers);
numspacers++;
- items << new ThemeItem();
+ ThemeItem it;
+ items << it;
index = items.length() -1; //last item in the list
//read whether it is vertical
- items[index].isVertical = (val.section("::",0,0).toLower() == "vertical")
+ items[index].isVertical = (val.section("::",0,0).toLower() == "vertical");
//Now get the location
val = val.section("::",1,1).remove("[").remove("]").simplified();
items[index].x1 = val.section(",",0,0).section("-",0,0).toInt();
@@ -65,7 +69,10 @@
}else if(prop == "TOOLBAR_LOCATION"){
//special instructions for this item location
- items[index].icon = val; //should be [bottom | top | left | right]
+ items[index].value = val; //should be [bottom | top | left | right]
+ }else if(prop == "TOOLBAR_STYLE"){
+ //special instructions for this item
+ items[index].icon = val; //should be [icononly | textonly | textbesideicon | textundericon ]
}else if(itemCat == "LOCATION"){
val.remove("[").remove("]").simplified(); //remove the brackets
QString x = val.section(",",0,0);
@@ -74,6 +81,10 @@
else{ items[index].x1 = x.section("-",0,0).toInt(); items[index].x2 = x.section("-",1,1).toInt(); }
if(y.indexOf("-") == -1){ items[index].y1 = y.toInt(); items[index].y2 = -1;}
else{ items[index].y1 = y.section("-",0,0).toInt(); items[index].y2 = y.section("-",1,1).toInt(); }
+ }else if(itemCat == "ORIENTATION"){
+ items[index].isVertical = (val.toLower() == "vertical");
+ }else if(itemCat == "DISABLE"){
+ items[index].enabled = (val.toLower() != "true");
}
}
} // end if line is not a comment or empty
@@ -83,15 +94,14 @@
ThemeItem ThemeStruct::exportItem(QString item){
int index = itemNames.indexOf(item);
+ ThemeItem TI;
if( index == -1 ){
qDebug() << "ThemeStruct: Invalid export item:"<<item;
- ThemeItem TI = new ThemeItem();
- return TI;
}else{
//Now format the output
- ThemeItem TI = items[index];
- return TI;
+ TI = items[index];
}
+ return TI;
}
void ThemeStruct::importItem(QString item, ThemeItem TI){
@@ -105,80 +115,119 @@
bool ThemeStruct::validItem(QString item){
int index = itemNames.indexOf(item);
+ bool ret = FALSE;
if( index == -1 ){
qDebug() << "ThemeStruct: Invalid item:"<<item;
- return FALSE;
}else{
- bool ok = TRUE;
bool chk = items[index].enabled && items[index].value.isEmpty() && items[index].icon.isEmpty() && ( (items[index].x1==-1) || (items[index].y1==-1) );
- if(chk){ ok=FALSE; }
- return ok;
+ ret = !chk; //true if the checks do not catch an empty item
}
+ return ret;
}
+QStringList ThemeStruct::invalidItems(){
+ //Scan all the current Items and make a list of all the invalid ones
+ // This makes it easy to auto-populate these invalid items with defaults
+ QStringList inv;
+ for(int i=0; i<itemNames.length(); i++){
+ if( !validItem(itemNames[i]) ){ inv << itemNames[i]; }
+ }
+ return inv;
+}
+
bool ThemeStruct::itemIsEnabled(QString item){
int index = itemNames.indexOf(item);
+ bool ret = FALSE;
if( index == -1 ){
qDebug() << "ThemeStruct: Invalid item:"<<item;
- return FALSE;
}else{
- return items[index].enabled;
+ ret = items[index].enabled;
}
+ return ret;
}
+bool ThemeStruct::itemIsVertical(QString item){
+ int index = itemNames.indexOf(item);
+ bool ret = FALSE;
+ if( index == -1 ){
+ qDebug() << "ThemeStruct: Invalid item:"<<item;
+ }else{
+ ret = items[index].isVertical;
+ }
+ return ret;
+}
+
QString ThemeStruct::itemValue(QString item){
int index = itemNames.indexOf(item);
+ QString ret;
if( index == -1 ){
qDebug() << "ThemeStruct: Invalid item:"<<item;
- return FALSE;
+ ret = "";
}else{
- return items[index].value;
+ ret = items[index].value;
}
+ return ret;
}
QString ThemeStruct::itemIcon(QString item){
int index = itemNames.indexOf(item);
+ QString ret;
if( index == -1 ){
qDebug() << "ThemeStruct: Invalid item:"<<item;
- return FALSE;
+ ret = "";
}else{
- return items[index].icon;
+ ret = items[index].icon;
}
+ return ret;
}
QSize ThemeStruct::itemIconSize(QString item){
int index = itemNames.indexOf(item);
+ QSize ret;
if( index == -1 ){
qDebug() << "ThemeStruct: Invalid item:"<<item;
- return FALSE;
}else{
- return items[index].iconSize;
+ ret = items[index].iconSize;
}
+ return ret;
}
int ThemeStruct::itemLocation(QString item, QString variable){
int index = itemNames.indexOf(item);
+ int ret = 0;
if( index == -1 ){
qDebug() << "ThemeStruct: Invalid item:"<<item;
- return FALSE;
+ return ret;
}else{
variable = variable.toLower();
- if(variable == "row"){ return items[index].x1; }
- else if(variable == "col"){ return items[index].y1; }
+ if(variable == "row"){ ret = items[index].x1; }
+ else if(variable == "col"){ ret = items[index].y1; }
else if(variable == "rowspan"){
int span = items[index].x2 - items[index].x1;
- if(span < 0){ span = 0 - span; } //Make sure it is always positive
- span++; //add 1 for the end point
- return span;
+ if(span < 0){ span = 0; } //Make sure it is always positive
+ ret = span +1; //add 1 for the end point
}else if(variable == "colspan"){
int span = items[index].y2 - items[index].y1;
- if(span < 0){ span = 0 - span; } //Make sure it is always positive
- span++; //add 1 for the end point
- return span;
+ if(span < 0){ span = 0; } //Make sure it is always positive
+ ret = span +1; //add 1 for the end point
}
}
+ return ret; //catch for errors;
}
QString ThemeStruct::styleSheet(){
return applicationStyleSheet;
-}
\ No newline at end of file
+}
+
+QStringList ThemeStruct::getSpacers(){
+ QStringList spc;
+ QString isvert;
+ for(int i=0; i<itemNames.length(); i++){
+ if( itemNames[i].startsWith("spacer") ){
+ if(items[i].isVertical){ isvert="true"; }
+ else{ isvert="false"; }
+ spc << isvert + "::" + items[i].x1 +"::"+ items[i].y1;
+ }
+ }
+ return spc;
+}
Modified: pcbsd-projects/PCDM/themeStruct.h
===================================================================
--- pcbsd-projects/PCDM/themeStruct.h 2013-02-13 21:46:36 UTC (rev 21483)
+++ pcbsd-projects/PCDM/themeStruct.h 2013-02-13 23:20:13 UTC (rev 21484)
@@ -7,23 +7,8 @@
#include <QFile>
#include <QDebug>
#include <QSize>
+#include "themeItem.h"
-class ThemeItem{
-
-public:
- ThemeItem(){ enabled=FALSE; x1=-1; x2=-1; y1=-1; y2=-1; }
- ~ThemeItem();
- //values
- bool enabled;
- bool isVertical;
- QString value;
- int x1,x2,y1,y2;
- QString icon;
- QSize iconSize;
-
-};
-
-
class ThemeStruct{
private:
@@ -37,17 +22,20 @@
//How to fill a structure with items
void loadThemeFile(QString);
//import/export functions for passing items between different theme structures
- QString exportItem(QString);
- void importItem(QString);
+ ThemeItem exportItem(QString);
+ void importItem(QString, ThemeItem);
//Main Interface Functions
bool validItem(QString);
+ QStringList invalidItems();
bool itemIsEnabled(QString);
+ bool itemIsVertical(QString);
QString itemValue(QString);
QString itemIcon(QString);
QSize itemIconSize(QString);
int itemLocation(QString, QString variable);
QString styleSheet();
+ QStringList getSpacers();
};
More information about the Commits
mailing list