@ -533,10 +533,12 @@ void UBBoardController::duplicateScene()
duplicateScene ( mActiveSceneIndex ) ;
duplicateScene ( mActiveSceneIndex ) ;
}
}
void UBBoardController : : duplicateItem ( UBItem * item )
UBGraphicsItem * UBBoardController : : duplicateItem ( UBItem * item )
{
{
if ( ! item )
if ( ! item )
return ;
return NULL ;
UBGraphicsItem * retItem = NULL ;
mLastCreatedItem = NULL ;
mLastCreatedItem = NULL ;
@ -610,6 +612,7 @@ void UBBoardController::duplicateItem(UBItem *item)
case UBMimeType : : Group :
case UBMimeType : : Group :
{
{
UBGraphicsGroupContainerItem * groupItem = dynamic_cast < UBGraphicsGroupContainerItem * > ( item ) ;
UBGraphicsGroupContainerItem * groupItem = dynamic_cast < UBGraphicsGroupContainerItem * > ( item ) ;
UBGraphicsGroupContainerItem * duplicatedGroup = NULL ;
if ( groupItem ) {
if ( groupItem ) {
QTransform groupTransform = groupItem - > transform ( ) ;
QTransform groupTransform = groupItem - > transform ( ) ;
groupItem - > resetTransform ( ) ;
groupItem - > resetTransform ( ) ;
@ -628,13 +631,13 @@ void UBBoardController::duplicateItem(UBItem *item)
if ( ! selItems . empty ( ) ) {
if ( ! selItems . empty ( ) ) {
// I don't like this solution but for now this is the only way I found.
// I don't like this solution but for now this is the only way I found.
// Normally, at this state, only the duplicated group should be selected
// Normally, at this state, only the duplicated group should be selected
UBGraphicsGroupContainerItem * duplicatedGroup = dynamic_cast < UBGraphicsGroupContainerItem * > ( selItems . at ( 0 ) ) ;
duplicatedGroup = dynamic_cast < UBGraphicsGroupContainerItem * > ( selItems . at ( 0 ) ) ;
if ( NULL ! = duplicatedGroup ) {
if ( NULL ! = duplicatedGroup ) {
duplicatedGroup - > setTransform ( groupTransform ) ;
duplicatedGroup - > setTransform ( groupTransform ) ;
}
}
}
}
}
}
ret urn ;
retItem = dynamic_cast < UBG raphicsIt em * > ( d uplicatedG roup ) ;
break ;
break ;
}
}
@ -648,10 +651,13 @@ void UBBoardController::duplicateItem(UBItem *item)
mLastCreatedItem = gitem ;
mLastCreatedItem = gitem ;
gitem - > setSelected ( true ) ;
gitem - > setSelected ( true ) ;
}
}
return ;
retItem = dynamic_cast < UBGraphicsItem * > ( gitem ) ;
} break ;
} break ;
}
}
if ( retItem )
return retItem ;
UBItem * createdItem = downloadFinished ( true , sourceUrl , contentTypeHeader , pData , itemPos , QSize ( itemSize . width ( ) , itemSize . height ( ) ) , false ) ;
UBItem * createdItem = downloadFinished ( true , sourceUrl , contentTypeHeader , pData , itemPos , QSize ( itemSize . width ( ) , itemSize . height ( ) ) , false ) ;
if ( createdItem )
if ( createdItem )
{
{
@ -663,7 +669,10 @@ void UBBoardController::duplicateItem(UBItem *item)
createdGitem - > setPos ( itemPos ) ;
createdGitem - > setPos ( itemPos ) ;
mLastCreatedItem = dynamic_cast < QGraphicsItem * > ( createdItem ) ;
mLastCreatedItem = dynamic_cast < QGraphicsItem * > ( createdItem ) ;
mLastCreatedItem - > setSelected ( true ) ;
mLastCreatedItem - > setSelected ( true ) ;
retItem = dynamic_cast < UBGraphicsItem * > ( createdItem ) ;
}
}
return retItem ;
}
}
void UBBoardController : : deleteScene ( int nIndex )
void UBBoardController : : deleteScene ( int nIndex )
@ -2080,7 +2089,7 @@ UBGraphicsWidgetItem *UBBoardController::addW3cWidget(const QUrl &pUrl, const QP
QString snapshotPath = selectedDocument ( ) - > persistencePath ( ) + " / " + UBPersistenceManager : : widgetDirectory + " / " + struuid + " .png " ;
QString snapshotPath = selectedDocument ( ) - > persistencePath ( ) + " / " + UBPersistenceManager : : widgetDirectory + " / " + struuid + " .png " ;
w3cWidgetItem - > setSnapshotPath ( QUrl : : fromLocalFile ( snapshotPath ) ) ;
w3cWidgetItem - > setSnapshotPath ( QUrl : : fromLocalFile ( snapshotPath ) ) ;
UBGraphicsWidgetItem * tmpItem = dynamic_cast < UBGraphicsWidgetItem * > ( w3cWidgetItem ) ;
UBGraphicsWidgetItem * tmpItem = dynamic_cast < UBGraphicsWidgetItem * > ( w3cWidgetItem ) ;
if ( tmpItem )
if ( tmpItem & & tmpItem - > scene ( ) )
tmpItem - > takeSnapshot ( ) . save ( snapshotPath , " PNG " ) ;
tmpItem - > takeSnapshot ( ) . save ( snapshotPath , " PNG " ) ;
}
}
@ -2293,17 +2302,24 @@ void UBBoardController::togglePodcast(bool checked)
UBPodcastController : : instance ( ) - > toggleRecordingPalette ( checked ) ;
UBPodcastController : : instance ( ) - > toggleRecordingPalette ( checked ) ;
}
}
void UBBoardController : : moveGraphicsWidgetToControlView ( UBGraphicsWidgetItem * graphicsWidget )
void UBBoardController : : moveGraphicsWidgetToControlView ( UBGraphicsWidgetItem * graphicsWidget )
{
{
graphicsWidget - > remove ( ) ;
graphicsWidget - > remove ( ) ;
UBToolWidget * toolWidget = new UBToolWidget ( graphicsWidget ) ;
mActiveScene - > setURStackEnable ( false ) ;
UBGraphicsItem * toolW3C = duplicateItem ( dynamic_cast < UBItem * > ( graphicsWidget ) ) ;
UBGraphicsWidgetItem * copyedGraphicsWidget = NULL ;
if ( UBGraphicsWidgetItem : : Type = = toolW3C - > type ( ) )
copyedGraphicsWidget = static_cast < UBGraphicsWidgetItem * > ( toolW3C ) ;
UBToolWidget * toolWidget = new UBToolWidget ( copyedGraphicsWidget ) ;
mActiveScene - > addItem ( toolWidget ) ;
mActiveScene - > addItem ( toolWidget ) ;
qreal ssf = 1 / UBApplication : : boardController - > systemScaleFactor ( ) ;
qreal ssf = 1 / UBApplication : : boardController - > systemScaleFactor ( ) ;
toolWidget - > setScale ( ssf ) ;
toolWidget - > setScale ( ssf ) ;
toolWidget - > setPos ( graphicsWidget - > scenePos ( ) ) ;
toolWidget - > setPos ( graphicsWidget - > scenePos ( ) ) ;
mActiveScene - > setURStackEnable ( true ) ;
}
}