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
e181f054
Commit
e181f054
authored
Sep 14, 2012
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of github.com:Sankore/Sankore-3.1 into develop
parents
302579cd
19432ccf
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
124 additions
and
94 deletions
+124
-94
UBImportDocument.cpp
src/adaptors/UBImportDocument.cpp
+38
-48
UBImportDocument.h
src/adaptors/UBImportDocument.h
+1
-1
UBBoardController.cpp
src/board/UBBoardController.cpp
+4
-2
UBBoardController.h
src/board/UBBoardController.h
+1
-0
UBDocumentManager.cpp
src/core/UBDocumentManager.cpp
+5
-5
UBPersistenceManager.cpp
src/core/UBPersistenceManager.cpp
+28
-15
UBPersistenceManager.h
src/core/UBPersistenceManager.h
+4
-3
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+4
-2
UBFileSystemUtils.cpp
src/frameworks/UBFileSystemUtils.cpp
+2
-1
UBTeacherGuideWidget.cpp
src/gui/UBTeacherGuideWidget.cpp
+1
-1
UBTeacherGuideWidgetsTools.cpp
src/gui/UBTeacherGuideWidgetsTools.cpp
+34
-16
UBTeacherGuideWidgetsTools.h
src/gui/UBTeacherGuideWidgetsTools.h
+2
-0
No files found.
src/adaptors/UBImportDocument.cpp
View file @
e181f054
...
...
@@ -56,7 +56,7 @@ QString UBImportDocument::importFileFilter()
}
QString
UBImportDocument
::
expandFileToDir
(
const
QFile
&
pZipFile
,
const
QString
&
pDir
)
bool
UBImportDocument
::
extractFileToDir
(
const
QFile
&
pZipFile
,
const
QString
&
pDir
,
QString
&
documentRoot
)
{
QDir
rootDir
(
pDir
);
...
...
@@ -65,63 +65,45 @@ QString UBImportDocument::expandFileToDir(const QFile& pZipFile, const QString&
if
(
!
zip
.
open
(
QuaZip
::
mdUnzip
))
{
qWarning
()
<<
"Import failed. Cause zip.open(): "
<<
zip
.
getZipError
();
return
""
;
return
false
;
}
zip
.
setFileNameCodec
(
"UTF-8"
);
QuaZipFileInfo
info
;
QuaZipFile
file
(
&
zip
);
// TODO UB 4.x implement a mechanism that can replace an existing
// document based on the UID of the document.
bool
createNewDocument
=
true
;
QString
documentRootFolder
;
// first we search the metadata.rdf to check the document properties
for
(
bool
more
=
zip
.
goToFirstFile
();
more
;
more
=
zip
.
goToNextFile
())
{
if
(
!
zip
.
getCurrentFileInfo
(
&
info
))
{
qWarning
()
<<
"Import failed. Cause: getCurrentFileInfo(): "
<<
zip
.
getZipError
();
return
""
;
}
QFileInfo
currentFileInfo
(
pDir
+
"/"
+
file
.
getActualFileName
());
}
if
(
createNewDocument
)
documentRootFolder
=
UBPersistenceManager
::
persistenceManager
()
->
generateUniqueDocumentPath
();
QFile
out
;
char
c
;
documentRoot
=
UBPersistenceManager
::
persistenceManager
()
->
generateUniqueDocumentPath
(
pDir
);
for
(
bool
more
=
zip
.
goToFirstFile
();
more
;
more
=
zip
.
goToNextFile
())
{
if
(
!
zip
.
getCurrentFileInfo
(
&
info
))
{
//TOD UB 4.3 O display error to user or use crash reporter
qWarning
()
<<
"Import failed. Cause: getCurrentFileInfo(): "
<<
zip
.
getZipError
();
return
""
;
return
false
;
}
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
{
qWarning
()
<<
"Import failed. Cause: file.open(): "
<<
zip
.
getZipError
();
return
""
;
return
false
;
}
if
(
file
.
getZipError
()
!=
UNZ_OK
)
{
qWarning
()
<<
"Import failed. Cause: file.getFileName(): "
<<
zip
.
getZipError
();
return
""
;
return
false
;
}
QString
newFileName
=
documentRoot
Folder
+
"/"
+
file
.
getActualFileName
();
QString
newFileName
=
documentRoot
+
"/"
+
file
.
getActualFileName
();
QFileInfo
newFileInfo
(
newFileName
);
rootDir
.
mkpath
(
newFileInfo
.
absolutePath
());
if
(
!
rootDir
.
mkpath
(
newFileInfo
.
absolutePath
()))
return
false
;
out
.
setFileName
(
newFileName
);
out
.
open
(
QIODevice
::
WriteOnly
);
if
(
!
out
.
open
(
QIODevice
::
WriteOnly
))
return
false
;
// Slow like hell (on GNU/Linux at least), but it is not my fault.
// Not ZIP/UNZIP package's fault either.
...
...
@@ -131,7 +113,7 @@ QString UBImportDocument::expandFileToDir(const QFile& pZipFile, const QString&
{
qWarning
()
<<
"Import failed. Cause: Unable to write file"
;
out
.
close
();
return
""
;
return
false
;
}
while
(
file
.
getChar
(
&
c
))
...
...
@@ -142,13 +124,13 @@ QString UBImportDocument::expandFileToDir(const QFile& pZipFile, const QString&
if
(
file
.
getZipError
()
!=
UNZ_OK
)
{
qWarning
()
<<
"Import failed. Cause: "
<<
zip
.
getZipError
();
return
""
;
return
false
;
}
if
(
!
file
.
atEnd
())
{
qWarning
()
<<
"Import failed. Cause: read all but not EOF"
;
return
""
;
return
false
;
}
file
.
close
();
...
...
@@ -156,7 +138,7 @@ QString UBImportDocument::expandFileToDir(const QFile& pZipFile, const QString&
if
(
file
.
getZipError
()
!=
UNZ_OK
)
{
qWarning
()
<<
"Import failed. Cause: file.close(): "
<<
file
.
getZipError
();
return
""
;
return
false
;
}
}
...
...
@@ -166,11 +148,10 @@ QString UBImportDocument::expandFileToDir(const QFile& pZipFile, const QString&
if
(
zip
.
getZipError
()
!=
UNZ_OK
)
{
qWarning
()
<<
"Import failed. Cause: zip.close(): "
<<
zip
.
getZipError
();
return
""
;
return
false
;
}
return
documentRootFolder
;
return
true
;
}
UBDocumentProxy
*
UBImportDocument
::
importFile
(
const
QFile
&
pFile
,
const
QString
&
pGroup
)
...
...
@@ -183,17 +164,17 @@ UBDocumentProxy* UBImportDocument::importFile(const QFile& pFile, const QString&
// first unzip the file to the correct place
QString
path
=
UBSettings
::
userDocumentDirectory
();
QString
documentRootFolder
=
expandFileToDir
(
pFile
,
path
)
;
QString
documentRootFolder
;
if
(
!
documentRootFolder
.
length
(
)){
if
(
!
extractFileToDir
(
pFile
,
path
,
documentRootFolder
)){
UBApplication
::
showMessage
(
tr
(
"Import of file %1 failed."
).
arg
(
fi
.
baseName
()));
return
0
;
return
NULL
;
}
else
{
UBDocumentProxy
*
newDocument
=
UBPersistenceManager
::
persistenceManager
()
->
createDocumentFromDir
(
documentRootFolder
,
pGroup
);
UBApplication
::
showMessage
(
tr
(
"Import successful."
));
return
newDocument
;
}
}
bool
UBImportDocument
::
addFileToDocument
(
UBDocumentProxy
*
pDocument
,
const
QFile
&
pFile
)
...
...
@@ -203,9 +184,18 @@ bool UBImportDocument::addFileToDocument(UBDocumentProxy* pDocument, const QFile
QString
path
=
UBFileSystemUtils
::
createTempDir
();
QString
documentRootFolder
=
expandFileToDir
(
pFile
,
path
);
QString
documentRootFolder
;
if
(
!
extractFileToDir
(
pFile
,
path
,
documentRootFolder
))
{
UBApplication
::
showMessage
(
tr
(
"Import of file %1 failed."
).
arg
(
fi
.
baseName
()));
return
false
;
}
UBPersistenceManager
::
persistenceManager
()
->
addDirectoryContentToDocument
(
documentRootFolder
,
pDocument
);
if
(
!
UBPersistenceManager
::
persistenceManager
()
->
addDirectoryContentToDocument
(
documentRootFolder
,
pDocument
))
{
UBApplication
::
showMessage
(
tr
(
"Import of file %1 failed."
).
arg
(
fi
.
baseName
()));
return
false
;
}
UBFileSystemUtils
::
deleteDir
(
path
);
...
...
src/adaptors/UBImportDocument.h
View file @
e181f054
...
...
@@ -37,7 +37,7 @@ class UBImportDocument : public UBDocumentBasedImportAdaptor
virtual
bool
addFileToDocument
(
UBDocumentProxy
*
pDocument
,
const
QFile
&
pFile
);
private
:
QString
expandFileToDir
(
const
QFile
&
pZipFile
,
const
QString
&
pDir
);
bool
extractFileToDir
(
const
QFile
&
pZipFile
,
const
QString
&
pDir
,
QString
&
documentRoot
);
};
#endif
/* UBIMPORTDOCUMENT_H_ */
src/board/UBBoardController.cpp
View file @
e181f054
...
...
@@ -94,6 +94,7 @@ UBBoardController::UBBoardController(UBMainWindow* mainWindow)
,
mSystemScaleFactor
(
1.0
)
,
mCleanupDone
(
false
)
,
mCacheWidgetIsEnabled
(
false
)
,
mDeletingSceneIndex
(
-
1
)
{
mZoomFactor
=
UBSettings
::
settings
()
->
boardZoomFactor
->
get
().
toDouble
();
...
...
@@ -679,6 +680,7 @@ void UBBoardController::deleteScene(int nIndex)
{
if
(
selectedDocument
()
->
pageCount
()
>=
2
)
{
mDeletingSceneIndex
=
nIndex
;
QApplication
::
setOverrideCursor
(
QCursor
(
Qt
::
WaitCursor
));
persistCurrentScene
();
showMessage
(
tr
(
"Delete page %1 from document"
).
arg
(
nIndex
),
true
);
...
...
@@ -688,12 +690,12 @@ void UBBoardController::deleteScene(int nIndex)
deletePages
(
scIndexes
);
selectedDocument
()
->
setMetaData
(
UBSettings
::
documentUpdatedAt
,
UBStringUtils
::
toUtcIsoDateTime
(
QDateTime
::
currentDateTime
()));
if
(
nIndex
>=
pageCount
())
nIndex
=
pageCount
()
-
1
;
setActiveDocumentScene
(
nIndex
);
showMessage
(
tr
(
"Page %1 deleted"
).
arg
(
nIndex
));
QApplication
::
restoreOverrideCursor
();
mDeletingSceneIndex
=
-
1
;
}
}
...
...
@@ -1790,7 +1792,7 @@ void UBBoardController::show()
void
UBBoardController
::
persistCurrentScene
()
{
if
(
UBPersistenceManager
::
persistenceManager
()
&&
selectedDocument
()
&&
mActiveScene
&&
selectedDocument
()
&&
mActiveScene
&&
mActiveSceneIndex
!=
mDeletingSceneIndex
&&
(
mActiveSceneIndex
>=
0
)
&&
(
mActiveScene
->
isModified
()
||
(
UBApplication
::
boardController
->
paletteManager
()
->
teacherGuideDockWidget
()
&&
UBApplication
::
boardController
->
paletteManager
()
->
teacherGuideDockWidget
()
->
teacherGuideWidget
()
->
isModified
())))
{
...
...
src/board/UBBoardController.h
View file @
e181f054
...
...
@@ -281,6 +281,7 @@ class UBBoardController : public UBDocumentContainer
QMap
<
QAction
*
,
QPair
<
QString
,
QString
>
>
mActionTexts
;
bool
mCacheWidgetIsEnabled
;
QGraphicsItem
*
mLastCreatedItem
;
int
mDeletingSceneIndex
;
private
slots
:
void
stylusToolDoubleClicked
(
int
tool
);
...
...
src/core/UBDocumentManager.cpp
View file @
e181f054
...
...
@@ -66,15 +66,15 @@ UBDocumentManager::UBDocumentManager(QObject *parent)
QString
dummyWidgets
=
tr
(
"widgets"
);
UBExportCFF
*
cffExporter
=
new
UBExportCFF
(
this
);
mExportAdaptors
.
append
(
cffExporter
);
UBExportFullPDF
*
exportFullPdf
=
new
UBExportFullPDF
(
this
);
mExportAdaptors
.
append
(
exportFullPdf
);
UBExportDocument
*
exportDocument
=
new
UBExportDocument
(
this
);
UBWebPublisher
*
webPublished
=
new
UBWebPublisher
(
this
);
mExportAdaptors
.
append
(
exportDocument
);
mExportAdaptors
.
append
(
webPublished
);
mExportAdaptors
.
append
(
exportFullPdf
);
mExportAdaptors
.
append
(
cffExporter
);
// UBExportWeb* exportWeb = new UBExportWeb(this);
// mExportAdaptors.append(exportWeb);
UBWebPublisher
*
webPublished
=
new
UBWebPublisher
(
this
);
mExportAdaptors
.
append
(
webPublished
);
UBImportDocument
*
documentImport
=
new
UBImportDocument
(
this
);
mImportAdaptors
.
append
(
documentImport
);
...
...
@@ -194,7 +194,7 @@ int UBDocumentManager::addFilesToDocument(UBDocumentProxy* document, QStringList
int
nImportedDocuments
=
0
;
foreach
(
const
QString
&
fileName
,
fileNames
)
{
UBApplication
::
showMessage
(
tr
(
"Importing file"
).
arg
(
fileName
));
UBApplication
::
showMessage
(
tr
(
"Importing file
%1
"
).
arg
(
fileName
));
QFile
file
(
fileName
);
QFileInfo
fileInfo
(
file
);
...
...
src/core/UBPersistenceManager.cpp
View file @
e181f054
...
...
@@ -667,11 +667,8 @@ void UBPersistenceManager::copyPage(UBDocumentProxy* pDocumentProxy, const int s
int
UBPersistenceManager
::
sceneCount
(
const
UBDocumentProxy
*
proxy
)
{
return
sceneCountInDir
(
proxy
->
persistencePath
());
}
const
QString
pPath
=
proxy
->
persistencePath
();
int
UBPersistenceManager
::
sceneCountInDir
(
const
QString
&
pPath
)
{
int
pageIndex
=
0
;
bool
moreToProcess
=
true
;
bool
addedMissingZeroPage
=
false
;
...
...
@@ -709,15 +706,23 @@ int UBPersistenceManager::sceneCountInDir(const QString& pPath)
return
pageIndex
;
}
QString
UBPersistenceManager
::
generateUniqueDocumentPath
()
QStringList
UBPersistenceManager
::
getSceneFileNames
(
const
QString
&
folder
)
{
QString
ubPath
=
UBSettings
::
userDocumentDirectory
();
QDir
dir
(
folder
,
"page???.svg"
,
QDir
::
Name
,
QDir
::
Files
);
return
dir
.
entryList
();
}
QString
UBPersistenceManager
::
generateUniqueDocumentPath
(
const
QString
&
baseFolder
)
{
QDateTime
now
=
QDateTime
::
currentDateTime
();
QString
dirName
=
now
.
toString
(
"yyyy-MM-dd hh-mm-ss.zzz"
);
return
ubPath
+
QString
(
"/Sankore Document %1"
).
arg
(
dirName
);
return
baseFolder
+
QString
(
"/Sankore Document %1"
).
arg
(
dirName
);
}
QString
UBPersistenceManager
::
generateUniqueDocumentPath
()
{
return
generateUniqueDocumentPath
(
UBSettings
::
userDocumentDirectory
());
}
...
...
@@ -730,22 +735,26 @@ void UBPersistenceManager::generatePathIfNeeded(UBDocumentProxy* pDocumentProxy)
}
void
UBPersistenceManager
::
addDirectoryContentToDocument
(
const
QString
&
documentRootFolder
,
UBDocumentProxy
*
pDocument
)
bool
UBPersistenceManager
::
addDirectoryContentToDocument
(
const
QString
&
documentRootFolder
,
UBDocumentProxy
*
pDocument
)
{
int
sourcePageCount
=
sceneCountInDir
(
documentRootFolder
);
QStringList
sourceScenes
=
getSceneFileNames
(
documentRootFolder
);
if
(
sourceScenes
.
empty
())
return
false
;
int
targetPageCount
=
pDocument
->
pageCount
();
for
(
int
sourceIndex
=
0
;
sourceIndex
<
source
PageCount
;
sourceIndex
++
)
for
(
int
sourceIndex
=
0
;
sourceIndex
<
source
Scenes
.
size
()
;
sourceIndex
++
)
{
int
targetIndex
=
targetPageCount
+
sourceIndex
;
QFile
svg
(
documentRootFolder
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.svg"
,
sourceIndex
));
svg
.
copy
(
pDocument
->
persistencePath
()
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.svg"
,
targetIndex
));
QFile
svg
(
documentRootFolder
+
"/"
+
sourceScenes
[
sourceIndex
]);
if
(
!
svg
.
copy
(
pDocument
->
persistencePath
()
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.svg"
,
targetIndex
)))
return
false
;
UBSvgSubsetAdaptor
::
setSceneUuid
(
pDocument
,
targetIndex
,
QUuid
::
createUuid
());
QFile
thumb
(
documentRootFolder
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.thumbnail.jpg"
,
sourceIndex
));
// We can ignore error in this case, thumbnail will be genarated
thumb
.
copy
(
pDocument
->
persistencePath
()
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.thumbnail.jpg"
,
targetIndex
));
}
...
...
@@ -753,11 +762,15 @@ void UBPersistenceManager::addDirectoryContentToDocument(const QString& document
{
qDebug
()
<<
"copying "
<<
documentRootFolder
<<
"/"
<<
dir
<<
" to "
<<
pDocument
->
persistencePath
()
<<
"/"
+
dir
;
UBFileSystemUtils
::
copyDir
(
documentRootFolder
+
"/"
+
dir
,
pDocument
->
persistencePath
()
+
"/"
+
dir
);
QDir
srcDir
(
documentRootFolder
+
"/"
+
dir
);
if
(
srcDir
.
exists
())
if
(
!
UBFileSystemUtils
::
copyDir
(
documentRootFolder
+
"/"
+
dir
,
pDocument
->
persistencePath
()
+
"/"
+
dir
))
return
false
;
}
pDocument
->
setPageCount
(
sceneCount
(
pDocument
));
return
false
;
}
...
...
src/core/UBPersistenceManager.h
View file @
e181f054
...
...
@@ -79,13 +79,14 @@ class UBPersistenceManager : public QObject
virtual
QStringList
allVideos
(
const
QDir
&
dir
);
virtual
QStringList
allWidgets
(
const
QDir
&
dir
);
virtual
QString
generateUniqueDocumentPath
();
QString
generateUniqueDocumentPath
();
QString
generateUniqueDocumentPath
(
const
QString
&
baseFolder
);
QString
teacherGuideAbsoluteObjectPath
(
UBDocumentProxy
*
pDocumentProxy
);
QString
addObjectToTeacherGuideDirectory
(
UBDocumentProxy
*
proxy
,
QString
pPath
);
QString
addWidgetToTeacherGuideDirectory
(
UBDocumentProxy
*
pDocumentProxy
,
QString
pPath
);
virtual
void
addDirectoryContentToDocument
(
const
QString
&
documentRootFolder
,
UBDocumentProxy
*
pDocument
);
bool
addDirectoryContentToDocument
(
const
QString
&
documentRootFolder
,
UBDocumentProxy
*
pDocument
);
virtual
void
upgradeDocumentIfNeeded
(
UBDocumentProxy
*
pDocumentProxy
);
...
...
@@ -128,7 +129,7 @@ class UBPersistenceManager : public QObject
int
sceneCount
(
const
UBDocumentProxy
*
pDocumentProxy
);
int
sceneCountInDir
(
const
QString
&
pPath
);
static
QStringList
getSceneFileNames
(
const
QString
&
folder
);
QList
<
QPointer
<
UBDocumentProxy
>
>
allDocumentProxies
();
...
...
src/domain/UBGraphicsScene.cpp
View file @
e181f054
...
...
@@ -1095,8 +1095,10 @@ void UBGraphicsScene::clearContent(clearCase pCase)
switch
(
pCase
)
{
case
clearBackground
:
if
(
mBackgroundObject
){
removeItem
(
mBackgroundObject
);
removedItems
<<
mBackgroundObject
;
}
break
;
case
clearItemsAndAnnotations
:
...
...
src/frameworks/UBFileSystemUtils.cpp
View file @
e181f054
...
...
@@ -273,7 +273,8 @@ bool UBFileSystemUtils::copyDir(const QString& pSourceDirPath, const QString& pT
QDir
dirSource
(
pSourceDirPath
);
QDir
dirTarget
(
pTargetDirPath
);
dirTarget
.
mkpath
(
pTargetDirPath
);
if
(
!
dirTarget
.
mkpath
(
pTargetDirPath
))
return
false
;
bool
successSoFar
=
true
;
...
...
src/gui/UBTeacherGuideWidget.cpp
View file @
e181f054
...
...
@@ -554,7 +554,7 @@ void UBTeacherGuidePresentationWidget::showData( QVector<tUBGEElementNode*> data
QTreeWidgetItem
*
newWidgetItem
=
new
QTreeWidgetItem
(
mpRootWidgetItem
);
newWidgetItem
->
setText
(
0
,
element
->
attributes
.
value
(
"task"
));
newWidgetItem
->
setFlags
(
Qt
::
ItemIsEnabled
|
Qt
::
ItemIsSelectable
);
QString
colorString
=
element
->
attributes
.
value
(
"owner"
).
toInt
()
==
0
?
"
red
"
:
"green"
;
QString
colorString
=
element
->
attributes
.
value
(
"owner"
).
toInt
()
==
0
?
"
blue
"
:
"green"
;
UBTGAdaptableText
*
textWidget
=
new
UBTGAdaptableText
(
newWidgetItem
,
0
);
textWidget
->
bottomMargin
(
14
);
textWidget
->
setStyleSheet
(
"QWidget {background: #EEEEEE; border:none; color:"
+
colorString
+
";}"
);
...
...
src/gui/UBTeacherGuideWidgetsTools.cpp
View file @
e181f054
...
...
@@ -86,7 +86,6 @@ UBTGActionWidget::UBTGActionWidget(QTreeWidgetItem* widget, QWidget* parent, con
mpTask
=
new
UBTGAdaptableText
(
widget
,
this
);
mpTask
->
setPlaceHolderText
(
tr
(
"Type task here ..."
));
mpTask
->
setAcceptRichText
(
true
);
mpTask
->
setTextColor
(
QColor
().
green
());
mpTask
->
setObjectName
(
"ActionWidgetTaskTextEdit"
);
mpLayout
->
addWidget
(
mpOwner
);
mpLayout
->
addWidget
(
mpTask
);
...
...
@@ -147,7 +146,6 @@ void UBTGAdaptableText::setPlaceHolderText(QString text)
// the space addition is to make this string unique and check against it to know
// if we are talking about a typed string or the placeholder string
mPlaceHolderText
=
text
+
" "
;
setTextColor
(
QColor
(
Qt
::
lightGray
));
setPlainText
(
mPlaceHolderText
);
}
...
...
@@ -230,9 +228,12 @@ void UBTGAdaptableText::bottomMargin(int newValue)
onTextChanged
();
}
void
UBTGAdaptableText
::
focusInEvent
(
QFocusEvent
*
e
){
void
UBTGAdaptableText
::
focusInEvent
(
QFocusEvent
*
e
)
{
qDebug
()
<<
"pippa"
;
if
(
isReadOnly
()){
e
->
ignore
();
qDebug
()
<<
"ignored"
;
}
managePlaceholder
(
true
);
QTextEdit
::
focusInEvent
(
e
);
...
...
@@ -246,11 +247,13 @@ void UBTGAdaptableText::focusOutEvent(QFocusEvent* e){
void
UBTGAdaptableText
::
managePlaceholder
(
bool
focus
){
if
(
focus
){
if
(
toPlainText
()
==
mPlaceHolderText
){
qDebug
()
<<
"Place holder found"
;
setTextColor
(
QColor
(
Qt
::
black
));
setPlainText
(
""
);
}
setCursorToTheEnd
();
}
else
{
}
else
{
if
(
toPlainText
().
isEmpty
()){
setTextColor
(
QColor
(
Qt
::
lightGray
));
setPlainText
(
mPlaceHolderText
);
...
...
@@ -323,6 +326,7 @@ UBTGMediaWidget::UBTGMediaWidget(QTreeWidgetItem* widget, QWidget* parent,const
,
mpDropMeWidget
(
NULL
)
,
mpWorkWidget
(
NULL
)
,
mpLayout
(
NULL
)
,
mpMediaLayout
(
NULL
)
,
mpTitle
(
NULL
)
,
mpMediaLabelWidget
(
NULL
)
,
mpMediaWidget
(
NULL
)
...
...
@@ -330,6 +334,7 @@ UBTGMediaWidget::UBTGMediaWidget(QTreeWidgetItem* widget, QWidget* parent,const
,
mMediaPath
(
QString
(
""
))
,
mIsPresentationMode
(
false
)
,
mIsInitializationMode
(
false
)
,
mMediaWidgetHeight
(
150
)
{
setObjectName
(
name
);
mpDropMeWidget
=
new
QLabel
();
...
...
@@ -347,6 +352,7 @@ UBTGMediaWidget::UBTGMediaWidget(QString mediaPath, QTreeWidgetItem* widget, QWi
,
mpDropMeWidget
(
NULL
)
,
mpWorkWidget
(
NULL
)
,
mpLayout
(
NULL
)
,
mpMediaLayout
(
NULL
)
,
mpTitle
(
NULL
)
,
mpMediaLabelWidget
(
NULL
)
,
mpMediaWidget
(
NULL
)
...
...
@@ -354,6 +360,7 @@ UBTGMediaWidget::UBTGMediaWidget(QString mediaPath, QTreeWidgetItem* widget, QWi
,
mIsPresentationMode
(
true
)
,
mMediaType
(
""
)
,
mIsInitializationMode
(
false
)
,
mMediaWidgetHeight
(
150
)
{
setObjectName
(
name
);
mMediaPath
=
UBApplication
::
boardController
->
selectedDocument
()
->
persistencePath
()
+
"/"
+
mediaPath
;
...
...
@@ -368,6 +375,7 @@ UBTGMediaWidget::~UBTGMediaWidget()
DELETEPTR
(
mpMediaLabelWidget
);
DELETEPTR
(
mpMediaWidget
);
DELETEPTR
(
mpWebView
);
DELETEPTR
(
mpMediaLayout
);
DELETEPTR
(
mpLayout
);
removeWidget
(
mpDropMeWidget
);
...
...
@@ -456,9 +464,8 @@ void UBTGMediaWidget::createWorkWidget(bool forceFlashMediaType)
mpMediaLabelWidget
=
new
QLabel
();
QPixmap
pixmap
=
QPixmap
(
mMediaPath
);
pixmap
=
pixmap
.
scaledTo
Width
(
mpTreeWidgetItem
->
treeWidget
()
->
size
().
width
()
);
pixmap
=
pixmap
.
scaledTo
Height
(
mMediaWidgetHeight
);
mpMediaLabelWidget
->
setPixmap
(
pixmap
);
mpMediaLabelWidget
->
setScaledContents
(
true
);
}
else
if
(
mimeType
.
contains
(
"widget"
)
&&
!
forceFlashMediaType
){
mMediaType
=
"w3c"
;
...
...
@@ -508,31 +515,43 @@ void UBTGMediaWidget::createWorkWidget(bool forceFlashMediaType)
if
(
setMedia
){
setAcceptDrops
(
false
);
mpWorkWidget
=
new
QWidget
(
this
);
mpLayout
=
new
QVBoxLayout
(
mpWorkWidget
);
if
(
!
mIsPresentationMode
){
mpLayout
=
new
QVBoxLayout
(
mpWorkWidget
);
mpTitle
=
new
UBTGAdaptableText
(
mpTreeWidgetItem
,
mpWorkWidget
);
mpTitle
->
setPlaceHolderText
(
tr
(
"Type title here..."
));
mpLayout
->
addWidget
(
mpTitle
);
mpMediaLayout
=
new
QHBoxLayout
;
mpLayout
->
addLayout
(
mpMediaLayout
);
mpWorkWidget
->
setLayout
(
mpLayout
);
}
else
{
mpMediaLayout
=
new
QHBoxLayout
(
mpWorkWidget
);
mpWorkWidget
->
setLayout
(
mpMediaLayout
);
}
mpMediaLayout
->
addStretch
(
1
);
if
(
mpMediaLabelWidget
){
mpMediaLabelWidget
->
set
MaximumHeight
(
width
()
);
mpMediaLabelWidget
->
set
FixedHeight
(
mMediaWidgetHeight
);
mpMediaLabelWidget
->
setParent
(
mpWorkWidget
);
mpLayout
->
addWidget
(
mpMediaLabelWidget
);
mp
Media
Layout
->
addWidget
(
mpMediaLabelWidget
);
}
else
if
(
mpMediaWidget
){
mpMediaWidget
->
set
MaximumHeight
(
width
()
);
mpMediaWidget
->
set
FixedHeight
(
mMediaWidgetHeight
);
mpMediaWidget
->
setParent
(
mpWorkWidget
);
mpLayout
->
addWidget
(
mpMediaWidget
);
mp
Media
Layout
->
addWidget
(
mpMediaWidget
);
}
else
if
(
mpWebView
){
mpWebView
->
set
MaximumHeight
(
width
()
);
mpWebView
->
set
FixedHeight
(
mMediaWidgetHeight
);
mpWebView
->
setParent
(
mpWorkWidget
);
mpLayout
->
addWidget
(
mpWebView
);
mp
Media
Layout
->
addWidget
(
mpWebView
);
mpWebView
->
show
();
}
mp
WorkWidget
->
setLayout
(
mpLayout
);
mp
MediaLayout
->
addStretch
(
1
);
addWidget
(
mpWorkWidget
);
setCurrentWidget
(
mpWorkWidget
);
mpWorkWidget
->
show
();
}
}
...
...
@@ -566,7 +585,6 @@ void UBTGMediaWidget::mousePressEvent(QMouseEvent *event)
if
(
!
mIsPresentationMode
)
event
->
ignore
();
else
{
QDrag
*
drag
=
new
QDrag
(
this
);
QMimeData
*
mimeData
=
new
QMimeData
();
QList
<
QUrl
>
urlList
;
...
...
src/gui/UBTeacherGuideWidgetsTools.h
View file @
e181f054
...
...
@@ -166,6 +166,7 @@ private:
QLabel
*
mpDropMeWidget
;
QWidget
*
mpWorkWidget
;
QVBoxLayout
*
mpLayout
;
QHBoxLayout
*
mpMediaLayout
;
UBTGAdaptableText
*
mpTitle
;
QLabel
*
mpMediaLabelWidget
;
UBMediaWidget
*
mpMediaWidget
;
...
...
@@ -174,6 +175,7 @@ private:
bool
mIsPresentationMode
;
QString
mMediaType
;
bool
mIsInitializationMode
;
int
mMediaWidgetHeight
;
};
...
...
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