[PC-BSD Commits] r17977 - pcbsd-projects/PCDM
svn at pcbsd.org
svn at pcbsd.org
Fri Jul 27 15:14:02 PDT 2012
Author: kenmoore
Date: 2012-07-27 22:14:02 +0000 (Fri, 27 Jul 2012)
New Revision: 17977
Modified:
pcbsd-projects/PCDM/fancySwitcher.cpp
pcbsd-projects/PCDM/fancySwitcher.h
pcbsd-projects/PCDM/pcdm-gui.cpp
pcbsd-projects/PCDM/pcdm-themes.cpp
Log:
Set the PCDM background image to be stretched instead of tiled, and also add the ability to modify the animation speed for the FancySwitcher. If the main background is stratched and the FancySwitcher background is transparent, the animation slows to a crawl, so this allows me to set a quick (2 frame) animation in this case to make sure it is not too slow, while still having an animation.
Modified: pcbsd-projects/PCDM/fancySwitcher.cpp
===================================================================
--- pcbsd-projects/PCDM/fancySwitcher.cpp 2012-07-27 19:50:41 UTC (rev 17976)
+++ pcbsd-projects/PCDM/fancySwitcher.cpp 2012-07-27 22:14:02 UTC (rev 17977)
@@ -9,15 +9,19 @@
//Set the default values for the current item
idL.clear(); icL.clear();
item=-1; oldItem=0; //default values for the current/old item number
+ frames=-1; //smoothest animation possible (1 pixel at a time)
//Save whether it is a horizontal or vertical display
isHorizontal = horizontal;
//Set the default size for the images
- iconSize = 32; //default all icons in the viewer to 32x32 (can be changed later)
+ iconSize = 64; //default all icons in the viewer to 64x64 (can be changed later)
//Create the Grid layout
QGridLayout* layout = new QGridLayout();
//Add the buttons to the grid (back is always left/up)
pushForward = new QPushButton;
pushBack = new QPushButton;
+ pushForward->setIconSize(QSize(iconSize/2,iconSize/2));
+ pushBack->setIconSize(QSize(iconSize/2,iconSize/2));
+
textLabel = new QLabel;
textLabel->setAlignment(Qt::AlignCenter);
@@ -25,9 +29,7 @@
iconViewer->setInteractive(FALSE);
iconViewer->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
iconViewer->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
- pushForward->setIconSize(QSize(iconSize/2,iconSize/2));
- pushBack->setIconSize(QSize(iconSize/2,iconSize/2));
- qDebug() << "Set the orientation and images";
+ iconViewer->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
if(isHorizontal){
iconViewer->setFixedSize(2*iconSize,iconSize+2);
pushBack->setIcon(QIcon(":images/left.png"));
@@ -110,10 +112,13 @@
if(tPixel == cPixel){ showAnimation = FALSE; } //same item, skip the animation loop and just refresh
//qDebug() << "displayItem:" << item << oldItem << cPixel << tPixel << moveForward;
//Show the scrolling animation if desired
- if(showAnimation){
+ if(showAnimation && (frames!=0)){
+ int pixchange = 1;
+ if(frames > 0){ pixchange=abs(tPixel-cPixel)/frames; } //draw fewer frames per animation
+
if(moveForward){
- while(cPixel < tPixel){
- cPixel++;
+ while(cPixel < (tPixel-pixchange+1)){
+ cPixel += pixchange;
if(isHorizontal){
iconViewer->centerOn(cPixel,0);
}else{
@@ -123,8 +128,8 @@
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 22);
}
}else{
- while(cPixel > tPixel){
- cPixel--;
+ while(cPixel > (tPixel+pixchange-1)){
+ cPixel -= pixchange;
if(isHorizontal){
iconViewer->centerOn(cPixel,0);
}else{
@@ -134,7 +139,8 @@
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 22);
}
}
-
+ iconViewer->centerOn(icL[item]);
+ iconViewer->show();
}else{
//Just center on the desired item (skip animation)
iconViewer->centerOn(icL[item]);
@@ -268,6 +274,17 @@
}
}
+void FancySwitcher::setNumberAnimationFrames(QString numframes){
+ if(numframes.toLower()=="smooth"){frames=-1; return;} //auto-detect max
+ if(numframes.toLower()=="instant"){frames=0; return;} //don't use animation
+ bool ok;
+ int num = numframes.toInt(&ok);
+ if(!ok){qDebug() << "FancySwitcher: invalid input for number of animation frames. Must be \"smooth\", \"instant\", or an integer > 0."; return; }
+ if(num < 2){ frames=0; } //1 frame = instant
+ else{ frames=num; } //don't worry about huge numbers, min pixel animation will always be 1 at a time
+
+}
+
void FancySwitcher::setIconSize(int xysize){
iconSize = xysize; //change the saved icon size
//Update the pushbuttons icons
Modified: pcbsd-projects/PCDM/fancySwitcher.h
===================================================================
--- pcbsd-projects/PCDM/fancySwitcher.h 2012-07-27 19:50:41 UTC (rev 17976)
+++ pcbsd-projects/PCDM/fancySwitcher.h 2012-07-27 22:14:02 UTC (rev 17977)
@@ -42,7 +42,9 @@
void changeButtonIcon(QString button, QString iconFile);
//Change the style sheet for all widget items (see QtStyle options for more)
void setStyleSheet(QString style);
-
+ //Change the "smoothness" of the animation by the number of frames to draw (default is smoothest)
+ void setNumberAnimationFrames(QString numframes); // [ smooth | instant | int > 0 ]
+
private:
QPushButton* pushBack;
QPushButton* pushForward;
@@ -51,7 +53,7 @@
QStringList idL;
QList<QGraphicsPixmapItem*> icL;
QLabel* textLabel;
- int item, oldItem;
+ int item, oldItem, frames;
bool isHorizontal;
int iconSize;
Modified: pcbsd-projects/PCDM/pcdm-gui.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-gui.cpp 2012-07-27 19:50:41 UTC (rev 17976)
+++ pcbsd-projects/PCDM/pcdm-gui.cpp 2012-07-27 22:14:02 UTC (rev 17977)
@@ -25,7 +25,8 @@
QString style;
//Set the background image
if(Theme::customBackground()){
- QString bgstyle = "PCDMgui {background-image: url(BGIMAGE);}";
+ //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() );
style.append(bgstyle);
}
@@ -45,7 +46,7 @@
//Populate the Toolbar with items (starts at leftmost/topmost)
//----Virtual Keyboard
- QAction* virtkeyboardButton = new QAction( QIcon(Theme::objectIconPath("virt-keyboard")),tr("Keyboard"),this );
+ QAction* virtkeyboardButton = new QAction( QIcon(Theme::objectIconPath("virt-keyboard")),tr("Virtual Keyboard"),this );
toolbar->addAction(virtkeyboardButton);
connect( virtkeyboardButton, SIGNAL(triggered()), this, SLOT(slotPushVirtKeyboard()) );
virtkeyboardButton->setToolTip(tr("Virtual Keyboard"));
@@ -171,7 +172,13 @@
deSwitcher = new FancySwitcher(this,horizontalDE);
QSize deSize = Theme::objectIconSize("desktop");
deSwitcher->setIconSize(deSize.height());
- deSwitcher->setStyleSheet(Theme::objectStyleSheet("desktop"));
+ QString deStyle = Theme::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");
+ }
//Add the available desktops to the switcher
QStringList deList = Backend::getAvailableDesktops();
for(int i=0; i<deList.length(); i++){
Modified: pcbsd-projects/PCDM/pcdm-themes.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-themes.cpp 2012-07-27 19:50:41 UTC (rev 17976)
+++ pcbsd-projects/PCDM/pcdm-themes.cpp 2012-07-27 22:14:02 UTC (rev 17977)
@@ -2,7 +2,8 @@
//Setup variables that save the current theme data
QStringList images, imSizes, imLayout, gridLayout, tbFormat, validLayouts, needText, objStruct, spacers, objStyleSheet;
-bool fullscreenWindow;
+QList<bool> customStyle;
+bool fullscreenWindow, customTbStyle;
int wWidth, wHeight, gridWidth, gridHeight;
//Create the functions to read and output the theme data
@@ -31,7 +32,7 @@
images <<":images/keyboard.png"; imSizes << "32x32"; // [6]=Keyboard Layout
images <<":images/language.png"; imSizes << "32x32"; // [7]=Locale
images <<":images/system.png"; imSizes << "32x32"; // [8]=System
- images <<":images/desktop.png"; imSizes << "32x32"; // [9]=Desktop
+ images <<":images/desktop.png"; imSizes << "54x54"; // [9]=Desktop
images <<":images/input-keyboard.png"; imSizes << "32x32"; // [10]=Virtual Keyboard
}
if( (vars=="all") || (vars=="layout") ){
@@ -43,11 +44,11 @@
imLayout << "icononly"; gridLayout << ""; // [2]=Splash Screen
imLayout << "left"; gridLayout << "2x1"; // [3]=User
imLayout << "left"; gridLayout << "3x1"; // [4]=Password
- imLayout << "disabled"; gridLayout << "4x1"; // [5]=Login
+ imLayout << "left"; gridLayout << "4x1"; // [5]=Login
imLayout << "icononly"; gridLayout << ""; // [6]=Keyboard Layout
imLayout << "icononly"; gridLayout << ""; // [7]=Locale
imLayout << "icononly"; gridLayout << ""; // [8]=System
- imLayout << "left"; gridLayout << "6x1"; // [9]=Desktop
+ imLayout << "horizontal"; gridLayout << "6x1"; // [9]=Desktop
imLayout << "icononly"; gridLayout << ""; // [10]=Virtual Keyboard
spacers.clear();
spacers << "vertical::1::1"; //vertical spacer at row 1, column 1
@@ -64,19 +65,23 @@
objStyleSheet << ""; // [3]=User
objStyleSheet << ""; // [4]=Password
objStyleSheet << ""; // [5]=Login
- objStyleSheet << ""; // [6]=Keyboard Layout
- objStyleSheet << ""; // [7]=Locale
- objStyleSheet << ""; // [8]=System
- objStyleSheet << ""; // [9]=Desktop
- objStyleSheet << ""; // [10]=Virtual Keyboard
+ objStyleSheet << ""; // [6]=Keyboard Layout (not used - toolbar style)
+ objStyleSheet << ""; // [7]=Locale (not used - toolbar style)
+ objStyleSheet << ""; // [8]=System (not used - toolbar style)
+ objStyleSheet << "background: transparent;"; // [9]=Desktop
+ objStyleSheet << ""; // [10]=Virtual Keyboard (not used - toolbar style)
+ //Flag the styles as being defaults
+ customStyle.clear();
+ customStyle << FALSE << FALSE << FALSE << FALSE << FALSE << FALSE << FALSE << FALSE << FALSE << FALSE << FALSE;
}
if( (vars=="all") || (vars=="toolbar") ){
tbFormat.clear();
- tbFormat << "bottom"; // [0] Location [bottom | top | left | right]
- tbFormat << "textunder"; // [1] Style [icononly | textonly | textbeside | textunder]
- tbFormat << "32"; // [2] Width in pixels
- tbFormat << "32"; // [3] Height in pixels
+ tbFormat << "left"; // [0] Location [bottom | top | left | right]
+ tbFormat << "icononly"; // [1] Style [icononly | textonly | textbeside | textunder]
+ tbFormat << "44"; // [2] Width in pixels
+ tbFormat << "44"; // [3] Height in pixels
tbFormat << ""; // [4] Toolbar stylesheet
+ customTbStyle = FALSE;
}
}
@@ -219,9 +224,13 @@
QString obj = val.section("::",0,0);
QString prop = val.section("::",1,1);
QString var = val.section("::",2,2);
- if(obj.toLower()=="toolbar"){ tbFormat[4].append( prop+": "+var+"; "); }
+ if(obj.toLower()=="toolbar"){
+ if(!customTbStyle){ customTbStyle=TRUE; tbFormat[4].clear() ; }
+ tbFormat[4].append( prop+": "+var+"; ");
+ }
else{
int index = getObjectIndex(obj);
+ if(!customStyle[index]){ customStyle[index]=TRUE; objStyleSheet[index].clear(); }
if(index != -1){ objStyleSheet[index].append( prop+": "+var+"; "); }
}
}
@@ -242,7 +251,7 @@
bool Theme::goodLayout(){
//Sanity Check the layout from this theme
- qDebug() << "PCDM: Window Layout Checker not implemented yet";
+ qDebug() << "PCDM: Window layout sanity-check not implemented yet";
return TRUE;
}
//********** WINDOW OBJECTS *************
More information about the Commits
mailing list