[PC-BSD Commits] r17725 - pcbsd-projects/PCDM
svn at pcbsd.org
svn at pcbsd.org
Fri Jul 13 12:44:38 PDT 2012
Author: kenmoore
Date: 2012-07-13 19:44:38 +0000 (Fri, 13 Jul 2012)
New Revision: 17725
Added:
pcbsd-projects/PCDM/pcdm-config.cpp
pcbsd-projects/PCDM/pcdm-config.h
Modified:
pcbsd-projects/PCDM/PCDM.pro
pcbsd-projects/PCDM/main.cpp
pcbsd-projects/PCDM/pcdm-backend.cpp
pcbsd-projects/PCDM/pcdm-backend.h
pcbsd-projects/PCDM/pcdm-gui.cpp
pcbsd-projects/PCDM/pcdm-gui.h
pcbsd-projects/PCDM/pcdm-themes.cpp
pcbsd-projects/PCDM/pcdm-themes.h
Log:
Get the PCDM auto-generated GUI working, still has a bit of rough edges that need to be worked out (such as toolbar not showing properly, and needing to auto-add spacers appropriately)
Modified: pcbsd-projects/PCDM/PCDM.pro
===================================================================
--- pcbsd-projects/PCDM/PCDM.pro 2012-07-13 19:41:30 UTC (rev 17724)
+++ pcbsd-projects/PCDM/PCDM.pro 2012-07-13 19:44:38 UTC (rev 17725)
@@ -5,10 +5,12 @@
SOURCES += main.cpp \
pcdm-gui.cpp \
pcdm-backend.cpp \
- pcdm-themes.cpp
+ pcdm-themes.cpp \
+ pcdm-config.cpp
HEADERS += pcdm-gui.h \
pcdm-backend.h \
- pcdm-themes.h
+ pcdm-themes.h \
+ pcdm-config.h
TRANSLATIONS = i18n/PCDM_af.ts \
i18n/PCDM_ar.ts \
i18n/PCDM_az.ts \
Modified: pcbsd-projects/PCDM/main.cpp
===================================================================
--- pcbsd-projects/PCDM/main.cpp 2012-07-13 19:41:30 UTC (rev 17724)
+++ pcbsd-projects/PCDM/main.cpp 2012-07-13 19:44:38 UTC (rev 17725)
@@ -8,6 +8,7 @@
#include "pcdm-themes.h"
#include "pcdm-gui.h"
#include "pcdm-backend.h"
+#include "pcdm-config.h"
int main(int argc, char *argv[])
{
@@ -23,7 +24,7 @@
}
//Load the configuration file
- Config::loadConfiguration(appDir+"/pcdm.conf");
+ Config::loadConfigFile(appDir+"/pcdm.conf");
//Load the Desired Theme
Theme::loadTheme(Config::themeFile());
@@ -49,27 +50,28 @@
}
// Show our splash screen, so the user doesn't freak that that it takes a few seconds to show up
- QPixmap pixmap(); //create an empty pixmap
+ //QPixmap* pixmap; //create an empty pixmap
+ QSplashScreen splash;
if(Theme::useSplashscreen()){
- pixmap = new QPixmap(Theme::splashscreen()); //load the splashscreen file
+ splash.setPixmap( QPixmap(Theme::splashscreen()) ); //load the splashscreen file
}
- QSplashScreen splash(pixmap);
+ //QSplashScreen splash(pixmap);
splash.show();
PCDMgui w;
//Set the proper size on the Application
- if(Theme::isFullScreen()){
+ if(Theme::isFullScreen() ){
w.setWindowFlags(w.windowFlags() ^Qt::WindowSoftkeysVisibleHint);
- w.showFullScreen();
+ w.setWindowState(Qt::WindowFullScreen);
}else{
//Get the screen and desired geometries
QRect dimensions = QApplication::desktop()->screenGeometry();
int wid = dimensions.width(); // returns desktop width
int hig = dimensions.height(); // returns desktop height
- int thHig = Theme::windowSize("height"); // desired height
- int thWid = Theme::windowSize("width"); //desired width
+ int thHig = Theme::windowHeight(); // desired height
+ int thWid = Theme::windowWidth(); //desired width
//Sanity check the desired geometry versus the actual screen resolution
if(thHig > hig){ thHig = hig; }
if(thWid > wid){ thWid = wid; }
@@ -78,28 +80,30 @@
}
// Start the init
- w.progInit();
+ //w.progInit();
// Check if we are using diff language
- if ( ! langCode.isEmpty() )
- w.changeLang(langCode);
+ //if ( ! langCode.isEmpty() )
+ //w.changeLang(langCode);
w.show();
splash.finish(&w);
returnCode = a.exec();
-
- if ( QFile::exists(TMPLANGFILE) ) {
- QFile lfile(TMPLANGFILE);
+ bool changeLang = FALSE; //QFile::exists(TMPLANGFILE)
+ if ( changeLang ) {
+/* QFile lfile(TMPLANGFILE);
if (!lfile.open(QIODevice::ReadOnly | QIODevice::Text))
return 150;
changeLang = lfile.readLine();
lfile.close();
qDebug() << "Language switch requested for:" << changeLang;
QFile::remove(TMPLANGFILE);
+*/
} else {
break;
}
+
}
return returnCode;
Modified: pcbsd-projects/PCDM/pcdm-backend.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.cpp 2012-07-13 19:41:30 UTC (rev 17724)
+++ pcbsd-projects/PCDM/pcdm-backend.cpp 2012-07-13 19:44:38 UTC (rev 17725)
@@ -1,141 +1,17 @@
#include <QApplication>
#include <QFile>
#include <QProcess>
+#include <QDebug>
#include "pcdm-backend.h"
-using namespace Scripts;
-QStringList Backend::languages()
-{
- QStringList _languages;
- QString code, desc, line;
-
- QFile mFile;
- mFile.setFileName("/usr/share/pc-sysinstall/conf/avail-langs");
- if ( ! mFile.open(QIODevice::ReadOnly | QIODevice::Text))
- return QStringList();
-
- // Read in the meta-file for categories
- QTextStream in(&mFile);
- in.setCodec("UTF-8");
- while ( !in.atEnd() ) {
- line = in.readLine();
- code = line;
- code.truncate(line.indexOf(" "));
- desc = line.remove(0, line.indexOf(" "));
- _languages.append(desc.simplified() + " - (" + code.simplified() + ")");
- }
- mFile.close();
- return _languages;
+QStringList Backend::getAvailableDesktops(){
+ qDebug() << "PCDM: Scanning for available desktop environments is not integrated yet";
+ return QStringList("");
}
-QStringList Backend::keyModels()
-{
- QStringList _models;
- QString code, desc, line;
-
- Process p(QStringList() << "xkeyboard-models");
-
- if (p.waitForFinished()) {
- while (p.canReadLine()) {
- line = p.readLine();
- code = line;
- code.truncate(line.indexOf(" "));
- desc = line.remove(0, line.indexOf(" "));
- _models.append(desc.simplified() + " - (" + code.simplified() + ")");
- }
- }
- return _models;
+QStringList Backend::getSystemUsers(){
+ qDebug() << "PCDM: Scanning for available usernames is not integrated yet";
+ return QStringList("");
}
-
-QStringList Backend::keyLayouts()
-{
- QStringList _layouts;
- QString code, desc, line;
-
- Process p(QStringList() << "xkeyboard-layouts");
-
- if (p.waitForFinished()) {
- while (p.canReadLine()) {
- line = p.readLine();
- code = line;
- code.truncate(line.indexOf(" "));
- desc = line.remove(0, line.indexOf(" "));
- _layouts.append(desc.simplified() + " - (" + code.simplified() + ")");
- }
- }
- return _layouts;
-}
-
-// Function which gets the key Variants for the target layout
-QStringList Backend::keyVariants(const QString &layout, QStringList &savedKeyVariants)
-{
- QStringList _variants;
- QString code, desc, line;
-
- if ( savedKeyVariants.empty() )
- {
- Process p(QStringList() << "xkeyboard-variants");
- if (p.waitForFinished()) {
- while (p.canReadLine()) {
- line = p.readLine();
- savedKeyVariants << line;
- }
- }
- }
-
- for (int i = 0; i < savedKeyVariants.size(); ++i) {
- // Look for variants for this particular layout
- line = savedKeyVariants.at(i);
- if ( line.indexOf(" " + layout + ":") != -1 )
- {
- code = line.simplified();
- code.truncate(code.indexOf(" "));
- desc = line.remove(0, line.indexOf(": ") + 1);
- _variants.append(desc.simplified() + " - (" + code.simplified() + ")");
- }
- }
-
- return _variants;
-}
-
-
-// Function which lets us run setxkbmap
-void Backend::changeKbMap(QString model, QString layout, QString variant)
-{
- QProcess kbp;
- QStringList args;
- QString prog;
- prog = "setxkbmap";
- args << "-model" << model << "-layout" << layout << "-variant" << variant;
- qDebug() << "setxkbmap:" << args;
- kbp.start(prog, args);
- kbp.waitForFinished();
-}
-
-void Backend::loadConfFile(QString confFilePath, QList<QPixmap> imageList, QStringList autoLoginUser){
- //Initialize the arrays with the defaults
- QStringList PD; // [background, banner, default desktop icon]
- PD << ":defaults/images/background-image.jpg" << ":defaults/images/pcbsd-banner.png" << ":defaults/images/freebsd.png";
- imageList->clear();
- for(int i=0; i<PD.length(); i++){
- imageList << QPixmap(PD[i]);
- }
- //Load the configuration file (if it exists) to overwrite arrays
- if( !confFilePath.isEmpty() && QFile::exists(confFilePath) ){
- //QFile cFile(confFilePath);
- //if( !cFile.open(QIODevice::ReadOnly | QIODEVICE::Text)){ return; } //cannot open file - return defaults
- //QTextStream in(&cFile);
- //while (!in.atEnd()){
- //QString line = in.readLine();
-
- //Add configuration file format later
- qDebug() << "Configuration file formatting not yet supported";
- //}
- }
-
- //Enable the output for a detected user that should be automatically logged in
-
-}
-
Modified: pcbsd-projects/PCDM/pcdm-backend.h
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.h 2012-07-13 19:41:30 UTC (rev 17724)
+++ pcbsd-projects/PCDM/pcdm-backend.h 2012-07-13 19:44:38 UTC (rev 17725)
@@ -1,5 +1,5 @@
-#ifndef BACKEND_H
-#define BACKEND_H
+#ifndef PCDE_BACKEND_H
+#define PCDE_BACKEND_H
#include <QStringList>
#include <QString>
@@ -7,17 +7,14 @@
#include <QDebug>
#include <QProcess>
+#include "pcdm-config.h"
class Backend {
public:
- static QStringList languages();
- static QStringList keyLayouts();
- static QStringList keyModels();
- static QStringList keyVariants(const QString &, QStringList &savedKeyVariants);
- static void changeKbMap(QString model, QString layout, QString variant);
- static void loadConfFile(QString, QList<QPixmap>, QStringList);
+ static QStringList getAvailableDesktops();
static QStringList getSystemUsers();
+
};
Modified: pcbsd-projects/PCDM/pcdm-gui.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-gui.cpp 2012-07-13 19:41:30 UTC (rev 17724)
+++ pcbsd-projects/PCDM/pcdm-gui.cpp 2012-07-13 19:44:38 UTC (rev 17725)
@@ -6,36 +6,13 @@
#include "pcdm-backend.h"
#include "pcdm-themes.h"
+bool DEBUG_MODE=TRUE;
+
PCDMgui::PCDMgui()
{
//Create the GUI based upon the current Theme
createGUIfromTheme();
- connect(abortButton, SIGNAL(clicked()), this, SLOT(slotAbort()));
- connect(backButton, SIGNAL(clicked()), this, SLOT(slotBack()));
- connect(nextButton, SIGNAL(clicked()), this, SLOT(slotNext()));
-
- connect(helpButton, SIGNAL(clicked()), this, SLOT(slotHelp()));
- connect(pushTouchKeyboard, SIGNAL(clicked()), this, SLOT(slotPushVirtKeyboard()));
- connect(pushChangeKeyLayout, SIGNAL(clicked()), this, SLOT(slotPushKeyLayout()));
-
- // Init the MBR to yes
- loadMBR = true;
- // Init the GPT to no
- loadGPT = false;
-
- // No optional components by default
- fSRC=false;
- fPORTS=false;
-
- // Load the keyboard info
- keyModels = Scripts::Backend::keyModels();
- keyLayouts = Scripts::Backend::keyLayouts();
-
-
- // Start on the first screen
- installStackWidget->setCurrentIndex(0);
- backButton->setVisible(false);
}
PCDMgui::~PCDMgui()
@@ -44,11 +21,18 @@
}
void PCDMgui::createGUIfromTheme(){
+ //Set the background image
+ if(Theme::customBackground()){
+ QString bgstyle = "PCDMgui {background-image: url(BGIMAGE);}";
+ bgstyle.replace("BGIMAGE",Theme::background() );
+ this->setStyleSheet(bgstyle);
+ }
+
//Create the Toolbar
- QToolbar* toolbar;
+ toolbar = new QToolBar();
//Put it in the proper location
this->addToolBar( Theme::toolbarLocation(), toolbar ); //use the theme location
- toolbar->setMovable(FALSE);
+ //toolbar->setMovable(FALSE);
toolbar->setFloatable(FALSE);
//Set the default style and icon sizes
toolbar->setToolButtonStyle( Theme::toolbarStyle() ); //use the theme style
@@ -56,26 +40,26 @@
//Populate the Toolbar with items
//----Locale Switcher
-
+ qDebug() << "PCDM: Locale switcher not implemented yet";
//----Keyboard Layout Switcher
-
+ qDebug() << "PCDM: Keyboard switcher not implemented yet";
//----System Shutdown/Restart
QToolButton* systemButton = new QToolButton(toolbar);
- QMenu* systemMenu;
+ systemMenu = new QMenu();
systemMenu->addAction( tr("Restart"),this, SLOT(slotRestartComputer()) );
systemMenu->addAction( tr("Shut Down"), this, SLOT(slotShutdownComputer()) );
- systemMenu->addAction( tr("Close PCDM"), this, SLOT(slotClosePCDM()) );
+ if(DEBUG_MODE){systemMenu->addAction( tr("Close PCDM"), this, SLOT(slotClosePCDM()) ); }
systemButton->setMenu(systemMenu);
systemButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
//Create the grid layout
- QGridLayout* grid;
+ QGridLayout* grid = new QGridLayout;
//Populate the grid with items
//----Header Image
QString hLayout = Theme::objectIconStyle("header");
- QLabel* header;
+ QLabel* header = new QLabel;
if(hLayout!="disabled"){
header->setPixmap( QPixmap( Theme::objectIconPath("header") ) );
grid->addWidget( header, Theme::objectLocationRow("header"), \
@@ -85,11 +69,11 @@
}
//----Username Input collection
- QString pLayout = Theme::objectIconStyle("user");
- QComboBox* unameline;
+ QString uLayout = Theme::objectIconStyle("user");
+ unameline = new QComboBox;
unameline->addItems(Backend::getSystemUsers());
unameline->setCurrentIndex(0); //select the first username on the list
- if(pLayout == "disabled"){
+ if(uLayout == "disabled"){
//Icon Disabled - just add widget to the grid
grid->addWidget( unameline, Theme::objectLocationRow("user"), \
Theme::objectLocationColumn("user"), \
@@ -98,13 +82,13 @@
}else{
//Put the Icon and Widget in their own layout before adding to the main grid
int rI,rW,cI,cW;
- if(pLayout=="above"){ rI=0; cI=0; rW=1; cW=0; } //icon above
- if(pLayout=="below"){ rI=1; cI=0; rW=0; cW=0; } //icon below
- if(pLayout=="left") { rI=0; cI=1; rW=0; cW=0; } //icon to the left
- if(pLayout=="right"){ rI=0; cI=0; rW=0; cW=1; } //icon to the right
- QGridLayout* ugrid;
+ if(uLayout=="above"){ rI=0; cI=0; rW=1; cW=0; } //icon above
+ if(uLayout=="below"){ rI=1; cI=0; rW=0; cW=0; } //icon below
+ if(uLayout=="left") { rI=0; cI=0; rW=0; cW=1; } //icon to the left
+ if(uLayout=="right"){ rI=0; cI=1; rW=0; cW=0; } //icon to the right
+ QGridLayout* ugrid = new QGridLayout;
QPixmap tmp( Theme::objectIconPath("user") );
- QLabel* unameIcon; unameIcon->setPixmap(tmp.scaled(Theme::objectIconSize("user")));
+ QLabel* unameIcon = new QLabel; unameIcon->setPixmap(tmp.scaled(Theme::objectIconSize("user")));
ugrid->addWidget(unameline,rW,cW,Qt::AlignCenter);
ugrid->addWidget(unameIcon,rI,cI,Qt::AlignCenter);
@@ -116,7 +100,7 @@
//----Password Input collection
QString pLayout = Theme::objectIconStyle("password");
- QLineEdit* pwline; pwline->setEchoMode(QLineEdit::Password);
+ pwline = new QLineEdit; pwline->setEchoMode(QLineEdit::Password);
if(pLayout == "disabled"){
//Icon Disabled - just add widget to the grid
grid->addWidget( pwline, Theme::objectLocationRow("password"), \
@@ -128,11 +112,11 @@
int rI,rW,cI,cW;
if(pLayout=="above"){ rI=0; cI=0; rW=1; cW=0; } //icon above
if(pLayout=="below"){ rI=1; cI=0; rW=0; cW=0; } //icon below
- if(pLayout=="left") { rI=0; cI=1; rW=0; cW=0; } //icon to the left
- if(pLayout=="right"){ rI=0; cI=0; rW=0; cW=1; } //icon to the right
- QGridLayout* pgrid;
+ if(pLayout=="left") { rI=0; cI=0; rW=0; cW=1; } //icon to the left
+ if(pLayout=="right"){ rI=0; cI=1; rW=0; cW=0; } //icon to the right
+ QGridLayout* pgrid = new QGridLayout;
QPixmap tmp( Theme::objectIconPath("password") );
- QLabel* pwIcon; pwIcon->setPixmap(tmp.scaled(Theme::objectIconSize("password")));
+ QLabel* pwIcon = new QLabel; pwIcon->setPixmap(tmp.scaled(Theme::objectIconSize("password")));
pgrid->addWidget(pwline,rW,cW,Qt::AlignCenter);
pgrid->addWidget(pwIcon,rI,cI,Qt::AlignCenter);
@@ -144,18 +128,17 @@
//----Login Button
QString lLayout = Theme::objectIconStyle("login");
- if(lLayout=="disabled"){ QPushButton* pushlogin = new QPushButton(tr("Login")); }
- else{ QPushButton* pushlogin = new QPushButton( QIcon(Theme::objectIconPath("login")),tr("Login") ); }
- pushlogin
- grid->addWidget( pwline, Theme::objectLocationRow("password"), \
- Theme::objectLocationColumn("password"), \
- Theme::objectLocationRowSpan("password"), \
- Theme::objectLocationColumnSpan("password"), Qt::AlignCenter);
+ QPushButton* pushlogin = new QPushButton(QIcon(Theme::objectIconPath("login")),tr("Login") );
+ if(lLayout=="disabled"){ pushlogin->setIcon(QIcon("")); } //Remove the icon
+ grid->addWidget( pushlogin, Theme::objectLocationRow("login"), \
+ Theme::objectLocationColumn("login"), \
+ Theme::objectLocationRowSpan("login"), \
+ Theme::objectLocationColumnSpan("login"), Qt::AlignCenter);
//----Desktop Environment Switcher
//NOTE: This will be changed to a "fancy" switcher later)
QString deLayout = Theme::objectIconStyle("desktop");
- QComboBox* deSwitcher;
+ QComboBox* deSwitcher = new QComboBox;
deSwitcher->addItems(Backend::getAvailableDesktops());
deSwitcher->setCurrentIndex(0); //select the first desktop on the list (for now)
if(deLayout == "disabled"){
@@ -169,11 +152,11 @@
int rI,rW,cI,cW;
if(deLayout=="above"){ rI=0; cI=0; rW=1; cW=0; } //icon above
if(deLayout=="below"){ rI=1; cI=0; rW=0; cW=0; } //icon below
- if(deLayout=="left") { rI=0; cI=1; rW=0; cW=0; } //icon to the left
- if(deLayout=="right"){ rI=0; cI=0; rW=0; cW=1; } //icon to the right
- QGridLayout* degrid;
+ if(deLayout=="left") { rI=0; cI=0; rW=0; cW=1; } //icon to the left
+ if(deLayout=="right"){ rI=0; cI=1; rW=0; cW=0; } //icon to the right
+ QGridLayout* degrid = new QGridLayout;
QPixmap tmp( Theme::objectIconPath("desktop") );
- QLabel* deIcon; pwIcon->setPixmap(tmp.scaled(Theme::objectIconSize("desktop")));
+ QLabel* deIcon = new QLabel; deIcon->setPixmap(tmp.scaled(Theme::objectIconSize("desktop")));
degrid->addWidget(deSwitcher,rW,cW,Qt::AlignCenter);
degrid->addWidget(deIcon,rI,cI,Qt::AlignCenter);
@@ -184,80 +167,29 @@
}
//Connect the grid to the Window
- this->setLayout(grid);
+ //qDebug() << "Creating Widget";
+ QWidget* widget = new QWidget;
+ //qDebug() << "Adding the grid to the widget";
+ widget->setLayout(grid);
+ //qDebug() << "Setting the widget as the central widget in the mainwindow";
+ this->setCentralWidget(widget);
//Connect all the buttons to their proper slots
}
-void PCDMgui::slotPushKeyLayout()
-{
- wKey = new widgetKeyboard();
- wKey->programInit(keyModels, keyLayouts);
- wKey->setWindowModality(Qt::ApplicationModal);
- wKey->show();
- wKey->raise();
+void PCDMgui::slotShutdownComputer(){
+ qDebug() << "PCDM: Shutdown Computer not implemented yet";
}
-void PCDMgui::progInit()
-{
- //Load the config file to set private variables
-
- //Set the display scheme (based on the config file)
-
- //Find what desktop environments are available
-
- // load languages
- comboLanguage->clear();
- languages = Scripts::Backend::languages();
- for (int i=0; i < languages.count(); ++i) {
- QString languageStr = languages.at(i);
- QString language = languageStr.split("-").at(0);
- comboLanguage->addItem(language.trimmed());
- }
- connect(comboLanguage, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotChangeLanguage()));
-
- // Load up the keyboard information
- //connectKeyboardSlots();
-
+void PCDMgui::slotRestartComputer(){
+ qDebug() << "PCDM: Restart COmputer not implemented yet";
}
-void PCDMgui::slotChangeLanguage()
-{
- if ( comboLanguage->currentIndex() == -1 )
- return;
-
- // Figure out the language code
- QString langCode = languages.at(comboLanguage->currentIndex());
-
- // Grab the language code
- langCode.truncate(langCode.lastIndexOf(")"));
- langCode.remove(0, langCode.lastIndexOf("(") + 1);
-
- // Now write out the lang code and close
- QFile lfile( TMPLANGFILE );
- if ( lfile.open( QIODevice::WriteOnly ) ) {
- QTextStream stream( &lfile );
- stream << langCode;
- lfile.close();
- }
- close();
+void PCDMgui::slotClosePCDM(){
+ close();
}
-void PCDMgui::changeLang(QString code)
-{
- // Change the language in the combobox with the current running one
- comboLanguage->disconnect();
-
- for (int i=0; i < languages.count(); ++i) {
- if ( languages.at(i).indexOf("(" + code + ")" ) != -1 ) {
- comboLanguage->setCurrentIndex(i);
- }
- }
-
- connect(comboLanguage, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotChangeLanguage()));
-}
-
// Start xvkbd
void PCDMgui::slotPushVirtKeyboard()
{
Modified: pcbsd-projects/PCDM/pcdm-gui.h
===================================================================
--- pcbsd-projects/PCDM/pcdm-gui.h 2012-07-13 19:41:30 UTC (rev 17724)
+++ pcbsd-projects/PCDM/pcdm-gui.h 2012-07-13 19:44:38 UTC (rev 17725)
@@ -5,6 +5,15 @@
#include <QMessageBox>
#include <QFile>
#include <QGraphicsScene>
+#include <QMainWindow>
+#include <QToolBar>
+#include <QToolButton>
+#include <QMenu>
+#include <QLabel>
+#include <QComboBox>
+#include <QPushButton>
+#include <QLineEdit>
+#include <QGridLayout>
#include "pcdm-backend.h"
#include "pcdm-themes.h"
@@ -22,31 +31,21 @@
private slots:
void slotRestartComputer();
void slotShutdownComputer();
-
- void slotChangeLanguage();
-
+ void slotClosePCDM();
// Start xvkbd
void slotPushVirtKeyboard();
- // Keyboard selector
- void slotPushKeyLayout();
-
private:
- QList<QPixmap> imageList;
- QGraphicsScene *defaultScene;
- QGraphicsScene *customScene;
- QStringList languages;
+ //Objects
+ QToolBar* toolbar;
+ QMenu* systemMenu;
+ QComboBox* unameline,deSwitcher;
+ QLineEdit* pwline;
//Functions
void createGUIfromTheme();
- // Internal functions for the GUI
- bool toggleKeyLayout;
- // Keyboard Widget
- widgetKeyboard *wKey;
- QStringList keyModels;
- QStringList keyLayouts;
};
Modified: pcbsd-projects/PCDM/pcdm-themes.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-themes.cpp 2012-07-13 19:41:30 UTC (rev 17724)
+++ pcbsd-projects/PCDM/pcdm-themes.cpp 2012-07-13 19:44:38 UTC (rev 17725)
@@ -1,26 +1,31 @@
#include "pcdm-themes.h"
//Setup variables that save the current theme data
-QStringList images, imSizes, imLayout, gridLayout, tbFormat, validLayouts, needText;
-bool isFullscreen=TRUE;
-int windowWidth, windowHeight, gridWidth, gridHeight;
-validLayouts << "above" << "below" << "left" << "right" << "none" << "icononly";
-needText << "user" << "password" << "login";
-/*
-tbFormat = [locationString, styleString, widthInt, heightInt]
+QStringList images, imSizes, imLayout, gridLayout, tbFormat, validLayouts, needText, objStruct;
+bool fullscreenWindow;
+int wWidth, wHeight, gridWidth, gridHeight;
-*/
-
//Create the functions to read and output the theme data
void Theme::loadDefaults(QString vars){
+ if( vars=="all" ){
+ validLayouts << "above" << "below" << "left" << "right" << "none" << "icononly";
+ needText << "user" << "password" << "login";
+ objStruct << "header" << "background" << "splashscreen" << "user" << "password" << "login" << "keyboard" << "locale" << "system" << "desktop" << "virt-keyboard";
+ }
+ if( (vars=="all") || (vars=="window") ){
+ //Main Window Setup
+ fullscreenWindow=FALSE;
+ wWidth=800;
+ wHeight=600;
+ }
if( (vars=="all") || (vars=="images") ){
//Default Images and Sizes
images.clear(); imSizes.clear();
images <<":images/banner.png"; imSizes << ""; // [0]=Header
images <<":images/backgroundimage.jpg"; imSizes << ""; // [1]=Background
images <<":images/splash.png"; imSizes << ""; // [2]=Splash Screen
- images <<":images/user.png"; imSizes << "64x64"; // [3]=User
- images <<":images/password.png"; imSizes << "64x64"; // [4]=Password
+ images <<":images/user.png"; imSizes << "32x32"; // [3]=User
+ images <<":images/password.png"; imSizes << "32x32"; // [4]=Password
images <<":images/next.png"; imSizes << "15x15"; // [5]=Login
images <<":images/input-keyboard.png"; imSizes << "32x32"; // [6]=Keyboard Layout
images <<":images/language.png"; imSizes << "32x32"; // [7]=Locale
@@ -29,20 +34,19 @@
images <<":images/keyboard.png"; imSizes << "32x32"; // [10]=Virtual Keyboard
}
if( (vars=="all") || (vars=="layout") ){
- tbLocation="bottom";
gridWidth=5; gridHeight=6;
- //Default Layout for the application
+ //Default Layout for the application (row x column)
imLayout.clear(); gridLayout.clear();
- imLayout << "icononly"; gridLayout << "0-4x0"; // [0]=Header
+ imLayout << "icononly"; gridLayout << "0x0"; // [0]=Header
imLayout << "icononly"; gridLayout << ""; // [1]=Background
imLayout << "icononly"; gridLayout << ""; // [2]=Splash Screen
- imLayout << "left"; gridLayout << "1-3x1"; // [3]=User
- imLayout << "left"; gridLayout << "1-3x2"; // [4]=Password
- imLayout << "left"; gridLayout << "1-3x3"; // [5]=Login
+ imLayout << "left"; gridLayout << "2x0"; // [3]=User
+ imLayout << "left"; gridLayout << "3x0"; // [4]=Password
+ imLayout << "disabled"; gridLayout << "4x0"; // [5]=Login
imLayout << "icononly"; gridLayout << ""; // [6]=Keyboard Layout
imLayout << "icononly"; gridLayout << ""; // [7]=Locale
imLayout << "icononly"; gridLayout << ""; // [8]=System
- imLayout << "icononly"; gridLayout << "4x5"; // [9]=Desktop
+ imLayout << "left"; gridLayout << "6x0"; // [9]=Desktop
imLayout << "icononly"; gridLayout << ""; // [10]=Virtual Keyboard
}
if( (vars=="all") || (vars=="toolbar") ){
@@ -61,7 +65,7 @@
qDebug() << "PCDM: Loaded theme file" << themeFile;
if(!goodLayout){
loadDefaults("layout"); //return to default layout if theme layout is not valid
- qDebug() << "PCDM: Invalid Theme Layout Detected - Using default layout instead
+ qDebug() << "PCDM: Invalid Theme Layout Detected - Using default layout instead";
}
}else{
qDebug() << "PCDM: No theme file detected - Using default theme";
@@ -69,73 +73,99 @@
}
+bool Theme::isFullScreen(){
+ return fullscreenWindow;
+}
+
+int Theme::windowWidth(){
+ return wWidth;
+}
+int Theme::windowHeight(){
+ return wHeight;
+}
void Theme::readThemeFile(QString themeFile){
+ qDebug() << "PCDM: Loading Theme Files is not implemented yet - using defaults";
+ return;
+ /*
QFile file(themeFile);
if( !file.open(QIODevice::ReadOnly | QIODevice::Text)){ return; }
QTextStream in(&file);
while( !in.atEnd() ){
QString line = in.readLine().simplified();
if( !line.isEmpty() && !line.startsWith("#") ){ //ignore empty and comment lines
+ //Remove comments at the end of lines
+ line.section("#",0,0);
//Parse out the line into the proper variables
-
+
}
}
file.close();
+ */
}
-bool goodLayout(){
+int Theme::getObjectIndex(QString obj){
+ int i = objStruct.indexOf(obj.toLower());
+ if(i==-1){
+ qDebug() << "PCDM: ERROR: Invalid call for object" << obj.toLower() << "- Object does not exist";
+ }
+ return i;
+}
+
+bool Theme::goodLayout(){
//Sanity Check the layout from this theme
-
+ qDebug() << "PCDM: Window Layout Checker not implemented yet";
return TRUE;
}
//********** WINDOW OBJECTS *************
-QString objectIconStyle(QString obj){
+QString Theme::objectIconStyle(QString obj){
int i = getObjectIndex(obj);
bool invalid = FALSE;
QString output = imLayout[i].toLower();
- if(output="icononly" && needText.contains(obj)){ invalid=TRUE; }
+ if( (output=="icononly") && needText.contains(obj) ){ invalid=TRUE; }
if(!validLayouts.contains(output) || invalid){
qDebug() << "PCDM: Invalid layout detected for" << obj << "- defaulting to \"left\"";
return "left";
}
- QString
- return imLayout[i].toLower();
+ return output;
}
-QString objectIconPath(QString obj){
+QString Theme::objectIconPath(QString obj){
int i = getObjectIndex(obj);
return images[i];
}
-QSize objectIconSize(QString obj){
+QSize Theme::objectIconSize(QString obj){
int i = getObjectIndex(obj);
- int width = imSizes[i].section("x",0,0).toInt();
- int height = imSizes[i].section("x",1,1).toInt();
- if(width.isEmpty()){
+ int width, height;
+ if(imSizes[i].isEmpty()){
qDebug() << "PCDM: No image size given for" << obj << "- defaulting to 64x64";
width=64;
height=64;
+ }else{
+ width = imSizes[i].section("x",0,0).toInt();
+ if( !imSizes[i].contains("x") ){
+ qDebug() << "PCDM: No image height given for" << obj << "- assuming a square image";
+ height = width;
+ }else{
+ height = imSizes[i].section("x",1,1).toInt();
+ }
}
- if(height.isEmpty()){
- qDebug() << "PCDM: No image height given for" << obj << "- assuming a square image";
- height = width;
- }
return QSize(width,height);
}
-int objectLocationRow(QString obj){
+int Theme::objectLocationRow(QString obj){
int i = getObjectIndex(obj);
QString row = gridLayout[i].section("x",0,0).section("-",0,0);
return row.toInt();
}
-int objectLocationColumn(QString obj){
+int Theme::objectLocationColumn(QString obj){
int i = getObjectIndex(obj);
QString col = gridLayout[i].section("x",1,1).section("-",0,0);
return col.toInt();
}
-int objectLocationRowSpan(QString obj){
+int Theme::objectLocationRowSpan(QString obj){
int i = getObjectIndex(obj);
QString row = gridLayout[i].section("x",0,0).section("-",1,1);
if(row.isEmpty()){ return 1; }
@@ -144,7 +174,7 @@
return rowSpan;
}
-int objectLocationColumnSpan(QString obj){
+int Theme::objectLocationColumnSpan(QString obj){
int i = getObjectIndex(obj);
QString col = gridLayout[i].section("x",1,1).section("-",1,1);
if(col.isEmpty()){ return 1; }
@@ -158,13 +188,24 @@
bool Theme::useSplashscreen(){
if(images[2].isEmpty() || images[2] == "disabled"){ return FALSE; }
else
- return isSplashscreen;
+ return TRUE;
}
QString Theme::splashscreen(){
return images[2];
};
+//********** BACKGROUND ***********
+bool Theme::customBackground(){
+ if(images[1].isEmpty() || images[1] == "disabled"){ return FALSE; }
+ else
+ return TRUE;
+}
+
+QString Theme::background(){
+ return images[1];
+};
+
//********** TOOLBAR INFORMATION ***********
Qt::ToolBarArea Theme::toolbarLocation(){
if(tbFormat[0].toLower()=="left"){ return Qt::LeftToolBarArea; }
@@ -189,9 +230,9 @@
}
int Theme::toolbarSizeWidth(){
- return tbFormat[3].toInt();
+ return tbFormat[2].toInt();
}
int Theme::toolbarSizeHeight(){
- return tbFormat[4].toInt();
+ return tbFormat[3].toInt();
}
Modified: pcbsd-projects/PCDM/pcdm-themes.h
===================================================================
--- pcbsd-projects/PCDM/pcdm-themes.h 2012-07-13 19:41:30 UTC (rev 17724)
+++ pcbsd-projects/PCDM/pcdm-themes.h 2012-07-13 19:44:38 UTC (rev 17725)
@@ -5,6 +5,7 @@
#include <QStringList>
#include <QFile>
#include <QDebug>
+#include <QSize>
class Theme{
@@ -12,16 +13,14 @@
static bool goodLayout();
static void loadDefaults(QString);
static void readThemeFile(QString);
+ static int getObjectIndex(QString);
public:
//General Theme Settings
static void loadTheme(QString);
static bool isFullScreen();
- static int windowSize(QString);
- //Window Layout
- static QString imagePath(QString);
- static int imageSize(QString,QString);
- static int objectLocation(QString,QString);
+ static int windowWidth();
+ static int windowHeight();
//Window objects
static QString objectIconStyle(QString);
static QString objectIconPath(QString);
@@ -33,6 +32,9 @@
//Splash Screen
static QString splashscreen();
static bool useSplashscreen();
+ //Background
+ static QString background();
+ static bool customBackground();
//Toolbar functions
static Qt::ToolBarArea toolbarLocation();
static Qt::ToolButtonStyle toolbarStyle();
More information about the Commits
mailing list