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

Conflicts:
	src/adaptors/UBSvgSubsetAdaptor.cpp
preferencesAboutTextFull
Didier 14 years ago
commit bfd3c05b2c
  1. 2
      src/adaptors/UBExportDocument.cpp
  2. 8
      src/adaptors/UBImportVirtualPrinter.cpp
  3. 2
      src/adaptors/UBMetadataDcSubsetAdaptor.cpp
  4. 23
      src/adaptors/UBSvgSubsetAdaptor.cpp
  5. 2
      src/adaptors/UBWebPublisher.cpp
  6. 522
      src/adaptors/publishing/UBDocumentPublisher.cpp
  7. 82
      src/adaptors/publishing/UBDocumentPublisher.h
  8. 2
      src/board/UBBoardController.cpp
  9. 4
      src/board/UBBoardPaletteManager.cpp
  10. 20
      src/core/UBApplication.cpp
  11. 1
      src/core/UBApplication.h
  12. 31
      src/core/UBApplicationController.cpp
  13. 4
      src/core/UBApplicationController.h
  14. 6
      src/core/UBDocumentManager.cpp
  15. 2
      src/core/UBPersistenceManager.cpp
  16. 2
      src/document/UBDocumentController.cpp
  17. 6
      src/document/UBDocumentController.h
  18. 42
      src/frameworks/UBPlatformUtils_mac.mm
  19. 14
      src/gui/UBMainWindow.cpp
  20. 5
      src/gui/UBMainWindow.h
  21. 2
      src/podcast/UBPodcastController.cpp
  22. 125
      src/tools/UBAbstractDrawRuler.h
  23. 239
      src/tools/UBGraphicsProtractor.cpp
  24. 10
      src/tools/UBGraphicsProtractor.h
  25. 2
      src/web/browser/WBWebView.cpp

@ -99,5 +99,5 @@ QString UBExportDocument::exportExtention()
QString UBExportDocument::exportName() QString UBExportDocument::exportName()
{ {
return tr("Export to Uniboard Format"); return tr("Export to Sankore Format");
} }

