Commit e5031714 authored by Ivan Ilin's avatar Ivan Ilin

Merge branch 'master' of github.com:Sankore/Sankore-3.1

parents 3fed7dc8 2ea30bf9
......@@ -13,7 +13,7 @@ linux-g++-64 {
VERSION_MAJ = 1
VERSION_MIN = 40
VERSION_TYPE = b # a = alpha, b = beta, r = release, other => error
VERSION_PATCH = 02
VERSION_PATCH = 03
VERSION = "$${VERSION_MAJ}.$${VERSION_MIN}.$${VERSION_TYPE}.$${VERSION_PATCH}"
VERSION = $$replace(VERSION, "\\.r", "")
......@@ -53,6 +53,8 @@ include(src/desktop/desktop.pri)
include(src/web/web.pri)
include(src/softwareupdate/softwareupdate.pri)
include(src/transition/transition.pri)
include(src/customWidgets/customWidgets.pri)
include(src/interfaces/interfaces.pri)
DEPENDPATH += src/pdf-merger
INCLUDEPATH += src/pdf-merger
......@@ -398,3 +400,4 @@ INSTALLS = UB_ETC \
UB_THIRDPARTY_INTERACTIVE
OTHER_FILES +=
......@@ -49,8 +49,8 @@ else
LAST_COMMITED_VERSION="`git describe $(git rev-list --tags --max-count=1)`"
if [ "v$VERSION" != "$LAST_COMMITED_VERSION" ]; then
echo creating a tag with the version $VERSION
# git tag -a "v$VERSION" -m "Generating setup for v$VERSION"
# git push origin --tags
git tag -a "v$VERSION" -m "Generating setup for v$VERSION"
git push origin --tags
fi
fi
......@@ -192,6 +192,9 @@ CONTROL_FILE="$BASE_WORKING_DIR/DEBIAN/control"
CHANGE_LOG_TEXT="changelog.txt"
ARCHITECTURE=`uname -i`
if [ "$ARCHITECTURE" == "x86_64" ]; then
ARCHITECTURE="amd64"
fi
echo "Open-Sankore ($VERSION) $ARCHITECTURE; urgency=low" > "$CHANGE_LOG_FILE"
echo >> "$CHANGE_LOG_FILE"
......@@ -206,8 +209,8 @@ echo "Priority: optional" >> "$CONTROL_FILE"
echo "Architecture: $ARCHITECTURE" >> "$CONTROL_FILE"
echo "Essential: no" >> "$CONTROL_FILE"
echo "Installed-Size: `du -s $SANKORE_PACKAGE_DIRECTORY | awk '{ print $1 }'`" >> "$CONTROL_FILE"
echo "Maintainer: Claudio VALERIO <claudio@open-sankore.org>" >> "$CONTROL_FILE"
echo "Homepage: http://www.open-sankore.org" >> "$CONTROL_FILE"
echo "Maintainer: Open-Sankoré Developers team <dev@open-sankore.org>" >> "$CONTROL_FILE"
echo "Homepage: http://dev.open-sankore.org" >> "$CONTROL_FILE"
echo -n "Depends: " >> "$CONTROL_FILE"
unset tab
declare -a tab
......@@ -223,6 +226,10 @@ for l in `objdump -p $SANKORE_PACKAGE_DIRECTORY/Open-Sankore | grep NEEDED | awk
done;
done;
#additional dependencies
tab[$count]="gtk2-engines-pixbuf"
((count++))
for ((i=0;i<${#tab[@]};i++)); do
if [ $i -ne "0" ]; then
echo -n ", " >> "$CONTROL_FILE"
......@@ -254,10 +261,10 @@ chmod 755 "$BASE_WORKING_DIR/DEBIAN/postint"
mkdir -p "install/linux"
sudo chown -R root:root $BASE_WORKING_DIR
fakeroot chown -R root:root $BASE_WORKING_DIR
dpkg -b "$BASE_WORKING_DIR" install/linux/Open-Sankore_${VERSION}_$ARCHITECTURE.deb
notify-send "Open-Sankore" "Package built"
#clean up mess
#sudo rm -rf $BASE_WORKING_DIR
#fakeroot rm -rf $BASE_WORKING_DIR
File mode changed from 100644 to 100755
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:ub="http://uniboard.mnemis.com/widgets"
id="http://uniboard.mnemis.com/widgets/notes"
version="1.2"
width="700"
height="400"
ub:resizable="true">
<name>Notes</name>
<author href="http://www.getuniboard.com"
email="info@mnemis.com">Mnemis SA</author>
<description>Ordonner des images</description>
<content src="index.html"/>
</widget>
html, body{
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.toggle_mode{
width: 100%;
height: 25px;
border-bottom: 1px solid black;
background-color: #ccc;
position: fixed;
top: 0;
left: 0;
z-index: 2;
}
#display_img, #edit_img{
width: 15px;
height: 15px;
margin: 5px 10px;
}
.green_point{
background-image: url(../img/green_point.png);
}
.red_point{
background-image: url(../img/red_point.png);
}
#display_text, #edit_text{
height: 19px;
padding: 3px 0 0 0;
}
.selected{
background-color: #666;
}
#display:hover, #edit:hover{
background-color: #999;
}
.cont{
width: 100%;
border-bottom: 1px solid black;
margin: 0;
padding: 0;
position: relative;
}
.sub_cont{
width: 100%;
padding: 0;
margin: 20px 0 0 0;
min-height: 60px;
}
.imgs_cont{
width: 100%;
margin: 0;
}
.number_cont{
width: 40px;
height: 33px;
margin-left: 40px;
margin-right: 10px;
background-image: url(../img/circle.png);
background-repeat: no-repeat;
text-align: center;
float: left;
font-size: 130%;
padding-top: 7px;
font-weight: bold;
}
.text_cont{
width: 80%;
min-height: 40px;
float: right;
background-color: #ccc;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
padding-left: 10px;
}
.close_cont{
width: 20px;
height: 20px;
background-image: url(../img/close_cont.png);
cursor: pointer;
position: absolute;
top: -15px;
left: 5px;
}
.add_img{
width: 120px;
height: 120px;
margin: 10px 20px;
background-image: url(../img/add_img.png);
background-position: center;
background-repeat: no-repeat;
cursor: pointer;
display: inline-block;
}
.img_block{
width: 120px;
height: 120px;
margin: 10px 20px;
cursor: pointer;
display: inline-block;
position: relative;
border: 1px solid #ccc;
-moz-box-shadow: #ccc -1px 0 4px;
-webkit-box-shadow: #ccc -1px 0 4px;
box-shadow: #ccc -1px 0 4px;
background-color: white;
}
.close_img{
width: 30px;
height: 30px;
background-image: url(../img/close_img.png);
background-repeat: no-repeat;
position: absolute;
top: -15px;
right: -15px;
cursor: pointer;
}
.clear_img{
width: 30px;
height: 30px;
background-image: url(../img/clear_img.png);
background-repeat: no-repeat;
position: absolute;
top: 15px;
right: -15px;
cursor: pointer;
}
.fill_img{
width: 30px;
height: 30px;
background-image: url(../img/fill_hor.png);
background-repeat: no-repeat;
position: absolute;
top: -15px;
right: 17px;
cursor: pointer;
}
.add_block{
margin: 20px 0 0 20px;
width: 110px;
height: 25px;
background-image: url(../img/add_block.png);
background-repeat: no-repeat;
padding-left: 40px;
padding-top: 5px;
cursor: pointer;
background-color: #ccc;
-webkit-border-radius: 15px;
border-radius: 15px;
}
.black_overlay{
display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
z-index:1001;
-moz-opacity: 0.8;
opacity:.80;
filter: alpha(opacity=80);
}
.white_content {
display: none;
position:fixed;
top: 50%;
left: 50%;
width: 340px;
height: 480px;
padding: 16px;
background-color: white;
z-index:1002;
overflow: auto;
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>D'n'd</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="css/basic.css"/>
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.9.custom.min.js"></script>
<script type="text/javascript" src="js/languages.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var lang = ""; //locale language
if(window.sankore){
lang = sankore.locale().substr(0,2);
} else
lang = "en";
$("<script type='text/javascript' src='js/translation/" + lang + ".js'>").appendTo("head");
if((typeof sankoreLang) == "undefined")
$("<script type='text/javascript' src='js/translation/en.js'>").appendTo("head");
start();
//here you can put your code
if(window.sankore)
sankore.enableDropOnWidget();
});
</script>
</head>
<body>
<!--<div class="dnd_container">
<div class="dnd_1" id="dnd_1" ondragenter="return false;" ondragleave="$(this).css('border-color','#ccc'); return false;" ondragover="$(this).css('border-color','orange'); return false;" ondrop="$(this).css('border-color','#ccc'); return onDropTarget1(event);">Drop the item here ...</div>
<div class="dnd_2" id="dnd_2" ondragenter="return false;" ondragleave="$(this).css('border-color','#ccc'); return false;" ondragover="$(this).css('border-color','orange'); return false;" ondrop="$(this).css('border-color','#ccc'); return onDropTarget2(event);">Drop the item here ...</div>
</div>
<div class='black_overlay' id='fade'></div>
<a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">открыть</a></p>
<div id="light" class="white_content">
Содержание<a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">закрыть</a></div>-->
<div class="toggle_mode">
<div style="width: 50%; height: 100%; float: left;">
<div id="display" style="float: right; width: 90px; cursor: pointer;" class="selected">
<div id="display_img" style="float: right;" class="green_point"></div>
<div id="display_text" style="float: right;">Display</div>
</div>
</div>
<div style="width: 50%; height: 100%; float: right;">
<div id="edit" style="float: left; width: 90px; cursor: pointer;">
<div id="edit_img" style="float: left;" class="red_point"></div>
<div id="edit_text" style="float: left;">Edit</div>
</div>
</div>
</div>
<div style="width: 100%; height: 25px;"></div>
</body>
</html>
This source diff could not be displayed because it is too large. You can view the blob instead.
var sankoreLang = {
short_desc: "Place the pictures in ascending order.",
display:"Display",
edit:"Edit",
add:"Add new block"
};
var sankoreLang = {
short_desc: "Placez les photos dans l'ordre croissant.",
display:"D'affichage",
edit:"Modifier",
add:"Ajouter nouveau bloc"
};
var sankoreLang = {
short_desc: "Расположите картинки в порядке возрастания цифр.",
display:"Показать",
edit:"Изменить",
add:"Добавить новый блок"
};
......@@ -338,5 +338,14 @@
<file>images/download_close.png</file>
<file>images/download_open.png</file>
<file>images/tab_mask.png</file>
<file>images/duration1.png</file>
<file>images/duration2.png</file>
<file>images/duration3.png</file>
<file>images/licenses/ccby.png</file>
<file>images/licenses/ccbync.png</file>
<file>images/licenses/ccbyncnd.png</file>
<file>images/licenses/ccbyncsa.png</file>
<file>images/licenses/ccbynd.png</file>
<file>images/licenses/ccbysa.png</file>
</qresource>
</RCC>
QWidget#DockPaletteWidgetBox,
QWidget#documentNavigator,
QWidget#UBLibPathViewer,
QWidget#UBTeacherStudentAction,
QWidget#UBLibNavigatorWidget,
QWidget#UBLibItemProperties,
QWidget#UBDownloadWidget
QWidget#UBDownloadWidget,
QWidget#UBWidgetList,
QWidget#UBTeacherBarDropMediaZone,
QWidget#UBTBMediaContainer
{
background: #EEEEEE;
border-radius: 10px;
border: 2px solid #999999;
}
QFrame#UBTBSeparator
{
background: #DDDDDD;
border-radius: 2px;
border: 1px solid #DDDDDD;
}
QWidget#UBMediaVideoContainer
{
background: #000000;
border-radius: 10px;
border: 2px solid #999999;
}
QWidget#UBTeacherBarPreviewWidget
{
background: #FFFFFF;
border-radius: 10px;
border: 2px solid #999999;
}
QLabel#UBTBPreviewSessionTitle
{
font-size: 12px;
}
QLabel#UBTeacherBarPreviewTitle
{
color: #555555;
font-size : 20px;
font-weight:bold;
padding-left:5px;
}
QLabel#UBMediaPlayerButton
{
padding: 0px 0px 0px 0px;
}
QLabel#UBTeacherBarPreviewSubtitle
{
color: #555555;
font-size : 15px;
font-weight:bold;
padding-left:5px;
}
QWidget#UBLibWebView
{
background: #EEEEEE;
......@@ -18,6 +67,30 @@ QWidget#UBLibWebView
border: 2px solid #999999;
}
QWidget#UBActionPreviewOwner
{
color: #555555;
font-size : 12px;
font-weight: bold;
}
QWidget#UBTeacherBarPreviewComments,
QWidget#UBTeacherBarTargetBox
{
border-radius: 10px;
border: white 2px solid;
padding: 5px 5px 5px 5px;
background-color: white;
}
QWidget#UBActionPreviewContent,
QTextEdit#UBCommentPreview
{
border-radius : 10px;
border: 2px solid #999999;
padding: 5px 5px 5px 5px;
}
QWebView#SearchEngineView
{
background:white;
......
......@@ -280,6 +280,15 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolygon(const QDomElement &e
point.setY(sCoord.at(1).toFloat());
polygon << point;
}
else if (sCoord.size() == 4){
//This is the case on system were the "," is used to seperate decimal
QPointF point;
QString x = sCoord.at(0) + "." + sCoord.at(1);
QString y = sCoord.at(2) + "." + sCoord.at(3);
point.setX(x.toFloat());
point.setY(y.toFloat());
polygon << point;
}
else {
qWarning() << "cannot make sense of a 'point' value" << sCoord;
}
......@@ -354,6 +363,15 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolyline(const QDomElement &
point.setY(sCoord.at(1).toFloat());
polygon << point;
}
else if (sCoord.size() == 4){
//This is the case on system were the "," is used to seperate decimal
QPointF point;
QString x = sCoord.at(0) + "." + sCoord.at(1);
QString y = sCoord.at(2) + "." + sCoord.at(3);
point.setX(x.toFloat());
point.setY(y.toFloat());
polygon << point;
}
else {
qWarning() << "cannot make sense of a 'point' value" << sCoord;
}
......
......@@ -46,7 +46,10 @@ using namespace merge_lib;
UBExportFullPDF::UBExportFullPDF(QObject *parent)
: UBExportAdaptor(parent)
{
// NOOP
//need to calculate screen resolution
QDesktopWidget* desktop = UBApplication::desktop();
int dpiCommon = (desktop->physicalDpiX() + desktop->physicalDpiY()) / 2;
mScaleFactor = 72.0f / dpiCommon;
}
......@@ -56,7 +59,7 @@ UBExportFullPDF::~UBExportFullPDF()
}
void UBExportFullPDF::saveOverlayPdf(UBDocumentProxy* pDocumentProxy, QString filename)
void UBExportFullPDF::saveOverlayPdf(UBDocumentProxy* pDocumentProxy, const QString& filename)
{
if (!pDocumentProxy || filename.length() == 0 || pDocumentProxy->pageCount() == 0)
return;
......@@ -70,9 +73,6 @@ void UBExportFullPDF::saveOverlayPdf(UBDocumentProxy* pDocumentProxy, QString fi
pdfPrinter.setOutputFileName(filename);
pdfPrinter.setFullPage(true);
const qreal margin = UBSettings::settings()->pdfMargin->get().toDouble() * pdfPrinter.resolution() / 25.4;
mMargin = margin;
QPainter* pdfPainter = 0;
for(int pageIndex = 0 ; pageIndex < pDocumentProxy->pageCount(); pageIndex++)
......@@ -87,54 +87,20 @@ void UBExportFullPDF::saveOverlayPdf(UBDocumentProxy* pDocumentProxy, QString fi
scene->setRenderingQuality(UBItem::RenderingQualityHigh);
scene->setRenderingContext(UBGraphicsScene::PdfExport);
UBGraphicsPDFItem *pdfItem = qgraphicsitem_cast<UBGraphicsPDFItem*>(scene->backgroundObject());
if (pdfItem)
{
QSizeF sceneItemsBound = scene->itemsBoundingRect().size();
qreal ratio = (qreal)pdfPrinter.resolution() / 72.0;
QSizeF scaled = sceneItemsBound * ratio;
pdfPrinter.setPaperSize(scaled, QPrinter::DevicePixel);
if (pageIndex != 0)
pdfPrinter.newPage();
if (!pdfPainter)
pdfPainter = new QPainter(&pdfPrinter);
//render to PDF
scene->render(pdfPainter, QRectF(0, 0, sceneItemsBound.width() * ratio
, sceneItemsBound.height() * ratio), scene->itemsBoundingRect());
mHasPDFBackgrounds = true;
}
else
{
if (UBSettings::settings()->pdfPageFormat->get().toString() == "Letter")
pdfPrinter.setPageSize(QPrinter::Letter);
else
pdfPrinter.setPageSize(QPrinter::A4);
QSize pageSize = scene->nominalSize();
QSize docSize = pDocumentProxy->defaultDocumentSize();
if(docSize.width() > docSize.height())
{
pdfPrinter.setOrientation(QPrinter::Landscape);
}
UBGraphicsPDFItem *pdfItem = qgraphicsitem_cast<UBGraphicsPDFItem*>(scene->backgroundObject());
if (pageIndex != 0)
pdfPrinter.newPage();
if (pdfItem) mHasPDFBackgrounds = true;
pdfPrinter.setPaperSize(QSizeF(pageSize.width()*mScaleFactor, pageSize.height()*mScaleFactor), QPrinter::Point);
mDefaultPageRect = pdfPrinter.paperRect();
QRectF paperRect = mDefaultPageRect.adjusted(margin, margin, -margin, -margin);
QRectF normalized = scene->normalizedSceneRect(paperRect.width() / paperRect.height());
if (!pdfPainter) pdfPainter = new QPainter(&pdfPrinter);
if (!pdfPainter)
pdfPainter = new QPainter(&pdfPrinter);
if (pageIndex != 0) pdfPrinter.newPage();
//render to PDF
scene->render(pdfPainter, paperRect, normalized);
}
//render to PDF
scene->render(pdfPainter);
//restore screen rendering quality
scene->setRenderingContext(UBGraphicsScene::Screen);
......@@ -144,8 +110,7 @@ void UBExportFullPDF::saveOverlayPdf(UBDocumentProxy* pDocumentProxy, QString fi
scene->setBackground(isDark, isCrossed);
}
if (pdfPainter)
delete pdfPainter;
if (pdfPainter) delete pdfPainter;
}
......@@ -171,12 +136,10 @@ void UBExportFullPDF::persist(UBDocumentProxy* pDocumentProxy)
}
void UBExportFullPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, QString filename)
void UBExportFullPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, const QString& filename)
{
QFile file(filename);
if (file.exists())
file.remove();
if (file.exists()) file.remove();
QString overlayName = filename;
overlayName.replace(".pdf", "_overlay.pdf");
......@@ -209,31 +172,27 @@ void UBExportFullPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, QString
UBGraphicsScene* scene = UBPersistenceManager::persistenceManager()->loadDocumentScene(pDocumentProxy, pageIndex);
UBGraphicsPDFItem *pdfItem = qgraphicsitem_cast<UBGraphicsPDFItem*>(scene->backgroundObject());
if (pdfItem)
QSize pageSize = scene->nominalSize();
if (pdfItem)
{
QString pdfName = UBPersistenceManager::objectDirectory + "/" + pdfItem->fileUuid().toString() + ".pdf";
QString backgroundPath = pDocumentProxy->persistencePath() + "/" + pdfName;
QPointF boudingRectBottomLeft = scene->itemsBoundingRect().bottomLeft();
QPointF pdfItemBottomLeft = pdfItem->sceneBoundingRect().bottomLeft();
QPointF offset = pdfItemBottomLeft - boudingRectBottomLeft;
qDebug() << "scene->itemsBoundingRect()" << scene->itemsBoundingRect();
qDebug() << "pdfItem->boundingRect()" << pdfItem->boundingRect();
qDebug() << "pdfItem->sceneBoundingRect()" << pdfItem->sceneBoundingRect();
qDebug() << offset;
TransformationDescription baseTrans(offset.x(), offset.y() * -1, 1, 0);
//TransformationDescription baseTrans(0, 0, 1, 0);
TransformationDescription overlayTrans(0, 0, 1, 0);
MergePageDescription pageDescription(scene->itemsBoundingRect().width(),
scene->itemsBoundingRect().height(),
MergePageDescription pageDescription(pageSize.width() * mScaleFactor,
pageSize.height() * mScaleFactor,
pdfItem->pageNumber(),
QFile::encodeName(backgroundPath).constData(),
baseTrans,
TransformationDescription(),
pageIndex + 1,
overlayTrans,
TransformationDescription(),
false, false);
mergeInfo.push_back(pageDescription);
......@@ -242,12 +201,8 @@ void UBExportFullPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, QString
}
else
{
QRectF paperRect = mDefaultPageRect.adjusted(mMargin, mMargin, -mMargin, -mMargin);
QRectF normalized = scene->normalizedSceneRect(paperRect.width() / paperRect.height());
MergePageDescription pageDescription(normalized.width(),
normalized.height(),
MergePageDescription pageDescription(pageSize.width() * mScaleFactor,
pageSize.height() * mScaleFactor,
0,
"",
TransformationDescription(),
......
......@@ -33,14 +33,13 @@ class UBExportFullPDF : public UBExportAdaptor
virtual QString exportExtention();
virtual void persist(UBDocumentProxy* pDocument);
virtual void persistsDocument(UBDocumentProxy* pDocument, QString filename);
virtual void persistsDocument(UBDocumentProxy* pDocument, const QString& filename);
protected:
void saveOverlayPdf(UBDocumentProxy* pDocumentProxy, QString filename);
void saveOverlayPdf(UBDocumentProxy* pDocumentProxy, const QString& filename);
private:
QRect mDefaultPageRect;
int mMargin;
float mScaleFactor;
bool mHasPDFBackgrounds;
};
......
......@@ -63,9 +63,8 @@ void UBExportPDF::persist(UBDocumentProxy* pDocumentProxy)
}
void UBExportPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, QString filename)
void UBExportPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, const QString& filename)
{
//PDF
QPrinter pdfPrinter;
qDebug() << "exporting document to PDF" << filename;
......@@ -73,19 +72,15 @@ void UBExportPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, QString file
pdfPrinter.setOutputFormat(QPrinter::PdfFormat);
pdfPrinter.setResolution(UBSettings::settings()->pdfResolution->get().toInt());
pdfPrinter.setOutputFileName(filename);
pdfPrinter.setFullPage(true);
if (UBSettings::settings()->pdfPageFormat->get().toString() == "Letter")
pdfPrinter.setPageSize(QPrinter::Letter);
else
pdfPrinter.setPageSize(QPrinter::A4);
// pdfMargin is in mm, but margin should be in px
qreal margin = UBSettings::settings()->pdfMargin->get().toDouble() * pdfPrinter.resolution() / 25.4;
pdfPrinter.setOrientation(QPrinter::Landscape);
pdfPrinter.setFullPage(true);
QPainter pdfPainter(&pdfPrinter);
//need to calculate screen resolution
QDesktopWidget* desktop = UBApplication::desktop();
int dpiCommon = (desktop->physicalDpiX() + desktop->physicalDpiY()) / 2;
float scaleFactor = 72.0f / dpiCommon;
QPainter pdfPainter;
bool painterNeedsBegin = true;
int existingPageCount = pDocumentProxy->pageCount();
......@@ -98,20 +93,19 @@ void UBExportPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, QString file
bool isCrossed = scene->isCrossedBackground();
scene->setBackground(false, false);
QRectF paperRect = pdfPrinter.paperRect();
paperRect = paperRect.adjusted(margin, margin, -margin, -margin);
QRectF normalized = scene->normalizedSceneRect(paperRect.width() / paperRect.height());
QSize pageSize = scene->nominalSize();
// set high res rendering
scene->setRenderingQuality(UBItem::RenderingQualityHigh);
scene->setRenderingContext(UBGraphicsScene::NonScreen);
//setting page size to appropriate value
pdfPrinter.setPaperSize(QSizeF(pageSize.width()*scaleFactor, pageSize.height()*scaleFactor), QPrinter::Point);
if(painterNeedsBegin) painterNeedsBegin = !pdfPainter.begin(&pdfPrinter);
//render to PDF
scene->render(&pdfPainter, paperRect, normalized);
scene->render(&pdfPainter);
if (pageIndex < existingPageCount - 1)
pdfPrinter.newPage();
if (pageIndex < existingPageCount - 1) pdfPrinter.newPage();
//restore screen rendering quality
scene->setRenderingContext(UBGraphicsScene::Screen);
......@@ -120,6 +114,7 @@ void UBExportPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, QString file
//restore background state
scene->setBackground(isDark, isCrossed);
}
if(!painterNeedsBegin) pdfPainter.end();
}
QString UBExportPDF::exportExtention()
......
......@@ -33,7 +33,7 @@ class UBExportPDF : public UBExportAdaptor
virtual QString exportExtention();
virtual void persist(UBDocumentProxy* pDocument);
static void persistsDocument(UBDocumentProxy* pDocument, QString filename);
static void persistsDocument(UBDocumentProxy* pDocument, const QString& filename);
};
#endif /* UBEXPORTPDF_H_ */
......@@ -14,7 +14,6 @@
*/
#include "UBImportDocument.h"
#include "UBMetadataDcSubsetAdaptor.h"
#include "document/UBDocumentProxy.h"
#include "frameworks/UBFileSystemUtils.h"
......@@ -49,7 +48,7 @@ QStringList UBImportDocument::supportedExtentions()
QString UBImportDocument::importFileFilter()
{
return tr("Sankore 3.1 (*.ubz)");
return tr("Open-Sankore (*.ubz)");
}
......
......@@ -14,7 +14,6 @@
*/
#include "UBImportImage.h"
#include "UBMetadataDcSubsetAdaptor.h"
#include "UBSvgSubsetAdaptor.h"
#include "document/UBDocumentProxy.h"
......
......@@ -14,7 +14,6 @@
*/
#include "UBImportPDF.h"
#include "UBMetadataDcSubsetAdaptor.h"
#include "UBSvgSubsetAdaptor.h"
#include "document/UBDocumentProxy.h"
......
......@@ -68,12 +68,17 @@ UBMetadataDcSubsetAdaptor::~UBMetadataDcSubsetAdaptor()
void UBMetadataDcSubsetAdaptor::persist(UBDocumentProxy* proxy)
{
if(!QDir(proxy->persistencePath()).exists()){
//In this case the a document is an empty document so we do not persist it
return;
}
QString fileName = proxy->persistencePath() + "/" + metadataFilename;
qWarning() << fileName;
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
{
qCritical() << "cannot open " << fileName << " for writing ...";
qCritical() << "error : " << file.errorString();
return;
}
......@@ -97,7 +102,7 @@ void UBMetadataDcSubsetAdaptor::persist(UBDocumentProxy* proxy)
// introduced in UB 4.2
xmlWriter.writeTextElement(nsDc, "identifier", proxy->metaData(UBSettings::documentIdentifer).toString());
xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "version", UBSettings::currentFileVersion);
xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "version", UBSettings::currentFileVersion);
QString width = QString::number(proxy->defaultDocumentSize().width());
QString height = QString::number(proxy->defaultDocumentSize().height());
xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "size", QString("%1x%2").arg(width).arg(height));
......@@ -105,6 +110,15 @@ void UBMetadataDcSubsetAdaptor::persist(UBDocumentProxy* proxy)
// introduced in UB 4.4
xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "updated-at", proxy->metaData(UBSettings::documentUpdatedAt).toString());
// introduced in OpenSankore 1.40.00
xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionTitle,proxy->metaData(UBSettings::sessionTitle).toString());
xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionTarget,proxy->metaData(UBSettings::sessionTarget).toString());
xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionLicence,proxy->metaData(UBSettings::sessionLicence).toString());
xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionKeywords,proxy->metaData(UBSettings::sessionKeywords).toString());
xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionLevel,proxy->metaData(UBSettings::sessionLevel).toString());
xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionTopic,proxy->metaData(UBSettings::sessionTopic).toString());
xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri,UBSettings::sessionAuthors,proxy->metaData(UBSettings::sessionAuthors).toString());
xmlWriter.writeEndElement(); //dc:Description
xmlWriter.writeEndElement(); //RDF
......@@ -204,7 +218,41 @@ QMap<QString, QVariant> UBMetadataDcSubsetAdaptor::load(QString pPath)
metadata.insert(UBSettings::documentUpdatedAt, xml.readElementText());
updatedAtFound = true;
}
else if (xml.name() == UBSettings::sessionTitle // introduced in OpenSankore 1.40.00
&& xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri)
{
metadata.insert(UBSettings::sessionTitle, xml.readElementText());
}
else if (xml.name() == UBSettings::sessionTarget // introduced in OpenSankore 1.40.00
&& xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri)
{
metadata.insert(UBSettings::sessionTarget, xml.readElementText());
}
else if (xml.name() == UBSettings::sessionLicence // introduced in OpenSankore 1.40.00
&& xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri)
{
metadata.insert(UBSettings::sessionLicence, xml.readElementText());
}
else if (xml.name() == UBSettings::sessionKeywords // introduced in OpenSankore 1.40.00
&& xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri)
{
metadata.insert(UBSettings::sessionKeywords, xml.readElementText());
}
else if (xml.name() == UBSettings::sessionLevel // introduced in OpenSankore 1.40.00
&& xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri)
{
metadata.insert(UBSettings::sessionLevel, xml.readElementText());
}
else if (xml.name() == UBSettings::sessionTopic // introduced in OpenSankore 1.40.00
&& xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri)
{
metadata.insert(UBSettings::sessionTopic, xml.readElementText());
}
else if (xml.name() == UBSettings::sessionAuthors // introduced in OpenSankore 1.40.00
&& xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri)
{
metadata.insert(UBSettings::sessionAuthors, xml.readElementText());
}
metadata.insert(UBSettings::documentVersion, docVersion);
}
......
......@@ -1301,6 +1301,15 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromPol
point.setY(sCoord.at(1).toFloat());
polygon << point;
}
else if (sCoord.size() == 4){
//This is the case on system were the "," is used to seperate decimal
QPointF point;
QString x = sCoord.at(0) + "." + sCoord.at(1);
QString y = sCoord.at(2) + "." + sCoord.at(3);
point.setX(x.toFloat());
point.setY(y.toFloat());
polygon << point;
}
else
{
qWarning() << "cannot make sense of a 'point' value" << sCoord;
......@@ -1583,6 +1592,15 @@ QList<UBGraphicsPolygonItem*> UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItem
point.setY(sCoord.at(1).toFloat());
points << point;
}
else if (sCoord.size() == 4){
//This is the case on system were the "," is used to seperate decimal
QPointF point;
QString x = sCoord.at(0) + "." + sCoord.at(1);
QString y = sCoord.at(2) + "." + sCoord.at(3);
point.setX(x.toFloat());
point.setY(y.toFloat());
points << point;
}
else
{
qWarning() << "cannot make sense of a 'point' value" << sCoord;
......@@ -1836,7 +1854,7 @@ UBGraphicsAudioItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::audioItemFromSvg()
href = mDocumentPath + "/" + href.right(href.length() - indexOfAudioDirectory);
}
UBGraphicsAudioItem* audioItem = new UBGraphicsAudioItem(href);
UBGraphicsAudioItem* audioItem = new UBGraphicsAudioItem(QUrl::fromLocalFile(href));
graphicsItemFromSvg(audioItem);
QStringRef ubPos = mXmlReader.attributes().value(mNamespaceUri, "position");
......
......@@ -112,11 +112,6 @@ UBBoardPaletteManager::~UBBoardPaletteManager()
delete mpLibWidget;
mpLibWidget = NULL;
}
if(NULL != mpTeacherBarWidget)
{
delete mpTeacherBarWidget;
mpTeacherBarWidget = NULL;
}
if(NULL != mpCachePropWidget)
{
delete mpCachePropWidget;
......@@ -193,6 +188,10 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
mLeftPalette->registerWidget(mpPageNavigWidget);
mLeftPalette->addTab(mpPageNavigWidget);
// The teacher bar widget will always be there
mLeftPalette->registerWidget(mpTeacherBarWidget);
mLeftPalette->addTab(mpTeacherBarWidget);
mLeftPalette->connectSignals();
mRightPalette = new UBRightPalette(mContainer);
......@@ -201,9 +200,7 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
mRightPalette->addTab(mpLibWidget);
// The cache widget will be visible only if a cache is put on the page
mRightPalette->registerWidget(mpCachePropWidget);
// The teacher bar widget will always be there
mRightPalette->registerWidget(mpTeacherBarWidget);
mRightPalette->addTab(mpTeacherBarWidget);
// The download widget will be part of the right palette but
// will become visible only when the first download starts
mRightPalette->registerWidget(mpDownloadWidget);
......@@ -211,8 +208,8 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
changeMode(eUBDockPaletteWidget_BOARD, true);
// Hide the tabs that must be hidden
mRightPalette->removeTab(mpDownloadWidget->name());
mRightPalette->removeTab(mpCachePropWidget->name());
mRightPalette->removeTab(mpDownloadWidget);
mRightPalette->removeTab(mpCachePropWidget);
// mLeftPalette->showTabWidget(0);
// mRightPalette->showTabWidget(0);
......@@ -788,9 +785,6 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
}
else
mKeyboardPalette->setParent(0);
// mKeyboardPalette->update();
}
}
break;
......@@ -828,7 +822,7 @@ void UBBoardPaletteManager::addItem(const QPixmap& pPixmap, const QPointF& pos,
void UBBoardPaletteManager::addItemToCurrentPage()
{
UBApplication::applicationController->showBoard();
UBApplication::applicationController->showBoard();
mAddItemPalette->hide();
if(mPixmap.isNull())
UBApplication::boardController->downloadURL(mItemUrl);
......@@ -998,7 +992,7 @@ void UBBoardPaletteManager::stopDownloads()
{
mDownloadInProgress = false;
mpDownloadWidget->setVisibleState(false);
mRightPalette->removeTab(mpDownloadWidget->name());
mRightPalette->removeTab(mpDownloadWidget);
}
}
......
......@@ -20,6 +20,7 @@
#include "UBDrawingController.h"
#include "frameworks/UBGeometryUtils.h"
#include "frameworks/UBPlatformUtils.h"
#include "core/UBSettings.h"
#include "core/UBMimeData.h"
......@@ -34,6 +35,8 @@
#include "gui/UBToolWidget.h"
#include "gui/UBResources.h"
#include "gui/UBMainWindow.h"
#include "gui/UBMediaPlayer.h"
#include "gui/UBThumbnailWidget.h"
#include "board/UBBoardController.h"
......@@ -43,9 +46,9 @@
#include "domain/UBItem.h"
#include "document/UBDocumentProxy.h"
#include "../gui/UBThumbnailWidget.h"
#include "frameworks/UBPlatformUtils.h"
#include "customWidgets/UBDraggableLabel.h"
#include "customWidgets/UBDraggableMedia.h"
#include "core/memcheck.h"
......@@ -887,7 +890,8 @@ void UBBoardView::dropEvent (QDropEvent *event)
return;
}
if(!event->source() || dynamic_cast<UBThumbnailWidget *>(event->source()) || dynamic_cast<QWebView*>(event->source()))
qDebug() << event->source();
if(!event->source() || dynamic_cast<UBThumbnailWidget *>(event->source()) || dynamic_cast<QWebView*>(event->source()) || dynamic_cast<UBDraggableMediaPlayer *>(event->source()) || dynamic_cast<UBDraggableLabel *>(event->source()) || dynamic_cast<UBDraggableMedia *>(event->source()))
{
mController->processMimeData (event->mimeData (), mapToScene (event->pos ()));
event->acceptProposedAction ();
......
......@@ -347,6 +347,7 @@ void UBApplicationController::showBoard()
if (UBApplication::boardController)
UBApplication::boardController->show();
mIsShowingDesktop = false;
UBPlatformUtils::setDesktopMode(false);
mUninoteController->hideWindow();
......@@ -722,7 +723,6 @@ void UBApplicationController::importFile(const QString& pFilePath)
void UBApplicationController::useMultiScreen(bool use)
{
mDisplayManager->setUseMultiScreen(use);
}
......
......@@ -1102,16 +1102,35 @@ void UBPersistenceManager::persistTeacherBar(UBDocumentProxy* pDocumentProxy, in
// Set the <teacherBar> element values
QDomElement teacherBarElem = teacherBarNode.toElement();
teacherBarElem.setAttribute("title", infos.title);
teacherBarElem.setAttribute("phasis", infos.phasis);
teacherBarElem.setAttribute("duration", infos.Duration);
teacherBarElem.setAttribute("equipment", infos.material);
teacherBarElem.setAttribute("activity", infos.activity);
teacherBarElem.setAttribute("action1Teacher", infos.action1Master);
teacherBarElem.setAttribute("action1Student", infos.action1Student);
teacherBarElem.setAttribute("action2Teacher", infos.action2Master);
teacherBarElem.setAttribute("action2Student", infos.action2Student);
teacherBarElem.setAttribute("action3Teacher", infos.action3Master);
teacherBarElem.setAttribute("action3Student", infos.action3Student);
QString qsAct;
for(int i=0; i<infos.actions.size(); i++){
if(0 != i){
qsAct.append('@');
}
qsAct.append(infos.actions.at(i));
}
teacherBarElem.setAttribute("actions", qsAct);
QString qsMedias;
for(int j=0; j<infos.medias.size(); j++){
if(0 != j){
qsMedias.append('@');
}
qsMedias.append(infos.medias.at(j));
}
teacherBarElem.setAttribute("medias", qsMedias);
QString qsUrls;
for(int k=0; k<infos.urls.size(); k++){
if(0 != k){
qsUrls.append('@');
}
qsUrls.append(infos.urls.at(k));
}
teacherBarElem.setAttribute("links", qsUrls);
teacherBarElem.setAttribute("comments", infos.comments);
// Save the file
f.write(domDoc.toString().toAscii());
......@@ -1142,16 +1161,10 @@ sTeacherBarInfos UBPersistenceManager::getTeacherBarInfos(UBDocumentProxy* pDocu
QDomNode teacherBarNode = rootElem.namedItem("teacherBar");
infos.title = teacherBarNode.toElement().attributeNode("title").value();
infos.phasis = teacherBarNode.toElement().attributeNode("phasis").value().toInt();
infos.Duration = teacherBarNode.toElement().attributeNode("duration").value().toInt();
infos.material = teacherBarNode.toElement().attributeNode("equipment").value();
infos.activity = teacherBarNode.toElement().attributeNode("activity").value().toInt();
infos.action1Master = teacherBarNode.toElement().attributeNode("action1Teacher").value();
infos.action1Student = teacherBarNode.toElement().attributeNode("action1Student").value();
infos.action2Master = teacherBarNode.toElement().attributeNode("action2Teacher").value();
infos.action2Student = teacherBarNode.toElement().attributeNode("action2Student").value();
infos.action3Master = teacherBarNode.toElement().attributeNode("action3Teacher").value();
infos.action3Student = teacherBarNode.toElement().attributeNode("action3Student").value();
infos.actions = teacherBarNode.toElement().attributeNode("actions").value().split("@");
infos.medias = teacherBarNode.toElement().attributeNode("medias").value().split("@");
infos.urls = teacherBarNode.toElement().attributeNode("links").value().split("@");
infos.comments = teacherBarNode.toElement().attributeNode("comments").value();
}
f.close();
}
......
......@@ -23,16 +23,10 @@
struct sTeacherBarInfos
{
QString title;
int phasis;
int Duration;
QString material;
int activity;
QString action1Master;
QString action1Student;
QString action2Master;
QString action2Student;
QString action3Master;
QString action3Student;
QStringList actions;
QStringList medias;
QStringList urls;
QString comments;
};
class UBDocument;
......@@ -41,7 +35,7 @@ class UBGraphicsScene;
class UBPersistenceManager : public QObject
{
Q_OBJECT;
Q_OBJECT
private:
UBPersistenceManager(QObject *pParent = 0);
......
......@@ -36,6 +36,13 @@ QString UBSettings::documentSize = QString("Size");
QString UBSettings::documentIdentifer = QString("ID");
QString UBSettings::documentVersion = QString("Version");
QString UBSettings::documentUpdatedAt = QString("UpdatedAt");
QString UBSettings::sessionTitle = QString("sessionTitle");
QString UBSettings::sessionTarget = QString("sessionTarget");
QString UBSettings::sessionLicence = QString("sessionLicence");
QString UBSettings::sessionKeywords = QString("sessionKeywords");
QString UBSettings::sessionLevel = QString("sessionLevel");
QString UBSettings::sessionTopic = QString("sessionTopic");
QString UBSettings::sessionAuthors = QString("sessionAuthors");
QString UBSettings::trashedDocumentGroupNamePrefix = QString("_Trash:");
......
......@@ -153,6 +153,13 @@ class UBSettings : public QObject
static QString documentIdentifer;
static QString documentVersion;
static QString documentUpdatedAt;
static QString sessionTitle;
static QString sessionTarget;
static QString sessionLicence;
static QString sessionKeywords;
static QString sessionLevel;
static QString sessionTopic;
static QString sessionAuthors;
static QString trashedDocumentGroupNamePrefix;
......@@ -266,8 +273,6 @@ class UBSettings : public QObject
QMap<DocumentSizeRatio::Enum, QSize> documentSizes;
//QSize defaultDocumentSize;
UBSetting* svgViewBoxMargin;
UBSetting* pdfMargin;
UBSetting* pdfPageFormat;
......
#include <QMimeData>
#include <QDrag>
#include <QUrl>
#include "UBDraggableLabel.h"
UBDraggableLabel::UBDraggableLabel(QWidget *parent) :
QLabel(parent)
{
}
UBDraggableLabel::~UBDraggableLabel()
{
//NOOP
}
void UBDraggableLabel::loadImage(QString imagePath)
{
mSourcePath = imagePath;
QPixmap pix = QPixmap(mSourcePath);
setPixmap(pix);
setScaledContents(true);
}
void UBDraggableLabel::mousePressEvent(QMouseEvent *event)
{
Q_UNUSED(event);
QMimeData *mimeData = new QMimeData;
QList<QUrl> urls;
urls << QUrl::fromLocalFile(mSourcePath);
mimeData->setUrls(urls);
mimeData->setText(mSourcePath);
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->start();
}
#ifndef UBDRAGGABLELABEL_H
#define UBDRAGGABLELABEL_H
#include <QLabel>
class UBDraggableLabel : public QLabel
{
Q_OBJECT
public:
UBDraggableLabel(QWidget *parent = 0);
~UBDraggableLabel();
void loadImage(QString imagePath);
signals:
public slots:
protected:
QString mSourcePath;
void mousePressEvent(QMouseEvent *event);
};
#endif // UBDRAGGABLELABEL_H
#include <QApplication>
#include <QUrl>
#include "UBDraggableMedia.h"
UBDraggableMedia::UBDraggableMedia(eMediaType type, QWidget *parent, const char *name):UBMediaWidget(type, parent, name)
{
}
UBDraggableMedia::~UBDraggableMedia()
{
}
void UBDraggableMedia::mousePressEvent(QMouseEvent* ev)
{
if(Qt::LeftButton == ev->button()){
mDragStartPos = ev->pos();
}
}
void UBDraggableMedia::mouseMoveEvent(QMouseEvent* ev)
{
if(!(ev->buttons() & Qt::LeftButton)){
return;
}
if((ev->pos() - mDragStartPos).manhattanLength() < QApplication::startDragDistance()){
return;
}
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
QList<QUrl> urls;
urls << QUrl(mFilePath);
mimeData->setText(mFilePath);
mimeData->setUrls(urls);
drag->setMimeData(mimeData);
Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction);
}
#ifndef UBDRAGGABLEMEDIA_H
#define UBDRAGGABLEMEDIA_H
#include "UBMediaWidget.h"
class UBDraggableMedia : public UBMediaWidget
{
public:
UBDraggableMedia(eMediaType type = eMediaType_Video, QWidget* parent=0, const char* name="UBDraggableMedia");
~UBDraggableMedia();
protected:
void mousePressEvent(QMouseEvent* ev);
void mouseMoveEvent(QMouseEvent* ev);
private:
QPoint mDragStartPos;
};
#endif // UBDRAGGABLEMEDIA_H
#ifndef UBGLOBALS_H
#define UBGLOBALS_H
#define DELETEPTR(ptr) if(NULL != ptr){ \
delete ptr; \
ptr = NULL; \
}
#endif // UBGLOBALS_H
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "core/UBApplication.h"
#include "UBGlobals.h"
#include "UBMediaWidget.h"
/**
* \brief Constructor
* @param type as the media type
* @param parent as the parent widget
* @param name as the object name
*/
UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name):QWidget(parent)
, mpMediaObject(NULL)
, mpVideoWidget(NULL)
, mpAudioOutput(NULL)
, mpPlayStopButton(NULL)
, mpPauseButton(NULL)
, mpSlider(NULL)
, mAutoUpdate(false)
, mGeneratingThumbnail(false)
, mBorder(5)
, mpMediaContainer(NULL)
, mpCover(NULL)
{
setObjectName(name);
setAttribute(Qt::WA_StyledBackground, true);
setStyleSheet(UBApplication::globalStyleSheet());
mType = type;
setLayout(&mLayout);
mpPlayStopButton = new UBMediaButton(this);
mpPlayStopButton->setPixmap(QPixmap(":images/play.svg"));
mpPauseButton = new UBMediaButton(this);
mpPauseButton->setPixmap(QPixmap(":images/pause.svg"));
mpPauseButton->setEnabled(false);
mpSlider = new QSlider(this);
mpSlider->setOrientation(Qt::Horizontal);
mpSlider->setMinimum(0);
mpSlider->setMaximum(0);
mSeekerLayout.addWidget(mpPlayStopButton, 0);
mSeekerLayout.addWidget(mpPauseButton, 0);
mSeekerLayout.addWidget(mpSlider, 1);
mSeekerLayout.setContentsMargins(0, 0, 0, 0);
connect(mpPlayStopButton, SIGNAL(clicked()), this, SLOT(onPlayStopClicked()));
connect(mpPauseButton, SIGNAL(clicked()), this, SLOT(onPauseClicked()));
connect(mpSlider, SIGNAL(valueChanged(int)), this, SLOT(onSliderChanged(int)));
}
/**
* \brief Destructor
*/
UBMediaWidget::~UBMediaWidget()
{
DELETEPTR(mpSlider);
DELETEPTR(mpPauseButton);
DELETEPTR(mpPlayStopButton);
DELETEPTR(mpAudioOutput);
DELETEPTR(mpVideoWidget);
DELETEPTR(mpMediaObject);
DELETEPTR(mpCover);
}
/**
* \brief Set the media file
* @param filePath as the media file path
*/
void UBMediaWidget::setFile(const QString &filePath)
{
Q_ASSERT("" != filePath);
mFilePath = filePath;
mpMediaObject = new Phonon::MediaObject(this);
mpMediaObject->setTickInterval(TICK_INTERVAL);
connect(mpMediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(onStateChanged(Phonon::State,Phonon::State)));
connect(mpMediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(onTotalTimeChanged(qint64)));
connect(mpMediaObject, SIGNAL(tick(qint64)), this, SLOT(onTick(qint64)));
mpMediaObject->setCurrentSource(Phonon::MediaSource(filePath));
createMediaPlayer();
}
/**
* \brief Get the media type
* @returns the media type
*/
eMediaType UBMediaWidget::mediaType()
{
return mType;
}
void UBMediaWidget::showEvent(QShowEvent* event)
{
if(!mpVideoWidget){
mpVideoWidget = new Phonon::VideoWidget(this);
mMediaLayout.addStretch(1);
mMediaLayout.addWidget(mpVideoWidget, 0);
mMediaLayout.addStretch(1);
Phonon::createPath(mpMediaObject, mpVideoWidget);
adaptSizeToVideo();
mpMediaObject->play();
mpMediaObject->stop();
}
QWidget::showEvent(event);
}
/**
* \brief Create the media player
*/
void UBMediaWidget::createMediaPlayer()
{
mpMediaContainer = new QWidget(this);
mpMediaContainer->setObjectName("UBMediaVideoContainer");
mpMediaContainer->setLayout(&mMediaLayout);
if(eMediaType_Video == mType){
mMediaLayout.setContentsMargins(10, 10, 25, 10);
if(isVisible()){
mpVideoWidget = new Phonon::VideoWidget(this);
mMediaLayout.addStretch(1);
mMediaLayout.addWidget(mpVideoWidget, 0);
mMediaLayout.addStretch(1);
Phonon::createPath(mpMediaObject, mpVideoWidget);
adaptSizeToVideo();
}
mpAudioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this);
Phonon::createPath(mpMediaObject, mpAudioOutput);
}else if(eMediaType_Audio == mType){
mMediaLayout.setContentsMargins(10, 10, 10, 10);
mpCover = new QLabel(mpMediaContainer);
mpMediaContainer->setStyleSheet(QString("background: none;"));
setAudioCover(":images/libpalette/soundIcon.svg");
mpCover->setScaledContents(true);
mMediaLayout.addStretch(1);
mMediaLayout.addWidget(mpCover, 0);
mMediaLayout.addStretch(1);
mpAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
Phonon::createPath(mpMediaObject, mpAudioOutput);
}
mLayout.addWidget(mpMediaContainer, 1);
mLayout.addLayout(&mSeekerLayout, 0);
}
/**
* \brief Adapt the widget size to the video in order to keep the good aspect ratio
*/
void UBMediaWidget::adaptSizeToVideo()
{
if(NULL != mpMediaContainer){
int origW = mpMediaContainer->width();
int origH = mpMediaContainer->height();
int newW = width();
float scaleFactor = (float)origW/(float)newW;
int newH = origH/scaleFactor;
resize(newW, height() + newH);
}
}
/**
* \brief Handle the media state change notification
* @param newState as the new state
* @param oldState as the old state
*/
void UBMediaWidget::onStateChanged(Phonon::State newState, Phonon::State oldState)
{
if(!mGeneratingThumbnail){
if(Phonon::LoadingState == oldState && Phonon::StoppedState == newState){
if(eMediaType_Video == mType){
// We do that here to generate the thumbnail of the video
mGeneratingThumbnail = true;
mpMediaObject->play();
mpMediaObject->pause();
mGeneratingThumbnail = false;
}
}else if(Phonon::PlayingState == oldState && Phonon::PausedState == newState){
mpPlayStopButton->setPixmap(QPixmap(":images/play.svg"));
mpPauseButton->setEnabled(false);
}else if((Phonon::PausedState == oldState && Phonon::PlayingState == newState) ||
(Phonon::StoppedState == oldState && Phonon::PlayingState == newState)){
mpPlayStopButton->setPixmap(QPixmap(":images/stop.svg"));
mpPauseButton->setEnabled(true);
}else if(Phonon::PlayingState == oldState && Phonon::StoppedState == newState){
mpPlayStopButton->setPixmap(QPixmap(":images/play.svg"));
mpPauseButton->setEnabled(false);
mpSlider->setValue(0);
}
}
}
/**
* \brief Handles the total time change notification
* @param total as the new total time
*/
void UBMediaWidget::onTotalTimeChanged(qint64 total)
{
mpSlider->setMaximum(total);
}
/**
* \brief Handles the tick notification
* @param currentTime as the current time
*/
void UBMediaWidget::onTick(qint64 currentTime)
{
mAutoUpdate = true;
mpSlider->setValue((int)currentTime);
mAutoUpdate = false;
}
/**
* \brief Handles the seeker value change notification
* @param value as the new seeker value
*/
void UBMediaWidget::onSliderChanged(int value)
{
if(!mAutoUpdate){
mpMediaObject->seek(value);
}
}
/**
* \brief Toggle Play-Stop
*/
void UBMediaWidget::onPlayStopClicked()
{
switch(mpMediaObject->state()){
case Phonon::PlayingState:
mpMediaObject->stop();
break;
case Phonon::StoppedState:
case Phonon::PausedState:
mpMediaObject->play();
break;
default:
break;
}
}
/**
* \brief Pause the media
*/
void UBMediaWidget::onPauseClicked()
{
mpMediaObject->pause();
}
/**
* Get the border
* @returns the actual border
*/
int UBMediaWidget::border()
{
return mBorder;
}
/**
* \brief Handles the resize event
* @param ev as the resize event
*/
void UBMediaWidget::resizeEvent(QResizeEvent* ev)
{
Q_UNUSED(ev);
}
/**
* \brief Set the audio cover
* @param coverPath as the cover image file path
*/
void UBMediaWidget::setAudioCover(const QString &coverPath)
{
if(NULL != mpCover){
mpCover->setPixmap(QPixmap(coverPath));
}
}
// -----------------------------------------------------------------------------------------------------------
/**
* \brief Constructor
* @param parent as the parent widget
* @param name as the object name
*/
UBMediaButton::UBMediaButton(QWidget *parent, const char *name):QLabel(parent)
, mPressed(false)
{
setObjectName(name);
resize(UBMEDIABUTTON_SIZE, UBMEDIABUTTON_SIZE);
setStyleSheet(QString("padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;"));
}
/**
* \brief Destructor
*/
UBMediaButton::~UBMediaButton()
{
}
/**
* \brief Handles the mouse press notification
* @param ev as the mouse press event
*/
void UBMediaButton::mousePressEvent(QMouseEvent* ev)
{
Q_UNUSED(ev);
mPressed = true;
}
/**
* \brief Handles the mouse release notification
* @param ev as the mouse release event
*/
void UBMediaButton::mouseReleaseEvent(QMouseEvent* ev)
{
Q_UNUSED(ev);
if(mPressed){
mPressed = false;
emit clicked();
}
}
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBMEDIAWIDGET_H
#define UBMEDIAWIDGET_H
#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QSlider>
#include <QMouseEvent>
#include <phonon/MediaObject>
#include <phonon/VideoWidget>
#include <phonon/AudioOutput>
#include "interfaces/IResizeable.h"
#define UBMEDIABUTTON_SIZE 32
#define TICK_INTERVAL 1000
/**
* \brief The media type
*/
typedef enum{
eMediaType_Video,
eMediaType_Audio
}eMediaType;
class UBMediaButton : public QLabel
{
Q_OBJECT
public:
UBMediaButton(QWidget* parent=0, const char* name="UBMediaButton");
~UBMediaButton();
signals:
void clicked();
protected:
void mousePressEvent(QMouseEvent* ev);
void mouseReleaseEvent(QMouseEvent* ev);
private:
/** And indicator of the press event in progress */
bool mPressed;
};
class UBMediaWidget : public QWidget
{
Q_OBJECT
public:
UBMediaWidget(eMediaType type = eMediaType_Video, QWidget* parent=0, const char* name="UBMediaWidget");
~UBMediaWidget();
void setFile(const QString& filePath);
eMediaType mediaType();
int border();
void setAudioCover(const QString& coverPath);
protected:
void resizeEvent(QResizeEvent* ev);
void showEvent(QShowEvent* event);
/** The current media file path */
QString mFilePath;
private slots:
void onPlayStopClicked();
void onPauseClicked();
void onStateChanged(Phonon::State newState, Phonon::State oldState);
void onTotalTimeChanged(qint64 total);
void onTick(qint64 currentTime);
void onSliderChanged(int value);
private:
void createMediaPlayer();
void adaptSizeToVideo();
/** The current media type */
eMediaType mType;
/** The media object */
Phonon::MediaObject* mpMediaObject;
/** The video renderer */
Phonon::VideoWidget* mpVideoWidget;
/** The audio renderer */
Phonon::AudioOutput* mpAudioOutput;
/** The principal layout of this widget */
QVBoxLayout mLayout;
/** The seeker layout */
QHBoxLayout mSeekerLayout;
/** The play-stop button */
UBMediaButton* mpPlayStopButton;
/** The pause button */
UBMediaButton* mpPauseButton;
/** The seeker slider */
QSlider* mpSlider;
/** An indicator of the seeker auto update in progress */
bool mAutoUpdate;
/** An indicator of the thumbnail generation in progress */
bool mGeneratingThumbnail;
/** The border */
int mBorder;
/** A widget that will contain the media */
QWidget* mpMediaContainer;
/** The media layout */
QHBoxLayout mMediaLayout;
/** The audio cover */
QLabel* mpCover;
};
#endif // UBMEDIAWIDGET_H
#include <QDebug>
#include <QScrollBar>
#include "UBGlobals.h"
#include "UBWidgetList.h"
UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, const char* name):QScrollArea(parent)
, mpLayout(NULL)
, mpContainer(NULL)
, mMargin(5)
, mListElementsSpacing(10)
, mpEmptyLabel(NULL)
{
setObjectName(name);
mOrientation = orientation;
mpContainer = new QWidget(this);
mpEmptyLabel = new QLabel(this);
mpEmptyLabel->setObjectName("emptyString");
mpEmptyLabel->setWordWrap(true);
mpEmptyLabel->setAlignment(Qt::AlignCenter);
if(eWidgetListOrientation_Vertical == orientation){
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
mpLayout = new QVBoxLayout(mpContainer);
}
else{
setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
mpLayout = new QHBoxLayout(mpContainer);
}
mpLayout->setContentsMargins(margin(), margin(), margin(), margin());
mpContainer->setLayout(mpLayout);
setWidget(mpContainer);
}
UBWidgetList::~UBWidgetList()
{
DELETEPTR(mpEmptyLabel);
DELETEPTR(mpLayout);
DELETEPTR(mpContainer);
}
void UBWidgetList::addWidget(QWidget *widget)
{
if(NULL != mpLayout && NULL != widget){
widget->setParent(mpContainer);
mpEmptyLabel->setVisible(false);
mWidgetInfo[widget] = widget->size();
updateView(size());
mpLayout->addWidget(widget);
// This call is used only to refresh the size of the widgets
updateSizes();
}
}
void UBWidgetList::removeWidget(QWidget *widget)
{
if(NULL != mpLayout && NULL != widget){
mpLayout->removeWidget(widget);
mWidgetInfo.remove(widget);
widget->setVisible(false);
updateView(size());
if(0 == mpLayout->count()){
mpEmptyLabel->setVisible(true);
}
}
}
int UBWidgetList::scaleWidgets(QSize pSize)
{
// to remove the first spacing that shouldn't be there.
int result = -mListElementsSpacing;
foreach(QWidget* eachWidget, mWidgetInfo.keys()){
qreal scaleFactor = 0;
int newWidgetWidth = pSize.width();
int newWidgetHeight = pSize.height();
if(eWidgetListOrientation_Vertical == mOrientation){
scaleFactor = (float)mWidgetInfo[eachWidget].width() / (float)pSize.width();
newWidgetHeight = mWidgetInfo[eachWidget].height()/scaleFactor;
result += newWidgetHeight;
eachWidget->setMinimumHeight(newWidgetHeight- 1);
eachWidget->setMaximumHeight(newWidgetHeight);
}
else{
scaleFactor = (float)mWidgetInfo[eachWidget].height() / (float)pSize.height();
newWidgetWidth = mWidgetInfo[eachWidget].width()/scaleFactor;
result += newWidgetWidth;
eachWidget->setMinimumWidth(newWidgetWidth - 1);
eachWidget->setMaximumWidth(newWidgetWidth);
}
//Adding a vertical/horizontal space between each element of the list
result += mListElementsSpacing;
}
return result;
}
void UBWidgetList::scaleContainer(QSize pSize, int updateValue)
{
if(eWidgetListOrientation_Vertical == mOrientation)
mpContainer->resize(pSize.width(), updateValue);
else
mpContainer->resize(updateValue, pSize.height());
}
void UBWidgetList::updateView(QSize pSize)
{
// Widgets on list are resized automatically to fit the mpcontainer.
// so if you want to keep the aspect ratio you have to calculate
// the sum of the new widget height and give it to the mpContainer.
// The container resize will trig the widgets resize and the good
// height permits to respect the aspect ratio.
int updatedValue = scaleWidgets(pSize);
scaleContainer(pSize,updatedValue);
}
void UBWidgetList::resizeEvent(QResizeEvent *ev)
{
Q_UNUSED(ev);
mpEmptyLabel->setGeometry((width() - mpEmptyLabel->width()) / 2,
(height() - mpEmptyLabel->height()) /2,
mpEmptyLabel->width(),
mpEmptyLabel->height());
updateView(size());
updateSizes();
}
void UBWidgetList::updateSizes()
{
// Resize all the widgets
foreach(QWidget* eachWidget, mWidgetInfo.keys()){
if(NULL != eachWidget){
QSize originalSize = mWidgetInfo[eachWidget];
int currentWidth = mpContainer->width();
int currentHeight = mpContainer->height();
if(eWidgetListOrientation_Vertical == mOrientation){
if(verticalScrollBar()->isVisible()){
currentWidth -= verticalScrollBar()->width();
eachWidget->setStyleSheet(QString("margin-right:%0;").arg(verticalScrollBar()->width()));
}
float scaleFactor = (float)currentWidth/(float)originalSize.width();
currentHeight = originalSize.height()*scaleFactor;
}else{
if(horizontalScrollBar()->isVisible()){
currentHeight -= horizontalScrollBar()->height();
eachWidget->setStyleSheet(QString("padding-bottom:%0;").arg(horizontalScrollBar()->height()));
}
float scaleFactor = (float)currentHeight/(float)originalSize.height();
currentWidth = originalSize.width()*scaleFactor;
}
eachWidget->resize(currentWidth, currentHeight);
}
}
}
void UBWidgetList::setMargin(int margin)
{
mMargin = margin;
}
int UBWidgetList::margin()
{
return mMargin;
}
void UBWidgetList::setEmptyText(const QString &text)
{
if(NULL != mpEmptyLabel){
mpEmptyLabel->setText(text);
}
}
bool UBWidgetList::empty()
{
return mWidgetInfo.empty();
}
// TODO : - add onHover 'delete' button
#ifndef UBWIDGETLIST_H
#define UBWIDGETLIST_H
#include <QWidget>
#include <QScrollArea>
#include <QBoxLayout>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QResizeEvent>
#include <QVector>
#include <QLabel>
#include "interfaces/IResizeable.h"
typedef enum{
eWidgetListOrientation_Vertical,
eWidgetListOrientation_Horizontal
}eWidgetListOrientation;
class UBWidgetList : public QScrollArea
{
Q_OBJECT
typedef struct
{
QSize size;
bool isResizable;
} sWidgetProperties;
public:
UBWidgetList(QWidget* parent=0, eWidgetListOrientation orientation = eWidgetListOrientation_Vertical, const char* name = "UBWidgetList");
~UBWidgetList();
void addWidget(QWidget* widget);
void removeWidget(QWidget* widget);
void setMargin(int margin);
void setEmptyText(const QString& text);
int margin();
bool empty();
void setListElementSpacing(int margin) { mListElementsSpacing = margin; }
int listElementsSpacing() {return mListElementsSpacing; }
protected:
void resizeEvent(QResizeEvent* ev);
private:
int scaleWidgets(QSize pSize);
void scaleContainer(QSize pSize, int updateValue);
void updateView(QSize pSize);
void updateSizes();
QBoxLayout* mpLayout;
QWidget* mpContainer;
eWidgetListOrientation mOrientation;
int mMargin;
int mListElementsSpacing;
QMap<QWidget*, QSize> mWidgetInfo;
QLabel* mpEmptyLabel;
};
#endif // UBWIDGETLIST_H
HEADERS += src/customWidgets/UBWidgetList.h \
src/customWidgets/UBDraggableLabel.h \
src/customWidgets/UBMediaWidget.h \
src/customWidgets/UBGlobals.h \
src/customWidgets/UBDraggableMedia.h
SOURCES += src/customWidgets/UBWidgetList.cpp \
src/customWidgets/UBDraggableLabel.cpp \
src/customWidgets/UBMediaWidget.cpp \
src/customWidgets/UBDraggableMedia.cpp
......@@ -37,7 +37,6 @@
#include "board/UBBoardPaletteManager.h"
#include "board/UBDrawingController.h"
//#include "gui/UBKeyboardPalette.h"
#include "gui/UBThumbnailView.h"
#include "gui/UBDocumentTreeWidget.h"
......@@ -69,7 +68,6 @@ UBDocumentController::UBDocumentController(UBMainWindow* mainWindow)
, mToolsPalette(0)
, mToolsPalettePositionned(false)
, mTrashTi(0)
// , mKeyboardPalette(0)
{
setupViews();
setupToolbar();
......
......@@ -49,6 +49,14 @@ void UBDocumentProxy::init()
setUuid(QUuid::createUuid());
setDefaultDocumentSize(UBSettings::settings()->pageSize->get().toSize());
setSessionTitle("");
setSessionTarget("");
setSessionLicence("");
setSessionKeywords("");
setSessionLevel("");
setSessionTopic("");
setSessionAuthor("");
}
......@@ -196,6 +204,97 @@ void UBDocumentProxy::setUuid(const QUuid& uuid)
UBSettings::uniboardDocumentNamespaceUri + "/" + UBStringUtils::toCanonicalUuid(uuid));
}
QString UBDocumentProxy::sessionTitle() const
{
if(mMetaDatas.contains(UBSettings::sessionTitle))
return metaData(UBSettings::sessionTitle).toString();
else
return QString();
}
void UBDocumentProxy::setSessionTitle(const QString & sessionTitle)
{
setMetaData(UBSettings::sessionTitle,QVariant(sessionTitle));
}
QString UBDocumentProxy::sessionTarget() const
{
if(mMetaDatas.contains(UBSettings::sessionTarget))
return metaData(UBSettings::sessionTarget).toString();
else
return QString();
}
void UBDocumentProxy::setSessionTarget(const QString & sessionTarget)
{
setMetaData(UBSettings::sessionTarget,QVariant(sessionTarget));
}
QString UBDocumentProxy::sessionLicence() const
{
if(mMetaDatas.contains(UBSettings::sessionLicence))
return metaData(UBSettings::sessionLicence).toString();
else
return QString();
}
void UBDocumentProxy::setSessionLicence(const QString & sessionLicence)
{
setMetaData(UBSettings::sessionLicence,QVariant(sessionLicence));
}
void UBDocumentProxy::setSessionKeywords(const QString &kw)
{
setMetaData(UBSettings::sessionKeywords,QVariant(kw));
}
QString UBDocumentProxy::sessionKeywords()
{
if(mMetaDatas.contains(UBSettings::sessionKeywords))
return metaData(UBSettings::sessionKeywords).toString();
else
return QString();
}
void UBDocumentProxy::setSessionLevel(const QString &level)
{
setMetaData(UBSettings::sessionLevel,QVariant(level));
}
QString UBDocumentProxy::sessionLevel()
{
if(mMetaDatas.contains(UBSettings::sessionLevel))
return metaData(UBSettings::sessionLevel).toString();
else
return QString();
}
void UBDocumentProxy::setSessionTopic(const QString &topic)
{
setMetaData(UBSettings::sessionTopic,QVariant(topic));
}
QString UBDocumentProxy::sessionTopic()
{
if(mMetaDatas.contains(UBSettings::sessionTopic))
return metaData(UBSettings::sessionTopic).toString();
else
return QString();
}
void UBDocumentProxy::setSessionAuthor(const QString &authors)
{
setMetaData(UBSettings::sessionAuthors,QVariant(authors));
}
QString UBDocumentProxy::sessionAuthors()
{
if(mMetaDatas.contains(UBSettings::sessionAuthors))
return metaData(UBSettings::sessionAuthors).toString();
else
return QString();
}
bool UBDocumentProxy::isModified() const
{
return mIsModified;
......
......@@ -45,6 +45,21 @@ class UBDocumentProxy : public QObject
QString name() const;
QString groupName() const;
QString sessionTitle() const;
void setSessionTitle(const QString& sessionTitle);
QString sessionTarget() const;
void setSessionTarget(const QString& sessionTarget);
QString sessionLicence() const;
void setSessionLicence(const QString& sessionLicence);
void setSessionKeywords(const QString& kw);
QString sessionKeywords();
void setSessionLevel(const QString& level);
QString sessionLevel();
void setSessionTopic(const QString& topic);
QString sessionTopic();
void setSessionAuthor(const QString& authors);
QString sessionAuthors();
QSize defaultDocumentSize() const;
void setDefaultDocumentSize(QSize pSize);
......
......@@ -86,12 +86,13 @@ QVariant UBGraphicsMediaItem::itemChange(GraphicsItemChange change, const QVaria
void UBGraphicsMediaItem::clearSource()
{
QString path = mediaFileUrl().path();
QString path = mediaFileUrl().toLocalFile();
//if path is absolute clean duplicated path string
if (!path.contains(UBApplication::boardController->activeDocument()->persistencePath()))
path = UBApplication::boardController->activeDocument()->persistencePath() + "/" + path;
UBFileSystemUtils::deleteFile(path);
if (!UBFileSystemUtils::deleteFile(path))
qDebug() << "cannot delete file: " << path;
}
void UBGraphicsMediaItem::toggleMute()
......
......@@ -1770,7 +1770,6 @@ void UBGraphicsScene::addMask(const QPointF &center)
QRectF rect = UBApplication::boardController->activeScene()->normalizedSceneRect();
rect.setRect(center.x() - rect.width()/4, center.y() - rect.height()/4, rect.width()/2 , rect.height()/2);
QPointF origin = center.isNull() ? rect.bottomRight() : center;
curtain->setRect(rect);
UBGraphicsItem::assignZValue(curtain, toolLayerStart + toolOffsetCurtain);
......
......@@ -57,12 +57,10 @@ void UBActionPalette::init(Qt::Orientation orientation)
mToolButtonStyle = Qt::ToolButtonIconOnly;
mButtons.clear();
QBoxLayout *layout = 0;
if (orientation == Qt::Horizontal)
layout = new QHBoxLayout(this);
new QHBoxLayout(this);
else
layout = new QVBoxLayout(this);
new QVBoxLayout(this);
updateLayout();
}
......
......@@ -222,7 +222,7 @@ void UBCachePropertiesWidget::onCloseClicked()
emit cacheListEmpty();
}
emit hideTab(name());
emit hideTab(this);
}
}
......@@ -300,7 +300,7 @@ void UBCachePropertiesWidget::updateCurrentCache()
if("Cache" == it->data(Qt::UserRole).toString())
{
setEnabled(true);
emit showTab(name());
emit showTab(this);
mpCurrentCache = dynamic_cast<UBGraphicsCache*>(it);
if((NULL != mpCurrentCache) && (!mCaches.contains(mpCurrentCache)))
{
......@@ -331,7 +331,7 @@ void UBCachePropertiesWidget::updateCurrentCache()
// 1 - that this page has no cache
// 2 - we are not in Board mode
// 3 - we are in Board mode, but show desktop (as really - Desktop mode)
emit hideTab(name());
emit hideTab(this);
mpCurrentCache = NULL;
setDisabled(true);
}
......@@ -346,6 +346,6 @@ void UBCachePropertiesWidget::onSizeChanged(int newSize)
void UBCachePropertiesWidget::onCacheEnabled()
{
emit showTab(name());
emit showTab(this);
}
......@@ -567,19 +567,15 @@ void UBDockPalette::addTab(UBDockPaletteWidget *widget)
* \brief Remove the given tab
* @param widgetName as the tab widget name
*/
void UBDockPalette::removeTab(const QString &widgetName)
void UBDockPalette::removeTab(UBDockPaletteWidget* widget)
{
for(int i = 0; i < mTabWidgets.size(); i++)
int nWidget = mTabWidgets.indexOf(widget);
if( nWidget >= 0 )
{
UBDockPaletteWidget* pCrntWidget = mTabWidgets.at(i);
if(NULL != pCrntWidget && (pCrntWidget->name() == widgetName))
{
mpStackWidget->removeWidget(pCrntWidget);
mTabWidgets.remove(i);
pCrntWidget->hide();
update();
break;
}
mpStackWidget->removeWidget(widget);
mTabWidgets.remove(nWidget);
widget->hide();
update();
}
resizeTabs();
mCurrentTab = qMax(mCurrentTab - 1, 0);
......@@ -607,17 +603,12 @@ int UBDockPalette::tabSpacing()
* \brief Show the given widget
* @param widgetName as the given widget name
*/
void UBDockPalette::onShowTabWidget(const QString &widgetName)
void UBDockPalette::onShowTabWidget(UBDockPaletteWidget* widget)
{
for(int i = 0; i < mRegisteredWidgets.size(); i++)
if (mRegisteredWidgets.contains(widget))
{
UBDockPaletteWidget* pCrntWidget = mRegisteredWidgets.at(i);
if(NULL != pCrntWidget && (pCrntWidget->name() == widgetName))
{
pCrntWidget->setVisibleState(true);
addTab(pCrntWidget);
break;
}
widget->setVisibleState(true);
addTab(widget);
}
}
......@@ -625,16 +616,13 @@ void UBDockPalette::onShowTabWidget(const QString &widgetName)
* \brief Hide the given widget
* @param widgetName as the given widget name
*/
void UBDockPalette::onHideTabWidget(const QString &widgetName)
void UBDockPalette::onHideTabWidget(UBDockPaletteWidget* widget)
{
for(int i = 0; i < mRegisteredWidgets.size(); i++){
UBDockPaletteWidget* pCrntWidget = mRegisteredWidgets.at(i);
if(NULL != pCrntWidget && (pCrntWidget->name() == widgetName)){
pCrntWidget->setVisibleState(false);
break;
}
if (mRegisteredWidgets.contains(widget))
{
widget->setVisibleState(false);
removeTab(widget);
}
removeTab(widgetName);
}
/**
......@@ -644,8 +632,8 @@ void UBDockPalette::connectSignals()
{
for(int i=0; i < mRegisteredWidgets.size(); i++)
{
connect(mRegisteredWidgets.at(i), SIGNAL(showTab(QString)), this, SLOT(onShowTabWidget(QString)));
connect(mRegisteredWidgets.at(i), SIGNAL(hideTab(QString)), this, SLOT(onHideTabWidget(QString)));
connect(mRegisteredWidgets.at(i), SIGNAL(showTab(UBDockPaletteWidget*)), this, SLOT(onShowTabWidget(UBDockPaletteWidget*)));
connect(mRegisteredWidgets.at(i), SIGNAL(hideTab(UBDockPaletteWidget*)), this, SLOT(onHideTabWidget(UBDockPaletteWidget*)));
}
}
......@@ -747,7 +735,7 @@ bool UBDockPalette::switchMode(eUBDockPaletteWidgetMode mode)
}
else
{
removeTab(pNextWidget->name());
removeTab(pNextWidget);
}
}
}
......
......@@ -111,8 +111,9 @@ public:
void setBackgroundBrush(const QBrush& brush);
void registerWidget(UBDockPaletteWidget* widget);
void addTab(UBDockPaletteWidget* widget);
void removeTab(const QString& widgetName);
void removeTab(UBDockPaletteWidget* widget);
void connectSignals();
......@@ -129,8 +130,8 @@ public:
eUBDockPaletteType paletteType(){return mPaletteType;}
public slots:
void onShowTabWidget(const QString& widgetName);
void onHideTabWidget(const QString& widgetName);
void onShowTabWidget(UBDockPaletteWidget* widget);
void onHideTabWidget(UBDockPaletteWidget* widget);
void onAllDownloadsFinished();
protected:
......
......@@ -27,6 +27,15 @@ QString UBDockPaletteWidget::name()
return mName;
}
/**
* When a widget registers a mode it means that it would be displayed on that mode
*/
void UBDockPaletteWidget::registerMode(eUBDockPaletteWidgetMode mode)
{
if(!mRegisteredModes.contains(mode))
mRegisteredModes.append(mode);
}
void UBDockPaletteWidget::slot_changeMode(eUBDockPaletteWidgetMode newMode)
{
this->setVisible(this->visibleInMode( newMode ));
......
......@@ -5,6 +5,10 @@
#include <QPixmap>
#include <QString>
/**
* This enum defines the different mode availables.
*/
typedef enum
{
eUBDockPaletteWidget_BOARD,
......@@ -27,12 +31,14 @@ public:
virtual bool visibleInMode(eUBDockPaletteWidgetMode mode) = 0;
void registerMode(eUBDockPaletteWidgetMode mode);
bool visibleState(){return mVisibleState;}
void setVisibleState(bool state){mVisibleState = state;}
signals:
void hideTab(const QString& widgetName);
void showTab(const QString& widgetName);
void hideTab(UBDockPaletteWidget* widget);
void showTab(UBDockPaletteWidget* widget);
public slots:
void slot_changeMode(eUBDockPaletteWidgetMode newMode);
......@@ -44,7 +50,7 @@ protected:
QString mName;
/* The current widget available mode list */
//QVector<eUBDockPaletteWidgetMode> mRegisteredModes;
QVector<eUBDockPaletteWidgetMode> mRegisteredModes;
bool mVisibleState;
};
......
This diff is collapsed.
#ifndef UBUBMediaPlayer_H
#define UBUBMediaPlayer_H
#include <QtGui/QWidget>
#include <QtGui/QApplication>
#include <QtCore/QTimerEvent>
#include <QtGui/QShowEvent>
#include <QtGui/QIcon>
#include <QtCore/QBasicTimer>
#include <QtGui/QAction>
#include <phonon/audiooutput.h>
#include <phonon/backendcapabilities.h>
#include <phonon/effect.h>
#include <phonon/effectparameter.h>
#include <phonon/effectwidget.h>
#include <phonon/mediaobject.h>
#include <phonon/seekslider.h>
#include <phonon/videowidget.h>
#include <phonon/volumeslider.h>
QT_BEGIN_NAMESPACE
class QPushButton;
class QLabel;
class QSlider;
class QTextEdit;
QT_END_NAMESPACE
class UBMediaPlayer;
class MediaVideoWidget : public Phonon::VideoWidget
{
Q_OBJECT;
public:
MediaVideoWidget(UBMediaPlayer *player, QWidget *parent = 0);
protected:
void timerEvent(QTimerEvent *e);
private:
UBMediaPlayer* m_player;
QBasicTimer m_timer;
// QAction m_action;
};
class UBMediaPlayer : public QWidget
{
Q_OBJECT
public:
UBMediaPlayer();
void setFile(const QString &text);
void setLocation(const QString &location);
void setVolume(qreal volume);
public slots:
void openFile();
void rewind();
void forward();
// void updateTime();
void finished();
void playPause();
protected:
void resizeEvent(QResizeEvent* pEvent);
private slots:
void stateChanged(Phonon::State newstate, Phonon::State oldstate);
void bufferStatus(int percent);
void openUrl();
void hasVideoChanged(bool);
private:
void initVideoWindow();
QIcon playIcon;
QIcon pauseIcon;
QPushButton *playButton;
// QPushButton *rewindButton;
// QPushButton *forwardButton;
Phonon::SeekSlider *slider;
// QLabel *timeLabel;
QLabel *progressLabel;
// QLabel *info;
QWidget m_videoWindow;
Phonon::MediaObject m_MediaObject;
Phonon::AudioOutput m_AudioOutput;
MediaVideoWidget *m_videoWidget;
Phonon::Path m_audioOutputPath;
};
class UBDraggableMediaPlayer : public UBMediaPlayer
{
Q_OBJECT
public:
UBDraggableMediaPlayer();
void setFile(const QString &text);
protected:
QString mSourcePath;
void mousePressEvent(QMouseEvent *event);
};
#endif // UBUBMediaPlayer_H
#include <QDebug>
#include "UBTBDocumentEditWidget.h"
#include "customWidgets/UBGlobals.h"
UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget *parent, const char *name):QWidget(parent)
, mpPageViewButton(NULL)
, mpPreviewButton(NULL)
, mpTitleLabel(NULL)
, mpTitle(NULL)
, mpTargetLabel(NULL)
, mpTarget(NULL)
, mpMetadataLabel(NULL)
, mpLicenseLabel(NULL)
, mpLicenseCombox(NULL)
, mpKeywords(NULL)
, mpLevel(NULL)
, mpTopic(NULL)
, mpAuthor(NULL)
, mpKeywordLabel(NULL)
, mpLevelLabel(NULL)
, mpTopicLabel(NULL)
, mpAuthorLabel(NULL)
{
setObjectName(name);
mpDataMgr = pDataMgr;
setLayout(&mLayout);
mLayout.setContentsMargins(0, 0, 0, 0);
mpContainer = new QWidget(this);
mpContainer->setObjectName("DockPaletteWidgetBox");
mLayout.addWidget(mpContainer, 1);
mpContainer->setLayout(&mContainerLayout);
// Title
mpTitleLabel = new QLabel(tr("Session Title"), mpContainer);
mpTitleLabel->setAlignment(Qt::AlignLeft);
mpTitleLabel->setObjectName("UBTeacherBarPreviewSubtitle");
mContainerLayout.addWidget(mpTitleLabel, 0);
mpTitle = new QLineEdit(mpContainer);
mpTitle->setObjectName("DockPaletteWidgetLineEdit");
mContainerLayout.addWidget(mpTitle, 0);
mContainerLayout.addWidget(&mTitleSeparator);
// Target
mpTargetLabel = new QLabel(tr("Session Target"), mpContainer);
mpTargetLabel->setObjectName("UBTeacherBarPreviewSubtitle");
mContainerLayout.addWidget(mpTargetLabel, 0);
mpTarget = new QTextEdit(mpContainer);
mpTarget->setObjectName("UBTeacherBarTargetBox");
mContainerLayout.addWidget(mpTarget, 1);
mContainerLayout.addWidget(&mTargetSeparator);
// Metadata
mpMetadataLabel = new QLabel(tr("Metadata"), mpContainer);
mpMetadataLabel->setObjectName("UBTeacherBarPreviewSubtitle");
mpMetadataLabel->setAlignment(Qt::AlignLeft);
mContainerLayout.addWidget(mpMetadataLabel, 0);
mpKeywords = new QLineEdit(this);
mpKeywords->setObjectName("DockPaletteWidgetLineEdit");
mpLevel = new QComboBox(this);
mpLevel->setObjectName("DockPaletteWidgetComboBox");
mpTopic = new QComboBox(this);
mpTopic->setObjectName("DockPaletteWidgetComboBox");
mpAuthor = new QLineEdit(this);
mpAuthor->setObjectName("DockPaletteWidgetLineEdit");
mpKeywordLabel = new QLabel(tr("Keywords:"), this);
mpLevelLabel = new QLabel(tr("Level:"), this);
mpTopicLabel = new QLabel(tr("Topic:"), this);
mpAuthorLabel = new QLabel(tr("Author"), this);
mKeywordLayout.addWidget(mpKeywordLabel, 0);
mKeywordLayout.addWidget(mpKeywords, 1);
mLevelLayout.addWidget(mpLevelLabel, 0);
mLevelLayout.addWidget(mpLevel, 1);
mTopicLayout.addWidget(mpTopicLabel, 0);
mTopicLayout.addWidget(mpTopic, 1);
mAuthorLayout.addWidget(mpAuthorLabel, 0);
mAuthorLayout.addWidget(mpAuthor, 1);
mContainerLayout.addLayout(&mKeywordLayout, 0);
mContainerLayout.addLayout(&mLevelLayout, 0);
mContainerLayout.addLayout(&mTopicLayout, 0);
mContainerLayout.addLayout(&mAuthorLayout, 0);
mContainerLayout.addWidget(&mLicenseSeparator);
// License
mpLicenseLabel = new QLabel(tr("License"), mpContainer);
mpLicenseLabel->setAlignment(Qt::AlignLeft);
mpLicenseLabel->setObjectName("UBTeacherBarPreviewSubtitle");
mContainerLayout.addWidget(mpLicenseLabel, 0);
mpLicenseCombox = new QComboBox(this);
mpLicenseCombox->setObjectName("DockPaletteWidgetComboBox");
QStringList qslLicenses;
qslLicenses << "CC BY";
qslLicenses << "CC BY-ND";
qslLicenses << "CC BY-NC-SA";
qslLicenses << "CC BY-SA";
qslLicenses << "CC BY-NC";
qslLicenses << "CC BY-NC-ND";
mpLicenseCombox->addItems(qslLicenses);
mContainerLayout.addWidget(mpLicenseCombox);
mpPageViewButton = new QPushButton(tr("Page View"), this);
mpPageViewButton->setObjectName("DockPaletteWidgetButton");
mPreviewLayout.addWidget(mpPageViewButton, 0);
mpPreviewButton = new QPushButton(tr("Preview"), this);
mpPreviewButton->setObjectName("DockPaletteWidgetButton");
mPreviewLayout.addWidget(mpPreviewButton, 0);
mPreviewLayout.addStretch(1);
mLayout.addLayout(&mPreviewLayout, 0);
connect(mpPageViewButton, SIGNAL(clicked()), this, SLOT(onPageView()));
connect(mpPreviewButton, SIGNAL(clicked()), this, SLOT(onPreview()));
connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onSessionTitleChanged()));
connect(mpTarget, SIGNAL(textChanged()), this, SLOT(onSessionTargetChanged()));
connect(mpLicenseCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(onLicenseCurrentIndexChanged(int)));
connect(mpKeywords, SIGNAL(textChanged(QString)), this, SLOT(onKeywordChanged(QString)));
connect(mpLevel, SIGNAL(currentIndexChanged(QString)), this, SLOT(onLevelChanged(QString)));
connect(mpTopic, SIGNAL(currentIndexChanged(QString)), this, SLOT(onTopicChanged(QString)));
connect(mpAuthor, SIGNAL(textChanged(QString)), this, SLOT(onAuthorChanged(QString)));
}
UBTBDocumentEditWidget::~UBTBDocumentEditWidget()
{
DELETEPTR(mpTitleLabel);
DELETEPTR(mpTitle);
DELETEPTR(mpTargetLabel);
DELETEPTR(mpTarget);
DELETEPTR(mpMetadataLabel);
DELETEPTR(mpKeywordLabel);
DELETEPTR(mpLevelLabel);
DELETEPTR(mpTopicLabel);
DELETEPTR(mpAuthorLabel);
DELETEPTR(mpKeywords);
DELETEPTR(mpLevel);
DELETEPTR(mpTopic);
DELETEPTR(mpAuthor);
DELETEPTR(mpLicenseLabel);
DELETEPTR(mpLicenseCombox);
DELETEPTR(mpPageViewButton);
DELETEPTR(mpPreviewButton);
}
void UBTBDocumentEditWidget::onPageView()
{
emit changeTBState(eTeacherBarState_PageEdit);
}
void UBTBDocumentEditWidget::onPreview()
{
emit changeTBState(eTeacherBarState_DocumentPreview);
}
void UBTBDocumentEditWidget::onSessionTitleChanged()
{
mpDataMgr->setSessionTitle(mpTitle->text());
emit valueChanged();
}
void UBTBDocumentEditWidget::onSessionTargetChanged()
{
mpDataMgr->setSessionTarget(mpTarget->document()->toPlainText());
emit valueChanged();
}
void UBTBDocumentEditWidget::onLicenseCurrentIndexChanged(int selection)
{
mpDataMgr->setSessionLicence((eLicense)selection);
emit valueChanged();
}
void UBTBDocumentEditWidget::updateFields()
{
mpTitle->setText(mpDataMgr->sessionTitle());
mpTarget->setPlainText(mpDataMgr->sessionTarget());
mpKeywords->setText(mpDataMgr->keywords());
// TODO: retrieve the level
// TODO retrieve the topic
mpAuthor->setText(mpDataMgr->authors());
}
void UBTBDocumentEditWidget::clearFields()
{
mpTitle->setText("");
mpTarget->setPlainText("");
}
void UBTBDocumentEditWidget::onKeywordChanged(const QString &kw)
{
mpDataMgr->setKeywords(kw);
qDebug() << ">>> KEYWORD CHANGED: " << kw;
emit valueChanged();
}
void UBTBDocumentEditWidget::onLevelChanged(const QString &level)
{
mpDataMgr->setLevel(level);
emit valueChanged();
}
void UBTBDocumentEditWidget::onTopicChanged(const QString &topic)
{
mpDataMgr->setTopic(topic);
emit valueChanged();
}
void UBTBDocumentEditWidget::onAuthorChanged(const QString &authors)
{
mpDataMgr->setAuthors(authors);
emit valueChanged();
}
#ifndef UBTBDOCUMENTEDITWIDGET_H
#define UBTBDOCUMENTEDITWIDGET_H
#include <QVBoxLayout>
#include <QPushButton>
#include <QLabel>
#include <QLineEdit>
#include <QTextEdit>
#include <QComboBox>
#include "UBTeacherBarDataMgr.h"
class UBTBDocumentEditWidget : public QWidget
{
Q_OBJECT
public:
UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBDocumentEditWidget");
~UBTBDocumentEditWidget();
void updateFields();
void clearFields();
signals:
void changeTBState(eTeacherBarState state);
void valueChanged();
private slots:
void onPageView();
void onPreview();
void onSessionTitleChanged();
void onSessionTargetChanged();
void onLicenseCurrentIndexChanged(int selection);
void onKeywordChanged(const QString& kw);
void onLevelChanged(const QString& level);
void onTopicChanged(const QString& topic);
void onAuthorChanged(const QString& authors);
private:
QVBoxLayout mLayout;
QHBoxLayout mPageLayout;
QHBoxLayout mPreviewLayout;
QVBoxLayout mContainerLayout;
QPushButton* mpPageViewButton;
QPushButton* mpPreviewButton;
UBTBSeparator mTitleSeparator;
UBTBSeparator mTargetSeparator;
UBTBSeparator mLicenseSeparator;
QHBoxLayout mKeywordLayout;
QHBoxLayout mLevelLayout;
QHBoxLayout mTopicLayout;
QHBoxLayout mAuthorLayout;
QWidget* mpContainer;
QLabel* mpTitleLabel;
QLineEdit* mpTitle;
QLabel* mpTargetLabel;
QTextEdit* mpTarget;
QLabel* mpMetadataLabel;
QLabel* mpLicenseLabel;
QComboBox* mpLicenseCombox;
QLineEdit* mpKeywords;
QComboBox* mpLevel;
QComboBox* mpTopic;
QLineEdit* mpAuthor;
QLabel* mpKeywordLabel;
QLabel* mpLevelLabel;
QLabel* mpTopicLabel;
QLabel* mpAuthorLabel;
UBTeacherBarDataMgr* mpDataMgr;
};
#endif // UBTBDOCUMENTEDITWIDGET_H
#include "customWidgets/UBGlobals.h"
#include "UBTBDocumentPreviewWidget.h"
UBTBDocumentPreviewWidget::UBTBDocumentPreviewWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *parent, const char *name):QWidget(parent)
, mpPageViewButton(NULL)
, mpEditButton(NULL)
{
setObjectName(name);
mpDataMgr = pDataMgr;
setLayout(&mLayout);
mpPageViewButton = new QPushButton(tr("Page View"), this);
mpPageViewButton->setObjectName("DockPaletteWidgetButton");
mPageLayout.addStretch(1);
mPageLayout.addWidget(mpPageViewButton, 0);
mPageLayout.addStretch(1);
mLayout.addLayout(&mPageLayout);
// TODO : Add the elements here
mpEditButton = new QPushButton(tr("Edit"), this);
mpEditButton->setObjectName("DockPaletteWidgetButton");
mPreviewLayout.addStretch(1);
mPreviewLayout.addWidget(mpEditButton, 0);
mPreviewLayout.addStretch(1);
mLayout.addLayout(&mPreviewLayout);
connect(mpPageViewButton, SIGNAL(clicked()), this, SLOT(onPageView()));
connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit()));
}
UBTBDocumentPreviewWidget::~UBTBDocumentPreviewWidget()
{
DELETEPTR(mpPageViewButton);
DELETEPTR(mpEditButton);
}
void UBTBDocumentPreviewWidget::onEdit()
{
emit changeTBState(eTeacherBarState_DocumentEdit);
}
void UBTBDocumentPreviewWidget::onPageView()
{
emit changeTBState(eTeacherBarState_PagePreview);
}
void UBTBDocumentPreviewWidget::updateFields()
{
}
void UBTBDocumentPreviewWidget::clearFields()
{
}
#ifndef UBTBDOCUMENTPREVIEWWIDGET_H
#define UBTBDOCUMENTPREVIEWWIDGET_H
#include <QVBoxLayout>
#include <QPushButton>
#include "UBTeacherBarDataMgr.h"
class UBTBDocumentPreviewWidget : public QWidget
{
Q_OBJECT
public:
UBTBDocumentPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBDocumentPreviewWidget");
~UBTBDocumentPreviewWidget();
void updateFields();
void clearFields();
signals:
void changeTBState(eTeacherBarState state);
private slots:
void onPageView();
void onEdit();
private:
QVBoxLayout mLayout;
QHBoxLayout mPageLayout;
QHBoxLayout mPreviewLayout;
QPushButton* mpPageViewButton;
QPushButton* mpEditButton;
UBTeacherBarDataMgr* mpDataMgr;
};
#endif // UBTBDOCUMENTPREVIEWWIDGET_H
This diff is collapsed.
#ifndef UBTBPAGEEDITWIDGET_H
#define UBTBPAGEEDITWIDGET_H
#include <QString>
#include <QTextEdit>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QComboBox>
#include <QLabel>
#include <QPushButton>
#include "core/UBPersistenceManager.h"
#include "customWidgets/UBWidgetList.h"
#include "interfaces/IDropable.h"
#include "UBTeacherBarDataMgr.h"
class UBTeacherStudentAction : public QWidget
{
Q_OBJECT
public:
UBTeacherStudentAction(QWidget* parent=0, const char* name="UBTeacherStudentAction");
~UBTeacherStudentAction();
QString text();
QString comboValue();
void setComboValue(int value);
void setText(const QString& text);
private:
QTextEdit* mpText;
QHBoxLayout* mpLayout;
QVBoxLayout* mpComboLayout;
QComboBox* mpCombo;
};
class UBUrlWidget : public QWidget
{
public:
UBUrlWidget(QWidget* parent=0, const char* name="UBUrlWidget");
~UBUrlWidget();
QString url();
void setUrl(const QString& url);
QString title(){return mpTitle->text();}
void setTitle(const QString& title){mpTitle->setText(title);}
private:
QVBoxLayout* mpLayout;
QHBoxLayout* mpLabelLayout;
QHBoxLayout* mpTitleLayout;
QLabel* mpUrlLabel;
QLineEdit* mpUrl;
QLabel* mpTitleLabel;
QLineEdit* mpTitle;
};
class UBTBMediaContainer : public UBWidgetList
, public IDropable
{
Q_OBJECT
public:
UBTBMediaContainer(QWidget* parent=0, const char* name="UBTBMediaContainer");
~UBTBMediaContainer();
QStringList mediaUrls();
QWidget* generateMediaWidget(const QString& url);
void cleanMedias();
signals:
void mediaDropped(const QString& url);
protected:
void dropEvent(QDropEvent* pEvent);
void dragEnterEvent(QDragEnterEvent* pEvent);
void dragMoveEvent(QDragMoveEvent* pEvent);
void dragLeaveEvent(QDragLeaveEvent* pEvent);
private:
void addMedia(const QString& mediaPath);
QStringList mMediaList;
};
class UBTBPageEditWidget : public QWidget
{
Q_OBJECT
public:
UBTBPageEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBPageEditWidget");
~UBTBPageEditWidget();
void saveFields();
void updateFields();
void clearFields();
signals:
void valueChanged();
void changeTBState(eTeacherBarState state);
private slots:
void onTitleChanged();
void onCommentsChanged();
void onActionButton();
void onLinkButton();
void onMediaDropped(const QString& url);
void onDocumentEditClicked();
void onPagePreviewClicked();
private:
QVBoxLayout mLayout;
QHBoxLayout mTitleLayout;
QVBoxLayout mContainerLayout;
QHBoxLayout mActionLayout;
QHBoxLayout mLinkLayout;
QHBoxLayout mDocumentViewLayout;
QHBoxLayout mPagePreviewLayout;
UBTeacherBarDataMgr* mpDataMgr;
QLabel* mpTitleLabel;
QLineEdit* mpTitle;
QLabel* mpMediaLabel;
UBTBMediaContainer* mpMediaContainer;
QLabel* mpActionLabel;
UBWidgetList* mpActions;
QPushButton* mpActionButton;
QLabel* mpLinkLabel;
UBWidgetList* mpLinks;
QPushButton* mpLinkButton;
QLabel* mpCommentLabel;
QTextEdit* mpComments;
QPushButton* mpDocumentEditbutton;
QPushButton* mpPagePreviewButton;
QWidget* mpContainer;
QVector<UBTeacherStudentAction*> mActions;
QVector<UBUrlWidget*> mUrls;
QVector<QWidget*> mMedias;
QStringList mMediaUrls;
bool mClearingFields;
};
#endif // UBTBPAGEEDITWIDGET_H
#include "UBTeacherBarDataMgr.h"
#include "core/UBApplication.h"
#include "core/UBPersistenceManager.h"
#include "board/UBBoardController.h"
#include "customWidgets/UBGlobals.h"
#include "adaptors/UBMetadataDcSubsetAdaptor.h"
UBTeacherBarDataMgr::UBTeacherBarDataMgr()
{
}
UBTeacherBarDataMgr::~UBTeacherBarDataMgr()
{
}
void UBTeacherBarDataMgr::clearLists()
{
mActionList.clear();
mUrlList.clear();
mMediaList.clear();
mMediaUrls.clear();
}
void UBTeacherBarDataMgr::saveContent()
{
// Store the page information in the UBZ
sTeacherBarInfos infos;
// Page Title
infos.title = mPageTitle;
// Actions
foreach(sAction action, mActionList){
infos.actions << QString("%0;%1").arg(action.type).arg(action.content);
}
// Media
foreach(QString media, mMediaUrls){
infos.medias << media;
}
// Links
foreach(sLink link, mUrlList){
if("" != link.title && "" != link.link){
infos.urls << QString("%0;%1").arg(link.title).arg(link.link);
}
}
// Comments
infos.comments = mComments;
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument();
if(documentProxy){
UBPersistenceManager::persistenceManager()->persistTeacherBar(documentProxy, UBApplication::boardController->activeSceneIndex(), infos);
documentProxy->setSessionTitle(mSessionTitle);
documentProxy->setSessionTarget(mSessionTarget);
documentProxy->setSessionLicence(QString("%0").arg(mSessionLicence));
qDebug() << "Saving keywords: " << mKeywords;
documentProxy->setSessionKeywords(mKeywords);
documentProxy->setSessionLevel(mLevel);
documentProxy->setSessionTopic(mTopic);
documentProxy->setSessionAuthor(mAuthors);
UBMetadataDcSubsetAdaptor::persist(documentProxy);
}
}
void UBTeacherBarDataMgr::loadContent(bool docChanged)
{
clearLists();
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument();
sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(documentProxy, UBApplication::boardController->activeSceneIndex());
if(true/*docChanged*/){
mSessionTitle = documentProxy->sessionTitle();
mSessionTarget = documentProxy->sessionTarget();
mSessionLicence = (eLicense)documentProxy->sessionLicence().toInt();
mKeywords = documentProxy->sessionKeywords();
qDebug() << "Keywords loaded: " << mKeywords << " (" << documentProxy->sessionKeywords() << ")";
mLevel = documentProxy->sessionLevel();
mTopic = documentProxy->sessionTopic();
mAuthors = documentProxy->sessionAuthors();
}
// Page Title
mPageTitle = nextInfos.title;
// Actions
foreach(QString eachAction, nextInfos.actions){
QStringList qslAction = eachAction.split(";");
if(2 <= qslAction.size()){
sAction action;
action.type = qslAction.at(0).toInt();
action.content = qslAction.at(1);
mActionList << action;
}
}
// Media URL
if((nextInfos.medias.size() == 1) && (nextInfos.medias.at(0) == "")){
// Do not retrieve it
}
else{
mMediaUrls = nextInfos.medias;
}
// Links
foreach(QString eachUrl, nextInfos.urls){
QStringList qslUrl = eachUrl.split(';');
if(2 <= qslUrl.size()){
sLink link;
link.title = qslUrl.at(0);
link.link = qslUrl.at(1);
mUrlList << link;
}
}
// Comments
mComments = nextInfos.comments;
}
// ------------------------------------------------------------------------------------
UBTBSeparator::UBTBSeparator(QWidget *parent, const char *name):QFrame(parent)
{
setObjectName("UBTBSeparator");
setMinimumHeight(5);
setMaximumHeight(5);
}
UBTBSeparator::~UBTBSeparator()
{
}
// ------------------------------------------------------------------------------------
UBTBLicenseWidget::UBTBLicenseWidget(QWidget *parent, const char *name):QWidget(parent)
{
setObjectName(name);
setLayout(&mLayout);
mpIcon = new QLabel(this);
mpText = new QLabel(this);
mpText->setWordWrap(true);
mLayout.addWidget(mpIcon);
mLayout.addWidget(mpText);
}
UBTBLicenseWidget::~UBTBLicenseWidget()
{
DELETEPTR(mpIcon);
DELETEPTR(mpText);
}
void UBTBLicenseWidget::setLicense(eLicense lic)
{
switch(lic){
case eLicense_CCBY:
mpIcon->setPixmap(QPixmap(":images/licenses/ccby.png"));
mpText->setText(tr("Creative Common License %0").arg("CC BY"));
break;
case eLicense_CCBYND:
mpIcon->setPixmap(QPixmap(":images/licenses/ccbynd.png"));
mpText->setText(tr("Creative Common License %0").arg("CC BY-ND"));
break;
case eLicense_CCBYNCSA:
mpIcon->setPixmap(QPixmap(":images/licenses/ccbyncsa.png"));
mpText->setText(tr("Creative Common License %0").arg("CC BY-NC-SA"));
break;
case eLicense_CCBYSA:
mpIcon->setPixmap(QPixmap(":images/licenses/ccbysa.png"));
mpText->setText(tr("Creative Common License %0").arg("CC BY-SA"));
break;
case eLicense_CCBYNC:
mpIcon->setPixmap(QPixmap(":images/licenses/ccbync.png"));
mpText->setText(tr("Creative Common License %0").arg("CC BY-NC"));
break;
case eLicense_CCBYNCND:
mpIcon->setPixmap(QPixmap(":images/licenses/ccbyncnd.png"));
mpText->setText(tr("Creative Common License %0").arg("CC BY-NC-ND"));
break;
}
}
#ifndef UBTEACHERBARDATAMGR_H
#define UBTEACHERBARDATAMGR_H
#include <QString>
#include <QWidget>
#include <QTextEdit>
#include <QLineEdit>
#include <QLabel>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QComboBox>
#include <QFrame>
typedef enum{
eTeacherBarState_DocumentEdit,
eTeacherBarState_DocumentPreview,
eTeacherBarState_PageEdit,
eTeacherBarState_PagePreview
}eTeacherBarState;
typedef enum{
eActionOwner_Teacher,
eActionOwner_Student
}eActionOwner;
typedef struct{
int type;
QString content;
}sAction;
typedef struct{
QString title;
QString link;
}sLink;
typedef enum{
eLicense_CCBY,
eLicense_CCBYND,
eLicense_CCBYNCSA,
eLicense_CCBYSA,
eLicense_CCBYNC,
eLicense_CCBYNCND
}eLicense;
class UBTBSeparator : public QFrame
{
public:
UBTBSeparator(QWidget* parent=0, const char* name="UBTBSeparator");
~UBTBSeparator();
};
class UBTBLicenseWidget : public QWidget
{
public:
UBTBLicenseWidget(QWidget* parent=0, const char* name="UBTBLicenseWidget");
~UBTBLicenseWidget();
void setLicense(eLicense lic);
private:
QHBoxLayout mLayout;
QLabel* mpIcon;
QLabel* mpText;
};
class UBTeacherBarDataMgr
{
public:
UBTeacherBarDataMgr();
~UBTeacherBarDataMgr();
// Session Title
void setSessionTitle(const QString& title){mSessionTitle = title;}
QString sessionTitle(){return mSessionTitle;}
// Session Target
void setSessionTarget(const QString& target){mSessionTarget = target;}
QString sessionTarget(){return mSessionTarget;}
// Licence
void setSessionLicence(eLicense licence){mSessionLicence = licence;}
eLicense sessionLicence(){return mSessionLicence;}
// Page Title
void setPageTitle(const QString& title){mPageTitle = title;}
QString pageTitle(){return mPageTitle;}
// Actions
QVector<sAction>* actions(){return &mActionList;}
// Medias
QVector<QWidget*>* medias(){return &mMediaList;}
void addMediaUrl(const QString& url){mMediaUrls << url;}
QStringList* mediaUrls(){return &mMediaUrls;}
// Urls
QVector<sLink>* urls(){return &mUrlList;}
// Comments
void setComments(const QString& c){mComments = c;}
QString comments(){return mComments;}
// Keywords
void setKeywords(const QString& kw){mKeywords = kw;}
QString keywords(){return mKeywords;}
// Level
void setLevel(const QString& level){mLevel = level;}
QString level(){return mLevel;}
// Topic
void setTopic(const QString& topic){mTopic = topic;}
QString topic(){return mTopic;}
// Authors
void setAuthors(const QString& authors){mAuthors = authors;}
QString authors(){return mAuthors;}
// Others
void clearLists();
void saveContent();
void loadContent(bool docChanged = false);
private:
QString mSessionTitle;
QString mSessionTarget;
eLicense mSessionLicence;
QString mPageTitle;
QString mComments;
QString mKeywords;
QString mLevel;
QString mTopic;
QString mAuthors;
QVector<sAction> mActionList;
QVector<sLink> mUrlList;
QVector<QWidget*> mMediaList;
QStringList mMediaUrls;
};
#endif // UBTEACHERBARDATAMGR_H
This diff is collapsed.
#ifndef UBTEACHERBARPREVIEWWIDGET_H
#define UBTEACHERBARPREVIEWWIDGET_H
#include <QLabel>
#include <QVBoxLayout>
#include <QPushButton>
#include "core/UBPersistenceManager.h"
#include "customWidgets/UBWidgetList.h"
#include "customWidgets/UBMediaWidget.h"
#include "customWidgets/UBDraggableMedia.h"
#include "customWidgets/UBDraggableLabel.h"
#include "UBTeacherBarDataMgr.h"
class UBTeacherBarPreviewMedia : public QWidget
{
Q_OBJECT
public:
UBTeacherBarPreviewMedia(QWidget* parent=0, const char* name="UBTeacherBarPreviewMedia");
~UBTeacherBarPreviewMedia();
// int loadMedia(QStringList pMedias);
void loadWidgets(QList<QWidget*> pWidgetList, bool isResizable = true);
void cleanMedia();
private:
UBWidgetList* mWidget;
QVBoxLayout mLayout;
QMap<QWidget*,QString>mWidgetList;
};
class UBActionPreview : public QWidget
{
public:
UBActionPreview(QWidget* parent=0, const char* name="UBActionPreview");
~UBActionPreview();
void setOwner(int owner);
void setContent(const QString& content);
private:
QLabel* mpOwner;
QTextEdit* mpContent;
QVBoxLayout mLayout;
QHBoxLayout mOwnerLayout;
};
class UBTBPreviewContainer : public UBWidgetList
{
public:
UBTBPreviewContainer(QWidget* parent=0, const char* name="UBTBPreviewContainer");
~UBTBPreviewContainer();
};
class UBTeacherBarPreviewWidget : public QWidget
{
Q_OBJECT
public:
UBTeacherBarPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTeacherBarPreviewWidget");
~UBTeacherBarPreviewWidget();
void updateFields();
void clearFields();
signals:
void showEditMode();
protected:
void showEvent(QShowEvent* ev);
private slots:
void onEdit();
void onActiveSceneChanged();
private:
void generateActions();
void generateMedias();
void generateLinks();
void generateComments();
QVBoxLayout mLayout;
QHBoxLayout mEditLayout;
QPushButton* mpEditButton;
// Titles
QVBoxLayout mTitleLayout;
UBTBSeparator mTitleSeparator;
QWidget* mpTitleContainer;
QLabel* mpSessionTitle;
QLabel* mpTitle;
QLabel* mpTitleLabel;
QLabel* mpPageNbrLabel;
UBTBPreviewContainer* mpContentContainer;
// Schedule
QLabel* mpScheduleLabel;
// License
UBTBSeparator mLicenseSeparator;
// TODO : replace the QLabel of the license by a widget done for that!
UBTBLicenseWidget* mpLicenseLabel;
/** Pointer to the datas */
UBTeacherBarDataMgr* mpDataMgr;
/** The list of stored widgets */
QList<QWidget*> mStoredWidgets;
/** A temporary action widget */
UBActionPreview* mpTmpAction;
/** A temporary media widget */
UBTeacherBarPreviewMedia* mpTmpMedia;
/** A temporary link */
QLabel* mpTmpLink;
/** A temporary comments field */
QTextEdit* mpTmpComment;
/** A temporary media object */
UBDraggableMedia* mTmpMedia;
/** A temporary label object */
UBDraggableLabel* mpTmpLabel;
};
#endif // UBTEACHERBARPREVIEWWIDGET_H
This diff is collapsed.
......@@ -7,38 +7,24 @@
#include <QLabel>
#include <QTextEdit>
#include <QLineEdit>
#include <QCheckBox>
#include <QTabWidget>
#include <QButtonGroup>
#include <QPushButton>
#include <QComboBox>
#include <QStackedWidget>
#include "UBDockPaletteWidget.h"
#include "customWidgets/UBWidgetList.h"
#include "interfaces/IDropable.h"
#include "UBTeacherBarDataMgr.h"
#include "UBTBDocumentPreviewWidget.h"
#include "UBTBPageEditWidget.h"
#include "UBTeacherBarPreviewWidget.h"
#include "UBTBDocumentEditWidget.h"
#define LABEL_MINWIDHT 80
class UBTeacherStudentAction : public QWidget
{
Q_OBJECT
public:
UBTeacherStudentAction(int actionNumber, QWidget* parent=0, const char* name="UBTeacherStudentAction");
~UBTeacherStudentAction();
QString teacherText();
QString studentText();
void setTeacherText(QString text);
void setStudentText(QString text);
QTextEdit* teacher();
QTextEdit* student();
private:
int mActionNumber;
QLabel* mpActionLabel;
QLabel* mpTeacherLabel;
QLabel* mpStudentLabel;
QTextEdit* mpTeacher;
QTextEdit* mpStudent;
QVBoxLayout* mpLayout;
QHBoxLayout* mpTeacherLayout;
QHBoxLayout* mpStudentLayout;
};
class UBTeacherBarWidget : public UBDockPaletteWidget
{
Q_OBJECT
......@@ -48,41 +34,34 @@ public:
bool visibleInMode(eUBDockPaletteWidgetMode mode)
{
return (mode == eUBDockPaletteWidget_BOARD) || (mode == eUBDockPaletteWidget_DESKTOP);
return (mode == eUBDockPaletteWidget_BOARD);
}
void loadContent(bool docChanged = false);
public slots:
void saveContent();
void loadContent();
private slots:
void loadContentInfos();
void onValueChanged();
void onTitleTextChanged(const QString& text);
void onEquipmentTextChanged(const QString& text);
void onShowEditMode();
void onTBStateChanged(eTeacherBarState state);
void onActiveDocumentChanged();
private:
void populateCombos();
bool isEmpty();
QVBoxLayout mLayout;
QStackedWidget* mpStackWidget;
eTeacherBarState mState;
UBTBPageEditWidget* mpPageEditWidget;
UBTeacherBarPreviewWidget* mpPreview;
UBTBDocumentPreviewWidget* mpDocPreviewWidget;
UBTBDocumentEditWidget* mpDocEditWidget;
QVBoxLayout* mpLayout;
QHBoxLayout* mpTitleLayout;
QHBoxLayout* mpPhasisLayout;
QHBoxLayout* mpDurationLayout;
QHBoxLayout* mpEquipmentLayout;
QHBoxLayout* mpActivityLayout;
QLabel* mpTitleLabel;
QLabel* mpPhasisLabel;
QLabel* mpDurationLabel;
QLabel* mpEquipmentLabel;
QLabel* mpActivityLabel;
QLineEdit* mpTitle;
QLineEdit* mpEquipment;
QComboBox* mpPhasis;
QComboBox* mpDuration;
QComboBox* mpActivity;
UBTeacherStudentAction* mpAction1;
UBTeacherStudentAction* mpAction2;
UBTeacherStudentAction* mpAction3;
QWidget* mpContainer;
QVBoxLayout* mpContainerLayout;
UBTeacherBarDataMgr mData;
};
#endif // UBTEACHERBARWIDGET_H
......@@ -35,6 +35,11 @@ class UBVideoPlayer : public QWidget
return mVideoPlayer;
}
void loadMedia(QUrl url)
{
mVideoPlayer->load(Phonon::MediaSource(url));
}
protected:
Phonon::VideoPlayer* mVideoPlayer;
......
This diff is collapsed.
#ifndef IDROPABLE_H
#define IDROPABLE_H
#include <QDropEvent>
#include <QDragEnterEvent>
#include <QDragLeaveEvent>
#include <QDragMoveEvent>
class IDropable
{
public:
virtual ~IDropable(){}
protected:
virtual void dropEvent(QDropEvent* pEvent) = 0;
virtual void dragEnterEvent(QDragEnterEvent* pEvent) = 0;
virtual void dragMoveEvent(QDragMoveEvent* pEvent) = 0;
virtual void dragLeaveEvent(QDragLeaveEvent* pEvent) = 0;
};
#endif // IDROPABLE_H
#ifndef IRESIZEABLE_H
#define IRESIZEABLE_H
#include <QResizeEvent>
class IResizeable
{
public:
~IResizeable();
protected:
virtual void resizeEvent(QResizeEvent* pEvent) = 0;
};
#endif // IRESIZEABLE_H
HEADERS += src/interfaces/IDropable.h \
src/interfaces/IDropable.h \
src/interfaces/IResizeable.h
......@@ -24,7 +24,7 @@
#include "core/UBSetting.h"
#include "gui/UBMainWindow.h"
#include "gui/UBVideoPlayer.h"
//#include "gui/UBVideoPlayer.h"
#include "network/UBNetworkAccessManager.h"
#include "network/UBServerXMLHttpRequest.h"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment