[PC-BSD Commits] r17928 - pcbsd-projects/PCDM
svn at pcbsd.org
svn at pcbsd.org
Tue Jul 24 20:03:25 PDT 2012
Author: kenmoore
Date: 2012-07-25 03:03:25 +0000 (Wed, 25 Jul 2012)
New Revision: 17928
Modified:
pcbsd-projects/PCDM/fancySwitcher.cpp
pcbsd-projects/PCDM/fancySwitcher.h
pcbsd-projects/PCDM/pcdm-gui.cpp
pcbsd-projects/PCDM/sample.pcdm-theme
Log:
Finish up the fancySwitcher widget. It now appears to work perfectly, and ready for in-depth testing within PCDM.
Modified: pcbsd-projects/PCDM/fancySwitcher.cpp
===================================================================
--- pcbsd-projects/PCDM/fancySwitcher.cpp 2012-07-25 00:18:09 UTC (rev 17927)
+++ pcbsd-projects/PCDM/fancySwitcher.cpp 2012-07-25 03:03:25 UTC (rev 17928)
@@ -18,6 +18,7 @@
//Add the buttons to the grid (back is always left/up)
pushForward = new QPushButton;
pushBack = new QPushButton;
+
iconViewer = new QGraphicsView();
iconViewer->setInteractive(FALSE);
iconViewer->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
@@ -59,19 +60,19 @@
//detect the base dimensions
int xsize,ysize;
if(isHorizontal){
- xsize = (idL.length()+1)*iconSize;
+ xsize = (idL.length()+1+(idL.length()-1)*5.0/4)*iconSize;
ysize = iconSize;
}else{ //vertical
xsize = iconSize;
- ysize = (idL.length()+1)*iconSize;
+ ysize = (idL.length()+1+(idL.length()-1)*5.0/4)*iconSize;
}
- qDebug() << "scene dimensions:" << xsize << ysize;
+ //qDebug() << "scene dimensions:" << xsize << ysize;
//Create the scene with the proper dimensions
scene = new QGraphicsScene(0,0,xsize,ysize);
//Fill the scene with the given images
int offset = iconSize/2; //initial offset
for(int i=0; i<idL.length(); i++){
- qDebug() << "offset" << offset;
+ //qDebug() << "offset" << offset;
if(isHorizontal){
icL[i]->setOffset(offset,0);
}else{
@@ -95,17 +96,15 @@
iconViewer->show();
return;
}
- int baseSize = iconSize*1.5;
- qDebug() << "iconSize:" << iconSize << "baseSize:" << baseSize;
//Get the current/old display pixel
- int cPixel = baseSize + (oldItem*iconSize) + (oldItem*iconSize/2);
+ int cPixel = (1 + oldItem*5.0/4)*iconSize;
//Get the new/desired display pixel
- int tPixel = baseSize + (item*iconSize) + (item*iconSize/2);
+ int tPixel = (1 + item*5.0/4)*iconSize;
//detect if we are moving back/forward
bool moveForward = TRUE;
if(tPixel < cPixel){ moveForward = FALSE; }
if(tPixel == cPixel){ showAnimation = FALSE; } //same item, skip the animation loop and just refresh
- qDebug() << "displayItem:" << item << oldItem << cPixel << tPixel << moveForward;
+ //qDebug() << "displayItem:" << item << oldItem << cPixel << tPixel << moveForward;
//Show the scrolling animation if desired
if(showAnimation){
if(moveForward){
@@ -187,15 +186,14 @@
icL[index]->setToolTip(tooltip);
}
}
- if(item==-1){item = 0; qDebug() << "Changed to index=0";}
+ if(item==-1){item = 0;} //There is now an item that can be selected
updateIconViewer();
checkButtons();
}
void FancySwitcher::addItems(QStringList idList, QStringList iconList, QStringList tooltipList){
-
//Check that all the lists are the same length
- if(!( idList.length()==iconList.length() && idList.length()==tooltipList.length() )){
+ if(!( (idList.length()==iconList.length()) && (idList.length()==tooltipList.length()) )){
qDebug() << "FancySwitcher: item lists are not equal length";
return;
}
@@ -215,7 +213,7 @@
}
}
}
- if(item==-1){item=0;}
+ if(item==-1){item = 0;} //There is now an item to be selected
updateIconViewer();
checkButtons();
}
@@ -249,11 +247,12 @@
}
QString FancySwitcher::currentItem(){
- return idL[item];
+ QString id = idL[item];
+ return id;
}
void FancySwitcher::setCurrentItem(QString id){
- int index = idL.indexOf(id.toLower());
+ int index = idL.indexOf(id);
if(index == -1){
qDebug() << "FancySwitcher: Item does not exist -" << id;
return;
@@ -287,3 +286,10 @@
}
}
+void FancySwitcher::setStyleSheet(QString style){
+ //Propagate the style sheet to both the buttons and the iconViewer
+ pushForward->setStyleSheet(style);
+ pushBack->setStyleSheet(style);
+ iconViewer->setStyleSheet(style);
+}
+
Modified: pcbsd-projects/PCDM/fancySwitcher.h
===================================================================
--- pcbsd-projects/PCDM/fancySwitcher.h 2012-07-25 00:18:09 UTC (rev 17927)
+++ pcbsd-projects/PCDM/fancySwitcher.h 2012-07-25 03:03:25 UTC (rev 17928)
@@ -25,14 +25,22 @@
FancySwitcher(QWidget* parent = 0, bool horizontal = TRUE);
~FancySwitcher();
- void addItem(QString, QString, QString tooltip = "");
- void addItems(QStringList, QStringList, QStringList);
- void removeItem(QString);
- void removeItems(QStringList);
+ //Add item(s) to the widget (icon must be a valid image file path)
+ void addItem(QString id, QString icon, QString tooltip = "");
+ void addItems(QStringList idList, QStringList iconList, QStringList tooltipList);
+ //Remove item(s) from the widget (given the item(s) identifier(s))
+ void removeItem(QString id);
+ void removeItems(QStringList idList);
+ //Get the currently selected item (returns the item identifier)
QString currentItem();
- void setCurrentItem(QString);
- void setIconSize(int);
- void changeButtonIcon(QString, QString);
+ //Set the currently selected item (by identifier)
+ void setCurrentItem(QString id);
+ //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);
+ //Change the style sheet for all widget items (see QtStyle options for more)
+ void setStyleSheet(QString style);
private:
QPushButton* pushBack;
@@ -54,6 +62,7 @@
void slotPushForward();
signals:
+ //Emits these signals whenever the selection is changed (forward/back clicked)
void itemChanged();
void itemChanged(QString);
Modified: pcbsd-projects/PCDM/pcdm-gui.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-gui.cpp 2012-07-25 00:18:09 UTC (rev 17927)
+++ pcbsd-projects/PCDM/pcdm-gui.cpp 2012-07-25 03:03:25 UTC (rev 17928)
@@ -167,15 +167,22 @@
//----Desktop Environment Switcher
//Get the available DE's
QStringList deList = Backend::getAvailableDesktops();
+ QStringList it, it2;
+ deList.clear();
+ deList << "kde" << "kde3";
+ it << "/home/kenmoore/Downloads/kde.png"<<"/home/kenmoore/Downloads/kde.png";
+ it2 << "KDE Desktop Environment" << "";
//Create the switcher
- FancySwitcher* deSwitcher = new FancySwitcher(this);
+ bool horizontalDE = TRUE;
+ if(Theme::objectIconStyle("desktop") == "vertical"){ horizontalDE = FALSE; }
+ deSwitcher = new FancySwitcher(this,horizontalDE);
deSwitcher->setIconSize(64);
- //deSwitcher->setStyleSheet(Theme::objectStyleSheet("desktop"));
+ deSwitcher->setStyleSheet(Theme::objectStyleSheet("desktop"));
//Add the available desktops to the switcher
- qDebug() << "At setup for deSwitcher";
- deSwitcher->addItem("kde","/home/kenmoore/Downloads/kde.png","KDE desktop environment");
+ deSwitcher->addItems(deList,it,it2);
//Set the switcher to the last used desktop environment
- //deSwitcher->setCurrentItem(deList[index]);
+ deSwitcher->setCurrentItem("kde3");
+ deSwitcher->changeButtonIcon("forward","/home/kenmoore/Downloads/kde.png");
grid->addWidget( deSwitcher, Theme::objectLocationRow("desktop"), \
Theme::objectLocationColumn("desktop"), \
Theme::objectLocationRowSpan("desktop"), \
@@ -203,6 +210,8 @@
void PCDMgui::slotStartLogin(){
qDebug() << "PCDM: Login procedure is not implemented yet";
+
+ qDebug() << "Selected DE:" << deSwitcher->currentItem();
}
void PCDMgui::slotShutdownComputer(){
Modified: pcbsd-projects/PCDM/sample.pcdm-theme
===================================================================
--- pcbsd-projects/PCDM/sample.pcdm-theme 2012-07-25 00:18:09 UTC (rev 17927)
+++ pcbsd-projects/PCDM/sample.pcdm-theme 2012-07-25 03:03:25 UTC (rev 17928)
@@ -44,7 +44,7 @@
WINDOW_ITEM=user::above::[2,0] #(required) username input display
WINDOW_ITEM=password::above::[2,1] #(required) password input display
WINDOW_ITEM=login::left::[2,2] #(required) login icon MUST be "none" or "left"
-WINDOW_ITEM=desktop::left::[4,1] #(required) Desktop environment switcher
+WINDOW_ITEM=desktop::horizontal::[4,1] #(required) Desktop environment switcher ("horizontal" or "vertical")
#optional spacers to help format the display
WINDOW_ITEM=spacer::vertical::[1,1] #Add a vertical spacer between the header and user
WINDOW_ITEM=spacer::vertical::[3,1] #Add a vertical spacer between the desktop and login
@@ -66,3 +66,4 @@
#SET_ITEM_STYLE=toolbar::selection-background-color::black #black background when selected
#SET_ITEM_STYLE=toolbar::selection-color::red #red text when selected
SET_ITEM_STYLE=user::font-size::32px #set the font to size 32
+SET_ITEM_STYLE=desktop::background::transparent
More information about the Commits
mailing list