@ -132,7 +132,7 @@ void UBImportVirtualPrinter::cleanUp(const QFile& pFile, const QString& pPdfFile
UBDocumentProxy* UBImportVirtualPrinter::importFile(const QFile& pFile, const QString& pGroup) UBDocumentProxy* UBImportVirtualPrinter::importFile(const QFile& pFile, const QString& pGroup)
{ {
UBApplication::showMessage(tr("Importing Uniboard printer file ...")); UBApplication::showMessage(tr("Importing Sankore printer file ..."));
UBDocumentProxy *document = 0; UBDocumentProxy *document = 0;
QString pdfFilename = pdfFileName(pFile); QString pdfFilename = pdfFileName(pFile);
@ -159,7 +159,7 @@ UBDocumentProxy* UBImportVirtualPrinter::importFile(const QFile& pFile, const QS
if (!document) if (!document)
{ {
UBApplication::showMessage(tr("Error while importing Uniboard printer file.")); UBApplication::showMessage(tr("Error while importing Sankore printer file."));
} }
cleanUp(pFile, pdfFilename, emfFileNames(pFile)); cleanUp(pFile, pdfFilename, emfFileNames(pFile));
@ -170,7 +170,7 @@ UBDocumentProxy* UBImportVirtualPrinter::importFile(const QFile& pFile, const QS
bool UBImportVirtualPrinter::addFileToDocument(UBDocumentProxy* pDocument, const QFile& pFile) bool UBImportVirtualPrinter::addFileToDocument(UBDocumentProxy* pDocument, const QFile& pFile)
{ {
UBApplication::showMessage(tr("Importing Uniboard printer file ...")); UBApplication::showMessage(tr("Importing Sankore printer file ..."));
bool result = false; bool result = false;
QString pdfFilename = pdfFileName(pFile); QString pdfFilename = pdfFileName(pFile);
@ -183,7 +183,7 @@ bool UBImportVirtualPrinter::addFileToDocument(UBDocumentProxy* pDocument, const
if (!result) if (!result)
{ {
UBApplication::showMessage(tr("Error while importing Uniboard printer file.")); UBApplication::showMessage(tr("Error while importing Sankore printer file."));
} }
cleanUp(pFile, pdfFilename, emfFileNames(pFile)); cleanUp(pFile, pdfFilename, emfFileNames(pFile));

@ -204,7 +204,7 @@ QMap<QString, QVariant> UBMetadataDcSubsetAdaptor::load(QString pPath)
if (xml.hasError()) if (xml.hasError())
{ {
qWarning() << "error parsing uniboard metadata.rdf file " << xml.errorString(); qWarning() << "error parsing sankore metadata.rdf file " << xml.errorString();
} }
} }

@ -781,7 +781,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
if (mXmlReader.hasError()) if (mXmlReader.hasError())
{ {
qWarning() << "error parsing uniboard file " << mXmlReader.errorString(); qWarning() << "error parsing Sankore file " << mXmlReader.errorString();
} }
if (scene) if (scene)
@ -2576,31 +2576,16 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg()
graphicsItemFromSvg(triangle); graphicsItemFromSvg(triangle);
//QStringRef angle = mXmlReader.attributes().value(mNamespaceUri, "angle");
//if (!angle.isNull())
//{
// protractor->setAngle(angle.toString().toFloat());
//}
//QStringRef markerAngle = mXmlReader.attributes().value(mNamespaceUri, "marker-angle");
//if (!markerAngle.isNull())
//{
// protractor->setMarkerAngle(markerAngle.toString().toFloat());
//}
QStringRef svgX = mXmlReader.attributes().value("x"); QStringRef svgX = mXmlReader.attributes().value("x");
QStringRef svgY = mXmlReader.attributes().value("y"); QStringRef svgY = mXmlReader.attributes().value("y");
QStringRef svgWidth = mXmlReader.attributes().value("width"); QStringRef svgWidth = mXmlReader.attributes().value("width");
QStringRef svgHeight = mXmlReader.attributes().value("height"); QStringRef svgHeight = mXmlReader.attributes().value("height");
QStringRef orientationStringRef = mXmlReader.attributes().value("orientation");
UBGraphicsTriangle::UBGraphicsTriangleOrientation orientation = UBGraphicsTriangle::UBGraphicsTriangleOrientation orientation = UBGraphicsTriangle::orientationFromStr(orientationStringRef);
UBGraphicsTriangle::orientationFromStr((mXmlReader.attributes().value("orientation")));
if (!svgX.isNull() && !svgY.isNull() && !svgWidth.isNull() && !svgHeight.isNull()) if (!svgX.isNull() && !svgY.isNull() && !svgWidth.isNull() && !svgHeight.isNull())
{ {
triangle->setRect(svgX.toString().toFloat(), svgY.toString().toFloat() triangle->setRect(svgX.toString().toFloat(), svgY.toString().toFloat(), svgWidth.toString().toFloat(), svgHeight.toString().toFloat(), orientation);
, svgWidth.toString().toFloat(), svgHeight.toString().toFloat(),
orientation);
} }
triangle->setVisible(true); triangle->setVisible(true);

@ -28,7 +28,7 @@ UBWebPublisher::~UBWebPublisher()
QString UBWebPublisher::exportName() QString UBWebPublisher::exportName()
{ {
return tr("Publish Document on Uniboard Web"); return tr("Publish Document on Sankore Web");
} }

@ -1,4 +1,4 @@
#include "UBDocumentPublisher.h" #include "UBDocumentPublisher.h"
#include "frameworks/UBPlatformUtils.h" #include "frameworks/UBPlatformUtils.h"
#include "frameworks/UBFileSystemUtils.h" #include "frameworks/UBFileSystemUtils.h"
@ -10,6 +10,7 @@
#include "core/UBDocumentManager.h" #include "core/UBDocumentManager.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "core/UBPersistenceManager.h" #include "core/UBPersistenceManager.h"
#include "core/UBApplicationController.h"
#include "gui/UBMainWindow.h" #include "gui/UBMainWindow.h"
@ -28,162 +29,119 @@
#include "core/memcheck.h" #include "core/memcheck.h"
UBDocumentPublisher::UBDocumentPublisher(UBDocumentProxy* pDocument, QObject *parent) UBDocumentPublisher::UBDocumentPublisher(UBDocumentProxy* pDocument, QObject *parent)
: UBAbstractPublisher(parent) : UBAbstractPublisher(parent)
, mSourceDocument(pDocument) , mSourceDocument(pDocument)
, mPublishingDocument(0) , mPublishingDocument(0)
, mUsername("")
, mPassword("")
{ {
connect(this, SIGNAL(authenticated(const QUuid&, const QString&)) mpWebView = new QWebView(0);
, this, SLOT(postDocument(const QUuid&, const QString&))); UBApplication::mainWindow->addSankoreWebDocumentWidget(mpWebView);
mpWebView->setWindowTitle(tr("Sankore Uploading Page"));
mpWebView->setAcceptDrops(false);
connect(mpWebView, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool)));
connect(mpWebView, SIGNAL(linkClicked(QUrl)), this, SLOT(onLinkClicked(QUrl)));
init();
} }
UBDocumentPublisher::~UBDocumentPublisher() UBDocumentPublisher::~UBDocumentPublisher()
{ {
delete mpWebView;
delete mPublishingDocument; delete mPublishingDocument;
} }
void UBDocumentPublisher::publish() void UBDocumentPublisher::publish()
{ {
UBAbstractPublisher::authenticate(); //check that the username and password are stored on preferences
mUsername = "Admin";
mPassword = "admin";
buildUbwFile();
UBApplication::showMessage(tr("Uploading Sankore File on Web."));
sendUbw();
} }
void UBDocumentPublisher::postDocument(const QUuid& tokenUuid, const QString& encryptedBase64Token) void UBDocumentPublisher::buildUbwFile()
{ {
mAuthenticationUuid = tokenUuid; QDir d;
mAuthenticationBase64Token = encryptedBase64Token; d.mkpath(UBFileSystemUtils::defaultTempDirPath());
UBDocumentPublishingDialog dialog(UBApplication::mainWindow);
dialog.videoWarning->setVisible(UBPersistenceManager::persistenceManager()->mayHaveVideo(mSourceDocument));
dialog.title->setText(mSourceDocument->name());
QString defaultEMail = UBSettings::settings()->uniboardWebEMail->get().toString();
dialog.email->setText(defaultEMail);
QString defaultAuthor = UBSettings::settings()->uniboardWebAuthor->get().toString(); QString tmpDir = UBFileSystemUtils::createTempDir();
dialog.author->setText(defaultAuthor);
if (dialog.exec() == QDialog::Accepted) if (UBFileSystemUtils::copyDir(mSourceDocument->persistencePath(), tmpDir))
{ {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QUuid publishingUuid = QUuid::createUuid();
UBApplication::showMessage(tr("Preparing document for upload..."), true);
mTitle = dialog.title->text(); mPublishingDocument = new UBDocumentProxy(tmpDir);
mDescription = dialog.description->toPlainText(); mPublishingDocument->setPageCount(mSourceDocument->pageCount());
mEMail = dialog.email->text();
mAuthor = dialog.author->text();
bool attachPDF = dialog.attachPDF->isChecked(); rasterizeScenes();
bool attachUBZ = dialog.attachUBZ->isChecked();
mPublishingServiceUrl = UBSettings::settings()->documentsPublishingUrl; upgradeDocumentForPublishing();
UBSettings::settings()->uniboardWebEMail->set(mEMail); UBExportFullPDF pdfExporter;
UBSettings::settings()->uniboardWebAuthor->set(mAuthor); pdfExporter.setVerbode(false);
pdfExporter.persistsDocument(mSourceDocument, mPublishingDocument->persistencePath() + "/" + UBStringUtils::toCanonicalUuid(publishingUuid) + ".pdf");
QDir d; UBExportDocument ubzExporter;
d.mkpath(UBFileSystemUtils::defaultTempDirPath()); ubzExporter.setVerbode(false);
ubzExporter.persistsDocument(mSourceDocument, mPublishingDocument->persistencePath() + "/" + UBStringUtils::toCanonicalUuid(publishingUuid) + ".ubz");
QString tmpDir = UBFileSystemUtils::createTempDir();
if (UBFileSystemUtils::copyDir(mSourceDocument->persistencePath(), tmpDir)) // remove all useless files
{
QUuid publishingUuid = QUuid::createUuid();
mPublishingDocument = new UBDocumentProxy(tmpDir);
mPublishingDocument->setPageCount(mSourceDocument->pageCount());
rasterizeScenes();
//rasterizePDF(); // not needed as we do not publish svg file anymore
//rasterizeSVGImages(); // not needed as we do not publish svg file anymore
upgradeDocumentForPublishing(); for (int pageIndex = 0; pageIndex < mPublishingDocument->pageCount(); pageIndex++) {
QString filename = mPublishingDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", pageIndex + 1);
if (attachPDF) QFile::remove(filename);
{ }
UBExportFullPDF pdfExporter;
pdfExporter.setVerbode(false);
pdfExporter.persistsDocument(mSourceDocument,
mPublishingDocument->persistencePath() + "/" + UBStringUtils::toCanonicalUuid(publishingUuid) + ".pdf");
}
if (attachUBZ)
{
UBExportDocument ubzExporter;
ubzExporter.setVerbode(false);
ubzExporter.persistsDocument(mSourceDocument,
mPublishingDocument->persistencePath() + "/" + UBStringUtils::toCanonicalUuid(publishingUuid) + ".ubz");
}
// remove all useless files
for (int pageIndex = 0; pageIndex < mPublishingDocument->pageCount(); pageIndex++)
{
QString filename = mPublishingDocument->persistencePath() +
UBFileSystemUtils::digitFileFormat("/page%1.svg", pageIndex + 1);
QFile::remove(filename);
}
UBFileSystemUtils::deleteDir(mPublishingDocument->persistencePath() + "/" + UBPersistenceManager::imageDirectory);
UBFileSystemUtils::deleteDir(mPublishingDocument->persistencePath() + "/" + UBPersistenceManager::objectDirectory);
UBFileSystemUtils::deleteDir(mPublishingDocument->persistencePath() + "/" + UBPersistenceManager::videoDirectory);
UBFileSystemUtils::deleteDir(mPublishingDocument->persistencePath() + "/" + UBPersistenceManager::audioDirectory);
QString tempZipFile = UBFileSystemUtils::defaultTempDirPath()
+ "/" + UBStringUtils::toCanonicalUuid(QUuid::createUuid()) + ".zip";
//qDebug() << "compressing" << mPublishingDocument->persistencePath() << "in" << tempZipFile;
QuaZip zip(tempZipFile); UBFileSystemUtils::deleteDir(mPublishingDocument->persistencePath() + "/" + UBPersistenceManager::imageDirectory);
zip.setFileNameCodec("UTF-8"); UBFileSystemUtils::deleteDir(mPublishingDocument->persistencePath() + "/" + UBPersistenceManager::objectDirectory);
if (!zip.open(QuaZip::mdCreate)) UBFileSystemUtils::deleteDir(mPublishingDocument->persistencePath() + "/" + UBPersistenceManager::videoDirectory);
{ UBFileSystemUtils::deleteDir(mPublishingDocument->persistencePath() + "/" + UBPersistenceManager::audioDirectory);
qWarning() << "Export failed. Cause: zip.open(): " << zip.getZipError() << "," << tempZipFile;
QApplication::restoreOverrideCursor();
return;
}
QuaZipFile outFile(&zip); mTmpZipFile = UBFileSystemUtils::defaultTempDirPath() + "/" + UBStringUtils::toCanonicalUuid(QUuid::createUuid()) + ".zip";
if (!UBFileSystemUtils::compressDirInZip(mPublishingDocument->persistencePath(), "", &outFile, true)) QuaZip zip(mTmpZipFile);
{ zip.setFileNameCodec("UTF-8");
qWarning("Export failed. compressDirInZip failed ..."); if (!zip.open(QuaZip::mdCreate))
zip.close(); {
//zip.remove(); qWarning() << "Export failed. Cause: zip.open(): " << zip.getZipError() << "," << mTmpZipFile;
UBApplication::showMessage(tr("Export failed.")); QApplication::restoreOverrideCursor();
QApplication::restoreOverrideCursor(); return;
return; }
}
if (zip.getZipError() != 0) QuaZipFile outFile(&zip);
{
qWarning("Export failed. Cause: zip.close(): %d", zip.getZipError());
zip.close();
//zip.remove();
UBApplication::showMessage(tr("Export failed."));
QApplication::restoreOverrideCursor();
return;
}
if (!UBFileSystemUtils::compressDirInZip(mPublishingDocument->persistencePath(), "", &outFile, true))
{
qWarning("Export failed. compressDirInZip failed ...");
zip.close(); zip.close();
UBApplication::showMessage(tr("Export failed."));
mPublishingUrl = QUrl(mPublishingServiceUrl + "/documents/publish/" QApplication::restoreOverrideCursor();
+ UBStringUtils::toCanonicalUuid(mSourceDocument->uuid())); return;
sendZipToUniboardWeb(tempZipFile, publishingUuid);
} }
else
if (zip.getZipError() != 0)
{ {
UBApplication::showMessage(tr("Export failed ...")); qWarning("Export failed. Cause: zip.close(): %d", zip.getZipError());
zip.close();
UBApplication::showMessage(tr("Export failed."));
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
return;
} }
zip.close();
} }
else else
{ {
@ -192,64 +150,16 @@ void UBDocumentPublisher::postDocument(const QUuid& tokenUuid, const QString& en
} }
} }
/*
* // not needed as we do not publish svg file anymore
*
void UBDocumentPublisher::rasterizePDF()
{
if (UBPersistenceManager::persistenceManager()->mayHavePDF(mPublishingDocument))
{
UBSvgSubsetAdaptor::convertPDFObjectsToImages(mPublishingDocument);
QDir objectDir(mPublishingDocument->persistencePath() + "/" + UBPersistenceManager::objectDirectory);
QStringList filters;
filters << "*.pdf";
foreach(QFileInfo fi, objectDir.entryInfoList(filters))
{
QFile::remove(fi.absoluteFilePath());
}
}
}
*/
/*
* // not needed as we do not publish svg file anymore
void UBDocumentPublisher::rasterizeSVGImages()
{
if (UBPersistenceManager::persistenceManager()->mayHaveSVGImages(mPublishingDocument))
{
UBSvgSubsetAdaptor::convertSvgImagesToImages(mPublishingDocument);
QDir objectDir(mPublishingDocument->persistencePath() + "/" + UBPersistenceManager::imageDirectory);
QStringList filters;
filters << "*.svg";
foreach(QFileInfo fi, objectDir.entryInfoList(filters))
{
QFile::remove(fi.absoluteFilePath());
}
}
}
*/
void UBDocumentPublisher::rasterizeScenes() void UBDocumentPublisher::rasterizeScenes()
{ {
for(int pageIndex = 0; pageIndex < mPublishingDocument->pageCount(); pageIndex++) for (int pageIndex = 0; pageIndex < mPublishingDocument->pageCount(); pageIndex++)
{ {
UBApplication::showMessage(tr("Converting page %1/%2 ...").arg(pageIndex + 1).arg(mPublishingDocument->pageCount()), true); UBApplication::showMessage(tr("Converting page %1/%2 ...").arg(pageIndex + 1).arg(mPublishingDocument->pageCount()), true);
UBSvgSubsetRasterizer rasterizer(mPublishingDocument, pageIndex); UBSvgSubsetRasterizer rasterizer(mPublishingDocument, pageIndex);
QString filename = mPublishingDocument->persistencePath() + QString filename = mPublishingDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.jpg", pageIndex + 1);
UBFileSystemUtils::digitFileFormat("/page%1.jpg", pageIndex + 1);
rasterizer.rasterizeToFile(filename); rasterizer.rasterizeToFile(filename);
@ -275,7 +185,7 @@ void UBDocumentPublisher::updateGoogleMapApiKey()
{ {
QFile file(fileInfo.absoluteFilePath()); QFile file(fileInfo.absoluteFilePath());
if(file.open(QIODevice::ReadWrite)) if (file.open(QIODevice::ReadWrite))
{ {
QTextStream stream(&file); QTextStream stream(&file);
QString content = stream.readAll(); QString content = stream.readAll();
@ -298,7 +208,7 @@ void UBDocumentPublisher::updateGoogleMapApiKey()
void UBDocumentPublisher::upgradeDocumentForPublishing() void UBDocumentPublisher::upgradeDocumentForPublishing()
{ {
for(int pageIndex = 0; pageIndex < mPublishingDocument->pageCount(); pageIndex++) for (int pageIndex = 0; pageIndex < mPublishingDocument->pageCount(); pageIndex++)
{ {
UBGraphicsScene *scene = UBSvgSubsetAdaptor::loadScene(mPublishingDocument, pageIndex); UBGraphicsScene *scene = UBSvgSubsetAdaptor::loadScene(mPublishingDocument, pageIndex);
@ -306,25 +216,17 @@ void UBDocumentPublisher::upgradeDocumentForPublishing()
QList<UBGraphicsW3CWidgetItem*> widgets; QList<UBGraphicsW3CWidgetItem*> widgets;
foreach(QGraphicsItem* item, scene->items()) foreach(QGraphicsItem* item, scene->items()){
{
UBGraphicsW3CWidgetItem *widgetItem = dynamic_cast<UBGraphicsW3CWidgetItem*>(item); UBGraphicsW3CWidgetItem *widgetItem = dynamic_cast<UBGraphicsW3CWidgetItem*>(item);
if (widgetItem) if(widgetItem){
{
generateWidgetPropertyScript(widgetItem, pageIndex + 1); generateWidgetPropertyScript(widgetItem, pageIndex + 1);
sceneHasWidget = true; sceneHasWidget = true;
widgets << widgetItem; widgets << widgetItem;
} }
} }
//if (sceneHasWidget) QString filename = mPublishingDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.json", pageIndex + 1);
//{
// updateSVGForWidget(pageIndex); // not needed as we do not publish svg file anymore
//}
QString filename = mPublishingDocument->persistencePath() +
UBFileSystemUtils::digitFileFormat("/page%1.json", pageIndex + 1);
QFile jsonFile(filename); QFile jsonFile(filename);
if (jsonFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) if (jsonFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
@ -381,10 +283,10 @@ void UBDocumentPublisher::upgradeDocumentForPublishing()
sep = ""; sep = "";
jsonFile.write(QString(" \"%1\": \"%2\"%3\n") jsonFile.write(QString(" \"%1\": \"%2\"%3\n")
.arg(key) .arg(key)
.arg(preferences.value(key)) .arg(preferences.value(key))
.arg(sep) .arg(sep)
.toUtf8()); .toUtf8());
} }
jsonFile.write(QString(" },\n").toUtf8()); jsonFile.write(QString(" },\n").toUtf8());
@ -399,10 +301,10 @@ void UBDocumentPublisher::upgradeDocumentForPublishing()
sep = ""; sep = "";
jsonFile.write(QString(" \"%1\": \"%2\"%3\n") jsonFile.write(QString(" \"%1\": \"%2\"%3\n")
.arg(entry) .arg(entry)
.arg(datastoreEntries.value(entry)) .arg(datastoreEntries.value(entry))
.arg(sep) .arg(sep)
.toUtf8()); .toUtf8());
} }
jsonFile.write(QString(" }\n").toUtf8()); jsonFile.write(QString(" }\n").toUtf8());
@ -426,57 +328,6 @@ void UBDocumentPublisher::upgradeDocumentForPublishing()
} }
/** // not needed as we do not publish svg file anymore
void UBDocumentPublisher::updateSVGForWidget(int pageIndex)
{
QString fileName = mPublishingDocument->persistencePath() +
UBFileSystemUtils::digitFileFormat("/page%1.svg", pageIndex + 1);
QFile svgFile(fileName);
if (svgFile.exists())
{
if (!svgFile.open(QIODevice::ReadWrite))
{
qWarning() << "Cannot open file " << fileName << " for widget upgrade ...";
return;
}
QTextStream stream(&svgFile);
QStringList lines;
QString line;
do
{
line = stream.readLine();
if (!line.isNull())
{
if (line.contains("<svg") && line.contains(">")) // TODO UB 4.6, this is naive ... the SVG tag may be on several lines
{
lines << "<?xml-stylesheet type=\"text/css\" href=\"" + UBSettings::settings()->documentPlayerCssUrl + "\" ?>";
lines << line;
lines << "";
lines << " <script type=\"text/ecmascript\" xlink:href=\"" + UBSettings::settings()->documentPlayerScriptUrl + "\"/>";
lines << " <script type=\"text/ecmascript\" xlink:href=\"" + UBSettings::settings()->documentPlayerPageScriptUrl + "\"/>";
lines << "";
}
else
{
lines << line;
}
}
}
while (!line.isNull());
svgFile.resize(0);
svgFile.write(lines.join("\n").toUtf8()); // TODO UB 4.x detect real html encoding
svgFile.close();
}
}
*/
void UBDocumentPublisher::generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *widgetItem, int pageNumber) void UBDocumentPublisher::generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *widgetItem, int pageNumber)
{ {
@ -487,15 +338,13 @@ void UBDocumentPublisher::generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *
if (!startFileName.startsWith("http://")) if (!startFileName.startsWith("http://"))
{ {
QString startFilePath = mPublishingDocument->persistencePath() + "/" QString startFilePath = mPublishingDocument->persistencePath() + "/" + UBPersistenceManager::widgetDirectory + "/" + widgetItem->uuid().toString() + ".wgt/" + startFileName;
+ UBPersistenceManager::widgetDirectory + "/"
+ widgetItem->uuid().toString() + ".wgt/" + startFileName;
QFile startFile(startFilePath); QFile startFile(startFilePath);
if(startFile.exists()) if (startFile.exists())
{ {
if(startFile.open(QIODevice::ReadWrite)) if (startFile.open(QIODevice::ReadWrite))
{ {
QTextStream stream(&startFile); QTextStream stream(&startFile);
QStringList lines; QStringList lines;
@ -663,111 +512,138 @@ void UBDocumentPublisher::generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *
} }
} }
} }
else else{
{
qWarning() << "Remote Widget start file, cannot inject widget preferences and datastore entries"; qWarning() << "Remote Widget start file, cannot inject widget preferences and datastore entries";
} }
} }
void UBDocumentPublisher::sendZipToUniboardWeb(const QString& zipFilePath, const QUuid& publishingUuid)
{
QFile zipFile(zipFilePath);
if(!zipFile.open(QIODevice::ReadOnly))
{
qWarning() << "Cannot open file" << zipFilePath << "for upload to Uniboard Web";
return;
}
QUrl publishingEndpoint = QUrl(mPublishingServiceUrl);
mUploadRequest = new UBServerXMLHttpRequest(UBNetworkAccessManager::defaultAccessManager() void UBDocumentPublisher::init()
, "application/octet-stream");
mUploadRequest->setVerbose(true);
connect(mUploadRequest, SIGNAL(progress(qint64, qint64)), this, SLOT(uploadProgress(qint64, qint64)));
connect(mUploadRequest, SIGNAL(finished(bool, const QByteArray&)), this, SLOT(postZipUploadResponse(bool, const QByteArray&)));
mUploadRequest->addHeader("Publishing-UUID", UBStringUtils::toCanonicalUuid(publishingUuid));
mUploadRequest->addHeader("Document-UUID", UBStringUtils::toCanonicalUuid(mSourceDocument->uuid()));
mUploadRequest->addHeader("Document-PageCount", QString("%1").arg(mSourceDocument->pageCount()));
mUploadRequest->addHeader("Document-Title", mTitle);
mUploadRequest->addHeader("Document-Author", mAuthor);
mUploadRequest->addHeader("Document-AuthorEMail", mEMail);
mUploadRequest->addHeader("Document-Description", mDescription);
mUploadRequest->addHeader("Deletion-Token", UBStringUtils::toCanonicalUuid(QUuid::createUuid()));
mUploadRequest->addHeader("Token-UUID", UBStringUtils::toCanonicalUuid(mAuthenticationUuid));
mUploadRequest->addHeader("Token-Encrypted", mAuthenticationBase64Token);
mUploadRequest->post(publishingEndpoint, zipFile.readAll());
zipFile.remove();
}
void UBDocumentPublisher::uploadProgress(qint64 bytesSent, qint64 bytesTotal)
{ {
int percentage = (((qreal)bytesSent / (qreal)bytesTotal ) * 100); mCrlf=0x0d;
mCrlf+=0x0a;
if (bytesSent < bytesTotal) mpNetworkMgr = new QNetworkAccessManager(this);
UBApplication::showMessage(tr("Upload to Uniboard Web in progress %1 %").arg(percentage), true); mpCookieJar = new QNetworkCookieJar();
else
UBApplication::showMessage(tr("Sending document ..."), true);
connect(mpNetworkMgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(onFinished(QNetworkReply*)));
} }
void UBDocumentPublisher::onFinished(QNetworkReply *reply)
void UBDocumentPublisher::postZipUploadResponse(bool success, const QByteArray& payload)
{ {
if (success) QByteArray response = reply->readAll();
{
UBApplication::showMessage(tr("The document has been sent to %1").arg(UBSettings::settings()->uniboardWebUrl->get().toString()), false); if (!bCookieSet)
}
else
{ {
qWarning() << "error uploading document to Uniboard Web" << QString::fromUtf8(payload); QList<QNetworkCookie> cookiesList;
QVariant cookieHeader = reply->rawHeader("Set-Cookie");
qDebug() << cookieHeader.toString();
// First we concatenate all the Set-Cookie values (the packet can contains many of them)
QStringList qslCookie = cookieHeader.toString().split("\n");
QString qsCookieValue = qslCookie.at(0);
for (int i = 1; i < qslCookie.size(); i++) {
qsCookieValue += "; " +qslCookie.at(i);
}
qDebug() << "qsCookieValue " << qsCookieValue;
// Now we isolate every cookie value
QStringList qslCookieVals = qsCookieValue.split("; ");
QString errorMessage = QString::fromUtf8(payload); // Finally we create the cookies
for (int i = 0; i < qslCookieVals.size(); i++)
{
QString cookieString = qslCookieVals.at(i);
qDebug() << "qslCookieVals.at(i): " << cookieString.replace("\"", "");
QStringList qslCrntCookie = cookieString.split("=");
QNetworkCookie crntCookie;
if (qslCrntCookie.length() == 2)
crntCookie = QNetworkCookie(qslCrntCookie.at(0).toAscii().constData(), qslCrntCookie.at(1).toAscii().constData());
else
crntCookie = QNetworkCookie(qslCrntCookie.at(0).toAscii().constData());
cookiesList << crntCookie;
}
if (errorMessage.length() == 0) // Set the cookiejar : it set the cookies that will be sent with every packet.
UBApplication::showMessage(tr("Error while publishing document to %1") qDebug() << reply->url().toString();
.arg(UBSettings::settings()->uniboardWebUrl->get().toString()), false); mpCookieJar->setCookiesFromUrl(cookiesList, reply->url());
else mpNetworkMgr->setCookieJar(mpCookieJar);
UBApplication::showMessage(tr("Error while publishing document to %1 : (%2)") bCookieSet = true;
.arg(UBSettings::settings()->uniboardWebUrl->get().toString())
.arg(errorMessage), false);
} }
QApplication::restoreOverrideCursor(); if (response.isEmpty()){
emit loginDone();
}
else{
// Display the iframe
mpWebView->setHtml(response, QUrl("http://sankore.devxwiki.com/xwiki/bin/view/Test/FileUpload"));
UBApplication::applicationController->showSankoreWebDocument();
deleteLater(); }
} }
void UBDocumentPublisher::sendUbw()
UBDocumentPublishingDialog::UBDocumentPublishingDialog(QWidget *parent)
: QDialog(parent)
{ {
Ui::documentPublishingDialog::setupUi(this); if (QFile::exists(mTmpZipFile))
{
QFile f(mTmpZipFile);
if (f.open(QIODevice::ReadOnly))
{
QByteArray ba = f.readAll();
QString boundary,data, multipartHeader;
QByteArray datatoSend;
boundary = "---WebKitFormBoundaryDKBTgA53MiyWrzLY";
multipartHeader = "multipart/form-data; boundary="+boundary;
data="--"+boundary+mCrlf;
data+="Content-Disposition: form-data; name=\"file\"; filename=\""+ f.fileName() +"\""+mCrlf;
data+="Content-Type: application/octet-stream"+mCrlf+mCrlf;
datatoSend=data.toAscii(); // convert data string to byte array for request
datatoSend += ba;
datatoSend += mCrlf.toAscii();
datatoSend += QString("--%0--%1").arg(boundary).arg(mCrlf).toAscii();
QNetworkRequest request(QUrl("http://sankore.devxwiki.com/xwiki/bin/view/Test/FileUpload"));
request.setHeader(QNetworkRequest::ContentTypeHeader, multipartHeader);
request.setHeader(QNetworkRequest::ContentLengthHeader,datatoSend.size());
request.setRawHeader("Accept", "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
request.setRawHeader("Accept-Language", "en-US,*");
request.setRawHeader("Referer", "http://sankore.devxwiki.com/xwiki/bin/view/Test/FileUpload");
request.setRawHeader("Origin", "http://sankore.devxwiki.com");
QString b64Auth = getBase64Of(QString("%0:%1").arg(mUsername).arg(mPassword));
request.setRawHeader("Authorization", QString("Basic %0").arg(b64Auth).toAscii().constData());
// Send the file
mpNetworkMgr->post(request,datatoSend);
}
}
}
connect(dialogButtons, SIGNAL(accepted()), this, SLOT(accept())); QString UBDocumentPublisher::getBase64Of(QString stringToEncode)
connect(dialogButtons, SIGNAL(rejected()), this, SLOT(reject())); {
return stringToEncode.toAscii().toBase64();
}
connect(title, SIGNAL(textChanged(const QString&)), this, SLOT(updateUIState(const QString&))); void UBDocumentPublisher::onLinkClicked(const QUrl &url)
connect(email, SIGNAL(textChanged(const QString&)), this, SLOT(updateUIState(const QString&))); {
// [Basic Auth] Here we interpret the link and send the request with the basic auth header.
QNetworkRequest request;
request.setUrl(url);
QString b64Auth = getBase64Of(QString("%0:%1").arg(mUsername).arg(mPassword));
request.setRawHeader("Authorization", QString("Basic %0").arg(b64Auth).toAscii().constData());
mpNetworkMgr->get(request);
}
dialogButtons->button(QDialogButtonBox::Ok)->setEnabled(false); void UBDocumentPublisher::onLoadFinished(bool result)
dialogButtons->button(QDialogButtonBox::Ok)->setText(tr("Publish")); {
Q_UNUSED(result);
// [Basic Auth] This line says: if the user click on a link, do not interpret it.
mpWebView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
} }
void UBDocumentPublishingDialog::updateUIState(const QString& string)
{
Q_UNUSED(string);
bool ok = title->text().length() > 0
&& email->text().length() > 0;
dialogButtons->button(QDialogButtonBox::Ok)->setEnabled(ok);
}

@ -10,74 +10,56 @@
class UBDocumentProxy; class UBDocumentProxy;
class UBServerXMLHttpRequest; class UBServerXMLHttpRequest;
class UBGraphicsW3CWidgetItem; class UBGraphicsW3CWidgetItem;
class QWebView;
class UBDocumentPublisher : public UBAbstractPublisher class UBDocumentPublisher : public UBAbstractPublisher
{ {
Q_OBJECT; Q_OBJECT;
public: public:
explicit UBDocumentPublisher(UBDocumentProxy* sourceDocument, QObject *parent = 0); explicit UBDocumentPublisher(UBDocumentProxy* sourceDocument, QObject *parent = 0);
virtual ~UBDocumentPublisher(); virtual ~UBDocumentPublisher();
void publish(); void publish();
protected: signals:
// not needed as we do not publish svg file anymore void loginDone();
//virtual void rasterizePDF();
//virtual void rasterizeSVGImages();
//virtual void updateSVGForWidget(int sceneIndex);
virtual void updateGoogleMapApiKey(); protected:
virtual void rasterizeScenes(); virtual void updateGoogleMapApiKey();
virtual void rasterizeScenes();
virtual void upgradeDocumentForPublishing();
virtual void generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *widgetItem, int pageNumber);
virtual void upgradeDocumentForPublishing(); private slots:
virtual void generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *widgetItem, int pageNumber); void onFinished(QNetworkReply* reply);
void onLinkClicked(const QUrl& url);
void onLoadFinished(bool result);
void sendZipToUniboardWeb(const QString& zipFile, const QUuid& publishingUuid);
private slots: private:
void postDocument(const QUuid& tokenUuid, const QString& encryptedBase64Token); void init();
void uploadProgress(qint64, qint64); void sendUbw();
void postZipUploadResponse(bool, const QByteArray&); QString getBase64Of(QString stringToEncode);
private: QWebView* mpWebView;
QHBoxLayout* mpLayout;
QNetworkAccessManager* mpNetworkMgr;
QNetworkCookieJar* mpCookieJar;
QString mUsername;
QString mPassword;
QString mCrlf;
bool bCookieSet;
UBDocumentProxy *mSourceDocument; void buildUbwFile();
UBDocumentProxy *mPublishingDocument; QString mTmpZipFile;
UBServerXMLHttpRequest* mUploadRequest; UBDocumentProxy *mSourceDocument;
UBDocumentProxy *mPublishingDocument;
QString mTitle;
QString mAuthor;
QString mDescription;
QString mEMail;
bool mAttachPDF;
bool mAttachUBZ;
QUrl mPublishingUrl;
QString mPublishingServiceUrl;
QUuid mAuthenticationUuid;
QString mAuthenticationBase64Token;
};
class UBDocumentPublishingDialog : public QDialog, public Ui::documentPublishingDialog
{
Q_OBJECT;
public:
UBDocumentPublishingDialog(QWidget *parent = 0);
~UBDocumentPublishingDialog(){}
private slots:
void updateUIState(const QString& string);
}; };
#endif // UBDOCUMENTPUBLISHER_H #endif // UBDOCUMENTPUBLISHER_H

@ -956,7 +956,7 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
} }
else else
{ {
UBApplication::showMessage(tr("Flash is not supported on Uniboard Linux")); UBApplication::showMessage(tr("Flash is not supported on Sankore Linux"));
} }
} }
else if (mimeType.startsWith("application/pdf")) else if (mimeType.startsWith("application/pdf"))

@ -152,7 +152,7 @@ void UBBoardPaletteManager::setupPalettes()
addItemActions << UBApplication::mainWindow->actionAddItemToCurrentPage; addItemActions << UBApplication::mainWindow->actionAddItemToCurrentPage;
addItemActions << UBApplication::mainWindow->actionAddItemToNewPage; addItemActions << UBApplication::mainWindow->actionAddItemToNewPage;
addItemActions << UBApplication::mainWindow->actionAddItemToLibrary; addItemActions << UBApplication::mainWindow->actionAddItemToLibrary;
//addItemActions << UBApplication::mainWindow->actionShareItemOnWeb; addItemActions << UBApplication::mainWindow->actionShareItemOnWeb;
mAddItemPalette = new UBActionPalette(addItemActions, Qt::Horizontal, 0); mAddItemPalette = new UBActionPalette(addItemActions, Qt::Horizontal, 0);
mAddItemPalette->setButtonIconSize(QSize(128, 128)); mAddItemPalette->setButtonIconSize(QSize(128, 128));
@ -306,7 +306,7 @@ void UBBoardPaletteManager::connectPalettes()
connect(UBApplication::mainWindow->actionAddItemToCurrentPage, SIGNAL(triggered()), this, SLOT(addItemToCurrentPage())); connect(UBApplication::mainWindow->actionAddItemToCurrentPage, SIGNAL(triggered()), this, SLOT(addItemToCurrentPage()));
connect(UBApplication::mainWindow->actionAddItemToNewPage, SIGNAL(triggered()), this, SLOT(addItemToNewPage())); connect(UBApplication::mainWindow->actionAddItemToNewPage, SIGNAL(triggered()), this, SLOT(addItemToNewPage()));
connect(UBApplication::mainWindow->actionAddItemToLibrary, SIGNAL(triggered()), this, SLOT(addItemToLibrary())); connect(UBApplication::mainWindow->actionAddItemToLibrary, SIGNAL(triggered()), this, SLOT(addItemToLibrary()));
//connect(UBApplication::mainWindow->actionShareItemOnWeb, SIGNAL(triggered()), this, SLOT(shareItemOnWeb())); connect(UBApplication::mainWindow->actionShareItemOnWeb, SIGNAL(triggered()), this, SLOT(shareItemOnWeb()));
connect(UBApplication::mainWindow->actionEraseItems, SIGNAL(triggered()), mErasePalette, SLOT(close())); connect(UBApplication::mainWindow->actionEraseItems, SIGNAL(triggered()), mErasePalette, SLOT(close()));
connect(UBApplication::mainWindow->actionEraseAnnotations, SIGNAL(triggered()), mErasePalette, SLOT(close())); connect(UBApplication::mainWindow->actionEraseAnnotations, SIGNAL(triggered()), mErasePalette, SLOT(close()));

@ -53,7 +53,6 @@ UBApplicationController* UBApplication::applicationController = 0;
UBBoardController* UBApplication::boardController = 0; UBBoardController* UBApplication::boardController = 0;
UBWebController* UBApplication::webController = 0; UBWebController* UBApplication::webController = 0;
UBDocumentController* UBApplication::documentController = 0; UBDocumentController* UBApplication::documentController = 0;
//UBSoftwareUpdateController* UBApplication::softwareUpdateController = 0;
UniboardSankoreTransition* UBApplication::mUniboardSankoreTransition = 0; UniboardSankoreTransition* UBApplication::mUniboardSankoreTransition = 0;
UBMainWindow* UBApplication::mainWindow = 0; UBMainWindow* UBApplication::mainWindow = 0;
@ -91,9 +90,8 @@ static OSStatus ub_appleEventProcessor(const AppleEvent *ae, AppleEvent *event,
#endif #endif
UBApplication::UBApplication(const QString &id, int &argc, char **argv) UBApplication::UBApplication(const QString &id, int &argc, char **argv) : QtSingleApplication(id, argc, argv),
: QtSingleApplication(id, argc, argv), mPreferencesController(NULL)
mPreferencesController(NULL)
{ {
staticMemoryCleaner = new QObject(0); // deleted in UBApplication destructor staticMemoryCleaner = new QObject(0); // deleted in UBApplication destructor
@ -186,11 +184,11 @@ UBApplication::~UBApplication()
delete mUniboardSankoreTransition; delete mUniboardSankoreTransition;
mUniboardSankoreTransition = 0; mUniboardSankoreTransition = 0;
if (mPreferencesController) if (mPreferencesController)
{ {
delete mPreferencesController; delete mPreferencesController;
mPreferencesController = 0; mPreferencesController = 0;
} }
} }
int UBApplication::exec(const QString& pFileToImport) int UBApplication::exec(const QString& pFileToImport)
@ -343,6 +341,10 @@ void UBApplication::showDocument()
applicationController->showDocument(); applicationController->showDocument();
} }
void UBApplication::showSankoreWebDocument()
{
applicationController->showSankoreWebDocument();
}
int UBApplication::toolBarHeight() int UBApplication::toolBarHeight()
{ {

@ -88,6 +88,7 @@ class UBApplication : public QtSingleApplication
void showBoard(); void showBoard();
void showInternet(); void showInternet();
void showDocument(); void showDocument();
void showSankoreWebDocument();
void toolBarPositionChanged(QVariant topOrBottom); void toolBarPositionChanged(QVariant topOrBottom);
void toolBarDisplayTextChanged(QVariant display); void toolBarDisplayTextChanged(QVariant display);

@ -87,11 +87,10 @@ UBApplicationController::UBApplicationController(UBBoardView *pControlView, UBBo
, this, SLOT(addCapturedPixmap(const QPixmap &, bool, const QUrl&))); , this, SLOT(addCapturedPixmap(const QPixmap &, bool, const QUrl&)));
networkAccessManager = new QNetworkAccessManager (this); networkAccessManager = new QNetworkAccessManager (this);
connect (networkAccessManager, SIGNAL (finished (QNetworkReply*)), this, SLOT (downloadJsonFinished (QNetworkReply*)));
QTimer::singleShot (1000, this, SLOT (checkUpdateAtLaunch())); QTimer::singleShot (1000, this, SLOT (checkUpdateAtLaunch()));
#ifdef Q_WS_X11 #ifdef Q_WS_X11
// mMainWindow->setStyleSheet("QToolButton { font-size: 11px}"); mMainWindow->setStyleSheet("QToolButton { font-size: 11px}");
#endif #endif
} }
@ -326,7 +325,7 @@ void UBApplicationController::showBoard()
if (UBApplication::boardController) if (UBApplication::boardController)
UBApplication::boardController->show(); UBApplication::boardController->show();
UBPlatformUtils::setDesktopMode(false); UBPlatformUtils::setDesktopMode(false);
mUninoteController->hideWindow(); mUninoteController->hideWindow();
mMainWindow->show(); mMainWindow->show();
@ -397,6 +396,32 @@ void UBApplicationController::showDocument()
emit mainModeChanged(Document); emit mainModeChanged(Document);
} }
void UBApplicationController::showSankoreWebDocument()
{
mMainWindow->webToolBar->hide();
mMainWindow->boardToolBar->hide();
mMainWindow->tutorialToolBar->hide();
mMainWindow->documentToolBar->show();
mMainMode = WebDocument;
adaptToolBar();
mirroringEnabled(false);
mMainWindow->switchToSankoreWebDocumentWidget();
UBApplication::documentController->hide();
mMainWindow->show();
mUninoteController->hideWindow();
emit mainModeChanged(WebDocument);
}
void UBApplicationController::showDesktop(bool dontSwitchFrontProcess) void UBApplicationController::showDesktop(bool dontSwitchFrontProcess)
{ {

@ -53,6 +53,8 @@ class UBApplicationController : public QObject
void showDocument(); void showDocument();
void showSankoreWebDocument();
void showMessage(const QString& message, bool showSpinningWheel); void showMessage(const QString& message, bool showSpinningWheel);
void importFile(const QString& pFilePath); void importFile(const QString& pFilePath);
@ -69,7 +71,7 @@ class UBApplicationController : public QObject
enum MainMode enum MainMode
{ {
Board = 0, Internet, Document, Tutorial, ParaschoolEditor Board = 0, Internet, Document, Tutorial, ParaschoolEditor, WebDocument
}; };
MainMode displayMode() MainMode displayMode()

@ -29,6 +29,7 @@
#include "UBPersistenceManager.h" #include "UBPersistenceManager.h"
#include "core/memcheck.h" #include "core/memcheck.h"
#include "../adaptors/UBExportWeb.h"
UBDocumentManager* UBDocumentManager::sDocumentManager = 0; UBDocumentManager* UBDocumentManager::sDocumentManager = 0;
@ -53,9 +54,12 @@ UBDocumentManager::UBDocumentManager(QObject *parent)
UBExportFullPDF* exportFullPdf = new UBExportFullPDF(this); UBExportFullPDF* exportFullPdf = new UBExportFullPDF(this);
mExportAdaptors.append(exportFullPdf); mExportAdaptors.append(exportFullPdf);
UBExportDocument* exportDocument = new UBExportDocument(this); UBExportDocument* exportDocument = new UBExportDocument(this);
mExportAdaptors.append(exportDocument); mExportAdaptors.append(exportDocument);
// UBExportWeb* exportWeb = new UBExportWeb(this);
// mExportAdaptors.append(exportWeb);
UBWebPublisher* webPublished = new UBWebPublisher(this);
mExportAdaptors.append(webPublished);
UBImportDocument* documentImport = new UBImportDocument(this); UBImportDocument* documentImport = new UBImportDocument(this);
mImportAdaptors.append(documentImport); mImportAdaptors.append(documentImport);

@ -1000,7 +1000,7 @@ void UBPersistenceManager::checkIfDocumentRepositoryExists()
QMessageBox::question( QMessageBox::question(
QApplication::activeWindow(), QApplication::activeWindow(),
tr("Document Repository Loss"), tr("Document Repository Loss"),
tr("Uniboard has lost access to the document repository '%1'. Unfortunately the application must shut down to avoid data corruption. Latest changes may be lost as well.").arg(humanPath), tr("Sankore has lost access to the document repository '%1'. Unfortunately the application must shut down to avoid data corruption. Latest changes may be lost as well.").arg(humanPath),
QMessageBox::Yes); QMessageBox::Yes);
UBApplication::quit(); UBApplication::quit();

@ -1446,7 +1446,7 @@ bool UBDocumentController::isOKToOpenDocument(UBDocumentProxy* proxy)
else else
{ {
if (QMessageBox::question( 0, tr("Open Document"), if (QMessageBox::question( 0, tr("Open Document"),
tr("The document '%1' has been generated with a newer version of Uniboard (%2). By opening it, you may lose some information. Do you want to proceed?") tr("The document '%1' has been generated with a newer version of Sankore (%2). By opening it, you may lose some information. Do you want to proceed?")
.arg(proxy->metaData(UBSettings::documentName).toString()) .arg(proxy->metaData(UBSettings::documentName).toString())
.arg(docVersion), .arg(docVersion),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)

@ -33,10 +33,10 @@ class UBDocumentController : public QObject
QWidget* controlView(); QWidget* controlView();
UBDocumentProxyTreeItem* findDocument(UBDocumentProxy* proxy); UBDocumentProxyTreeItem* findDocument(UBDocumentProxy* proxy);
bool addFileToDocument(UBDocumentProxy* document); bool addFileToDocument(UBDocumentProxy* document);
UBDocumentProxy* getCurrentDocument(); UBDocumentProxy* getCurrentDocument();
signals: signals:
void refreshThumbnails(); void refreshThumbnails();
void exportDone(); void exportDone();
public slots: public slots:
@ -91,7 +91,7 @@ class UBDocumentController : public QObject
UBDocumentToolsPalette *mToolsPalette; UBDocumentToolsPalette *mToolsPalette;
bool mToolsPalettePositionned; bool mToolsPalettePositionned;
UBDocumentGroupTreeItem* mTrashTi; UBDocumentGroupTreeItem* mTrashTi;
UBDocumentProxy* mCurrentDocument; UBDocumentProxy* mCurrentDocument;
private slots: private slots:
void documentZoomSliderValueChanged (int value); void documentZoomSliderValueChanged (int value);

@ -46,8 +46,8 @@ void UBPlatformUtils::init()
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *currentPath = [[NSBundle mainBundle] pathForResource:@"Save PDF to Uniboard" ofType:@"workflow"]; NSString *currentPath = [[NSBundle mainBundle] pathForResource:@"Save PDF to Sankore" ofType:@"workflow"];
NSString *installedPath = [[[@"~/Library/PDF Services" stringByExpandingTildeInPath] stringByAppendingPathComponent:@"Save PDF to Uniboard"] stringByAppendingPathExtension:@"workflow"]; NSString *installedPath = [[[@"~/Library/PDF Services" stringByExpandingTildeInPath] stringByAppendingPathComponent:@"Save PDF to Sankore"] stringByAppendingPathExtension:@"workflow"];
NSString *currentVersion = bundleShortVersion([NSBundle bundleWithPath:currentPath]); NSString *currentVersion = bundleShortVersion([NSBundle bundleWithPath:currentPath]);
NSString *installedVersion = bundleShortVersion([NSBundle bundleWithPath:installedPath]); NSString *installedVersion = bundleShortVersion([NSBundle bundleWithPath:installedPath]);
@ -59,7 +59,7 @@ void UBPlatformUtils::init()
BOOL copyOK = [fileManager copyPath:currentPath toPath:installedPath handler:nil]; BOOL copyOK = [fileManager copyPath:currentPath toPath:installedPath handler:nil];
if (!copyOK) if (!copyOK)
{ {
qWarning("Could not install the 'Save PDF to Uniboard' workflow"); qWarning("Could not install the 'Save PDF to Sankore' workflow");
} }
} }
@ -364,25 +364,25 @@ KEYBT* createKeyBt(const UCKeyboardLayout* keyLayout, int vkk)
void UBPlatformUtils::initializeKeyboardLayouts() void UBPlatformUtils::initializeKeyboardLayouts()
{ {
CFStringRef keys[] = { kTISPropertyInputSourceCategory, kTISPropertyInputSourceIsEnableCapable, kTISPropertyInputSourceIsSelectCapable }; CFStringRef keys[] = { kTISPropertyInputSourceCategory, kTISPropertyInputSourceIsEnableCapable, kTISPropertyInputSourceIsSelectCapable };
const void* values[] = { kTISCategoryKeyboardInputSource, kCFBooleanTrue, kCFBooleanTrue }; const void* values[] = { kTISCategoryKeyboardInputSource, kCFBooleanTrue, kCFBooleanTrue };
CFDictionaryRef dict = CFDictionaryCreate(NULL, (const void **)keys, (const void **)values, 3, NULL, NULL); CFDictionaryRef dict = CFDictionaryCreate(NULL, (const void **)keys, (const void **)values, 3, NULL, NULL);
CFArrayRef kbds = TISCreateInputSourceList(dict, false); CFArrayRef kbds = TISCreateInputSourceList(dict, false);
int count = CFArrayGetCount(kbds); int count = CFArrayGetCount(kbds);
QList<UBKeyboardLocale*> result; QList<UBKeyboardLocale*> result;
for(int i=0; i<count; i++) for(int i=0; i<count; i++)
{ {
TISInputSourceRef keyLayoutRef = (TISInputSourceRef)CFArrayGetValueAtIndex(kbds, i); TISInputSourceRef keyLayoutRef = (TISInputSourceRef)CFArrayGetValueAtIndex(kbds, i);
if (keyLayoutRef==NULL) if (keyLayoutRef==NULL)
continue; continue;
CFDataRef ref = (CFDataRef) TISGetInputSourceProperty(keyLayoutRef, CFDataRef ref = (CFDataRef) TISGetInputSourceProperty(keyLayoutRef,
kTISPropertyUnicodeKeyLayoutData); kTISPropertyUnicodeKeyLayoutData);
if (ref==NULL) if (ref==NULL)
continue; continue;
const UCKeyboardLayout* keyLayout = (const UCKeyboardLayout*) CFDataGetBytePtr(ref); const UCKeyboardLayout* keyLayout = (const UCKeyboardLayout*) CFDataGetBytePtr(ref);
if (keyLayoutRef==NULL) if (keyLayoutRef==NULL)
continue; continue;
@ -438,12 +438,12 @@ void UBPlatformUtils::initializeKeyboardLayouts()
keybt[44] = createKeyBt(keyLayout, 43); keybt[44] = createKeyBt(keyLayout, 43);
keybt[45] = createKeyBt(keyLayout, 47); keybt[45] = createKeyBt(keyLayout, 47);
keybt[46] = createKeyBt(keyLayout, 44); keybt[46] = createKeyBt(keyLayout, 44);
CFStringRef sr = (CFStringRef) TISGetInputSourceProperty(keyLayoutRef, kTISPropertyInputSourceID); CFStringRef sr = (CFStringRef) TISGetInputSourceProperty(keyLayoutRef, kTISPropertyInputSourceID);
QString ID = QStringFromStringRef(sr); QString ID = QStringFromStringRef(sr);
sr = (CFStringRef) TISGetInputSourceProperty(keyLayoutRef, kTISPropertyLocalizedName); sr = (CFStringRef) TISGetInputSourceProperty(keyLayoutRef, kTISPropertyLocalizedName);
QString fullName = QStringFromStringRef(sr); QString fullName = QStringFromStringRef(sr);
CFArrayRef langs = (CFArrayRef) TISGetInputSourceProperty(keyLayoutRef, CFArrayRef langs = (CFArrayRef) TISGetInputSourceProperty(keyLayoutRef,
@ -455,13 +455,13 @@ void UBPlatformUtils::initializeKeyboardLayouts()
CFStringRef langRef = (CFStringRef)CFArrayGetValueAtIndex(langs, 0); CFStringRef langRef = (CFStringRef)CFArrayGetValueAtIndex(langs, 0);
name = QStringFromStringRef(langRef); name = QStringFromStringRef(langRef);
} }
//IconRef iconRef = (IconRef)TISGetInputSourceProperty(kTISPropertyIconRef, //IconRef iconRef = (IconRef)TISGetInputSourceProperty(kTISPropertyIconRef,
// kTISPropertyInputSourceLanguages); // kTISPropertyInputSourceLanguages);
result.append(new UBKeyboardLocale(fullName, name, ID, NULL, keybt)); result.append(new UBKeyboardLocale(fullName, name, ID, NULL, keybt));
} }
if (result.size()==0) if (result.size()==0)
{ {
nKeyboardLayouts = 0; nKeyboardLayouts = 0;

@ -14,6 +14,7 @@ UBMainWindow::UBMainWindow(QWidget *parent, Qt::WindowFlags flags)
, mBoardWidget(0) , mBoardWidget(0)
, mWebWidget(0) , mWebWidget(0)
, mDocumentsWidget(0) , mDocumentsWidget(0)
, mSankoreWebDocumentWidget(0)
{ {
Ui::MainWindow::setupUi(this); Ui::MainWindow::setupUi(this);
@ -91,6 +92,19 @@ void UBMainWindow::switchToDocumentsWidget()
} }
} }
void UBMainWindow::addSankoreWebDocumentWidget(QWebView* pWidget)
{
if(!mSankoreWebDocumentWidget){
mSankoreWebDocumentWidget = pWidget;
mStackedLayout->addWidget(mSankoreWebDocumentWidget);
}
}
void UBMainWindow::switchToSankoreWebDocumentWidget()
{
if(mSankoreWebDocumentWidget)
mStackedLayout->setCurrentWidget(mSankoreWebDocumentWidget);
}
void UBMainWindow::keyPressEvent(QKeyEvent *event) void UBMainWindow::keyPressEvent(QKeyEvent *event)
{ {
QMainWindow::keyPressEvent(event); QMainWindow::keyPressEvent(event);

@ -5,6 +5,7 @@
#include <QMainWindow> #include <QMainWindow>
#include <QWidget> #include <QWidget>
#include <QWebView>
class QStackedLayout; class QStackedLayout;
@ -27,6 +28,9 @@ class UBMainWindow : public QMainWindow, public Ui::MainWindow
void addDocumentsWidget(QWidget *pWidget); void addDocumentsWidget(QWidget *pWidget);
void switchToDocumentsWidget(); void switchToDocumentsWidget();
void addSankoreWebDocumentWidget(QWebView* pWidget);
void switchToSankoreWebDocumentWidget();
public slots: public slots:
void onExportDone(); void onExportDone();
@ -45,6 +49,7 @@ class UBMainWindow : public QMainWindow, public Ui::MainWindow
QWidget *mBoardWidget; QWidget *mBoardWidget;
QWidget *mWebWidget; QWidget *mWebWidget;
QWidget *mDocumentsWidget; QWidget *mDocumentsWidget;
QWebView* mSankoreWebDocumentWidget;
}; };

@ -338,7 +338,7 @@ void UBPodcastController::start()
} }
else else
{ {
videoFileName = mPodcastRecordingPath + "/" + tr("Uniboard Cast") + "." + mVideoEncoder->videoFileExtension(); videoFileName = mPodcastRecordingPath + "/" + tr("Sankore Cast") + "." + mVideoEncoder->videoFileExtension();
} }
videoFileName = UBFileSystemUtils::nextAvailableFileName(videoFileName, " "); videoFileName = UBFileSystemUtils::nextAvailableFileName(videoFileName, " ");

@ -7,68 +7,69 @@ class QGraphicsSvgItem;
class UBAbstractDrawRuler : public QObject class UBAbstractDrawRuler : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
UBAbstractDrawRuler(); UBAbstractDrawRuler();
~UBAbstractDrawRuler(); ~UBAbstractDrawRuler();
void create(QGraphicsItem& item); void create(QGraphicsItem& item);
virtual void StartLine(const QPointF& position, qreal width); virtual void StartLine(const QPointF& position, qreal width);
virtual void DrawLine(const QPointF& position, qreal width); virtual void DrawLine(const QPointF& position, qreal width);
virtual void EndLine(); virtual void EndLine();
protected:
protected:
void paint();
void paint();
virtual UBGraphicsScene* scene() const = 0;
virtual UBGraphicsScene* scene() const = 0;
virtual void rotateAroundTopLeftOrigin(qreal angle) = 0;
virtual void rotateAroundTopLeftOrigin(qreal angle) = 0;
virtual QPointF topLeftOrigin() const = 0;
virtual QRectF resizeButtonRect() const = 0; virtual QPointF topLeftOrigin() const = 0;
virtual QRectF closeButtonRect() const = 0; virtual QRectF resizeButtonRect() const = 0;
virtual QRectF rotateButtonRect() const = 0; virtual QRectF closeButtonRect() const = 0;
virtual QRectF rotateButtonRect() const = 0;
void updateResizeCursor(QGraphicsItem &item);
void updateResizeCursor(QGraphicsItem &item);
bool mResizing;
bool mRotating; bool mResizing;
bool mShowButtons; bool mRotating;
QGraphicsSvgItem* mCloseSvgItem; bool mShowButtons;
QGraphicsSvgItem* mRotateSvgItem; QGraphicsSvgItem* mCloseSvgItem;
QCursor mResizeCursor; QGraphicsSvgItem* mRotateSvgItem;
qreal mAntiScaleRatio; QCursor mResizeCursor;
qreal mAntiScaleRatio;
QPointF startDrawPosition;
QPointF startDrawPosition;
QCursor moveCursor() const;
QCursor resizeCursor() const; QCursor moveCursor() const;
QCursor rotateCursor() const; QCursor resizeCursor() const;
QCursor closeCursor() const; QCursor rotateCursor() const;
QCursor drawRulerLineCursor() const; QCursor closeCursor() const;
QCursor drawRulerLineCursor() const;
QColor drawColor() const;
QColor middleFillColor() const; QColor drawColor() const;
QColor edgeFillColor() const; QColor middleFillColor() const;
QFont font() const; QColor edgeFillColor() const;
QFont font() const;
static const QColor sLightBackgroundEdgeFillColor;
static const QColor sLightBackgroundMiddleFillColor; static const QColor sLightBackgroundEdgeFillColor;
static const QColor sLightBackgroundDrawColor; static const QColor sLightBackgroundMiddleFillColor;
static const QColor sDarkBackgroundEdgeFillColor; static const QColor sLightBackgroundDrawColor;
static const QColor sDarkBackgroundMiddleFillColor; static const QColor sDarkBackgroundEdgeFillColor;
static const QColor sDarkBackgroundDrawColor; static const QColor sDarkBackgroundMiddleFillColor;
static const QColor sDarkBackgroundDrawColor;
static const int sLeftEdgeMargin = 10;
static const int sMinLength = 150; static const int sLeftEdgeMargin = 10;
static const int sDegreeToQtAngleUnit = 16; static const int sMinLength = 150;
static const int sRotationRadius = 15; static const int sDegreeToQtAngleUnit = 16;
static const int sPixelsPerMillimeter = 5; static const int sRotationRadius = 15;
static const int sFillTransparency = 127; static const int sPixelsPerMillimeter = 5;
static const int sDrawTransparency = 192; static const int sFillTransparency = 127;
static const int sRoundingRadius = sLeftEdgeMargin / 2; static const int sDrawTransparency = 192;
static const int sRoundingRadius = sLeftEdgeMargin / 2;
}; };

@ -13,30 +13,33 @@
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "board/UBDrawingController.h" #include "board/UBDrawingController.h"
#include "core/memcheck.h" #include "core/memcheck.h"
const QRectF UBGraphicsProtractor::sDefaultRect = QRectF(-175, -175, 350, 350); const QRectF UBGraphicsProtractor::sDefaultRect = QRectF(-175, -175, 350, 350);
UBGraphicsProtractor::UBGraphicsProtractor() UBGraphicsProtractor::UBGraphicsProtractor()
: QGraphicsEllipseItem(sDefaultRect) : QGraphicsEllipseItem(sDefaultRect)
, mCurrentTool(None) , mCurrentTool(None)
, mShowButtons(false) , mShowButtons(false)
, mCurrentAngle(0) , mCurrentAngle(0)
, mSpan(180) , mSpan(180)
, mStartAngle(0) , mStartAngle(0)
, mScaleFactor(1) , mScaleFactor(1)
, mResetSvgItem(0) , mResetSvgItem(0)
, mResizeSvgItem(0) , mResizeSvgItem(0)
, mMarkerSvgItem(0) , mMarkerSvgItem(0)
{ {
sFillTransparency = 127;
sDrawTransparency = 192;
create(*this); create(*this);
setCacheMode(QGraphicsItem::DeviceCoordinateCache); setCacheMode(QGraphicsItem::DeviceCoordinateCache);
setStartAngle(0); setStartAngle(0);
setSpanAngle(180 * 16); setSpanAngle(180 * 16);
mResetSvgItem = new QGraphicsSvgItem(":/images/resetTool.svg", this); mResetSvgItem = new QGraphicsSvgItem(":/images/resetTool.svg", this);
mResetSvgItem->setVisible(false); mResetSvgItem->setVisible(false);
@ -68,7 +71,7 @@ void UBGraphicsProtractor::paint(QPainter *painter, const QStyleOptionGraphicsIt
painter->setPen(drawColor()); painter->setPen(drawColor());
painter->setBrush(fillBrush()); painter->setBrush(fillBrush());
painter->drawPie(QRectF(rect().center().x() - radius(), rect().center().y() - radius(), painter->drawPie(QRectF(rect().center().x() - radius(), rect().center().y() - radius(),
2 * radius(), 2 * radius()), mStartAngle * 16, mSpan * 16); 2 * radius(), 2 * radius()), mStartAngle * 16, mSpan * 16);
paintGraduations(painter); paintGraduations(painter);
paintButtons(painter); paintButtons(painter);
paintAngleMarker(painter); paintAngleMarker(painter);
@ -125,10 +128,10 @@ QPainterPath UBGraphicsProtractor::shape() const
qreal centerY = center.y(); qreal centerY = center.y();
buttonPath.addRect(resizeButtonRect().adjusted(centerX, centerY, centerX, centerY)); buttonPath.addRect(resizeButtonRect().adjusted(centerX, centerY, centerX, centerY));
if(!resizeButtonRect().contains(markerRect)) if (!resizeButtonRect().contains(markerRect))
{ {
buttonPath.addRect(markerRect.adjusted(centerX - markerRect.left() * 2 - markerRect.width(), centerY buttonPath.addRect(markerRect.adjusted(centerX - markerRect.left() * 2 - markerRect.width(), centerY
, centerX - markerRect.left() * 2 - markerRect.width(), centerY)); , centerX - markerRect.left() * 2 - markerRect.width(), centerY));
buttonPath.addRect(markerRect.adjusted(centerX, centerY, centerX, centerY)); buttonPath.addRect(markerRect.adjusted(centerX, centerY, centerX, centerY));
} }
buttonPath.addRect(closeButtonRect().adjusted(centerX, centerY, centerX, centerY)); buttonPath.addRect(closeButtonRect().adjusted(centerX, centerY, centerX, centerY));
@ -166,44 +169,44 @@ void UBGraphicsProtractor::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
qreal angle = startLine.angleTo(currentLine); qreal angle = startLine.angleTo(currentLine);
qreal scaleFactor = currentLine.length()/startLine.length(); qreal scaleFactor = currentLine.length()/startLine.length();
switch(mCurrentTool) switch (mCurrentTool)
{ {
case Rotate : case Rotate :
prepareGeometryChange(); prepareGeometryChange();
mStartAngle = mStartAngle + angle; mStartAngle = mStartAngle + angle;
setStartAngle(mStartAngle * 16); setStartAngle(mStartAngle * 16);
mPreviousMousePos = currentPoint; mPreviousMousePos = currentPoint;
break; break;
case Resize : case Resize :
prepareGeometryChange(); prepareGeometryChange();
translate(rect().center().x(), rect().center().y()); translate(rect().center().x(), rect().center().y());
scale(scaleFactor, scaleFactor); scale(scaleFactor, scaleFactor);
translate(-rect().center().x(), -rect().center().y()); translate(-rect().center().x(), -rect().center().y());
mScaleFactor *= scaleFactor; mScaleFactor *= scaleFactor;
break; break;
case MoveMarker : case MoveMarker :
mCurrentAngle += angle; mCurrentAngle += angle;
if((int)mCurrentAngle % 360 > 270) if ((int)mCurrentAngle % 360 > 270)
mCurrentAngle = 0; mCurrentAngle = 0;
else if((int)mCurrentAngle % 360 >= 180) else if ((int)mCurrentAngle % 360 >= 180)
mCurrentAngle = 180; mCurrentAngle = 180;
mPreviousMousePos = currentPoint; mPreviousMousePos = currentPoint;
update(); update();
break; break;
case Move : case Move :
QGraphicsEllipseItem::mouseMoveEvent(event); QGraphicsEllipseItem::mouseMoveEvent(event);
break; break;
default : default :
break; break;
} }
if(mCurrentTool != Move) if (mCurrentTool != Move)
event->accept(); event->accept();
} }
@ -211,25 +214,25 @@ void UBGraphicsProtractor::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsProtractor::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsProtractor::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
switch(mCurrentTool) switch (mCurrentTool)
{ {
case Reset : case Reset :
setStartAngle(0); setStartAngle(0);
mStartAngle = 0; mStartAngle = 0;
break; break;
case Close : case Close :
hide(); hide();
emit hidden(); emit hidden();
break; break;
case MoveMarker : case MoveMarker :
update(); update();
break; break;
default : default :
QGraphicsEllipseItem::mouseReleaseEvent(event); QGraphicsEllipseItem::mouseReleaseEvent(event);
break; break;
} }
if (mCurrentTool != Move) if (mCurrentTool != Move)
@ -244,8 +247,8 @@ void UBGraphicsProtractor::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsProtractor::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsProtractor::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector) if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector)
return; return;
if (!mShowButtons) if (!mShowButtons)
{ {
@ -275,8 +278,8 @@ void UBGraphicsProtractor::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void UBGraphicsProtractor::hoverMoveEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsProtractor::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{ {
if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector) if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector)
return; return;
Tool currentTool = toolFromPos(event->pos()); Tool currentTool = toolFromPos(event->pos());
@ -286,7 +289,7 @@ void UBGraphicsProtractor::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
update(); update();
} }
if(currentTool == Move) if (currentTool == Move)
setCursor(Qt::SizeAllCursor); setCursor(Qt::SizeAllCursor);
else else
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
@ -305,12 +308,12 @@ QRectF UBGraphicsProtractor::resetButtonRect () const
{ {
qreal antiSc = antiScale(); qreal antiSc = antiScale();
if(buttonSizeReference().width() * antiSc <= buttonSizeReference().width() * 15) if (buttonSizeReference().width() * antiSc <= buttonSizeReference().width() * 15)
return QRectF(-buttonSizeReference().width() * 7, -buttonSizeReference().height() * antiSc / 2, return QRectF(-buttonSizeReference().width() * 7, -buttonSizeReference().height() * antiSc / 2,
buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc); buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc);
else else
return QRectF(-buttonSizeReference().width() * antiSc / 2, -buttonSizeReference().height() * antiSc / 2, return QRectF(-buttonSizeReference().width() * antiSc / 2, -buttonSizeReference().height() * antiSc / 2,
buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc); buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc);
} }
@ -320,13 +323,13 @@ QRectF UBGraphicsProtractor::closeButtonRect () const
if (buttonSizeReference().width() * antiSc <= buttonSizeReference().width() * 2) if (buttonSizeReference().width() * antiSc <= buttonSizeReference().width() * 2)
return QRectF(-buttonSizeReference().width() * 9, -buttonSizeReference().height() * antiSc / 2, return QRectF(-buttonSizeReference().width() * 9, -buttonSizeReference().height() * antiSc / 2,
buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc); buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc);
else if (buttonSizeReference().width() * antiSc <= buttonSizeReference().width() * 15) else if (buttonSizeReference().width() * antiSc <= buttonSizeReference().width() * 15)
return QRectF(-buttonSizeReference().width() * 7 -buttonSizeReference().width() * antiSc, -buttonSizeReference().height() * antiSc / 2, return QRectF(-buttonSizeReference().width() * 7 -buttonSizeReference().width() * antiSc, -buttonSizeReference().height() * antiSc / 2,
buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc); buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc);
else else
return QRectF(-buttonSizeReference().width() * antiSc / 2, -buttonSizeReference().height() * antiSc / 2, return QRectF(-buttonSizeReference().width() * antiSc / 2, -buttonSizeReference().height() * antiSc / 2,
buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc); buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc);
} }
@ -334,14 +337,14 @@ QRectF UBGraphicsProtractor::resizeButtonRect () const
{ {
qreal antiSc = antiScale(); qreal antiSc = antiScale();
if(buttonSizeReference().width() * antiSc <= buttonSizeReference().width() * 15) if (buttonSizeReference().width() * antiSc <= buttonSizeReference().width() * 15)
return QRectF(buttonSizeReference().width() * 8, -buttonSizeReference().height() * antiSc / 2, return QRectF(buttonSizeReference().width() * 8, -buttonSizeReference().height() * antiSc / 2,
buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc); buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc);
else else
{ {
mResizeSvgItem->setZValue(zValue()+10); mResizeSvgItem->setZValue(zValue()+10);
return QRectF(-buttonSizeReference().width() * antiSc / 2, -buttonSizeReference().height() * antiSc / 2, return QRectF(-buttonSizeReference().width() * antiSc / 2, -buttonSizeReference().height() * antiSc / 2,
buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc); buttonSizeReference().width() * antiSc, buttonSizeReference().height() * antiSc);
} }
} }
@ -356,7 +359,7 @@ void UBGraphicsProtractor::paintGraduations(QPainter *painter)
QFont font1 = painter->font(); QFont font1 = painter->font();
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
font1.setPointSizeF(font1.pointSizeF() - 3); font1.setPointSizeF(font1.pointSizeF() - 3);
#endif #endif
QFontMetricsF fm1(font1); QFontMetricsF fm1(font1);
@ -370,21 +373,21 @@ void UBGraphicsProtractor::paintGraduations(QPainter *painter)
QPointF center = rect().center(); QPointF center = rect().center();
painter->drawArc(QRectF(center.x() - rad/2, center.y() - rad/2, rad, rad), mStartAngle*16, mSpan*16); painter->drawArc(QRectF(center.x() - rad/2, center.y() - rad/2, rad, rad), mStartAngle*16, mSpan*16);
for(int angle = 1; angle < mSpan; angle++) for (int angle = 1; angle < mSpan; angle++)
{ {
int graduationLength = (0 == angle % 10) ? tenDegreeGraduationLength : ((0 == angle % 5) ? fiveDegreeGraduationLength : oneDegreeGraduationLength); int graduationLength = (0 == angle % 10) ? tenDegreeGraduationLength : ((0 == angle % 5) ? fiveDegreeGraduationLength : oneDegreeGraduationLength);
qreal co = cos(((qreal)angle + mStartAngle) * PI/180); qreal co = cos(((qreal)angle + mStartAngle) * PI/180);
qreal si = sin(((qreal)angle + mStartAngle) * PI/180); qreal si = sin(((qreal)angle + mStartAngle) * PI/180);
if(0 == angle % 90) if (0 == angle % 90)
painter->drawLine(QLineF(QPointF(center.x(), center.y()), QPointF(center.x() + co*tenDegreeGraduationLength, center.y() - si*tenDegreeGraduationLength))); painter->drawLine(QLineF(QPointF(center.x(), center.y()), QPointF(center.x() + co*tenDegreeGraduationLength, center.y() - si*tenDegreeGraduationLength)));
//external arc //external arc
painter->drawLine(QLineF(QPointF(center.x()+ rad*co, center.y() - rad*si), painter->drawLine(QLineF(QPointF(center.x()+ rad*co, center.y() - rad*si),
QPointF(center.x()+ (rad - graduationLength)*co, center.y() - (rad - graduationLength)*si))); QPointF(center.x()+ (rad - graduationLength)*co, center.y() - (rad - graduationLength)*si)));
//internal arc //internal arc
painter->drawLine(QLineF(QPointF(center.x()+ rad/2*co, center.y() - rad/2*si), painter->drawLine(QLineF(QPointF(center.x()+ rad/2*co, center.y() - rad/2*si),
QPointF(center.x()+ (rad/2 + graduationLength)*co, QPointF(center.x()+ (rad/2 + graduationLength)*co,
center.y() - (rad/2 + graduationLength)*si))); center.y() - (rad/2 + graduationLength)*si)));
if (0 == angle % 10) if (0 == angle % 10)
{ {
@ -394,14 +397,14 @@ void UBGraphicsProtractor::paintGraduations(QPainter *painter)
QString grad2 = QString("%1").arg((int)(mSpan - angle)); QString grad2 = QString("%1").arg((int)(mSpan - angle));
painter->drawText(QRectF(center.x() + (rad - graduationLength*1.5)*co - fm1.width(grad)/2, painter->drawText(QRectF(center.x() + (rad - graduationLength*1.5)*co - fm1.width(grad)/2,
center.y() - (rad - graduationLength*1.5)*si - fm1.height()/2, center.y() - (rad - graduationLength*1.5)*si - fm1.height()/2,
fm1.width(grad), fm1.height()), Qt::AlignTop, grad); fm1.width(grad), fm1.height()), Qt::AlignTop, grad);
//internal arc //internal arc
painter->setFont(font2); painter->setFont(font2);
painter->drawText(QRectF(center.x() + (rad/2 + graduationLength*1.5)*co - fm2.width(grad2)/2, painter->drawText(QRectF(center.x() + (rad/2 + graduationLength*1.5)*co - fm2.width(grad2)/2,
center.y() - (rad/2 + graduationLength*1.5)*si - fm2.height()/2, center.y() - (rad/2 + graduationLength*1.5)*si - fm2.height()/2,
fm2.width(grad2), fm2.height()), Qt::AlignTop, grad2); fm2.width(grad2), fm2.height()), Qt::AlignTop, grad2);
painter->setFont(font1); painter->setFont(font1);
} }
@ -415,7 +418,7 @@ void UBGraphicsProtractor::paintButtons(QPainter *painter)
{ {
Q_UNUSED(painter); Q_UNUSED(painter);
if(mShowButtons) if (mShowButtons)
{ {
qreal antiSc = antiScale(); qreal antiSc = antiScale();
@ -480,14 +483,14 @@ void UBGraphicsProtractor::paintAngleMarker(QPainter *painter)
painter->drawLine(QLineF(rect().center(), QPointF(rect().center().x()+ (rad+ 20)*co, rect().center().y() - (rad + 20)*si))); painter->drawLine(QLineF(rect().center(), QPointF(rect().center().x()+ (rad+ 20)*co, rect().center().y() - (rad + 20)*si)));
QPointF center = rect().center(); QPointF center = rect().center();
painter->drawArc(QRectF(center.x() - rad/8, center.y() - rad/8, rad / 4, rad / 4), 0 painter->drawArc(QRectF(center.x() - rad/8, center.y() - rad/8, rad / 4, rad / 4), 0
, (mCurrentAngle - (int)(mCurrentAngle/360)*360)*16); , (mCurrentAngle - (int)(mCurrentAngle/360)*360)*16);
painter->translate(rect().center()); painter->translate(rect().center());
painter->rotate(-mCurrentAngle); painter->rotate(-mCurrentAngle);
painter->translate(-rect().center().x(), -rect().center().y()); painter->translate(-rect().center().x(), -rect().center().y());
//Paint Angle text (horizontally) //Paint Angle text (horizontally)
//restore transformations //restore transformations
painter->translate(rect().center()); painter->translate(rect().center());
painter->rotate(mCurrentAngle); painter->rotate(mCurrentAngle);
painter->rotate(mStartAngle); painter->rotate(mStartAngle);
@ -495,23 +498,23 @@ void UBGraphicsProtractor::paintAngleMarker(QPainter *painter)
qreal angle = mCurrentAngle - (int)(mCurrentAngle/360)*360; qreal angle = mCurrentAngle - (int)(mCurrentAngle/360)*360;
if(angle != 0) if (angle != 0)
{ {
QString ang = QString("%1°").arg(angle,0, 'f', 1); QString ang = QString("%1°").arg(angle,0, 'f', 1);
QFont font2 = painter->font(); QFont font2 = painter->font();
font2.setBold(true); font2.setBold(true);
QFontMetricsF fm2(font2); QFontMetricsF fm2(font2);
painter->setFont(font2); painter->setFont(font2);
if (angle < 50) if (angle < 50)
angle = 90; angle = 90;
else else
angle = angle / 2; angle = angle / 2;
co = cos((mStartAngle + angle) * PI/180); co = cos((mStartAngle + angle) * PI/180);
si = sin((mStartAngle + angle) * PI/180); si = sin((mStartAngle + angle) * PI/180);
painter->drawText(QRectF(rect().center().x() + (rad*2.5/10)*co - fm2.width(ang)/2, painter->drawText(QRectF(rect().center().x() + (rad*2.5/10)*co - fm2.width(ang)/2,
rect().center().y() - (rad*2.5/10)*si - fm2.height()/2, rect().center().y() - (rad*2.5/10)*si - fm2.height()/2,
fm2.width(ang), fm2.height()), Qt::AlignTop, ang); fm2.width(ang), fm2.height()), Qt::AlignTop, ang);
} }
painter->restore(); painter->restore();
@ -528,17 +531,17 @@ UBGraphicsProtractor::Tool UBGraphicsProtractor::toolFromPos(QPointF pos)
t.rotate(mCurrentAngle); t.rotate(mCurrentAngle);
QPointF p2 = t.map(pos); QPointF p2 = t.map(pos);
if(resizeButtonRect().contains(p1)) if (resizeButtonRect().contains(p1))
return Resize; return Resize;
else if(closeButtonRect().contains(p1)) else if (closeButtonRect().contains(p1))
return Close; return Close;
else if(resetButtonRect().contains(p1)) else if (resetButtonRect().contains(p1))
return Reset; return Reset;
else if(rotateButtonRect().contains(p1)) else if (rotateButtonRect().contains(p1))
return Rotate; return Rotate;
else if(markerButtonRect().contains(p2)) else if (markerButtonRect().contains(p2))
return MoveMarker; return MoveMarker;
else if(line.length() <= radius()) else if (line.length() <= radius())
return Move; return Move;
else else
return None; return None;
@ -584,9 +587,11 @@ UBItem* UBGraphicsProtractor::deepCopy() const
void UBGraphicsProtractor::rotateAroundTopLeftOrigin(qreal angle) void UBGraphicsProtractor::rotateAroundTopLeftOrigin(qreal angle)
{} {
Q_UNUSED(angle);
}
QPointF UBGraphicsProtractor::topLeftOrigin() const QPointF UBGraphicsProtractor::topLeftOrigin() const
{ {
return QPointF(rect().x(), rect().y()); return QPointF(rect().x(), rect().y());
} }

@ -58,6 +58,7 @@ class UBGraphicsProtractor : public UBAbstractDrawRuler, public QGraphicsEllipse
virtual void hoverMoveEvent (QGraphicsSceneHoverEvent *event); virtual void hoverMoveEvent (QGraphicsSceneHoverEvent *event);
virtual QPainterPath shape() const; virtual QPainterPath shape() const;
QRectF boundingRect() const; QRectF boundingRect() const;
private: private:
// Helpers // Helpers
void paintGraduations (QPainter *painter); void paintGraduations (QPainter *painter);
@ -90,10 +91,13 @@ class UBGraphicsProtractor : public UBAbstractDrawRuler, public QGraphicsEllipse
QGraphicsSvgItem* mResizeSvgItem; QGraphicsSvgItem* mResizeSvgItem;
QGraphicsSvgItem* mMarkerSvgItem; QGraphicsSvgItem* mMarkerSvgItem;
static const QRectF sDefaultRect; static const QRectF sDefaultRect;
virtual void rotateAroundTopLeftOrigin(qreal angle);
virtual QPointF topLeftOrigin() const;
virtual void rotateAroundTopLeftOrigin(qreal angle); int sFillTransparency;
virtual QPointF topLeftOrigin() const; int sDrawTransparency;
}; };
#endif /* UBGRAPHICSPROTRACTOR_H_ */ #endif /* UBGRAPHICSPROTRACTOR_H_ */

@ -151,7 +151,7 @@ void WBWebPage::handleUnsupportedContent(QNetworkReply *reply)
if (isPDF) if (isPDF)
{ {
QMessageBox messageBox(mainWindow()); QMessageBox messageBox(mainWindow());
messageBox.setText(tr("Download PDF Document: would you prefer to download the PDF file or add it to the current Uniboard document?")); messageBox.setText(tr("Download PDF Document: would you prefer to download the PDF file or add it to the current Sankore document?"));
messageBox.addButton(tr("Download"), QMessageBox::AcceptRole); messageBox.addButton(tr("Download"), QMessageBox::AcceptRole);
QAbstractButton *addButton = QAbstractButton *addButton =

Loading…
Cancel
Save