Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
874e42a2
Commit
874e42a2
authored
May 27, 2011
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reviewed the code a little bit
parent
dbd2aeca
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
76 additions
and
3402 deletions
+76
-3402
Sankore_3.1.pro
Sankore_3.1.pro
+0
-1
library.ui
resources/forms/library.ui
+0
-922
UBBoardController.cpp
src/board/UBBoardController.cpp
+1
-21
UBBoardController.h
src/board/UBBoardController.h
+0
-1
UBLibraryController.cpp
src/board/UBLibraryController.cpp
+61
-1832
UBLibraryController.h
src/board/UBLibraryController.h
+0
-246
UBLibraryTreeWidget.cpp
src/board/UBLibraryTreeWidget.cpp
+0
-247
UBLibraryTreeWidget.h
src/board/UBLibraryTreeWidget.h
+0
-62
board.pri
src/board/board.pri
+0
-2
UBApplication.cpp
src/core/UBApplication.cpp
+5
-56
UBLibPathViewer.cpp
src/gui/UBLibPathViewer.cpp
+9
-12
No files found.
Sankore_3.1.pro
View file @
874e42a2
...
...
@@ -65,7 +65,6 @@ FORMS += resources/forms/mainWindow.ui \
resources
/
forms
/
preferences
.
ui
\
resources
/
forms
/
brushProperties
.
ui
\
resources
/
forms
/
documents
.
ui
\
resources
/
forms
/
library
.
ui
\
resources
/
forms
/
blackoutWidget
.
ui
\
resources
/
forms
/
trapFlash
.
ui
\
resources
/
forms
/
youTubePublishingDialog
.
ui
\
...
...
resources/forms/library.ui
deleted
100644 → 0
View file @
dbd2aeca
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
library
</class>
<widget
class=
"QWidget"
name=
"library"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
961
</width>
<height>
550
</height>
</rect>
</property>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Preferred"
vsizetype=
"Preferred"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"contextMenuPolicy"
>
<enum>
Qt::DefaultContextMenu
</enum>
</property>
<property
name=
"windowTitle"
>
<string>
Sankore Library
</string>
</property>
<layout
class=
"QGridLayout"
name=
"gridLayout"
>
<property
name=
"margin"
>
<number>
0
</number>
</property>
<property
name=
"spacing"
>
<number>
0
</number>
</property>
<item
row=
"0"
column=
"0"
>
<widget
class=
"QFrame"
name=
"topFrame"
>
<property
name=
"frameShape"
>
<enum>
QFrame::NoFrame
</enum>
</property>
<property
name=
"frameShadow"
>
<enum>
QFrame::Raised
</enum>
</property>
<property
name=
"lineWidth"
>
<number>
0
</number>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
>
<item>
<widget
class=
"QTabWidget"
name=
"libraryTab"
>
<property
name=
"tabShape"
>
<enum>
QTabWidget::Rounded
</enum>
</property>
<property
name=
"currentIndex"
>
<number>
0
</number>
</property>
<property
name=
"elideMode"
>
<enum>
Qt::ElideLeft
</enum>
</property>
<widget
class=
"QWidget"
name=
"gipTab"
>
<attribute
name=
"title"
>
<string>
Iteractive Models
</string>
</attribute>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_11"
>
<item>
<widget
class=
"UBThumbnailWidget"
name=
"gipThumbnailView"
>
<property
name=
"contextMenuPolicy"
>
<enum>
Qt::NoContextMenu
</enum>
</property>
<property
name=
"styleSheet"
>
<string
notr=
"true"
/>
</property>
<property
name=
"frameShape"
>
<enum>
QFrame::NoFrame
</enum>
</property>
<property
name=
"lineWidth"
>
<number>
0
</number>
</property>
<property
name=
"verticalScrollBarPolicy"
>
<enum>
Qt::ScrollBarAsNeeded
</enum>
</property>
<property
name=
"horizontalScrollBarPolicy"
>
<enum>
Qt::ScrollBarAlwaysOff
</enum>
</property>
<property
name=
"dragMode"
>
<enum>
QGraphicsView::NoDrag
</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget
class=
"QWidget"
name=
"interactiveTab"
>
<attribute
name=
"title"
>
<string>
Applications
</string>
</attribute>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_3"
>
<item>
<widget
class=
"QFrame"
name=
"interactiveTopLeftFrame"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Fixed"
vsizetype=
"Minimum"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"frameShape"
>
<enum>
QFrame::Box
</enum>
</property>
<property
name=
"frameShadow"
>
<enum>
QFrame::Plain
</enum>
</property>
<property
name=
"lineWidth"
>
<number>
1
</number>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_3"
>
<property
name=
"spacing"
>
<number>
0
</number>
</property>
<property
name=
"margin"
>
<number>
0
</number>
</property>
<item>
<widget
class=
"UBLibraryTreeWidget"
name=
"interactiveLibraryTreeWidget"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Fixed"
vsizetype=
"Expanding"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"styleSheet"
>
<string
notr=
"true"
/>
</property>
<property
name=
"frameShape"
>
<enum>
QFrame::NoFrame
</enum>
</property>
<property
name=
"frameShadow"
>
<enum>
QFrame::Plain
</enum>
</property>
<property
name=
"lineWidth"
>
<number>
0
</number>
</property>
<property
name=
"dragDropMode"
>
<enum>
QAbstractItemView::DropOnly
</enum>
</property>
<property
name=
"horizontalScrollMode"
>
<enum>
QAbstractItemView::ScrollPerPixel
</enum>
</property>
<property
name=
"autoExpandDelay"
>
<number>
2
</number>
</property>
<property
name=
"headerHidden"
>
<bool>
true
</bool>
</property>
<attribute
name=
"headerVisible"
>
<bool>
false
</bool>
</attribute>
<column>
<property
name=
"text"
>
<string
notr=
"true"
>
1
</string>
</property>
</column>
</widget>
</item>
<item>
<widget
class=
"QToolButton"
name=
"newInteractiveFolderButton"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Maximum"
vsizetype=
"Minimum"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"minimumSize"
>
<size>
<width>
0
</width>
<height>
0
</height>
</size>
</property>
<property
name=
"maximumSize"
>
<size>
<width>
16777215
</width>
<height>
42
</height>
</size>
</property>
<property
name=
"text"
>
<string>
New Folder
</string>
</property>
<property
name=
"icon"
>
<iconset
resource=
"../sankore.qrc"
>
<normaloff>
:/images/toolbar/newFolder.png
</normaloff>
:/images/toolbar/newFolder.png
</iconset>
</property>
<property
name=
"iconSize"
>
<size>
<width>
32
</width>
<height>
32
</height>
</size>
</property>
<property
name=
"toolButtonStyle"
>
<enum>
Qt::ToolButtonTextBesideIcon
</enum>
</property>
<property
name=
"autoRaise"
>
<bool>
true
</bool>
</property>
<property
name=
"arrowType"
>
<enum>
Qt::NoArrow
</enum>
</property>
</widget>
</item>
<item>
<widget
class=
"QToolButton"
name=
"addInteractiveToLibraryButton"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Maximum"
vsizetype=
"Minimum"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"minimumSize"
>
<size>
<width>
0
</width>
<height>
0
</height>
</size>
</property>
<property
name=
"maximumSize"
>
<size>
<width>
16777215
</width>
<height>
42
</height>
</size>
</property>
<property
name=
"text"
>
<string>
Import to Library
</string>
</property>
<property
name=
"icon"
>
<iconset
resource=
"../sankore.qrc"
>
<normaloff>
:/images/toolbar/addInteractiveToLibrary.png
</normaloff>
:/images/toolbar/addInteractiveToLibrary.png
</iconset>
</property>
<property
name=
"iconSize"
>
<size>
<width>
32
</width>
<height>
32
</height>
</size>
</property>
<property
name=
"toolButtonStyle"
>
<enum>
Qt::ToolButtonTextBesideIcon
</enum>
</property>
<property
name=
"autoRaise"
>
<bool>
true
</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget
class=
"QStackedWidget"
name=
"interactiveLibrariesStack"
>
<widget
class=
"QWidget"
name=
"interactivePageLocal"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_7"
>
<item>
<widget
class=
"UBThumbnailWidget"
name=
"interactiveThumbnailView"
>
<property
name=
"contextMenuPolicy"
>
<enum>
Qt::NoContextMenu
</enum>
</property>
<property
name=
"styleSheet"
>
<string
notr=
"true"
/>
</property>
<property
name=
"frameShape"
>
<enum>
QFrame::NoFrame
</enum>
</property>
<property
name=
"lineWidth"
>
<number>
0
</number>
</property>
<property
name=
"verticalScrollBarPolicy"
>
<enum>
Qt::ScrollBarAsNeeded
</enum>
</property>
<property
name=
"horizontalScrollBarPolicy"
>
<enum>
Qt::ScrollBarAlwaysOff
</enum>
</property>
<property
name=
"dragMode"
>
<enum>
QGraphicsView::NoDrag
</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget
class=
"QWidget"
name=
"interactivePageOnline"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_8"
/>
</widget>
</widget>
</item>
</layout>
</widget>
<widget
class=
"QWidget"
name=
"imageTab"
>
<attribute
name=
"title"
>
<string>
Images
</string>
</attribute>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<item>
<widget
class=
"QFrame"
name=
"imageTopLeftFrame"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Fixed"
vsizetype=
"Minimum"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"frameShape"
>
<enum>
QFrame::Box
</enum>
</property>
<property
name=
"frameShadow"
>
<enum>
QFrame::Plain
</enum>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_2"
>
<property
name=
"spacing"
>
<number>
0
</number>
</property>
<property
name=
"margin"
>
<number>
0
</number>
</property>
<item>
<widget
class=
"UBLibraryTreeWidget"
name=
"imageLibraryTreeWidget"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Fixed"
vsizetype=
"Expanding"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"styleSheet"
>
<string
notr=
"true"
/>
</property>
<property
name=
"frameShape"
>
<enum>
QFrame::NoFrame
</enum>
</property>
<property
name=
"frameShadow"
>
<enum>
QFrame::Plain
</enum>
</property>
<property
name=
"lineWidth"
>
<number>
0
</number>
</property>
<property
name=
"horizontalScrollMode"
>
<enum>
QAbstractItemView::ScrollPerPixel
</enum>
</property>
<property
name=
"autoExpandDelay"
>
<number>
2
</number>
</property>
<property
name=
"headerHidden"
>
<bool>
true
</bool>
</property>
<attribute
name=
"headerVisible"
>
<bool>
false
</bool>
</attribute>
<column>
<property
name=
"text"
>
<string
notr=
"true"
>
1
</string>
</property>
</column>
</widget>
</item>
<item>
<widget
class=
"QToolButton"
name=
"newFolderButton"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Maximum"
vsizetype=
"Fixed"
>
<horstretch>
1
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"minimumSize"
>
<size>
<width>
0
</width>
<height>
0
</height>
</size>
</property>
<property
name=
"maximumSize"
>
<size>
<width>
16777215
</width>
<height>
42
</height>
</size>
</property>
<property
name=
"text"
>
<string>
New Folder
</string>
</property>
<property
name=
"icon"
>
<iconset
resource=
"../sankore.qrc"
>
<normaloff>
:/images/toolbar/newFolder.png
</normaloff>
:/images/toolbar/newFolder.png
</iconset>
</property>
<property
name=
"iconSize"
>
<size>
<width>
32
</width>
<height>
32
</height>
</size>
</property>
<property
name=
"toolButtonStyle"
>
<enum>
Qt::ToolButtonTextBesideIcon
</enum>
</property>
<property
name=
"autoRaise"
>
<bool>
true
</bool>
</property>
</widget>
</item>
<item>
<widget
class=
"QToolButton"
name=
"addImageToLibraryButton"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Maximum"
vsizetype=
"Fixed"
>
<horstretch>
1
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"minimumSize"
>
<size>
<width>
0
</width>
<height>
0
</height>
</size>
</property>
<property
name=
"maximumSize"
>
<size>
<width>
16777215
</width>
<height>
42
</height>
</size>
</property>
<property
name=
"text"
>
<string>
Import to Library
</string>
</property>
<property
name=
"icon"
>
<iconset
resource=
"../sankore.qrc"
>
<normaloff>
:/images/toolbar/addToLibrary.png
</normaloff>
:/images/toolbar/addToLibrary.png
</iconset>
</property>
<property
name=
"iconSize"
>
<size>
<width>
32
</width>
<height>
32
</height>
</size>
</property>
<property
name=
"toolButtonStyle"
>
<enum>
Qt::ToolButtonTextBesideIcon
</enum>
</property>
<property
name=
"autoRaise"
>
<bool>
true
</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget
class=
"QStackedWidget"
name=
"imageLibrariesStack"
>
<property
name=
"currentIndex"
>
<number>
1
</number>
</property>
<widget
class=
"QWidget"
name=
"imagePageLocal"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_5"
>
<item>
<widget
class=
"UBThumbnailWidget"
name=
"imageThumbnailView"
>
<property
name=
"contextMenuPolicy"
>
<enum>
Qt::NoContextMenu
</enum>
</property>
<property
name=
"styleSheet"
>
<string
notr=
"true"
/>
</property>
<property
name=
"frameShape"
>
<enum>
QFrame::NoFrame
</enum>
</property>
<property
name=
"lineWidth"
>
<number>
0
</number>
</property>
<property
name=
"verticalScrollBarPolicy"
>
<enum>
Qt::ScrollBarAsNeeded
</enum>
</property>
<property
name=
"horizontalScrollBarPolicy"
>
<enum>
Qt::ScrollBarAlwaysOff
</enum>
</property>
<property
name=
"dragMode"
>
<enum>
QGraphicsView::NoDrag
</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget
class=
"QWidget"
name=
"imagePageOnline"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_4"
/>
</widget>
</widget>
</item>
</layout>
</widget>
<widget
class=
"QWidget"
name=
"videoTab"
>
<attribute
name=
"title"
>
<string>
Movies
</string>
</attribute>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_10"
>
<item>
<widget
class=
"QFrame"
name=
"videoTopLeftFrame"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Fixed"
vsizetype=
"Minimum"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"frameShape"
>
<enum>
QFrame::Box
</enum>
</property>
<property
name=
"frameShadow"
>
<enum>
QFrame::Plain
</enum>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_4"
>
<property
name=
"spacing"
>
<number>
0
</number>
</property>
<property
name=
"margin"
>
<number>
0
</number>
</property>
<item>
<widget
class=
"UBLibraryTreeWidget"
name=
"videoLibraryTreeWidget"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Fixed"
vsizetype=
"Expanding"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"styleSheet"
>
<string
notr=
"true"
/>
</property>
<property
name=
"frameShape"
>
<enum>
QFrame::NoFrame
</enum>
</property>
<property
name=
"frameShadow"
>
<enum>
QFrame::Plain
</enum>
</property>
<property
name=
"lineWidth"
>
<number>
0
</number>
</property>
<property
name=
"horizontalScrollMode"
>
<enum>
QAbstractItemView::ScrollPerPixel
</enum>
</property>
<property
name=
"autoExpandDelay"
>
<number>
2
</number>
</property>
<property
name=
"headerHidden"
>
<bool>
true
</bool>
</property>
<attribute
name=
"headerVisible"
>
<bool>
false
</bool>
</attribute>
<column>
<property
name=
"text"
>
<string
notr=
"true"
>
1
</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget
class=
"QStackedWidget"
name=
"videoLibrariesStack"
>
<property
name=
"currentIndex"
>
<number>
0
</number>
</property>
<widget
class=
"QWidget"
name=
"videoPageLocal"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_6"
>
<item>
<widget
class=
"UBThumbnailWidget"
name=
"videoThumbnailView"
>
<property
name=
"contextMenuPolicy"
>
<enum>
Qt::NoContextMenu
</enum>
</property>
<property
name=
"styleSheet"
>
<string
notr=
"true"
/>
</property>
<property
name=
"frameShape"
>
<enum>
QFrame::NoFrame
</enum>
</property>
<property
name=
"lineWidth"
>
<number>
0
</number>
</property>
<property
name=
"verticalScrollBarPolicy"
>
<enum>
Qt::ScrollBarAsNeeded
</enum>
</property>
<property
name=
"horizontalScrollBarPolicy"
>
<enum>
Qt::ScrollBarAlwaysOff
</enum>
</property>
<property
name=
"dragMode"
>
<enum>
QGraphicsView::NoDrag
</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget
class=
"QWidget"
name=
"videoPageOnline"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_9"
/>
</widget>
</widget>
</item>
</layout>
</widget>
<widget
class=
"QWidget"
name=
"shapeTab"
>
<attribute
name=
"title"
>
<string>
Shapes
</string>
</attribute>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_2"
>
<item>
<widget
class=
"UBThumbnailWidget"
name=
"shapeThumbnailView"
>
<property
name=
"contextMenuPolicy"
>
<enum>
Qt::NoContextMenu
</enum>
</property>
<property
name=
"styleSheet"
>
<string
notr=
"true"
/>
</property>
<property
name=
"frameShape"
>
<enum>
QFrame::NoFrame
</enum>
</property>
<property
name=
"frameShadow"
>
<enum>
QFrame::Plain
</enum>
</property>
<property
name=
"lineWidth"
>
<number>
0
</number>
</property>
<property
name=
"verticalScrollBarPolicy"
>
<enum>
Qt::ScrollBarAsNeeded
</enum>
</property>
<property
name=
"horizontalScrollBarPolicy"
>
<enum>
Qt::ScrollBarAlwaysOff
</enum>
</property>
<property
name=
"dragMode"
>
<enum>
QGraphicsView::NoDrag
</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget
class=
"QWidget"
name=
"soundTab"
>
<attribute
name=
"title"
>
<string>
Sounds
</string>
</attribute>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_12"
>
<item>
<widget
class=
"UBThumbnailWidget"
name=
"soundThumbnailView"
>
<property
name=
"contextMenuPolicy"
>
<enum>
Qt::NoContextMenu
</enum>
</property>
<property
name=
"styleSheet"
>
<string
notr=
"true"
/>
</property>
<property
name=
"frameShape"
>
<enum>
QFrame::NoFrame
</enum>
</property>
<property
name=
"lineWidth"
>
<number>
0
</number>
</property>
<property
name=
"verticalScrollBarPolicy"
>
<enum>
Qt::ScrollBarAsNeeded
</enum>
</property>
<property
name=
"horizontalScrollBarPolicy"
>
<enum>
Qt::ScrollBarAlwaysOff
</enum>
</property>
<property
name=
"dragMode"
>
<enum>
QGraphicsView::NoDrag
</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget
class=
"QFrame"
name=
"toolFrame"
>
<property
name=
"frameShape"
>
<enum>
QFrame::NoFrame
</enum>
</property>
<property
name=
"frameShadow"
>
<enum>
QFrame::Plain
</enum>
</property>
<property
name=
"lineWidth"
>
<number>
0
</number>
</property>
<property
name=
"midLineWidth"
>
<number>
0
</number>
</property>
<layout
class=
"QHBoxLayout"
name=
"toolFrameLayout"
>
<item>
<spacer
name=
"horizontalSpacer_1"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeType"
>
<enum>
QSizePolicy::Fixed
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
20
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
<item>
<widget
class=
"QToolButton"
name=
"removeButton"
>
<property
name=
"text"
>
<string>
Delete
</string>
</property>
<property
name=
"icon"
>
<iconset
resource=
"../sankore.qrc"
>
<normaloff>
:/images/toolbar/remove.png
</normaloff>
:/images/toolbar/remove.png
</iconset>
</property>
<property
name=
"iconSize"
>
<size>
<width>
32
</width>
<height>
32
</height>
</size>
</property>
<property
name=
"toolButtonStyle"
>
<enum>
Qt::ToolButtonTextUnderIcon
</enum>
</property>
<property
name=
"autoRaise"
>
<bool>
true
</bool>
</property>
</widget>
</item>
<item>
<widget
class=
"QToolButton"
name=
"setAsBackgroundButton"
>
<property
name=
"text"
>
<string>
Set as Background
</string>
</property>
<property
name=
"icon"
>
<iconset
resource=
"../sankore.qrc"
>
<normaloff>
:/images/toolbar/setBackground.png
</normaloff>
:/images/toolbar/setBackground.png
</iconset>
</property>
<property
name=
"iconSize"
>
<size>
<width>
32
</width>
<height>
32
</height>
</size>
</property>
<property
name=
"toolButtonStyle"
>
<enum>
Qt::ToolButtonTextUnderIcon
</enum>
</property>
<property
name=
"autoRaise"
>
<bool>
true
</bool>
</property>
</widget>
</item>
<item>
<widget
class=
"QToolButton"
name=
"removeBackgroundButton"
>
<property
name=
"text"
>
<string>
Remove Background
</string>
</property>
<property
name=
"icon"
>
<iconset
resource=
"../sankore.qrc"
>
<normaloff>
:/images/toolbar/removeBackground.png
</normaloff>
:/images/toolbar/removeBackground.png
</iconset>
</property>
<property
name=
"iconSize"
>
<size>
<width>
32
</width>
<height>
32
</height>
</size>
</property>
<property
name=
"toolButtonStyle"
>
<enum>
Qt::ToolButtonTextUnderIcon
</enum>
</property>
<property
name=
"autoRaise"
>
<bool>
true
</bool>
</property>
</widget>
</item>
<item>
<widget
class=
"QToolButton"
name=
"addToDocumentButton"
>
<property
name=
"text"
>
<string>
Add File to Page
</string>
</property>
<property
name=
"icon"
>
<iconset
resource=
"../sankore.qrc"
>
<normaloff>
:/images/toolbar/import.png
</normaloff>
:/images/toolbar/import.png
</iconset>
</property>
<property
name=
"iconSize"
>
<size>
<width>
32
</width>
<height>
32
</height>
</size>
</property>
<property
name=
"toolButtonStyle"
>
<enum>
Qt::ToolButtonTextUnderIcon
</enum>
</property>
<property
name=
"autoRaise"
>
<bool>
true
</bool>
</property>
</widget>
</item>
<item>
<widget
class=
"QToolButton"
name=
"addToPageButton"
>
<property
name=
"text"
>
<string>
Add to Page
</string>
</property>
<property
name=
"icon"
>
<iconset
resource=
"../sankore.qrc"
>
<normaloff>
:/images/toolbar/addToPage.png
</normaloff>
:/images/toolbar/addToPage.png
</iconset>
</property>
<property
name=
"iconSize"
>
<size>
<width>
32
</width>
<height>
32
</height>
</size>
</property>
<property
name=
"toolButtonStyle"
>
<enum>
Qt::ToolButtonTextUnderIcon
</enum>
</property>
<property
name=
"autoRaise"
>
<bool>
true
</bool>
</property>
</widget>
</item>
<item>
<widget
class=
"QToolButton"
name=
"addToParaschoolEditor"
>
<property
name=
"enabled"
>
<bool>
true
</bool>
</property>
<property
name=
"autoFillBackground"
>
<bool>
false
</bool>
</property>
<property
name=
"text"
>
<string>
Add to Editor
</string>
</property>
<property
name=
"icon"
>
<iconset
resource=
"../sankore.qrc"
>
<normaloff>
:/images/addItemToCurrentPage.svg
</normaloff>
:/images/addItemToCurrentPage.svg
</iconset>
</property>
<property
name=
"iconSize"
>
<size>
<width>
32
</width>
<height>
32
</height>
</size>
</property>
<property
name=
"toolButtonStyle"
>
<enum>
Qt::ToolButtonTextUnderIcon
</enum>
</property>
<property
name=
"autoRaise"
>
<bool>
true
</bool>
</property>
</widget>
</item>
<item>
<spacer
name=
"horizontalSpacer_4"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
40
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
<item>
<widget
class=
"QSlider"
name=
"zoomSlider"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Fixed"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"minimumSize"
>
<size>
<width>
150
</width>
<height>
0
</height>
</size>
</property>
<property
name=
"styleSheet"
>
<string
notr=
"true"
/>
</property>
<property
name=
"minimum"
>
<number>
50
</number>
</property>
<property
name=
"maximum"
>
<number>
500
</number>
</property>
<property
name=
"singleStep"
>
<number>
10
</number>
</property>
<property
name=
"value"
>
<number>
150
</number>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"invertedAppearance"
>
<bool>
false
</bool>
</property>
<property
name=
"invertedControls"
>
<bool>
false
</bool>
</property>
</widget>
</item>
<item>
<spacer
name=
"horizontalSpacer"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeType"
>
<enum>
QSizePolicy::Minimum
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
20
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault
spacing=
"0"
margin=
"0"
/>
<customwidgets>
<customwidget>
<class>
UBThumbnailWidget
</class>
<extends>
QGraphicsView
</extends>
<header>
gui/UBThumbnailWidget.h
</header>
</customwidget>
<customwidget>
<class>
UBLibraryTreeWidget
</class>
<extends>
QTreeWidget
</extends>
<header>
board/UBLibraryTreeWidget.h
</header>
</customwidget>
</customwidgets>
<resources>
<include
location=
"../sankore.qrc"
/>
</resources>
<connections/>
</ui>
src/board/UBBoardController.cpp
View file @
874e42a2
...
...
@@ -332,7 +332,6 @@ void UBBoardController::connectToolbar()
connect
(
mMainWindow
->
actionRedo
,
SIGNAL
(
triggered
()),
UBApplication
::
undoStack
,
SLOT
(
redo
()));
connect
(
mMainWindow
->
actionBack
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
previousScene
()));
connect
(
mMainWindow
->
actionForward
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
nextScene
()));
connect
(
mMainWindow
->
actionLibrary
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
showLibraryDialog
(
bool
)));
connect
(
mMainWindow
->
actionSleep
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
blackout
()));
connect
(
mMainWindow
->
actionVirtualKeyboard
,
SIGNAL
(
triggered
(
bool
)),
this
,
SLOT
(
showKeyboard
(
bool
)));
connect
(
mMainWindow
->
actionImportPage
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
importPage
()));
...
...
@@ -526,19 +525,6 @@ void UBBoardController::showDocumentsDialog()
}
void
UBBoardController
::
showLibraryDialog
(
bool
show
)
{
if
(
!
mLibraryController
)
{
mLibraryController
=
new
UBLibraryController
(
mMainWindow
->
centralWidget
(),
this
);
connect
(
mLibraryController
,
SIGNAL
(
dialogClosed
(
int
)),
this
,
SLOT
(
libraryDialogClosed
(
int
)));
}
mLibraryController
->
showLibraryDialog
(
show
);
}
void
UBBoardController
::
libraryDialogClosed
(
int
ret
)
{
Q_UNUSED
(
ret
);
...
...
@@ -1371,10 +1357,6 @@ UBToolWidget* UBBoardController::addTool(const QUrl& toolUrl)
UBToolWidget
*
UBBoardController
::
addTool
(
const
QUrl
&
toolUrl
,
QPointF
scenePos
)
{
UBToolWidget
*
toolWidget
=
new
UBToolWidget
(
toolUrl
,
mMainWindow
);
// Deleted in UBBoardController::removeTool
if
(
mLibraryController
&&
mLibraryController
->
libraryWindow
())
toolWidget
->
stackUnder
(
mLibraryController
->
libraryWindow
());
QPoint
pos
=
mControlView
->
mapToGlobal
(
mControlView
->
mapFromScene
(
scenePos
));
pos
-=
QPoint
(
toolWidget
->
width
()
/
2
,
toolWidget
->
height
()
/
2
);
...
...
@@ -1551,8 +1533,6 @@ void UBBoardController::updateBackgroundState()
newBackgroundStyle
=
"QWidget {background-color: #F1F1F1}"
;
}
// if (mControlContainer->styleSheet() != newBackgroundStyle)
// mControlContainer->setStyleSheet(newBackgroundStyle);
}
...
...
src/board/UBBoardController.h
View file @
874e42a2
...
...
@@ -149,7 +149,6 @@ class UBBoardController : public QObject
void
setActiveDocumentScene
(
UBDocumentProxy
*
pDocumentProxy
,
int
pSceneIndex
=
0
);
void
showDocumentsDialog
();
void
showLibraryDialog
(
bool
show
);
void
showKeyboard
(
bool
show
);
...
...
src/board/UBLibraryController.cpp
View file @
874e42a2
#include "UBLibraryController.h"
#include <QtSvg>
#include <QtXml>
#include <QSettings>
#include <Qt>
#include "frameworks/UBFileSystemUtils.h"
#include "frameworks/UBPlatformUtils.h"
#include "frameworks/UBDesktopServices.h"
#include "frameworks/UBFileSystemUtils.h"
#include "pdf/XPDFRenderer.h"
#include "core/UBApplication.h"
#include "core/UBPersistenceManager.h"
...
...
@@ -18,9 +10,6 @@
#include "core/UBSetting.h"
#include "core/UBApplicationController.h"
#include "network/UBNetworkAccessManager.h"
#include "network/UBServerXMLHttpRequest.h"
#include "domain/UBAbstractWidget.h"
#include "domain/UBGraphicsScene.h"
#include "domain/UBGraphicsSvgItem.h"
...
...
@@ -31,19 +20,10 @@
#include "tools/UBToolsManager.h"
#include "board/UBBoardView.h"
#include "board/UBDrawingController.h"
#include "web/UBWebPage.h"
#include "web/UBWebController.h"
#include "gui/UBMainWindow.h"
#include "api/UBLibraryAPI.h"
#include "UBBoardController.h"
#include "../frameworks/UBFileSystemUtils.h"
#include
<QDataStream>
#include
"gui/UBThumbnailWidget.h"
static
quint32
magicNumber
=
0xACDCAFE0
;
static
QString
favoriteVirtualPath
=
"$favorite$"
;
...
...
@@ -52,20 +32,8 @@ UBLibraryController::UBLibraryController(QWidget *pParentWidget, UBBoardControll
QObject
(
pParentWidget
),
mParentWidget
(
pParentWidget
),
mBoardController
(
pBoardController
),
mLibraryWindow
(
0
),
mLibraryUI
(
0
),
mImageWebView
(
0
),
mVideoWebView
(
0
),
mInteractiveWebView
(
0
),
mImageOnlineTi
(
0
),
mVideoOnlineTi
(
0
),
mInteractiveOnlineTi
(
0
),
mInteractiveUniboardTi
(
0
),
mLastItemOffsetIndex
(
0
),
mNeedRefreshOnNextDisplay
(
false
)
mLastItemOffsetIndex
(
0
)
{
QString
dummyBackgrounds
=
tr
(
"Backgrounds"
);
mLibraryFileToDownload
=
onlineLibraries
();
readFavoriteList
();
mAudioStandardDirectoryPath
=
QUrl
::
fromLocalFile
(
UBDesktopServices
::
storageLocation
(
QDesktopServices
::
MusicLocation
));
...
...
@@ -120,19 +88,6 @@ void UBLibraryController::createDirectory(QUrl& pDirPath)
QDir
().
mkpath
(
pDirPath
.
toLocalFile
());
}
void
UBLibraryController
::
preloadFirstOnlineLibrary
()
{
new
UBLibraryPreloader
(
UBApplication
::
staticMemoryCleaner
);
}
QStringList
UBLibraryController
::
onlineLibraries
()
{
QStringList
libraries
;
libraries
<<
UBSettings
::
settings
()
->
softwareLibrariesUrl
+
"/libraries-release.xml"
;
return
libraries
;
}
void
UBLibraryController
::
routeItem
(
QString
&
pItem
,
QString
pMiddleDirectory
)
{
QFileInfo
itemToRoute
(
pItem
);
...
...
@@ -450,7 +405,7 @@ QList<UBLibElement*> UBLibraryController::getContent(UBLibElement *element)
UBLibraryController
::~
UBLibraryController
()
{
delete
mLibraryUI
;
//NOOP
}
...
...
@@ -458,7 +413,7 @@ UBLibraryController::~UBLibraryController()
void
UBLibraryController
::
setItemAsBackground
(
UBLibElement
*
image
)
{
if
(
!
activeScene
()){
q
Warnin
g
()
<<
"No active scene"
;
q
Debu
g
()
<<
"No active scene"
;
return
;
}
QString
mimeType
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
image
->
path
().
toLocalFile
());
...
...
@@ -510,10 +465,9 @@ void UBLibraryController::addItemToPage(UBLibElement* item)
void
UBLibraryController
::
removeBackground
()
{
if
(
activeScene
())
{
if
(
activeScene
())
activeScene
()
->
setAsBackgroundObject
(
0
);
selectionChanged
();
}
}
UBGraphicsScene
*
UBLibraryController
::
activeScene
()
...
...
@@ -604,1823 +558,98 @@ void UBLibraryController::removeFromFavorite(QList<UBLibElement*> elementList)
persistFavoriteList
();
}
QRectF
UBLibraryController
::
visibleSceneRect
()
{
QRectF
visibleSceneRect
(
0
,
0
,
0
,
0
);
if
(
activeScene
()
&&
mBoardController
&&
mBoardController
->
controlView
())
{
QPointF
topLeftCorner
=
mBoardController
->
controlGeometry
().
topLeft
();
QPointF
bottomRightCorner
=
mBoardController
->
controlGeometry
().
bottomRight
();
QPointF
sceneTopLeft
=
mBoardController
->
controlView
()
->
mapToScene
(
topLeftCorner
.
toPoint
());
QPointF
sceneBottomRight
=
mBoardController
->
controlView
()
->
mapToScene
(
bottomRightCorner
.
toPoint
());
void
UBLibraryController
::
refreshShapeThumbnailsView
()
{
QApplication
::
setOverrideCursor
(
QCursor
(
Qt
::
WaitCursor
));
QStringList
shapePaths
=
UBPersistenceManager
::
persistenceManager
()
->
allShapes
();
mSvgItemToFilepath
.
clear
();
QList
<
QGraphicsItem
*>
items
;
QList
<
QUrl
>
itemsPath
;
for
(
int
i
=
0
;
i
<
shapePaths
.
size
();
i
++
)
{
QString
path
=
shapePaths
.
at
(
i
);
UBThumbnailSvg
*
svgItem
=
new
UBThumbnailSvg
(
path
);
mSvgItemToFilepath
.
insert
(
svgItem
,
path
);
items
.
append
(
svgItem
);
itemsPath
.
append
(
QUrl
::
fromLocalFile
(
path
));
}
mLibraryUI
->
shapeThumbnailView
->
setGraphicsItems
(
items
,
itemsPath
);
QApplication
::
restoreOverrideCursor
();
}
void
UBLibraryController
::
refreshImageThumbnailsView
()
{
QApplication
::
setOverrideCursor
(
QCursor
(
Qt
::
WaitCursor
));
mSvgImageItemToFilepath
.
clear
();
mPixmapItemToFilepath
.
clear
();
QList
<
QGraphicsItem
*>
items
;
QList
<
QUrl
>
itemsPath
;
QList
<
QTreeWidgetItem
*>
tw
=
mLibraryUI
->
imageLibraryTreeWidget
->
selectedItems
();
if
(
tw
.
size
()
>
0
)
{
UBLibraryFolderItem
*
fi
=
dynamic_cast
<
UBLibraryFolderItem
*>
(
tw
.
last
());
if
(
fi
)
{
QStringList
imagePaths
=
UBPersistenceManager
::
persistenceManager
()
->
allImages
(
fi
->
dir
());
for
(
int
i
=
0
;
i
<
imagePaths
.
size
();
i
++
)
{
QString
path
=
imagePaths
.
at
(
i
);
if
(
!
path
.
contains
(
".thumbnail."
))
{
if
(
path
.
endsWith
(
"svg"
,
Qt
::
CaseInsensitive
)
||
path
.
endsWith
(
"svgz"
,
Qt
::
CaseInsensitive
))
{
UBThumbnailSvg
*
svgItem
=
new
UBThumbnailSvg
(
path
);
items
.
append
(
svgItem
);
itemsPath
.
append
(
QUrl
::
fromLocalFile
(
path
));
mSvgImageItemToFilepath
.
insert
(
svgItem
,
path
);
}
else
{
// The image is not a thumbnail ...
QString
thumbnailPath
=
UBFileSystemUtils
::
thumbnailPath
(
path
);
if
(
!
QFileInfo
(
thumbnailPath
).
exists
())
{
// ... and the thumbnail does not exist
QPixmap
pix
(
path
);
if
(
!
pix
.
isNull
())
{
// actually create the thumbnail
pix
=
pix
.
scaledToWidth
(
qMin
(
UBSettings
::
maxThumbnailWidth
,
pix
.
width
()),
Qt
::
SmoothTransformation
);
pix
.
save
(
thumbnailPath
);
QGraphicsPixmapItem
*
pixmapItem
=
new
UBThumbnailPixmap
(
pix
);
items
.
append
(
pixmapItem
);
itemsPath
.
append
(
QUrl
::
fromLocalFile
(
path
));
mPixmapItemToFilepath
.
insert
(
pixmapItem
,
path
);
}
}
UBPlatformUtils
::
hideFile
(
thumbnailPath
);
}
}
else
{
// The image is a thumbnail
QString
originalImagePath
(
path
);
originalImagePath
.
remove
(
".thumbnail"
);
if
(
!
QFileInfo
(
originalImagePath
).
exists
())
{
// Skip images that have a thumbnail only but no corresponding original image
continue
;
}
QPixmap
pix
(
path
);
if
(
!
pix
.
isNull
())
{
QGraphicsPixmapItem
*
pixmapItem
=
new
UBThumbnailPixmap
(
pix
);
//deleted while replaced in the scene or by the scene destruction
items
.
append
(
pixmapItem
);
itemsPath
.
append
(
QUrl
::
fromLocalFile
(
originalImagePath
));
mPixmapItemToFilepath
.
insert
(
pixmapItem
,
originalImagePath
);
}
}
}
}
}
mLibraryUI
->
imageThumbnailView
->
setGraphicsItems
(
items
,
itemsPath
);
QApplication
::
restoreOverrideCursor
();
}
void
UBLibraryController
::
createNewFolder
()
{
QTreeWidget
*
currentTreeWidget
=
0
;
switch
(
mLibraryUI
->
libraryTab
->
currentIndex
())
{
case
TabIndex
:
:
Image
:
currentTreeWidget
=
mLibraryUI
->
imageLibraryTreeWidget
;
break
;
case
TabIndex
:
:
Interactive
:
currentTreeWidget
=
mLibraryUI
->
interactiveLibraryTreeWidget
;
break
;
}
if
(
currentTreeWidget
!=
0
)
{
QList
<
QTreeWidgetItem
*>
tw
=
currentTreeWidget
->
selectedItems
();
if
(
tw
.
size
()
>
0
)
{
UBLibraryFolderItem
*
fi
=
dynamic_cast
<
UBLibraryFolderItem
*>
(
tw
.
at
(
0
));
if
(
fi
)
{
QString
newFolderPath
=
fi
->
dir
().
path
()
+
"/"
+
tr
(
"New Folder"
);
int
count
=
1
;
if
(
QDir
(
newFolderPath
).
exists
())
{
while
(
QDir
(
newFolderPath
+
QString
(
" %1"
).
arg
(
count
)).
exists
())
{
count
++
;
}
newFolderPath
=
newFolderPath
+
QString
(
" %1"
).
arg
(
count
);
visibleSceneRect
.
setTopLeft
(
sceneTopLeft
);
visibleSceneRect
.
setBottomRight
(
sceneBottomRight
);
}
UBLibraryFolderItem
*
newFi
=
new
UBLibraryFolderItem
(
QDir
(
newFolderPath
),
QString
(),
fi
,
true
,
QStringList
());
currentTreeWidget
->
expandItem
(
fi
);
currentTreeWidget
->
setCurrentItem
(
newFi
);
}
}
}
return
visibleSceneRect
;
}
QStringList
UBLibraryController
::
addItemsToCurrentLibrary
(
const
QDir
&
pSelectedFolder
,
const
QStringList
&
pExtensions
)
{
QString
extensions
;
foreach
(
QString
ext
,
pExtensions
)
{
extensions
+=
" *."
;
extensions
+=
ext
;
}
QString
defaultPath
=
UBSettings
::
settings
()
->
lastImportToLibraryPath
->
get
().
toString
();
QStringList
filenames
=
QFileDialog
::
getOpenFileNames
(
mParentWidget
,
tr
(
"Add Item to Library"
),
defaultPath
,
tr
(
"All Supported (%1)"
).
arg
(
extensions
));
QStringList
importedFiles
;
if
(
filenames
.
size
()
==
0
)
return
filenames
;
QApplication
::
setOverrideCursor
(
QCursor
(
Qt
::
WaitCursor
));
UBApplication
::
processEvents
();
int
i
=
1
;
int
count
=
filenames
.
count
();
void
UBLibraryController
::
addImagesToCurrentPage
(
const
QList
<
QUrl
>&
images
)
{
QPointF
pos
=
visibleSceneRect
().
topLeft
();
foreach
(
const
Q
String
filename
,
filenam
es
)
foreach
(
const
Q
Url
url
,
imag
es
)
{
QFileInfo
source
(
filename
);
// we update last import location. We do it only once at the first imported file
if
(
i
==
1
)
{
UBSettings
::
settings
()
->
lastImportToLibraryPath
->
set
(
QVariant
(
source
.
absolutePath
()));
}
if
(
source
.
isDir
())
{
QString
target
=
pSelectedFolder
.
path
()
+
"/"
+
QFileInfo
(
source
).
fileName
();
UBFileSystemUtils
::
copyDir
(
source
.
absoluteFilePath
(),
target
);
importedFiles
<<
target
;
}
else
if
(
source
.
isFile
()
&&
(
filename
.
toLower
().
endsWith
(
".wgt"
)
||
filename
.
toLower
().
endsWith
(
".wdgt"
)
||
filename
.
toLower
().
endsWith
(
".pwgt"
)))
{
QString
baseFileName
=
source
.
fileName
();
QString
filePath
=
pSelectedFolder
.
path
()
+
"/"
+
baseFileName
;
QString
nextItemPath
=
UBFileSystemUtils
::
nextAvailableFileName
(
filePath
);
QFile
file
(
filename
);
UBFileSystemUtils
::
expandZipToDir
(
file
,
nextItemPath
);
importedFiles
<<
nextItemPath
;
}
else
if
(
source
.
isFile
()
&&
filename
.
toLower
().
endsWith
(
".pdf"
))
{
XPDFRenderer
pdfRenderer
(
filename
);
if
(
pdfRenderer
.
isValid
())
{
QString
title
=
pdfRenderer
.
title
();
if
(
title
.
length
()
==
0
)
title
=
QFileInfo
(
source
).
completeBaseName
();
for
(
int
i
=
0
;
i
<
pdfRenderer
.
pageCount
();
i
++
)
{
UBApplication
::
showMessage
(
tr
(
"Copying page %1 of file %2 to library %3"
)
.
arg
(
i
+
1
)
.
arg
(
title
)
.
arg
(
pSelectedFolder
.
dirName
()));
QString
filePath
=
pSelectedFolder
.
path
()
+
"/"
+
title
+
QString
(
" %1 %2.png"
).
arg
(
tr
(
"Page"
)).
arg
(
i
+
1
);
QSize
size
=
pdfRenderer
.
pageSizeF
(
i
+
1
).
toSize
();
QImage
image
(
size
,
QImage
::
Format_RGB32
);
QPainter
p
(
&
image
);
p
.
setRenderHint
(
QPainter
::
SmoothPixmapTransform
);
p
.
setRenderHint
(
QPainter
::
Antialiasing
);
mLastItemOffsetIndex
++
;
mLastItemOffsetIndex
=
qMin
(
mLastItemOffsetIndex
,
5
);
pdfRenderer
.
render
(
&
p
,
i
+
1
,
QRectF
(
0
,
0
,
size
.
width
(),
size
.
height
()));
p
.
end
();
QGraphicsItem
*
itemInScene
=
0
;
image
.
save
(
filePath
);
if
(
activeScene
())
{
QString
mimeType
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
url
.
toString
());
importedFiles
<<
filePath
;
}
}
else
{
qWarning
()
<<
"Failed to load file "
<<
filename
<<
"as PDF"
;
}
//TODO UB 4.x move this logic to the scene ..
if
(
mimeType
==
"image/svg+xml"
)
{
itemInScene
=
activeScene
()
->
addSvg
(
url
,
pos
);
}
else
{
QString
target
=
pSelectedFolder
.
path
()
+
"/"
+
QFileInfo
(
source
).
fileName
();
QFile
sourceFile
(
source
.
absoluteFilePath
());
UBApplication
::
showMessage
(
tr
(
"Copying file %1 to library %2 (%3/%4)"
).
arg
(
QFileInfo
(
source
).
fileName
()).
arg
(
pSelectedFolder
.
dirName
()).
arg
(
i
).
arg
(
count
));
sourceFile
.
copy
(
target
);
importedFiles
<<
target
;
itemInScene
=
activeScene
()
->
addPixmap
(
QPixmap
(
url
.
toLocalFile
()),
pos
);
}
i
++
;
}
UBApplication
::
showMessage
(
tr
(
"Finished copying %1 files ..."
).
arg
(
filenames
.
size
()));
QApplication
::
restoreOverrideCursor
();
return
importedFiles
;
}
void
UBLibraryController
::
addInteractivesToLibrary
()
{
QList
<
QTreeWidgetItem
*>
tw
=
mLibraryUI
->
interactiveLibraryTreeWidget
->
selectedItems
();
if
(
tw
.
size
()
>
0
)
{
UBLibraryFolderItem
*
fi
=
dynamic_cast
<
UBLibraryFolderItem
*>
(
tw
.
at
(
0
));
if
(
fi
)
{
addItemsToCurrentLibrary
(
fi
->
dir
(),
UBSettings
::
settings
()
->
widgetFileExtensions
);
if
(
itemInScene
)
{
itemInScene
=
activeScene
()
->
scaleToFitDocumentSize
(
itemInScene
,
false
,
UBSettings
::
objectInControlViewMargin
);
refreshInteractiveThumbnailsView
();
// TODO UB 4.x optimisation : could do better than refreshing the entire directory
itemInScene
->
setPos
(
QPoint
(
pos
.
x
()
+
50
*
mLastItemOffsetIndex
,
pos
.
y
()
+
50
*
mLastItemOffsetIndex
));
}
}
}
void
UBLibraryController
::
addImagesToLibrary
()
{
QList
<
QTreeWidgetItem
*>
tw
=
mLibraryUI
->
imageLibraryTreeWidget
->
selectedItems
();
if
(
tw
.
size
()
>
0
)
{
UBLibraryFolderItem
*
fi
=
dynamic_cast
<
UBLibraryFolderItem
*>
(
tw
.
at
(
0
));
if
(
fi
)
{
QStringList
extensions
=
UBSettings
::
imageFileExtensions
;
extensions
<<
"pdf"
;
QStringList
filenames
=
addItemsToCurrentLibrary
(
fi
->
dir
(),
extensions
);
QApplication
::
setOverrideCursor
(
QCursor
(
Qt
::
WaitCursor
));
UBApplication
::
processEvents
();
void
UBLibraryController
::
addVideosToCurrentPage
(
const
QList
<
QUrl
>&
videos
)
{
QPointF
pos
=
visibleSceneRect
().
topLeft
();
quint32
i
=
1
,
count
=
filenames
.
count
();
foreach
(
const
QString
filename
,
filenames
)
foreach
(
const
QUrl
url
,
videos
)
{
// Create thumbnail
// For large images, what actually takes time is the creation of the thumbnail, the copy is fast
QPixmap
pix
(
filename
);
UBApplication
::
showMessage
(
tr
(
"Creating thumbnail %1 (%2/%3)"
).
arg
(
filename
).
arg
(
i
).
arg
(
count
));
QString
thumbnailPath
=
UBFileSystemUtils
::
thumbnailPath
(
filename
);
pix
.
scaledToWidth
(
qMin
(
UBSettings
::
maxThumbnailWidth
,
pix
.
width
()),
Qt
::
SmoothTransformation
).
save
(
thumbnailPath
);
UBPlatformUtils
::
hideFile
(
thumbnailPath
);
i
++
;
}
refreshImageThumbnailsView
();
// TODO UB 4.x optimisation : could do better than refreshing the entire directory
QApplication
::
restoreOverrideCursor
();
}
}
}
void
UBLibraryController
::
removeDir
()
{
QTreeWidget
*
currentTreeWidget
=
0
;
switch
(
mLibraryUI
->
libraryTab
->
currentIndex
())
{
case
TabIndex
:
:
Image
:
currentTreeWidget
=
mLibraryUI
->
imageLibraryTreeWidget
;
break
;
case
TabIndex
:
:
Interactive
:
currentTreeWidget
=
mLibraryUI
->
interactiveLibraryTreeWidget
;
break
;
}
if
(
currentTreeWidget
!=
0
)
{
QList
<
QTreeWidgetItem
*>
tw
=
currentTreeWidget
->
selectedItems
();
if
(
tw
.
size
()
>
0
)
{
UBLibraryFolderItem
*
fi
=
dynamic_cast
<
UBLibraryFolderItem
*>
(
tw
.
last
());
if
(
fi
&&
fi
->
canWrite
())
{
if
(
QMessageBox
::
question
(
0
,
tr
(
"Remove Folder"
),
tr
(
"Are you sure you want to remove the folder %1 from the library?"
).
arg
(
fi
->
dir
().
dirName
()),
QMessageBox
::
Yes
|
QMessageBox
::
No
)
==
QMessageBox
::
Yes
)
{
qDebug
()
<<
"deleting dir"
<<
fi
->
dir
().
path
();
UBFileSystemUtils
::
deleteDir
(
fi
->
dir
().
path
());
fi
->
parent
()
->
removeChild
(
fi
);
}
}
}
}
}
void
UBLibraryController
::
remove
()
{
UBThumbnailWidget
*
currentThumbnailView
=
0
;
switch
(
mLibraryUI
->
libraryTab
->
currentIndex
())
{
case
TabIndex
:
:
Image
:
currentThumbnailView
=
mLibraryUI
->
imageThumbnailView
;
break
;
case
TabIndex
:
:
Interactive
:
currentThumbnailView
=
mLibraryUI
->
interactiveThumbnailView
;
break
;
}
mLastItemOffsetIndex
++
;
mLastItemOffsetIndex
=
qMin
(
mLastItemOffsetIndex
,
5
);
if
(
currentThumbnailView
)
{
if
(
currentThumbnailView
->
selectedItems
().
size
()
>
0
)
{
removeItemsFromLibrary
(
currentThumbnailView
);
}
else
{
removeDir
();
}
UBGraphicsVideoItem
*
itemInScene
=
UBApplication
::
boardController
->
addVideo
(
url
,
false
,
pos
);
itemInScene
->
setPos
(
QPoint
(
pos
.
x
()
+
50
*
mLastItemOffsetIndex
,
pos
.
y
()
+
50
*
mLastItemOffsetIndex
));
}
}
void
UBLibraryController
::
removeItemsFromLibrary
(
UBThumbnailWidget
*
pThumbnailView
)
{
QList
<
QGraphicsItem
*>
selectedItems
=
pThumbnailView
->
selectedItems
();
if
(
selectedItems
.
size
()
>
0
)
{
if
(
QMessageBox
::
question
(
0
,
tr
(
"Remove Item"
),
tr
(
"Are you sure you want to remove the item from the library?"
),
QMessageBox
::
Yes
|
QMessageBox
::
No
)
==
QMessageBox
::
Yes
)
{
QGraphicsPixmapItem
*
pixmapItem
=
dynamic_cast
<
QGraphicsPixmapItem
*>
(
selectedItems
.
last
());
if
(
pixmapItem
&&
mPixmapItemToFilepath
.
contains
(
pixmapItem
))
{
QString
path
=
mPixmapItemToFilepath
.
take
(
pixmapItem
);
QFile
file
(
path
);
QFile
thumbnailFile
(
UBFileSystemUtils
::
thumbnailPath
(
path
));
file
.
remove
();
thumbnailFile
.
remove
();
refreshImageThumbnailsView
();
}
else
if
(
pixmapItem
&&
mInteractiveItemToFilepath
.
contains
(
pixmapItem
))
{
QString
path
=
mInteractiveItemToFilepath
.
take
(
pixmapItem
);
//is it a tool ?
if
(
path
.
startsWith
(
"uniboardTool://"
))
{
QStringList
uris
=
UBSettings
::
settings
()
->
favoritesNativeToolUris
->
get
().
toStringList
();
if
(
uris
.
contains
(
path
))
{
uris
.
removeAll
(
path
);
UBSettings
::
settings
()
->
favoritesNativeToolUris
->
set
(
uris
);
}
}
else
{
qDebug
()
<<
"file to delete "
<<
path
;
QFileInfo
fileInfo
(
path
);
if
(
fileInfo
.
isDir
())
{
UBFileSystemUtils
::
deleteDir
(
fileInfo
.
absoluteFilePath
());
}
else
{
QFile
(
fileInfo
.
absoluteFilePath
()).
remove
();
}
}
refreshInteractiveThumbnailsView
();
}
else
{
QGraphicsSvgItem
*
svgItem
=
dynamic_cast
<
QGraphicsSvgItem
*>
(
selectedItems
.
last
());
if
(
svgItem
&&
mSvgImageItemToFilepath
.
contains
(
svgItem
))
{
QString
path
=
mSvgImageItemToFilepath
.
take
(
svgItem
);
QFile
file
(
path
);
void
UBLibraryController
::
addAudiosToCurrentPage
(
const
QList
<
QUrl
>&
sounds
)
{
QPointF
topLeftPos
=
visibleSceneRect
().
topLeft
();
file
.
remove
()
;
QPointF
pos
=
topLeftPos
;
refreshImageThumbnailsView
();
}
}
}
foreach
(
const
QUrl
url
,
sounds
)
{
mLastItemOffsetIndex
++
;
mLastItemOffsetIndex
=
qMin
(
mLastItemOffsetIndex
,
5
);
pos
=
QPointF
(
topLeftPos
.
x
()
+
50
*
mLastItemOffsetIndex
,
topLeftPos
.
y
()
+
50
*
mLastItemOffsetIndex
);
UBApplication
::
boardController
->
addAudio
(
url
,
false
,
pos
);
}
}
void
UBLibraryController
::
refreshInteractiveThumbnailsView
()
{
QApplication
::
setOverrideCursor
(
QCursor
(
Qt
::
WaitCursor
));
QList
<
QGraphicsItem
*>
items
;
QList
<
QUrl
>
itemsPath
;
QStringList
labels
;
QList
<
QTreeWidgetItem
*>
tw
=
mLibraryUI
->
interactiveLibraryTreeWidget
->
selectedItems
();
if
(
tw
.
size
()
>
0
)
{
UBLibraryFolderItem
*
fi
=
dynamic_cast
<
UBLibraryFolderItem
*>
(
tw
.
last
());
if
(
fi
)
{
QStringList
toolUris
;
if
(
fi
==
mInteractiveUniboardTi
)
{
toolUris
=
UBToolsManager
::
manager
()
->
allToolIDs
();
}
foreach
(
QString
toolUri
,
toolUris
)
void
UBLibraryController
::
addInteractivesToCurrentPage
(
const
QList
<
QUrl
>&
widgets
)
{
foreach
(
const
QUrl
url
,
widgets
)
{
UBToolsManager
::
UBToolDescriptor
tool
=
UBToolsManager
::
manager
()
->
toolByID
(
toolUri
);
QGraphicsPixmapItem
*
pixmapItem
=
new
UBThumbnailPixmap
(
tool
.
icon
);
if
(
!
pixmapItem
->
pixmap
().
isNull
())
{
QString
id
=
tool
.
id
;
mInteractiveItemToFilepath
.
insert
(
pixmapItem
,
id
);
items
.
append
(
pixmapItem
);
itemsPath
.
append
(
QUrl
(
id
));
labels
.
append
(
tool
.
label
+
" "
+
tool
.
version
);
}
}
QStringList
widgetPaths
=
UBPersistenceManager
::
persistenceManager
()
->
allWidgets
(
fi
->
dir
());
for
(
int
i
=
0
;
i
<
widgetPaths
.
size
();
i
++
)
{
QString
path
=
widgetPaths
.
at
(
i
);
QString
iconFilepath
=
UBAbstractWidget
::
iconFilePath
(
QUrl
::
fromLocalFile
(
path
));
QGraphicsPixmapItem
*
pixmapItem
=
new
UBThumbnailPixmap
(
QPixmap
(
iconFilepath
));
mInteractiveItemToFilepath
.
insert
(
pixmapItem
,
path
);
QString
name
=
UBAbstractWidget
::
widgetName
(
QUrl
::
fromLocalFile
(
path
));
items
.
append
(
pixmapItem
);
itemsPath
.
append
(
QUrl
::
fromLocalFile
(
path
));
labels
.
append
(
name
);
}
}
mBoardController
->
downloadURL
(
url
,
QPointF
(
0
,
0
));
}
mLibraryUI
->
interactiveThumbnailView
->
setGraphicsItems
(
items
,
itemsPath
,
labels
);
QApplication
::
restoreOverrideCursor
();
}
void
UBLibraryController
::
showLibraryDialog
(
bool
show
)
QString
UBLibraryController
::
favoritePath
(
)
{
if
(
show
&&
!
mLibraryWindow
)
{
Qt
::
WindowFlags
flag
=
Qt
::
Dialog
|
Qt
::
WindowMaximizeButtonHint
|
Qt
::
WindowCloseButtonHint
;
flag
&=
~
Qt
::
WindowContextHelpButtonHint
;
flag
&=
~
Qt
::
WindowMinimizeButtonHint
;
mLibraryWindow
=
new
QDialog
(
mParentWidget
,
flag
);
mLibraryUI
=
new
Ui
::
library
();
mLibraryUI
->
setupUi
(
mLibraryWindow
);
mLibraryUI
->
libraryTab
->
setCurrentIndex
(
TabIndex
::
Gip
);
// image tab
QString
ubPictures
=
UBSettings
::
settings
()
->
uniboardImageLibraryDirectory
();
QString
userPictures
=
UBSettings
::
settings
()
->
uniboardUserImageDirectory
();
UBLibraryFolderItem
*
ubLibrary
=
new
UBLibraryFolderItem
(
QDir
(
ubPictures
),
tr
(
"Sankore 3.1"
),
0
,
false
,
QStringList
());
UBLibraryFolderItem
*
userLibrary
=
new
UBLibraryFolderItem
(
QDir
(
userPictures
),
tr
(
"My Images"
),
0
,
true
,
QStringList
());
mLibraryUI
->
imageLibraryTreeWidget
->
addTopLevelItem
(
userLibrary
);
mLibraryUI
->
imageLibraryTreeWidget
->
addTopLevelItem
(
ubLibrary
);
QStringList
imageMimeTypes
;
imageMimeTypes
<<
"image"
;
mLibraryUI
->
imageLibraryTreeWidget
->
setMimeTypes
(
imageMimeTypes
);
mLibraryUI
->
imageLibraryTreeWidget
->
setFileExtensions
(
UBSettings
::
imageFileExtensions
);
ubLibrary
->
setIcon
(
0
,
QIcon
(
":/images/myContent.png"
));
ubLibrary
->
setExpanded
(
true
);
userLibrary
->
setIcon
(
0
,
QIcon
(
":/images/myFolder.png"
));
userLibrary
->
setExpanded
(
true
);
if
(
userLibrary
->
childCount
()
>
0
)
{
foreach
(
QTreeWidgetItem
*
ti
,
mLibraryUI
->
imageLibraryTreeWidget
->
selectedItems
())
{
ti
->
setSelected
(
false
);
}
userLibrary
->
child
(
0
)
->
setSelected
(
true
);
selectionChanged
();
}
else
{
ubLibrary
->
setSelected
(
true
);
}
mLibraryUI
->
imageLibraryTreeWidget
->
setRootIsDecorated
(
false
);
mLibraryUI
->
imageLibrariesStack
->
setCurrentWidget
(
mLibraryUI
->
imagePageLocal
);
mImageWebView
=
new
UBLibraryWebView
(
mLibraryUI
->
imagePageOnline
);
mLibraryUI
->
imagePageOnline
->
layout
()
->
addWidget
(
mImageWebView
);
// Interactive tab
QString
ubInteractive
=
UBSettings
::
settings
()
->
uniboardInteractiveLibraryDirectory
();
QString
userInteractive
=
UBSettings
::
settings
()
->
uniboardInteractiveUserDirectory
();
QString
ubInteractiveFavorites
=
UBSettings
::
settings
()
->
uniboardInteractiveFavoritesDirectory
();
mInteractiveUniboardTi
=
new
UBLibraryFolderItem
(
QDir
(
ubInteractive
),
tr
(
"Sankore 3.1"
),
0
,
false
,
UBSettings
::
interactiveContentFileExtensions
);
UBLibraryFolderItem
*
userInteractiveLibrary
=
new
UBLibraryFolderItem
(
QDir
(
userInteractive
),
tr
(
"My Applications"
),
0
,
true
,
UBSettings
::
interactiveContentFileExtensions
);
mLibraryUI
->
interactiveLibraryTreeWidget
->
addTopLevelItem
(
userInteractiveLibrary
);
mLibraryUI
->
interactiveLibraryTreeWidget
->
addTopLevelItem
(
mInteractiveUniboardTi
);
QStringList
icMimeTypes
;
icMimeTypes
<<
"application/widget"
;
icMimeTypes
<<
"application/x-shockwave-flash"
;
mLibraryUI
->
interactiveLibraryTreeWidget
->
setMimeTypes
(
icMimeTypes
);
mLibraryUI
->
interactiveLibraryTreeWidget
->
setFileExtensions
(
UBSettings
::
interactiveContentFileExtensions
);
QStringList
icProtocoles
;
icProtocoles
<<
"uniboardTool://"
;
mLibraryUI
->
interactiveLibraryTreeWidget
->
setProtocoles
(
icProtocoles
);
mInteractiveUniboardTi
->
setIcon
(
0
,
QIcon
(
":/images/myContent.png"
));
mInteractiveUniboardTi
->
setExpanded
(
true
);
userInteractiveLibrary
->
setIcon
(
0
,
QIcon
(
":/images/myFolder.png"
));
userInteractiveLibrary
->
setExpanded
(
true
);
mInteractiveUniboardTi
->
setSelected
(
true
);
mLibraryUI
->
interactiveLibraryTreeWidget
->
setRootIsDecorated
(
false
);
mLibraryUI
->
interactiveLibrariesStack
->
setCurrentWidget
(
mLibraryUI
->
interactivePageLocal
);
mInteractiveWebView
=
new
UBLibraryWebView
(
mLibraryUI
->
interactivePageOnline
);
mLibraryUI
->
interactivePageOnline
->
layout
()
->
addWidget
(
mInteractiveWebView
);
// video tab
QString
userVideos
=
UBSettings
::
settings
()
->
uniboardUserVideoDirectory
();
UBLibraryFolderItem
*
userVideoLibrary
=
new
UBLibraryFolderItem
(
QDir
(
userVideos
),
tr
(
"My Movies"
),
0
,
false
,
QStringList
());
mLibraryUI
->
videoLibraryTreeWidget
->
addTopLevelItem
(
userVideoLibrary
);
userVideoLibrary
->
setIcon
(
0
,
QIcon
(
":/images/myFolder.png"
));
userVideoLibrary
->
setExpanded
(
true
);
userVideoLibrary
->
setSelected
(
true
);
mLibraryUI
->
videoLibraryTreeWidget
->
setRootIsDecorated
(
false
);
QStringList
videoMimeTypes
;
videoMimeTypes
<<
"video"
;
mLibraryUI
->
videoLibraryTreeWidget
->
setMimeTypes
(
videoMimeTypes
);
mLibraryUI
->
videoLibrariesStack
->
setCurrentWidget
(
mLibraryUI
->
videoPageLocal
);
mVideoWebView
=
new
UBLibraryWebView
(
mLibraryUI
->
videoPageOnline
);
mLibraryUI
->
videoPageOnline
->
layout
()
->
addWidget
(
mVideoWebView
);
mLibraryUI
->
imageThumbnailView
->
setThumbnailWidth
(
UBSettings
::
settings
()
->
imageThumbnailWidth
->
get
().
toInt
());
mLibraryUI
->
gipThumbnailView
->
setThumbnailWidth
(
UBSettings
::
defaultGipWidth
);
mLibraryUI
->
soundThumbnailView
->
setThumbnailWidth
(
UBSettings
::
defaultSoundWidth
);
mLibraryUI
->
shapeThumbnailView
->
setThumbnailWidth
(
UBSettings
::
settings
()
->
shapeThumbnailWidth
->
get
().
toInt
());
mLibraryUI
->
interactiveThumbnailView
->
setThumbnailWidth
(
UBSettings
::
defaultWidgetIconWidth
);
mLibraryUI
->
videoThumbnailView
->
setThumbnailWidth
(
UBSettings
::
settings
()
->
videoThumbnailWidth
->
get
().
toInt
());
connect
(
mLibraryUI
->
imageLibraryTreeWidget
,
SIGNAL
(
itemSelectionChanged
()),
this
,
SLOT
(
itemSelectionChanged
()));
connect
(
mLibraryUI
->
imageLibraryTreeWidget
,
SIGNAL
(
itemChanged
(
QTreeWidgetItem
*
,
int
)),
this
,
SLOT
(
itemChanged
(
QTreeWidgetItem
*
,
int
)));
connect
(
mLibraryUI
->
imageLibraryTreeWidget
,
SIGNAL
(
contentChanged
()),
this
,
SLOT
(
refreshImageThumbnailsView
()));
connect
(
mLibraryUI
->
interactiveLibraryTreeWidget
,
SIGNAL
(
itemSelectionChanged
()),
this
,
SLOT
(
itemSelectionChanged
()));
connect
(
mLibraryUI
->
interactiveLibraryTreeWidget
,
SIGNAL
(
itemChanged
(
QTreeWidgetItem
*
,
int
)),
this
,
SLOT
(
itemChanged
(
QTreeWidgetItem
*
,
int
)));
connect
(
mLibraryUI
->
interactiveLibraryTreeWidget
,
SIGNAL
(
contentChanged
()),
this
,
SLOT
(
refreshInteractiveThumbnailsView
()));
connect
(
mLibraryUI
->
videoLibraryTreeWidget
,
SIGNAL
(
itemSelectionChanged
()),
this
,
SLOT
(
itemSelectionChanged
()));
connect
(
mLibraryUI
->
videoLibraryTreeWidget
,
SIGNAL
(
contentChanged
()),
this
,
SLOT
(
refreshVideoThumbnailsView
()));
connect
(
mLibraryUI
->
newInteractiveFolderButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
createNewFolder
()));
connect
(
mLibraryUI
->
newFolderButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
createNewFolder
()));
connect
(
mLibraryUI
->
addImageToLibraryButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
addImagesToLibrary
()));
connect
(
mLibraryUI
->
addInteractiveToLibraryButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
addInteractivesToLibrary
()));
connect
(
mLibraryUI
->
addToDocumentButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
addObjectFromFilesystemToPage
()));
connect
(
mLibraryUI
->
removeButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
remove
()));
connect
(
mLibraryUI
->
addToPageButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
addToPage
()));
connect
(
mLibraryUI
->
setAsBackgroundButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
setAsBackground
()));
connect
(
mLibraryUI
->
removeBackgroundButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
removeBackground
()));
connect
(
mLibraryUI
->
zoomSlider
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
zoomSliderValueChanged
(
int
)));
connect
(
mLibraryUI
->
imageThumbnailView
,
SIGNAL
(
resized
()),
this
,
SLOT
(
thumbnailViewResized
()));
connect
(
mLibraryUI
->
shapeThumbnailView
,
SIGNAL
(
resized
()),
this
,
SLOT
(
thumbnailViewResized
()));
connect
(
mLibraryUI
->
interactiveThumbnailView
,
SIGNAL
(
resized
()),
this
,
SLOT
(
thumbnailViewResized
()));
connect
(
mLibraryUI
->
videoThumbnailView
,
SIGNAL
(
resized
()),
this
,
SLOT
(
thumbnailViewResized
()));
connect
(
mLibraryUI
->
gipThumbnailView
,
SIGNAL
(
resized
()),
this
,
SLOT
(
thumbnailViewResized
()));
connect
(
mLibraryUI
->
soundThumbnailView
,
SIGNAL
(
resized
()),
this
,
SLOT
(
thumbnailViewResized
()));
connect
(
mLibraryUI
->
imageThumbnailView
,
SIGNAL
(
selectionChanged
()),
this
,
SLOT
(
selectionChanged
()));
connect
(
mLibraryUI
->
shapeThumbnailView
,
SIGNAL
(
selectionChanged
()),
this
,
SLOT
(
selectionChanged
()));
connect
(
mLibraryUI
->
interactiveThumbnailView
,
SIGNAL
(
selectionChanged
()),
this
,
SLOT
(
selectionChanged
()));
connect
(
mLibraryUI
->
videoThumbnailView
,
SIGNAL
(
selectionChanged
()),
this
,
SLOT
(
selectionChanged
()));
connect
(
mLibraryUI
->
gipThumbnailView
,
SIGNAL
(
selectionChanged
()),
this
,
SLOT
(
selectionChanged
()));
connect
(
mLibraryUI
->
soundThumbnailView
,
SIGNAL
(
selectionChanged
()),
this
,
SLOT
(
selectionChanged
()));
mLibraryUI
->
imageLibraryTreeWidget
->
setIndentation
(
30
);
mLibraryUI
->
interactiveLibraryTreeWidget
->
setIndentation
(
30
);
mLibraryUI
->
videoLibraryTreeWidget
->
setIndentation
(
30
);
mLibraryUI
->
imageThumbnailView
->
setBackgroundBrush
(
UBSettings
::
documentViewLightColor
);
mLibraryUI
->
shapeThumbnailView
->
setBackgroundBrush
(
UBSettings
::
documentViewLightColor
);
mLibraryUI
->
interactiveThumbnailView
->
setBackgroundBrush
(
UBSettings
::
documentViewLightColor
);
mLibraryUI
->
gipThumbnailView
->
setBackgroundBrush
(
UBSettings
::
documentViewLightColor
);
mLibraryUI
->
videoThumbnailView
->
setBackgroundBrush
(
UBSettings
::
documentViewLightColor
);
mLibraryUI
->
soundThumbnailView
->
setBackgroundBrush
(
UBSettings
::
documentViewLightColor
);
int
viewWidth
=
mParentWidget
->
width
()
/
2
;
int
viewHeight
=
mParentWidget
->
height
()
*
2.0
/
3.0
;
mLibraryWindow
->
setGeometry
((
mParentWidget
->
width
()
-
viewWidth
)
/
2
,
(
mParentWidget
->
height
()
-
viewHeight
)
/
2
,
viewWidth
,
viewHeight
);
connect
(
mLibraryUI
->
libraryTab
,
SIGNAL
(
currentChanged
(
int
)),
this
,
SLOT
(
tabChanged
(
int
)));
mLibraryUI
->
libraryTab
->
setCurrentIndex
(
TabIndex
::
Gip
);
tabChanged
(
TabIndex
::
Gip
);
connect
(
mLibraryWindow
,
SIGNAL
(
finished
(
int
)),
this
,
SIGNAL
(
dialogClosed
(
int
)));
loadLibraries
();
}
if
(
mLibraryWindow
)
{
mLibraryWindow
->
setVisible
(
show
);
if
(
show
)
{
mLibraryWindow
->
activateWindow
();
if
(
mNeedRefreshOnNextDisplay
)
{
refreshImageThumbnailsView
();
mNeedRefreshOnNextDisplay
=
false
;
}
}
}
selectionChanged
();
return
favoriteVirtualPath
;
}
void
UBLibraryController
::
tabChanged
(
int
value
)
{
selectionChanged
();
switch
(
value
)
{
case
TabIndex
:
:
Image
:
refreshImageThumbnailsView
();
break
;
case
TabIndex
:
:
Shape
:
refreshShapeThumbnailsView
();
break
;
case
TabIndex
:
:
Interactive
:
refreshInteractiveThumbnailsView
();
break
;
case
TabIndex
:
:
Video
:
refreshVideoThumbnailsView
();
break
;
case
TabIndex
:
:
Sound
:
refreshSoundThumbnailsView
();
break
;
default
:
break
;
}
}
void
UBLibraryController
::
selectionChanged
()
{
bool
hasSelectedItems
=
false
;
switch
(
mLibraryUI
->
libraryTab
->
currentIndex
())
{
case
TabIndex
:
:
Image
:
{
bool
canWrite
=
false
;
bool
isTopLevel
=
false
;
QList
<
QTreeWidgetItem
*>
tw
=
mLibraryUI
->
imageLibraryTreeWidget
->
selectedItems
();
if
(
tw
.
size
()
>
0
)
{
UBLibraryFolderItem
*
fi
=
dynamic_cast
<
UBLibraryFolderItem
*>
(
tw
.
last
());
if
(
fi
)
{
canWrite
=
fi
->
canWrite
();
isTopLevel
=
!
fi
->
parent
();
mLibraryUI
->
imageLibrariesStack
->
setCurrentWidget
(
mLibraryUI
->
imagePageLocal
);
}
else
{
UBOnlineLibraryItem
*
oi
=
dynamic_cast
<
UBOnlineLibraryItem
*>
(
tw
.
last
());
if
(
oi
)
{
mLibraryUI
->
imageLibrariesStack
->
setCurrentWidget
(
mLibraryUI
->
imagePageOnline
);
mImageWebView
->
load
(
oi
->
url
(),
oi
);
}
}
}
mLibraryUI
->
newFolderButton
->
setEnabled
(
canWrite
&&
isTopLevel
);
mLibraryUI
->
addImageToLibraryButton
->
setEnabled
(
canWrite
&&
!
isTopLevel
);
mLibraryUI
->
addToDocumentButton
->
setEnabled
(
true
);
mLibraryUI
->
removeButton
->
setEnabled
(
canWrite
&&
!
isTopLevel
);
hasSelectedItems
=
mLibraryUI
->
imageThumbnailView
->
selectedItems
().
size
()
>
0
;
mLibraryUI
->
addToPageButton
->
setEnabled
(
hasSelectedItems
);
mLibraryUI
->
setAsBackgroundButton
->
setEnabled
(
hasSelectedItems
);
mLibraryUI
->
removeBackgroundButton
->
setEnabled
(
activeScene
()
->
hasBackground
());
mLibraryUI
->
zoomSlider
->
setValue
(
mLibraryUI
->
imageThumbnailView
->
thumbnailWidth
());
mLibraryUI
->
zoomSlider
->
setVisible
(
true
);
}
break
;
case
TabIndex
:
:
Shape
:
{
mLibraryUI
->
newFolderButton
->
setEnabled
(
false
);
mLibraryUI
->
addImageToLibraryButton
->
setEnabled
(
false
);
mLibraryUI
->
addToDocumentButton
->
setEnabled
(
false
);
mLibraryUI
->
removeButton
->
setEnabled
(
false
);
hasSelectedItems
=
mLibraryUI
->
shapeThumbnailView
->
selectedItems
().
size
()
>
0
;
mLibraryUI
->
addToPageButton
->
setEnabled
(
hasSelectedItems
);
mLibraryUI
->
setAsBackgroundButton
->
setEnabled
(
hasSelectedItems
);
mLibraryUI
->
removeBackgroundButton
->
setEnabled
(
activeScene
()
->
hasBackground
());
mLibraryUI
->
zoomSlider
->
setValue
(
mLibraryUI
->
shapeThumbnailView
->
thumbnailWidth
());
mLibraryUI
->
zoomSlider
->
setVisible
(
true
);
}
break
;
case
TabIndex
:
:
Interactive
:
{
bool
canWrite
=
false
;
bool
isTopLevel
=
false
;
QList
<
QTreeWidgetItem
*>
tw
=
mLibraryUI
->
interactiveLibraryTreeWidget
->
selectedItems
();
if
(
tw
.
size
()
>
0
)
{
UBLibraryFolderItem
*
fi
=
dynamic_cast
<
UBLibraryFolderItem
*>
(
tw
.
last
());
if
(
fi
)
{
canWrite
=
fi
->
canWrite
();
isTopLevel
=
!
fi
->
parent
();
mLibraryUI
->
interactiveLibrariesStack
->
setCurrentWidget
(
mLibraryUI
->
interactivePageLocal
);
}
else
{
UBOnlineLibraryItem
*
oi
=
dynamic_cast
<
UBOnlineLibraryItem
*>
(
tw
.
last
());
if
(
oi
)
{
mLibraryUI
->
interactiveLibrariesStack
->
setCurrentWidget
(
mLibraryUI
->
interactivePageOnline
);
mInteractiveWebView
->
load
(
oi
->
url
(),
oi
);
}
}
}
mLibraryUI
->
newInteractiveFolderButton
->
setEnabled
(
canWrite
&&
isTopLevel
);
mLibraryUI
->
addInteractiveToLibraryButton
->
setEnabled
(
canWrite
&&
!
isTopLevel
);
mLibraryUI
->
addToDocumentButton
->
setEnabled
(
true
);
hasSelectedItems
=
mLibraryUI
->
interactiveThumbnailView
->
selectedItems
().
size
()
>
0
;
mLibraryUI
->
removeButton
->
setEnabled
((
canWrite
&&
!
isTopLevel
)
||
(
canWrite
&&
hasSelectedItems
));
mLibraryUI
->
addToPageButton
->
setEnabled
(
hasSelectedItems
);
mLibraryUI
->
setAsBackgroundButton
->
setEnabled
(
false
);
mLibraryUI
->
removeBackgroundButton
->
setEnabled
(
false
);
mLibraryUI
->
zoomSlider
->
setValue
(
mLibraryUI
->
interactiveThumbnailView
->
thumbnailWidth
());
mLibraryUI
->
zoomSlider
->
setVisible
(
false
);
}
break
;
case
TabIndex
:
:
Video
:
{
QList
<
QTreeWidgetItem
*>
tw
=
mLibraryUI
->
videoLibraryTreeWidget
->
selectedItems
();
if
(
tw
.
size
()
>
0
)
{
hasSelectedItems
=
true
;
UBOnlineLibraryItem
*
oi
=
dynamic_cast
<
UBOnlineLibraryItem
*>
(
tw
.
last
());
if
(
oi
)
{
mLibraryUI
->
videoLibrariesStack
->
setCurrentWidget
(
mLibraryUI
->
videoPageOnline
);
mVideoWebView
->
load
(
oi
->
url
(),
oi
);
}
else
{
mLibraryUI
->
videoLibrariesStack
->
setCurrentWidget
(
mLibraryUI
->
videoPageLocal
);
}
}
mLibraryUI
->
newFolderButton
->
setEnabled
(
false
);
mLibraryUI
->
addImageToLibraryButton
->
setEnabled
(
false
);
mLibraryUI
->
addToDocumentButton
->
setEnabled
(
true
);
mLibraryUI
->
removeButton
->
setEnabled
(
false
);
mLibraryUI
->
addToPageButton
->
setEnabled
(
true
);
mLibraryUI
->
setAsBackgroundButton
->
setEnabled
(
false
);
mLibraryUI
->
removeBackgroundButton
->
setEnabled
(
false
);
mLibraryUI
->
zoomSlider
->
setValue
(
mLibraryUI
->
videoThumbnailView
->
thumbnailWidth
());
mLibraryUI
->
zoomSlider
->
setVisible
(
true
);
}
break
;
case
TabIndex
:
:
Gip
:
{
hasSelectedItems
=
mLibraryUI
->
gipThumbnailView
->
selectedItems
().
size
()
>
0
;
mLibraryUI
->
newFolderButton
->
setEnabled
(
false
);
mLibraryUI
->
addImageToLibraryButton
->
setEnabled
(
false
);
mLibraryUI
->
addToDocumentButton
->
setEnabled
(
false
);
mLibraryUI
->
removeButton
->
setEnabled
(
false
);
mLibraryUI
->
addToPageButton
->
setEnabled
(
hasSelectedItems
);
mLibraryUI
->
setAsBackgroundButton
->
setEnabled
(
false
);
mLibraryUI
->
removeBackgroundButton
->
setEnabled
(
false
);
mLibraryUI
->
zoomSlider
->
setValue
(
mLibraryUI
->
gipThumbnailView
->
thumbnailWidth
());
mLibraryUI
->
zoomSlider
->
setVisible
(
true
);
}
break
;
case
TabIndex
:
:
Sound
:
{
hasSelectedItems
=
mLibraryUI
->
soundThumbnailView
->
selectedItems
().
size
()
>
0
;
mLibraryUI
->
newFolderButton
->
setEnabled
(
false
);
mLibraryUI
->
addImageToLibraryButton
->
setEnabled
(
false
);
mLibraryUI
->
addToDocumentButton
->
setEnabled
(
false
);
mLibraryUI
->
removeButton
->
setEnabled
(
false
);
mLibraryUI
->
addToPageButton
->
setEnabled
(
hasSelectedItems
);
mLibraryUI
->
setAsBackgroundButton
->
setEnabled
(
false
);
mLibraryUI
->
removeBackgroundButton
->
setEnabled
(
false
);
mLibraryUI
->
zoomSlider
->
setValue
(
mLibraryUI
->
soundThumbnailView
->
thumbnailWidth
());
mLibraryUI
->
zoomSlider
->
setVisible
(
true
);
}
default
:
break
;
}
}
void
UBLibraryController
::
zoomSliderValueChanged
(
int
value
)
{
switch
(
mLibraryUI
->
libraryTab
->
currentIndex
())
{
case
TabIndex
:
:
Image
:
mLibraryUI
->
imageThumbnailView
->
setThumbnailWidth
(
value
);
UBSettings
::
settings
()
->
imageThumbnailWidth
->
set
(
value
);
break
;
case
TabIndex
:
:
Shape
:
mLibraryUI
->
shapeThumbnailView
->
setThumbnailWidth
(
value
);
UBSettings
::
settings
()
->
shapeThumbnailWidth
->
set
(
value
);
break
;
case
TabIndex
:
:
Interactive
:
mLibraryUI
->
interactiveThumbnailView
->
setThumbnailWidth
(
value
);
break
;
case
TabIndex
:
:
Video
:
mLibraryUI
->
videoThumbnailView
->
setThumbnailWidth
(
value
);
UBSettings
::
settings
()
->
videoThumbnailWidth
->
set
(
value
);
break
;
case
TabIndex
:
:
Gip
:
mLibraryUI
->
gipThumbnailView
->
setThumbnailWidth
(
value
);
UBSettings
::
settings
()
->
gipThumbnailWidth
->
set
(
value
);
break
;
case
TabIndex
:
:
Sound
:
mLibraryUI
->
soundThumbnailView
->
setThumbnailWidth
(
value
);
UBSettings
::
settings
()
->
soundThumbnailWidth
->
set
(
value
);
break
;
default
:
break
;
}
}
void
UBLibraryController
::
addShape
()
{
QPointF
pos
(
0
,
0
);
if
(
activeScene
())
{
QPointF
topLeftCorner
=
mBoardController
->
controlGeometry
().
topLeft
();
pos
=
mBoardController
->
controlView
()
->
mapToScene
(
topLeftCorner
.
toPoint
());
}
int
i
=
0
;
foreach
(
QGraphicsItem
*
item
,
mLibraryUI
->
shapeThumbnailView
->
selectedItems
())
{
++
i
;
QGraphicsSvgItem
*
svgItem
=
dynamic_cast
<
QGraphicsSvgItem
*>
(
item
);
if
(
svgItem
&&
mSvgItemToFilepath
.
contains
(
svgItem
)
&&
activeScene
())
{
QUrl
url
=
QUrl
::
fromLocalFile
(
mSvgItemToFilepath
.
value
(
svgItem
));
QGraphicsItem
*
itemInScene
=
activeScene
()
->
addSvg
(
url
,
QPointF
(
0
,
0
));
itemInScene
->
setPos
(
QPoint
(
pos
.
x
()
+
10
*
i
,
pos
.
y
()
+
10
*
i
));
}
}
}
void
UBLibraryController
::
setShapeAsBackground
()
{
QList
<
QGraphicsItem
*>
selectedItems
=
mLibraryUI
->
shapeThumbnailView
->
selectedItems
();
if
(
selectedItems
.
size
()
>
0
)
{
QGraphicsSvgItem
*
svgItem
=
dynamic_cast
<
QGraphicsSvgItem
*>
(
selectedItems
.
last
());
if
(
svgItem
&&
mSvgItemToFilepath
.
contains
(
svgItem
)
&&
activeScene
())
{
QString
path
=
mSvgItemToFilepath
.
value
(
svgItem
);
UBGraphicsSvgItem
*
boardItem
=
activeScene
()
->
addSvg
(
QUrl
::
fromLocalFile
(
path
),
QPointF
(
0
,
0
));
activeScene
()
->
setAsBackgroundObject
(
boardItem
,
true
);
}
}
}
void
UBLibraryController
::
addToPage
()
{
switch
(
mLibraryUI
->
libraryTab
->
currentIndex
())
{
case
TabIndex
:
:
Image
:
addImage
();
break
;
case
TabIndex
:
:
Shape
:
addShape
();
break
;
case
TabIndex
:
:
Interactive
:
addInteractiveToCurrentPage
();
break
;
case
TabIndex
:
:
Video
:
addVideo
();
break
;
case
TabIndex
:
:
Sound
:
addAudio
();
break
;
default
:
break
;
}
mLibraryWindow
->
done
(
0
);
UBDrawingController
::
drawingController
()
->
setStylusTool
(
UBStylusTool
::
Selector
);
}
void
UBLibraryController
::
setAsBackground
()
{
switch
(
mLibraryUI
->
libraryTab
->
currentIndex
())
{
case
TabIndex
:
:
Image
:
setImageAsBackground
();
break
;
case
TabIndex
:
:
Shape
:
setShapeAsBackground
();
break
;
default
:
break
;
}
selectionChanged
();
}
QRectF
UBLibraryController
::
visibleSceneRect
()
{
QRectF
visibleSceneRect
(
0
,
0
,
0
,
0
);
if
(
activeScene
()
&&
mBoardController
&&
mBoardController
->
controlView
())
{
QPointF
topLeftCorner
=
mBoardController
->
controlGeometry
().
topLeft
();
QPointF
bottomRightCorner
=
mBoardController
->
controlGeometry
().
bottomRight
();
QPointF
sceneTopLeft
=
mBoardController
->
controlView
()
->
mapToScene
(
topLeftCorner
.
toPoint
());
QPointF
sceneBottomRight
=
mBoardController
->
controlView
()
->
mapToScene
(
bottomRightCorner
.
toPoint
());
visibleSceneRect
.
setTopLeft
(
sceneTopLeft
);
visibleSceneRect
.
setBottomRight
(
sceneBottomRight
);
}
return
visibleSceneRect
;
}
void
UBLibraryController
::
addImagesToCurrentPage
(
const
QList
<
QUrl
>&
images
)
{
QPointF
pos
=
visibleSceneRect
().
topLeft
();
foreach
(
const
QUrl
url
,
images
)
{
mLastItemOffsetIndex
++
;
mLastItemOffsetIndex
=
qMin
(
mLastItemOffsetIndex
,
5
);
QGraphicsItem
*
itemInScene
=
0
;
if
(
activeScene
())
{
QString
mimeType
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
url
.
toString
());
//TODO UB 4.x move this logic to the scene ..
if
(
mimeType
==
"image/svg+xml"
)
{
itemInScene
=
activeScene
()
->
addSvg
(
url
,
pos
);
}
else
{
itemInScene
=
activeScene
()
->
addPixmap
(
QPixmap
(
url
.
toLocalFile
()),
pos
);
}
}
if
(
itemInScene
)
{
itemInScene
=
activeScene
()
->
scaleToFitDocumentSize
(
itemInScene
,
false
,
UBSettings
::
objectInControlViewMargin
);
itemInScene
->
setPos
(
QPoint
(
pos
.
x
()
+
50
*
mLastItemOffsetIndex
,
pos
.
y
()
+
50
*
mLastItemOffsetIndex
));
}
}
}
void
UBLibraryController
::
addVideosToCurrentPage
(
const
QList
<
QUrl
>&
videos
)
{
QPointF
pos
=
visibleSceneRect
().
topLeft
();
foreach
(
const
QUrl
url
,
videos
)
{
mLastItemOffsetIndex
++
;
mLastItemOffsetIndex
=
qMin
(
mLastItemOffsetIndex
,
5
);
UBGraphicsVideoItem
*
itemInScene
=
UBApplication
::
boardController
->
addVideo
(
url
,
false
,
pos
);
itemInScene
->
setPos
(
QPoint
(
pos
.
x
()
+
50
*
mLastItemOffsetIndex
,
pos
.
y
()
+
50
*
mLastItemOffsetIndex
));
}
}
void
UBLibraryController
::
addAudiosToCurrentPage
(
const
QList
<
QUrl
>&
sounds
)
{
QPointF
topLeftPos
=
visibleSceneRect
().
topLeft
();
QPointF
pos
=
topLeftPos
;
foreach
(
const
QUrl
url
,
sounds
)
{
mLastItemOffsetIndex
++
;
mLastItemOffsetIndex
=
qMin
(
mLastItemOffsetIndex
,
5
);
pos
=
QPointF
(
topLeftPos
.
x
()
+
50
*
mLastItemOffsetIndex
,
topLeftPos
.
y
()
+
50
*
mLastItemOffsetIndex
);
UBApplication
::
boardController
->
addAudio
(
url
,
false
,
pos
);
}
}
void
UBLibraryController
::
addInteractivesToCurrentPage
(
const
QList
<
QUrl
>&
widgets
)
{
foreach
(
const
QUrl
url
,
widgets
)
{
mBoardController
->
downloadURL
(
url
,
QPointF
(
0
,
0
));
}
}
void
UBLibraryController
::
addImage
()
{
QList
<
QUrl
>
images
;
foreach
(
QGraphicsItem
*
item
,
mLibraryUI
->
imageThumbnailView
->
selectedItems
())
{
QGraphicsPixmapItem
*
pixmapItem
=
dynamic_cast
<
QGraphicsPixmapItem
*>
(
item
);
if
(
pixmapItem
&&
activeScene
())
{
images
<<
QUrl
::
fromLocalFile
(
mPixmapItemToFilepath
.
value
(
pixmapItem
));
}
else
{
QGraphicsSvgItem
*
svgItem
=
dynamic_cast
<
QGraphicsSvgItem
*>
(
item
);
images
<<
QUrl
::
fromLocalFile
(
mSvgImageItemToFilepath
.
value
(
svgItem
));
}
}
addImagesToCurrentPage
(
images
);
}
void
UBLibraryController
::
addVideo
()
{
QList
<
QUrl
>
urls
;
foreach
(
QGraphicsItem
*
item
,
mLibraryUI
->
videoThumbnailView
->
selectedItems
())
{
UBThumbnailVideo
*
videoItem
=
dynamic_cast
<
UBThumbnailVideo
*>
(
item
);
if
(
videoItem
&&
activeScene
())
{
urls
<<
videoItem
->
path
();
}
}
addVideosToCurrentPage
(
urls
);
}
void
UBLibraryController
::
addAudio
()
{
QList
<
QUrl
>
urls
;
foreach
(
QGraphicsItem
*
item
,
mLibraryUI
->
soundThumbnailView
->
selectedItems
())
{
QGraphicsPixmapItem
*
pixmapItem
=
dynamic_cast
<
QGraphicsPixmapItem
*>
(
item
);
if
(
pixmapItem
&&
activeScene
())
{
urls
<<
QUrl
::
fromLocalFile
(
mSoundItemToFilepath
.
value
(
pixmapItem
));
}
}
addAudiosToCurrentPage
(
urls
);
}
void
UBLibraryController
::
setImageAsBackground
()
{
QList
<
QGraphicsItem
*>
selectedItems
=
mLibraryUI
->
imageThumbnailView
->
selectedItems
();
if
(
selectedItems
.
size
()
>
0
)
{
QGraphicsPixmapItem
*
pixmapItem
=
dynamic_cast
<
QGraphicsPixmapItem
*>
(
selectedItems
.
last
());
if
(
pixmapItem
&&
activeScene
())
{
QPixmap
pix
=
mPixmapItemToFilepath
.
value
(
pixmapItem
);
UBGraphicsPixmapItem
*
boardItem
=
activeScene
()
->
addPixmap
(
pix
,
QPointF
(
0
,
0
));
activeScene
()
->
setAsBackgroundObject
(
boardItem
,
true
);
return
;
}
QGraphicsSvgItem
*
svgItem
=
dynamic_cast
<
QGraphicsSvgItem
*>
(
selectedItems
.
last
());
if
(
svgItem
&&
activeScene
()
&&
mSvgImageItemToFilepath
.
contains
(
svgItem
))
{
QUrl
url
=
QUrl
::
fromLocalFile
(
mSvgImageItemToFilepath
.
value
(
svgItem
));
QGraphicsSvgItem
*
boardItem
=
activeScene
()
->
addSvg
(
url
,
QPointF
(
0
,
0
));
activeScene
()
->
setAsBackgroundObject
(
boardItem
,
true
,
true
);
}
}
}
void
UBLibraryController
::
closeWindow
()
{
mLibraryWindow
->
hide
();
}
void
UBLibraryController
::
itemSelectionChanged
()
{
selectionChanged
();
switch
(
mLibraryUI
->
libraryTab
->
currentIndex
())
{
case
TabIndex
:
:
Image
:
refreshImageThumbnailsView
();
break
;
case
TabIndex
:
:
Interactive
:
refreshInteractiveThumbnailsView
();
break
;
case
TabIndex
:
:
Video
:
refreshVideoThumbnailsView
();
break
;
case
TabIndex
:
:
Sound
:
refreshSoundThumbnailsView
();
break
;
default
:
break
;
}
}
void
UBLibraryController
::
itemChanged
(
QTreeWidgetItem
*
item
,
int
column
)
{
UBLibraryFolderItem
*
fi
=
dynamic_cast
<
UBLibraryFolderItem
*>
(
item
);
if
(
fi
)
{
QString
newName
=
item
->
text
(
column
);
QString
oldPath
=
fi
->
dir
().
canonicalPath
();
int
lastSlashIndex
=
oldPath
.
lastIndexOf
(
"/"
);
QString
newPath
=
oldPath
.
left
(
lastSlashIndex
+
1
)
+
newName
;
qDebug
()
<<
"renaming"
<<
oldPath
<<
"to"
<<
newPath
;
if
(
fi
->
dir
().
rename
(
oldPath
,
newPath
))
{
fi
->
setDir
(
QDir
(
newPath
));
}
else
{
item
->
setText
(
column
,
fi
->
dir
().
dirName
());
}
}
}
void
UBLibraryController
::
thumbnailViewResized
()
{
switch
(
mLibraryUI
->
libraryTab
->
currentIndex
())
{
case
TabIndex
:
:
Image
:
mLibraryUI
->
zoomSlider
->
setMaximum
(
mLibraryUI
->
imageThumbnailView
->
width
());
break
;
case
TabIndex
:
:
Shape
:
mLibraryUI
->
zoomSlider
->
setMaximum
(
mLibraryUI
->
shapeThumbnailView
->
width
());
break
;
case
TabIndex
:
:
Interactive
:
mLibraryUI
->
zoomSlider
->
setMaximum
(
mLibraryUI
->
interactiveThumbnailView
->
width
());
break
;
case
TabIndex
:
:
Video
:
mLibraryUI
->
zoomSlider
->
setMaximum
(
mLibraryUI
->
videoThumbnailView
->
width
());
break
;
case
TabIndex
:
:
Gip
:
mLibraryUI
->
zoomSlider
->
setMaximum
(
mLibraryUI
->
gipThumbnailView
->
width
());
break
;
case
TabIndex
:
:
Sound
:
mLibraryUI
->
zoomSlider
->
setMaximum
(
mLibraryUI
->
soundThumbnailView
->
width
());
break
;
default
:
break
;
}
}
UBLibraryFolderItem
::
UBLibraryFolderItem
(
const
QDir
&
pDir
,
const
QString
&
name
,
QTreeWidgetItem
*
parent
,
bool
canWrite
,
const
QStringList
&
pExtensionsToHide
)
:
QTreeWidgetItem
(
parent
),
mExtensionsToHide
(
pExtensionsToHide
),
mDir
(
pDir
),
mCanWrite
(
canWrite
)
{
if
(
name
.
length
()
==
0
)
{
setText
(
0
,
UBLibraryController
::
trUtf8
(
pDir
.
dirName
().
toUtf8
()));
}
else
{
setText
(
0
,
UBLibraryController
::
trUtf8
(
name
.
toUtf8
()));
}
if
(
canWrite
)
{
setFlags
(
flags
()
|
Qt
::
ItemIsEditable
);
}
if
(
!
mDir
.
exists
())
mDir
.
mkpath
(
mDir
.
path
());
refreshSubDirs
();
}
void
UBLibraryFolderItem
::
refreshSubDirs
()
{
foreach
(
QTreeWidgetItem
*
ti
,
takeChildren
())
delete
ti
;
QStringList
subDirs
=
mDir
.
entryList
(
QStringList
(),
QDir
::
Dirs
|
QDir
::
NoDotAndDotDot
|
QDir
::
NoSymLinks
,
QDir
::
Name
);
// TODO UB 4.x support symlinks properly
foreach
(
QString
subDirName
,
subDirs
)
{
QString
ext
=
UBFileSystemUtils
::
extension
(
subDirName
);
if
(
!
mExtensionsToHide
.
contains
(
ext
))
{
new
UBLibraryFolderItem
(
QDir
(
mDir
.
path
()
+
"/"
+
subDirName
),
UBLibraryController
::
trUtf8
(
subDirName
.
toUtf8
()),
this
,
mCanWrite
,
mExtensionsToHide
);
}
}
}
void
UBLibraryController
::
refreshVideoThumbnailsView
()
{
QApplication
::
setOverrideCursor
(
QCursor
(
Qt
::
WaitCursor
));
QList
<
QGraphicsItem
*>
items
;
QList
<
QUrl
>
itemsPath
;
QStringList
labels
;
QList
<
QTreeWidgetItem
*>
tw
=
mLibraryUI
->
videoLibraryTreeWidget
->
selectedItems
();
if
(
tw
.
size
()
>
0
)
{
UBLibraryFolderItem
*
fi
=
dynamic_cast
<
UBLibraryFolderItem
*>
(
tw
.
last
());
if
(
fi
)
{
QStringList
videoPaths
=
UBPersistenceManager
::
persistenceManager
()
->
allVideos
(
fi
->
dir
());
for
(
int
i
=
0
;
i
<
videoPaths
.
size
();
i
++
)
{
QString
path
=
videoPaths
.
at
(
i
);
UBThumbnailVideo
*
pixmapItem
=
new
UBThumbnailVideo
(
QUrl
::
fromLocalFile
(
path
));
items
.
append
(
pixmapItem
);
itemsPath
.
append
(
QUrl
::
fromLocalFile
(
path
));
QFileInfo
file
(
path
);
labels
.
append
(
file
.
completeBaseName
());
}
}
}
mLibraryUI
->
videoThumbnailView
->
setGraphicsItems
(
items
,
itemsPath
,
labels
);
QApplication
::
restoreOverrideCursor
();
}
void
UBLibraryController
::
refreshSoundThumbnailsView
()
{
QList
<
QGraphicsItem
*>
soundItems
;
QList
<
QUrl
>
soundItemsPath
;
QStringList
soundLabels
;
QApplication
::
setOverrideCursor
(
QCursor
(
Qt
::
WaitCursor
));
QStringList
soundWidgetPaths
=
UBPersistenceManager
::
persistenceManager
()
->
allSounds
();
for
(
int
i
=
0
;
i
<
soundWidgetPaths
.
size
();
i
++
)
{
QString
path
=
soundWidgetPaths
.
at
(
i
);
QGraphicsPixmapItem
*
pixmapItem
=
new
UBThumbnailPixmap
(
QPixmap
(
":/images/soundIcon.svg"
));
QString
name
=
path
;
mSoundItemToFilepath
.
insert
(
pixmapItem
,
path
);
soundItems
.
append
(
pixmapItem
);
soundItemsPath
.
append
(
QUrl
::
fromLocalFile
(
path
));
soundLabels
.
append
(
UBFileSystemUtils
::
lastPathComponent
(
name
));
}
mLibraryUI
->
soundThumbnailView
->
setGraphicsItems
(
soundItems
,
soundItemsPath
,
soundLabels
);
QApplication
::
restoreOverrideCursor
();
}
void
UBLibraryController
::
addObjectFromFilesystemToPage
()
{
bool
hasAddedObjects
=
false
;
switch
(
mLibraryUI
->
libraryTab
->
currentIndex
())
{
case
TabIndex
:
:
Image
:
{
QString
extensions
;
foreach
(
QString
ext
,
UBSettings
::
settings
()
->
imageFileExtensions
)
{
extensions
+=
" *."
;
extensions
+=
ext
;
}
QString
defaultPath
=
UBSettings
::
settings
()
->
lastPicturePath
->
get
().
toString
();
QStringList
filenames
=
QFileDialog
::
getOpenFileNames
(
mParentWidget
,
tr
(
"Add Images to Current Page"
),
defaultPath
,
tr
(
"All Images (%1)"
).
arg
(
extensions
));
if
(
filenames
.
size
()
>
0
)
{
QFileInfo
fi
(
filenames
.
at
(
0
));
UBSettings
::
settings
()
->
lastPicturePath
->
set
(
QVariant
(
fi
.
dir
().
absolutePath
()));
QList
<
QUrl
>
urls
;
foreach
(
const
QString
s
,
filenames
)
{
urls
<<
QUrl
::
fromLocalFile
(
s
);
}
addImagesToCurrentPage
(
urls
);
hasAddedObjects
=
true
;
}
break
;
}
case
TabIndex
:
:
Interactive
:
{
QString
defaultWidgetPath
=
UBSettings
::
settings
()
->
lastWidgetPath
->
get
().
toString
();
QString
extensions
;
foreach
(
QString
ext
,
UBSettings
::
settings
()
->
interactiveContentFileExtensions
)
{
extensions
+=
" *."
;
extensions
+=
ext
;
}
QStringList
filenames
=
QFileDialog
::
getOpenFileNames
(
mParentWidget
,
tr
(
"Add Applications to Current Page"
),
defaultWidgetPath
,
tr
(
"All Applications (%1)"
).
arg
(
extensions
));
if
(
filenames
.
size
()
>
0
)
{
QFileInfo
fi
(
filenames
.
at
(
0
));
UBSettings
::
settings
()
->
lastWidgetPath
->
set
(
QVariant
(
fi
.
dir
().
absolutePath
()));
QList
<
QUrl
>
urls
;
foreach
(
const
QString
s
,
filenames
)
{
urls
<<
QUrl
::
fromLocalFile
(
s
);
}
addInteractivesToCurrentPage
(
urls
);
hasAddedObjects
=
true
;
}
break
;
}
case
TabIndex
:
:
Video
:
{
QString
defaultVideoPath
=
UBSettings
::
settings
()
->
lastVideoPath
->
get
().
toString
();
QStringList
filenames
=
QFileDialog
::
getOpenFileNames
(
mParentWidget
,
tr
(
"Add Movies to Current Page"
),
defaultVideoPath
,
tr
(
"All Files (*.*)"
));
if
(
filenames
.
size
()
>
0
)
{
QFileInfo
fi
(
filenames
.
at
(
0
));
UBSettings
::
settings
()
->
lastVideoPath
->
set
(
QVariant
(
fi
.
dir
().
absolutePath
()));
QList
<
QUrl
>
urls
;
foreach
(
const
QString
s
,
filenames
)
{
urls
<<
QUrl
::
fromLocalFile
(
s
);
}
addVideosToCurrentPage
(
urls
);
hasAddedObjects
=
true
;
}
break
;
}
case
TabIndex
:
:
Gip
:
{
//TODO
break
;
}
default
:
break
;
}
UBDrawingController
::
drawingController
()
->
setStylusTool
(
UBStylusTool
::
Selector
);
if
(
hasAddedObjects
)
{
mLibraryWindow
->
done
(
0
);
}
}
void
UBLibraryController
::
addInteractiveToCurrentPage
()
{
QList
<
QUrl
>
widgets
;
foreach
(
QGraphicsItem
*
item
,
mLibraryUI
->
interactiveThumbnailView
->
selectedItems
())
{
QGraphicsPixmapItem
*
iconItem
=
dynamic_cast
<
QGraphicsPixmapItem
*>
(
item
);
if
(
iconItem
&&
activeScene
())
{
QString
url
=
mInteractiveItemToFilepath
.
value
(
iconItem
);
if
(
url
.
startsWith
(
"uniboardTool"
))
{
widgets
<<
QUrl
(
url
);
}
else
{
widgets
<<
QUrl
::
fromLocalFile
(
url
);
}
}
}
addInteractivesToCurrentPage
(
widgets
);
}
void
UBLibraryController
::
loadLibraries
()
{
if
(
mLibraryFileToDownload
.
size
()
>
0
)
{
QString
mainLibrary
=
mLibraryFileToDownload
.
takeFirst
();
UBNetworkAccessManager
*
nam
=
UBNetworkAccessManager
::
defaultAccessManager
();
UBServerXMLHttpRequest
*
librariesReq
=
new
UBServerXMLHttpRequest
(
nam
);
// Deleted automatically after reply content is consumed
connect
(
librariesReq
,
SIGNAL
(
finished
(
bool
,
const
QByteArray
&
)),
this
,
SLOT
(
getLibraryListResponse
(
bool
,
const
QByteArray
&
)));
librariesReq
->
get
(
QUrl
(
mainLibrary
));
}
}
void
UBLibraryController
::
getLibraryListResponse
(
bool
ok
,
const
QByteArray
&
replyContent
)
{
if
(
!
ok
)
return
;
QXmlStreamReader
xml
(
replyContent
);
while
(
!
xml
.
atEnd
())
{
xml
.
readNext
();
if
(
xml
.
isStartElement
())
{
if
(
xml
.
name
()
==
"library"
)
{
QStringRef
libraryTitle
=
xml
.
attributes
().
value
(
"title"
);
QStringRef
libraryHref
=
xml
.
attributes
().
value
(
"href"
);
QStringRef
libraryType
=
xml
.
attributes
().
value
(
"type"
);
if
(
!
libraryTitle
.
isNull
()
&&
!
libraryTitle
.
isNull
()
&&
!
libraryType
.
isNull
())
{
QString
title
=
libraryTitle
.
toString
();
QUrl
href
(
libraryHref
.
toString
());
UBOnlineLibraryItem
*
ubLibrary
=
new
UBOnlineLibraryItem
(
href
,
title
,
0
);
if
(
libraryType
.
toString
()
==
"image"
)
{
if
(
!
mImageOnlineTi
)
{
mImageOnlineTi
=
new
QTreeWidgetItem
();
mImageOnlineTi
->
setText
(
0
,
tr
(
"Online"
));
mImageOnlineTi
->
setIcon
(
0
,
QPixmap
(
":/images/online.png"
));
mLibraryUI
->
imageLibraryTreeWidget
->
addTopLevelItem
(
mImageOnlineTi
);
}
mImageOnlineTi
->
addChild
(
ubLibrary
);
mImageOnlineTi
->
setExpanded
(
true
);
}
else
if
(
libraryType
.
toString
()
==
"video"
)
{
if
(
!
mVideoOnlineTi
)
{
mVideoOnlineTi
=
new
QTreeWidgetItem
();
mVideoOnlineTi
->
setText
(
0
,
tr
(
"Online"
));
mVideoOnlineTi
->
setIcon
(
0
,
QPixmap
(
":/images/online.png"
));
mLibraryUI
->
videoLibraryTreeWidget
->
addTopLevelItem
(
mVideoOnlineTi
);
}
mVideoOnlineTi
->
addChild
(
ubLibrary
);
mVideoOnlineTi
->
setExpanded
(
true
);
}
else
if
(
libraryType
.
toString
()
==
"interactive"
)
{
if
(
!
mInteractiveOnlineTi
)
{
mInteractiveOnlineTi
=
new
QTreeWidgetItem
();
mInteractiveOnlineTi
->
setText
(
0
,
tr
(
"Online"
));
mInteractiveOnlineTi
->
setIcon
(
0
,
QPixmap
(
":/images/online.png"
));
mLibraryUI
->
interactiveLibraryTreeWidget
->
addTopLevelItem
(
mInteractiveOnlineTi
);
}
mInteractiveOnlineTi
->
addChild
(
ubLibrary
);
mInteractiveOnlineTi
->
setExpanded
(
true
);
}
}
}
}
}
loadLibraries
();
}
UBLibraryWebView
::
UBLibraryWebView
(
QWidget
*
parent
)
:
QWebView
(
parent
),
mCurrentLibraryItem
(
0
)
{
setPage
(
new
UBWebPage
(
this
));
QWebView
::
settings
()
->
setAttribute
(
QWebSettings
::
PluginsEnabled
,
true
);
QWebView
::
page
()
->
setNetworkAccessManager
(
UBNetworkAccessManager
::
defaultAccessManager
());
connect
(
page
()
->
mainFrame
(),
SIGNAL
(
javaScriptWindowObjectCleared
()),
this
,
SLOT
(
javaScriptWindowObjectCleared
()));
connect
(
this
,
SIGNAL
(
iconChanged
()),
this
,
SLOT
(
newIconAvailable
()));
connect
(
this
,
SIGNAL
(
loadFinished
(
bool
)),
this
,
SLOT
(
loadFinished
(
bool
)));
}
void
UBLibraryWebView
::
javaScriptWindowObjectCleared
()
{
UBLibraryAPI
*
libraryAPI
=
new
UBLibraryAPI
(
this
);
page
()
->
mainFrame
()
->
addToJavaScriptWindowObject
(
"uniboard"
,
libraryAPI
);
}
void
UBLibraryWebView
::
loadFinished
(
bool
ok
)
{
if
(
ok
)
{
QString
installDragHandler
=
"document.body.ondragstart = function(event) {"
;
installDragHandler
+=
"var p = event.target.parentNode;"
;
installDragHandler
+=
"if (p && p.href){"
;
installDragHandler
+=
"event.preventDefault();"
;
installDragHandler
+=
"uniboard.startDrag(p.href);"
;
installDragHandler
+=
"}"
;
installDragHandler
+=
"}"
;
page
()
->
mainFrame
()
->
evaluateJavaScript
(
installDragHandler
);
}
mCurrentLibraryItem
->
setIcon
(
0
,
QWebSettings
::
iconForUrl
(
url
()));
}
void
UBLibraryWebView
::
newIconAvailable
()
{
if
(
mCurrentLibraryItem
)
mCurrentLibraryItem
->
setIcon
(
0
,
icon
());
}
QWebView
*
UBLibraryWebView
::
createWindow
(
QWebPage
::
WebWindowType
type
)
{
if
(
type
==
QWebPage
::
WebBrowserWindow
)
{
UBApplication
::
applicationController
->
showInternet
();
return
UBApplication
::
webController
->
createNewTab
();
}
else
{
return
this
;
}
}
UBLibraryPreloader
::
UBLibraryPreloader
(
QObject
*
pParent
)
:
QObject
(
pParent
)
{
QTimer
::
singleShot
(
30000
,
this
,
SLOT
(
loadLibrary
()));
}
void
UBLibraryPreloader
::
loadLibrary
()
{
QStringList
libraries
=
UBLibraryController
::
onlineLibraries
();
if
(
libraries
.
length
()
>
0
)
{
QString
mainLibrary
=
libraries
.
at
(
0
);
UBNetworkAccessManager
*
nam
=
UBNetworkAccessManager
::
defaultAccessManager
();
UBServerXMLHttpRequest
*
librariesReq
=
new
UBServerXMLHttpRequest
(
nam
);
// Deleted automatically after reply content is consumed
connect
(
librariesReq
,
SIGNAL
(
finished
(
bool
,
const
QByteArray
&
)),
this
,
SLOT
(
getLibraryListResponse
(
bool
,
const
QByteArray
&
)));
librariesReq
->
get
(
QUrl
(
mainLibrary
));
}
}
void
UBLibraryPreloader
::
getLibraryListResponse
(
bool
ok
,
const
QByteArray
&
replyContent
)
{
if
(
!
ok
)
return
;
QXmlStreamReader
xml
(
replyContent
);
while
(
!
xml
.
atEnd
())
{
xml
.
readNext
();
if
(
xml
.
isStartElement
())
{
if
(
xml
.
name
()
==
"library"
)
{
QStringRef
libraryHref
=
xml
.
attributes
().
value
(
"href"
);
QStringRef
libraryType
=
xml
.
attributes
().
value
(
"type"
);
if
(
!
libraryType
.
isNull
()
&&
!
libraryHref
.
isNull
())
{
if
(
libraryType
.
toString
()
==
"interactive"
)
{
QUrl
href
(
libraryHref
.
toString
());
mWebView
=
new
QWebView
(
UBApplication
::
mainWindow
);
mWebView
->
setVisible
(
false
);
connect
(
mWebView
,
SIGNAL
(
loadFinished
(
bool
)),
this
,
SLOT
(
loadFinished
(
bool
)));
mWebView
->
load
(
QUrl
(
libraryHref
.
toString
()));
return
;
}
}
}
}
}
}
void
UBLibraryPreloader
::
loadFinished
(
bool
ok
)
{
Q_UNUSED
(
ok
);
mWebView
->
deleteLater
();
deleteLater
();
}
void
UBLibraryController
::
addNativeToolToFavorites
(
const
QUrl
&
url
)
{
QString
id
=
url
.
toString
();
QStringList
favoritesNativeTools
=
UBSettings
::
settings
()
->
favoritesNativeToolUris
->
get
().
toStringList
();
if
(
!
favoritesNativeTools
.
contains
(
id
))
{
favoritesNativeTools
<<
id
;
UBSettings
::
settings
()
->
favoritesNativeToolUris
->
set
(
favoritesNativeTools
);
}
refreshInteractiveThumbnailsView
();
}
QString
UBLibraryController
::
favoritePath
()
{
return
favoriteVirtualPath
;
}
UBLibElement
::
UBLibElement
()
{
mType
=
eUBLibElementType_Category
;
mName
=
QObject
::
tr
(
"/Home"
,
"Category list label on navigation tool bar"
);
...
...
src/board/UBLibraryController.h
View file @
874e42a2
...
...
@@ -6,8 +6,6 @@
#include "web/UBWebPage.h"
#include "ui_library.h"
class
UBGraphicsScene
;
class
UBBoardController
;
class
QGraphicsSvgItem
;
...
...
@@ -82,14 +80,6 @@ class UBLibraryController : public QObject
UBLibraryController
(
QWidget
*
parentWidget
,
UBBoardController
*
boardController
);
virtual
~
UBLibraryController
();
QWidget
*
libraryWindow
()
{
return
mLibraryWindow
;
}
static
QStringList
onlineLibraries
();
static
void
preloadFirstOnlineLibrary
();
QList
<
UBLibElement
*>
getContent
(
UBLibElement
*
pElement
);
void
moveContent
(
QList
<
UBLibElement
*>
sourceList
,
UBLibElement
*
pDestination
);
void
trashElements
(
QList
<
UBLibElement
*>
trashList
);
...
...
@@ -117,42 +107,10 @@ class UBLibraryController : public QObject
public
slots
:
void
removeBackground
();
void
showLibraryDialog
(
bool
show
);
void
refreshShapeThumbnailsView
();
void
refreshImageThumbnailsView
();
void
refreshInteractiveThumbnailsView
();
void
refreshVideoThumbnailsView
();
void
refreshSoundThumbnailsView
();
void
addShape
();
void
setShapeAsBackground
();
void
addToPage
();
void
setAsBackground
();
void
addImage
();
void
addVideo
();
void
addAudio
();
void
addInteractiveToCurrentPage
();
void
addImagesToCurrentPage
(
const
QList
<
QUrl
>&
images
);
void
addVideosToCurrentPage
(
const
QList
<
QUrl
>&
videos
);
void
addAudiosToCurrentPage
(
const
QList
<
QUrl
>&
sounds
);
void
addInteractivesToCurrentPage
(
const
QList
<
QUrl
>&
interactiveWidgets
);
void
setImageAsBackground
();
void
closeWindow
();
void
addObjectFromFilesystemToPage
();
void
needRefreshOnNextDisplay
()
{
mNeedRefreshOnNextDisplay
=
true
;
}
protected
:
...
...
@@ -186,215 +144,11 @@ class UBLibraryController : public QObject
UBLibElement
*
isOnFavoriteList
(
UBLibElement
*
element
);
void
loadLibraries
();
QWidget
*
mParentWidget
;
UBBoardController
*
mBoardController
;
QDialog
*
mLibraryWindow
;
Ui
::
library
*
mLibraryUI
;
// TODO UB 4.x break this logic, by carrying the path within the thumb item (see Video items path)
//
QMap
<
QGraphicsSvgItem
*
,
QString
>
mSvgItemToFilepath
;
//shape mapping
QMap
<
QGraphicsSvgItem
*
,
QString
>
mSvgImageItemToFilepath
;
// svg image mapping
QMap
<
QGraphicsPixmapItem
*
,
QString
>
mPixmapItemToFilepath
;
// other image mapping
QMap
<
QGraphicsPixmapItem
*
,
QString
>
mInteractiveItemToFilepath
;
// interactive widget mapping
QMap
<
QGraphicsPixmapItem
*
,
QString
>
mSoundItemToFilepath
;
// sounds mapping
UBLibraryWebView
*
mImageWebView
;
UBLibraryWebView
*
mVideoWebView
;
UBLibraryWebView
*
mInteractiveWebView
;
QTreeWidgetItem
*
mImageOnlineTi
;
QTreeWidgetItem
*
mVideoOnlineTi
;
QTreeWidgetItem
*
mInteractiveOnlineTi
;
QTreeWidgetItem
*
mInteractiveUniboardTi
;
struct
TabIndex
{
enum
Enum
{
Gip
=
0
,
Interactive
=
1
,
Image
=
2
,
Video
=
3
,
Shape
=
4
,
Sound
=
5
};
};
int
mLastItemOffsetIndex
;
QStringList
mLibraryFileToDownload
;
bool
mNeedRefreshOnNextDisplay
;
private
slots
:
void
tabChanged
(
int
value
);
void
zoomSliderValueChanged
(
int
value
);
void
createNewFolder
();
void
addInteractivesToLibrary
();
void
addImagesToLibrary
();
void
removeItemsFromLibrary
(
UBThumbnailWidget
*
pThumbnailView
);
void
removeDir
();
void
remove
();
void
itemSelectionChanged
();
void
itemChanged
(
QTreeWidgetItem
*
item
,
int
column
);
void
selectionChanged
();
void
thumbnailViewResized
();
void
getLibraryListResponse
(
bool
,
const
QByteArray
&
);
};
class
UBLibraryFolderItem
:
public
QTreeWidgetItem
{
public
:
UBLibraryFolderItem
(
const
QDir
&
pDir
,
const
QString
&
name
,
QTreeWidgetItem
*
parent
,
bool
pCanWrite
,
const
QStringList
&
pExtensionsToHide
);
virtual
~
UBLibraryFolderItem
(){}
void
refreshSubDirs
();
QDir
dir
()
{
return
mDir
;
}
void
setDir
(
const
QDir
&
dir
)
{
mDir
=
dir
;
}
bool
canWrite
()
{
return
mCanWrite
;
}
void
setCanWrite
(
bool
canWrite
)
{
mCanWrite
=
canWrite
;
}
private
:
const
QStringList
mExtensionsToHide
;
QDir
mDir
;
bool
mCanWrite
;
};
class
UBOnlineLibraryItem
:
public
QTreeWidgetItem
{
public
:
UBOnlineLibraryItem
(
const
QUrl
&
pUrl
,
const
QString
&
name
,
QTreeWidgetItem
*
parent
)
:
QTreeWidgetItem
(
parent
)
,
mUrl
(
pUrl
)
{
setText
(
0
,
UBLibraryController
::
trUtf8
(
name
.
toUtf8
()));
setIcon
(
0
,
QWebSettings
::
iconForUrl
(
pUrl
));
}
virtual
~
UBOnlineLibraryItem
(){}
QUrl
url
()
const
{
return
mUrl
;
}
private
:
QUrl
mUrl
;
};
class
UBLibraryWebView
:
public
QWebView
{
Q_OBJECT
;
public
:
UBLibraryWebView
(
QWidget
*
parent
=
0
);
virtual
~
UBLibraryWebView
(){};
virtual
void
mousePressEvent
(
QMouseEvent
*
event
)
{
QWebView
::
mousePressEvent
(
event
);
}
virtual
void
mouseMoveEvent
(
QMouseEvent
*
event
)
{
QWebView
::
mouseMoveEvent
(
event
);
}
virtual
void
mouseReleaseEvent
(
QMouseEvent
*
event
)
{
QWebView
::
mouseReleaseEvent
(
event
);
}
void
load
(
const
QUrl
&
url
)
{
mCurrentLibraryItem
=
0
;
QWebView
::
load
(
url
);
}
void
load
(
const
QUrl
&
url
,
UBOnlineLibraryItem
*
pLibraryItem
)
{
mCurrentLibraryItem
=
pLibraryItem
;
QWebView
::
load
(
url
);
}
protected
:
virtual
QWebView
*
createWindow
(
QWebPage
::
WebWindowType
type
);
private
slots
:
void
javaScriptWindowObjectCleared
();
void
newIconAvailable
();
void
loadFinished
(
bool
ok
);
private
:
UBOnlineLibraryItem
*
mCurrentLibraryItem
;
};
class
UBLibraryPreloader
:
public
QObject
{
Q_OBJECT
;
public
:
UBLibraryPreloader
(
QObject
*
pParent
);
virtual
~
UBLibraryPreloader
(){};
private
slots
:
void
loadLibrary
();
void
getLibraryListResponse
(
bool
ok
,
const
QByteArray
&
replyContent
);
void
loadFinished
(
bool
ok
);
private
:
QWebView
*
mWebView
;
};
#endif
/* UBLIBRARYCONTROLLER_H_ */
src/board/UBLibraryTreeWidget.cpp
deleted
100644 → 0
View file @
dbd2aeca
/*
* UBLibraryTreeWidget.cpp
*
* Created on: 28 juil. 2009
* Author: Luc
*/
#include "UBLibraryTreeWidget.h"
#include "frameworks/UBFileSystemUtils.h"
#include "core/UBApplication.h"
#include "core/UBSettings.h"
#include "board/UBBoardController.h"
#include "network/UBHttpGet.h"
#include "domain/UBW3CWidget.h"
#include "UBLibraryController.h"
UBLibraryTreeWidget
::
UBLibraryTreeWidget
(
QWidget
*
parent
)
:
QTreeWidget
(
parent
)
,
mDropFolderItem
(
0
)
{
setDragDropMode
(
QAbstractItemView
::
DropOnly
);
setAcceptDrops
(
true
);
viewport
()
->
setAcceptDrops
(
true
);
setDropIndicatorShown
(
true
);
}
UBLibraryTreeWidget
::~
UBLibraryTreeWidget
()
{
// NOOP
}
bool
UBLibraryTreeWidget
::
supportMimeData
(
const
QMimeData
*
pMimeData
)
{
foreach
(
QString
mimeType
,
mMimeTypes
)
{
foreach
(
QString
format
,
pMimeData
->
formats
())
{
if
(
format
.
startsWith
(
mimeType
))
{
return
true
;
}
}
}
foreach
(
QUrl
url
,
pMimeData
->
urls
())
{
foreach
(
QString
ext
,
mFileExtensions
)
{
if
(
url
.
toString
().
endsWith
(
ext
))
{
return
true
;
}
}
}
foreach
(
QUrl
url
,
pMimeData
->
urls
())
{
foreach
(
QString
protocole
,
mProtocoles
)
{
if
(
url
.
toString
().
startsWith
(
protocole
))
{
return
true
;
}
}
}
return
false
;
}
void
UBLibraryTreeWidget
::
dragEnterEvent
(
QDragEnterEvent
*
event
)
{
mDropFolderItem
=
0
;
if
(
supportMimeData
(
event
->
mimeData
()))
{
event
->
acceptProposedAction
();
return
;
}
else
{
QTreeWidget
::
dragEnterEvent
(
event
);
}
}
void
UBLibraryTreeWidget
::
dragMoveEvent
(
QDragMoveEvent
*
event
)
{
QTreeWidgetItem
*
ti
=
itemAt
(
event
->
pos
());
UBLibraryFolderItem
*
lfi
=
dynamic_cast
<
UBLibraryFolderItem
*>
(
ti
);
if
(
lfi
&&
lfi
->
canWrite
()
&&
!
(
lfi
==
currentItem
()))
{
event
->
acceptProposedAction
();
return
;
}
QTreeWidget
::
dragMoveEvent
(
event
);
}
void
UBLibraryTreeWidget
::
dropEvent
(
QDropEvent
*
event
)
{
QTreeWidgetItem
*
ti
=
itemAt
(
event
->
pos
());
UBLibraryFolderItem
*
lfi
=
dynamic_cast
<
UBLibraryFolderItem
*>
(
ti
);
if
(
lfi
)
{
UBLibraryFolderItem
*
sourceLfi
=
dynamic_cast
<
UBLibraryFolderItem
*>
(
currentItem
());
mDropFolderItem
=
lfi
;
QDir
dir
=
lfi
->
dir
();
foreach
(
QUrl
url
,
event
->
mimeData
()
->
urls
())
{
// is it local ?
QString
localFile
=
url
.
toLocalFile
();
if
(
localFile
.
length
()
>
0
)
{
QFileInfo
fileInfo
(
localFile
);
//is it a file ?
if
(
fileInfo
.
isFile
())
{
// copy file to dir
QFile
file
(
localFile
);
if
(
sourceLfi
&&
sourceLfi
->
canWrite
())
{
file
.
rename
(
dir
.
filePath
(
fileInfo
.
fileName
()));
emit
contentChanged
();
}
else
{
file
.
copy
(
dir
.
filePath
(
fileInfo
.
fileName
()));
}
}
else
if
(
fileInfo
.
isDir
())
{
if
(
sourceLfi
&&
sourceLfi
->
canWrite
())
{
UBFileSystemUtils
::
moveDir
(
localFile
,
dir
.
filePath
(
fileInfo
.
fileName
()));
emit
contentChanged
();
}
else
{
UBFileSystemUtils
::
copyDir
(
localFile
,
dir
.
filePath
(
fileInfo
.
fileName
()));
}
}
}
else
if
(
url
.
toString
().
startsWith
(
"uniboardTool://"
))
{
UBApplication
::
boardController
->
libraryController
()
->
addNativeToolToFavorites
(
url
);
}
else
{
UBHttpGet
*
httpGet
=
new
UBHttpGet
(
this
);
// TODO UB 4.6 we are leaking here, tree widget is never destroyed
connect
(
httpGet
,
SIGNAL
(
downloadFinished
(
bool
,
QUrl
,
QString
,
QByteArray
,
QPointF
,
QSize
,
bool
)),
this
,
SLOT
(
downloadFinished
(
bool
,
QUrl
,
QString
,
QByteArray
)));
UBApplication
::
setOverrideCursor
(
Qt
::
WaitCursor
);
UBApplication
::
showMessage
(
tr
(
"Downloading content from %1"
).
arg
(
url
.
toString
()),
true
);
httpGet
->
get
(
url
);
}
}
event
->
acceptProposedAction
();
return
;
}
else
{
QTreeWidget
::
dropEvent
(
event
);
}
}
void
UBLibraryTreeWidget
::
downloadFinished
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
)
{
if
(
!
pSuccess
)
{
UBApplication
::
showMessage
(
tr
(
"Downloading content %1 failed"
).
arg
(
sourceUrl
.
toString
()));
}
else
{
UBApplication
::
showMessage
(
tr
(
"Download finished"
));
QStringList
urlPathParts
=
sourceUrl
.
path
().
split
(
"/"
);
if
(
urlPathParts
.
length
()
>
0
&&
mDropFolderItem
)
{
QString
fileName
=
urlPathParts
.
last
();
QString
ext
=
UBFileSystemUtils
::
fileExtensionFromMimeType
(
pContentTypeHeader
);
if
(
!
fileName
.
endsWith
(
ext
))
{
fileName
+=
"."
+
ext
;
}
QString
filePath
=
mDropFolderItem
->
dir
().
filePath
(
fileName
);
QString
nextItemPath
=
UBFileSystemUtils
::
nextAvailableFileName
(
filePath
);
if
(
UBSettings
::
widgetFileExtensions
.
contains
(
ext
))
{
QTemporaryFile
tempFile
;
if
(
tempFile
.
open
())
{
tempFile
.
write
(
pData
);
tempFile
.
close
();
QDir
widgetDir
(
nextItemPath
);
UBFileSystemUtils
::
expandZipToDir
(
tempFile
,
widgetDir
);
}
}
else
if
(
UBW3CWidget
::
hasNPAPIWrapper
(
pContentTypeHeader
))
{
QString
widgetPath
=
UBW3CWidget
::
createNPAPIWrapperInDir
(
sourceUrl
.
toString
()
,
mDropFolderItem
->
dir
(),
pContentTypeHeader
);
}
else
{
QFile
itemFile
(
nextItemPath
);
if
(
itemFile
.
open
(
QIODevice
::
WriteOnly
))
{
itemFile
.
write
(
pData
);
itemFile
.
close
();
}
}
}
}
UBApplication
::
restoreOverrideCursor
();
}
src/board/UBLibraryTreeWidget.h
deleted
100644 → 0
View file @
dbd2aeca
/*
* UBLibraryTreeWidget.h
*
* Created on: 28 juil. 2009
* Author: Luc
*/
#ifndef UBLIBRARYTREEWIDGET_H_
#define UBLIBRARYTREEWIDGET_H_
#include <QtGui>
class
UBLibraryFolderItem
;
class
UBLibraryTreeWidget
:
public
QTreeWidget
{
Q_OBJECT
;
public
:
UBLibraryTreeWidget
(
QWidget
*
parent
=
0
);
virtual
~
UBLibraryTreeWidget
();
void
setMimeTypes
(
const
QStringList
&
pMimeTypes
)
{
mMimeTypes
=
pMimeTypes
;
}
void
setFileExtensions
(
const
QStringList
&
pFileExtensions
)
{
mFileExtensions
=
pFileExtensions
;
}
void
setProtocoles
(
const
QStringList
&
pProtocoles
)
{
mProtocoles
=
pProtocoles
;
}
bool
supportMimeData
(
const
QMimeData
*
pMimeData
);
signals
:
void
contentChanged
();
protected
:
virtual
void
dragEnterEvent
(
QDragEnterEvent
*
event
);
virtual
void
dragMoveEvent
(
QDragMoveEvent
*
event
);
virtual
void
dropEvent
(
QDropEvent
*
event
);
private
slots
:
void
downloadFinished
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pContentTypeHeader
,
QByteArray
pData
);
private
:
UBLibraryFolderItem
*
mDropFolderItem
;
QStringList
mMimeTypes
;
QStringList
mFileExtensions
;
QStringList
mProtocoles
;
};
#endif
/* UBLIBRARYTREEWIDGET_H_ */
src/board/board.pri
View file @
874e42a2
...
...
@@ -3,14 +3,12 @@ HEADERS += src/board/UBBoardController.h \
src/board/UBBoardPaletteManager.h \
src/board/UBBoardView.h \
src/board/UBLibraryController.h \
src/board/UBLibraryTreeWidget.h \
src/board/UBDrawingController.h
SOURCES += src/board/UBBoardController.cpp \
src/board/UBBoardPaletteManager.cpp \
src/board/UBBoardView.cpp \
src/board/UBLibraryController.cpp \
src/board/UBLibraryTreeWidget.cpp \
src/board/UBDrawingController.cpp
...
...
src/core/UBApplication.cpp
View file @
874e42a2
...
...
@@ -140,8 +140,6 @@ UBApplication::UBApplication(const QString &id, int &argc, char **argv)
}
else
{
// Make sure we don't mix English language with unsupported language dates
//QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));
localString
=
"en_US"
;
}
...
...
@@ -182,6 +180,10 @@ UBApplication::~UBApplication()
// delete staticMemoryCleaner;
staticMemoryCleaner
=
0
;
delete
mUniboardSankoreTransition
;
mUniboardSankoreTransition
=
0
;
}
int
UBApplication
::
exec
(
const
QString
&
pFileToImport
)
...
...
@@ -256,9 +258,6 @@ int UBApplication::exec(const QString& pFileToImport)
// installEventFilter(new UBIdleTimer(this));
//#endif
// TODO UB 4.x make it better and reenable it ... or dump
//installEventFilter(new UBMousePressFilter);
applicationController
->
initScreenLayout
();
boardController
->
setupLayout
();
...
...
@@ -299,8 +298,6 @@ int UBApplication::exec(const QString& pFileToImport)
}
}
UBLibraryController
::
preloadFirstOnlineLibrary
();
mUniboardSankoreTransition
=
new
UniboardSankoreTransition
();
mUniboardSankoreTransition
->
documentTransition
();
...
...
@@ -526,30 +523,6 @@ bool UBApplication::handleOpenMessage(const QString& pMessage)
return
true
;
}
#if defined(Q_WS_MACX) && !defined(QT_MAC_USE_COCOA)
bool
UBApplication
::
macEventFilter
(
EventHandlerCallRef
caller
,
EventRef
event
)
{
Q_UNUSED
(
caller
);
if
((
GetEventClass
(
event
)
==
kEventClassCommand
)
&&
(
GetEventKind
(
event
)
==
kEventProcessCommand
))
{
HICommand
cmd
;
GetEventParameter
(
event
,
kEventParamDirectObject
,
typeHICommand
,
0
,
sizeof
(
cmd
),
0
,
&
cmd
);
if
(
cmd
.
commandID
==
kHICommandHide
)
{
// Override the command + H (Hide Uniboard) behavior
applicationController
->
showDesktop
();
return
true
;
}
}
return
false
;
}
#endif
void
UBStyle
::
drawItemText
(
QPainter
*
painter
,
const
QRect
&
rect
,
int
alignment
,
const
QPalette
&
pal
,
bool
enabled
,
const
QString
&
text
,
QPalette
::
ColorRole
textRole
)
const
{
...
...
@@ -577,30 +550,6 @@ void UBStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment,
painter
->
setPen
(
pen
);
}
/*
*
#if defined(Q_WS_MACX)
if (pal.brush(textRole).color() == Qt::black)
{
painter->save();
painter->translate(0, 0.1);
QBrush brush = pal.brush(QPalette::Light);
QColor color = brush.color();
color.setAlpha(color.alpha() * 0.6);
brush.setColor(color);
painter->setPen(QPen(brush, savedPen.widthF() * 0.8));
painter->drawText(rect, alignment, text);
painter->restore();
}
#endif
*/
painter
->
drawText
(
rect
,
alignment
,
text
);
if
(
textRole
!=
QPalette
::
NoRole
)
...
...
src/gui/UBLibPathViewer.cpp
View file @
874e42a2
...
...
@@ -172,15 +172,12 @@ void UBLibPathViewer::addItem(UBChainedLibElement *elem)
*/
void
UBLibPathViewer
::
resizeEvent
(
QResizeEvent
*
event
)
{
qDebug
()
<<
"old"
<<
event
->
oldSize
();
qDebug
()
<<
"new"
<<
event
->
size
();
if
(
event
->
oldSize
()
==
event
->
size
())
event
->
ignore
();
else
{
if
(
NULL
!=
mpContainer
)
{
if
(
NULL
!=
mpContainer
)
mpContainer
->
setMinimumWidth
(
width
()
-
20
);
}
viewport
()
->
resize
(
width
()
-
10
,
viewport
()
->
height
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment