Commit 8d1b059f authored by Anatoly Mihalchenko's avatar Anatoly Mihalchenko

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

parents e9bd3a6e 25bf9810
...@@ -7,7 +7,7 @@ CONFIG += debug_and_release \ ...@@ -7,7 +7,7 @@ CONFIG += debug_and_release \
no_include_pwd no_include_pwd
VERSION_MAJ = 1 VERSION_MAJ = 1
VERSION_MIN = 13 VERSION_MIN = 15
VERSION_TYPE = b # a = alpha, b = beta, r = release, other => error VERSION_TYPE = b # a = alpha, b = beta, r = release, other => error
VERSION_PATCH = 00 VERSION_PATCH = 00
......
...@@ -1551,21 +1551,6 @@ ...@@ -1551,21 +1551,6 @@
<enum>QAction::TextHeuristicRole</enum> <enum>QAction::TextHeuristicRole</enum>
</property> </property>
</action> </action>
<action name="actionShareItemOnWeb">
<property name="icon">
<iconset resource="../sankore.qrc">
<normaloff>:/images/addItemToLibrary.svg</normaloff>:/images/addItemToLibrary.svg</iconset>
</property>
<property name="text">
<string>Share Item on the Web</string>
</property>
<property name="toolTip">
<string>Share Capture on the Web</string>
</property>
<property name="visible">
<bool>true</bool>
</property>
</action>
<action name="actionDesktopTools"> <action name="actionDesktopTools">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
......
<?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/geogebra"
version="1.0"
width="800"
height="500"
ub:resizable="true"
ub:roles="tool cMAC cUNIX">
<name>Geogebra</name>
<content src="index.html"/>
</widget>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<BODY>
<DIV id=applet1></DIV>
<SCRIPT type=text/javascript>
function ggbOnInit()
{
alert("Geogebra applet is initialized");
}
var width=0;
var height=0;
setWidthHeight();
if (height < 500) height=500;
if (width < 800) width=800;
var applet1=document.getElementById('applet1');
applet1.innerHTML=geogebra_applet(0.95*width,height*0.95,"",true,true,true,false,true,true,true,true,true,true,true,true);
function geogebra_applet(width,height,filename,framePossible,enableRightClick,enableShiftDragZoom,showResetIcon,showMenuBar,showToolBar,showToolBarHelp,showAlgebraInput,enableLabelDrags,showSpreadsheet,showAlgebraView) {
ret = '<applet name="ggbApplet" code="geogebra.GeoGebraApplet" codebase="./bin/" archive="geogebra.jar" height="'+height+'" width="'+width+'">';
ret +='<param name="image" value="./images/loading.gif"/><param name="boxborder" value="false"/><param name="centerimage" value="true">';
ret +='<param name="java_arguments" value="-Xmx512m">';
if (filename != "") ret+='<param name="filename" value="'+filename+'">';
ret+='<param name="framePossible" value="'+framePossible+'">';
ret+='<param name="enableRightClick" value="'+enableRightClick+'">';
ret+='<param name="enableShiftDragZoom" value="'+enableShiftDragZoom+'">';
ret+='<param name="enableLabelDrags" value="'+enableLabelDrags+'">';
ret+='<param name="showSpreadsheet" value="'+showSpreadsheet+'">';
ret+='<param name="showAlgebraView" value="'+showAlgebraView+'">';
ret+='<param name="showResetIcon" value="'+showResetIcon+'">';
ret+='<param name="showMenuBar" value="'+showMenuBar+'">';
ret+='<param name="showToolBar" value="'+showToolBar+'">';
ret+='<param name="showToolBarHelp" value="'+showToolBarHelp+'">';
ret+='<param name="showAlgebraInput" value="'+showAlgebraInput+'">';
ret+='Sorry, the GeoGebra Applet could not be started. Please make sure that Java 1.4.2 (or later) is installed and activated.';
ret+='(<a href="http://java.sun.com/getjava">click here to install Java now</a>)';
ret+='</applet>';
return ret;
}
function setWidthHeight() {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
//window.alert( 'Width = ' + myWidth );
//window.alert( 'Height = ' + myHeight );
width=myWidth;
height=myHeight;
}
</SCRIPT>
</BODY></HTML>
// -------------------- Uniboard -------------------- // -------------------- sankore --------------------
// Ces fonctions permettent de dessiner le graphique directement dans Uniboard. // Ces fonctions permettent de dessiner le graphique directement dans sankore.
// Calcule tous les points de la fonction mathématique et les place dans des tableaux. // Calcule tous les points de la fonction mathématique et les place dans des tableaux.
function evaluerUniboard(eq) { function evaluerUniboard(eq) {
...@@ -28,33 +28,33 @@ ...@@ -28,33 +28,33 @@
// Regarde chaque coordonnées stockées dans le tableau et dessine le graphique // Regarde chaque coordonnées stockées dans le tableau et dessine le graphique
function calculerGraphUniboard(fin){ function calculerGraphUniboard(fin){
document.getElementById("affichage").innerHTML = "" document.getElementById("affichage").innerHTML = ""
uniboard.setTool('pen') sankore.setTool('pen')
uniboard.moveTo(pointX[2]+decalageX, pointY[2]+decalageY) sankore.moveTo(pointX[2]+decalageX, pointY[2]+decalageY)
for (i=3; i<fin; i++){ for (i=3; i<fin; i++){
if ((pointY[i]<0) || (pointY[i]>hauteur)){ if ((pointY[i]<0) || (pointY[i]>hauteur)){
uniboard.moveTo(pointX[i+1]+decalageX,pointY[i+1]+decalageY) sankore.moveTo(pointX[i+1]+decalageX,pointY[i+1]+decalageY)
continue continue
} }
uniboard.drawLineTo(pointX[i]+decalageX, pointY[i]+decalageY, lineWidth) sankore.drawLineTo(pointX[i]+decalageX, pointY[i]+decalageY, lineWidth)
} }
//dessiner le cadre //dessiner le cadre
uniboard.moveTo(0+decalageX,0+decalageY) sankore.moveTo(0+decalageX,0+decalageY)
uniboard.drawLineTo(largeur+decalageX, 0+decalageY, lineWidth) sankore.drawLineTo(largeur+decalageX, 0+decalageY, lineWidth)
uniboard.drawLineTo(largeur+decalageX, hauteur+decalageY, lineWidth) sankore.drawLineTo(largeur+decalageX, hauteur+decalageY, lineWidth)
uniboard.drawLineTo(0+decalageX, hauteur+decalageY, lineWidth) sankore.drawLineTo(0+decalageX, hauteur+decalageY, lineWidth)
uniboard.drawLineTo(0+decalageX, 0+decalageY, lineWidth) sankore.drawLineTo(0+decalageX, 0+decalageY, lineWidth)
//dessiner les axes //dessiner les axes
uniboard.moveTo((-borneXGauche*multiplicateurX)+decalageX, 0+decalageY) sankore.moveTo((-borneXGauche*multiplicateurX)+decalageX, 0+decalageY)
uniboard.drawLineTo((-borneXGauche*multiplicateurX)+decalageX, hauteur+decalageY, lineWidth) sankore.drawLineTo((-borneXGauche*multiplicateurX)+decalageX, hauteur+decalageY, lineWidth)
uniboard.moveTo(0+decalageX, (hauteur-(-borneYGauche*multiplicateurY))+decalageY) sankore.moveTo(0+decalageX, (hauteur-(-borneYGauche*multiplicateurY))+decalageY)
uniboard.drawLineTo(largeur+decalageX, (hauteur-(-borneYGauche*multiplicateurY))+decalageY, lineWidth) sankore.drawLineTo(largeur+decalageX, (hauteur-(-borneYGauche*multiplicateurY))+decalageY, lineWidth)
decalageX += 250 decalageX += 250
decalageY += 200 decalageY += 200
largeur -= 100 largeur -= 100
hauteur -= 100 hauteur -= 100
uniboard.setTool('arrow') sankore.setTool('arrow')
} }
\ No newline at end of file
...@@ -136,13 +136,13 @@ function pariteFct(){ ...@@ -136,13 +136,13 @@ function pariteFct(){
} }
} }
if(paire){ if(paire){
document.getElementById("etudeParite").innerHTML = "paire" document.getElementById("etudeParite").innerHTML = "even"
} }
else if(impaire){ else if(impaire){
document.getElementById("etudeParite").innerHTML = "impaire" document.getElementById("etudeParite").innerHTML = "uneven"
} }
else{ else{
document.getElementById("etudeParite").innerHTML = "aucune" document.getElementById("etudeParite").innerHTML = "n/a"
} }
} }
...@@ -272,7 +272,7 @@ function signeFct(fct){ ...@@ -272,7 +272,7 @@ function signeFct(fct){
listeZeros.splice((aSupprimer[i]-i), 1) listeZeros.splice((aSupprimer[i]-i), 1)
} }
if(listeZeros==""){ if(listeZeros==""){
texteZeros = "aucuns" texteZeros = "n/a"
} }
document.getElementById("etudeZeros").innerHTML = texteZeros+listeZeros document.getElementById("etudeZeros").innerHTML = texteZeros+listeZeros
} }
...@@ -282,32 +282,32 @@ function asymptotes(){ ...@@ -282,32 +282,32 @@ function asymptotes(){
if(Math.abs(limGauche[0])<1000){ if(Math.abs(limGauche[0])<1000){
var limRound = Math.round(limGauche[0]*100)/100 var limRound = Math.round(limGauche[0]*100)/100
if(limGauche[0]<limRound){ if(limGauche[0]<limRound){
document.getElementById("etudeAHG").innerHTML = "y = "+limRound +" <span class='texteSecondaire'>(courbe au-dessous de l'AH)</span>" document.getElementById("etudeAHG").innerHTML = "y = "+limRound +" <span class='texteSecondaire'>(curve is higher than a l'AH)</span>"
} }
else if(limGauche[0]>limRound){ else if(limGauche[0]>limRound){
document.getElementById("etudeAHG").innerHTML = "y = "+limRound +" <span class='texteSecondaire'>(courbe au-dessus de l'AH)</span>" document.getElementById("etudeAHG").innerHTML = "y = "+limRound +" <span class='texteSecondaire'>(curve is lower than a l'AH)</span>"
} }
else{ else{
document.getElementById("etudeAHG").innerHTML = "y = "+limRound document.getElementById("etudeAHG").innerHTML = "y = "+limRound
} }
} }
else{ else{
document.getElementById("etudeAHG").innerHTML = "aucune" document.getElementById("etudeAHG").innerHTML = "n/a"
} }
if(Math.abs(limDroite[0])<1000){ if(Math.abs(limDroite[0])<1000){
var limRound = Math.round(limDroite[0]*100)/100 var limRound = Math.round(limDroite[0]*100)/100
if(limDroite[0]<limRound){ if(limDroite[0]<limRound){
document.getElementById("etudeAHD").innerHTML = "y = "+limRound +" <span class='texteSecondaire'>(courbe au-dessous de l'AH)</span>" document.getElementById("etudeAHD").innerHTML = "y = "+limRound +" <span class='texteSecondaire'>(curve is lower than a l'AH)</span>"
} }
else if(limDroite[0]>limRound){ else if(limDroite[0]>limRound){
document.getElementById("etudeAHD").innerHTML = "y = "+limRound +" <span class='texteSecondaire'>(courbe au-dessus de l'AH)</span>" document.getElementById("etudeAHD").innerHTML = "y = "+limRound +" <span class='texteSecondaire'>(curve is higher than a l'AH)</span>"
} }
else{ else{
document.getElementById("etudeAHD").innerHTML = "y = "+limRound document.getElementById("etudeAHD").innerHTML = "y = "+limRound
} }
} }
else{ else{
document.getElementById("etudeAHD").innerHTML = "aucune" document.getElementById("etudeAHD").innerHTML = "n/a"
} }
// Verticales // Verticales
var texteAV = "" var texteAV = ""
...@@ -318,7 +318,7 @@ function asymptotes(){ ...@@ -318,7 +318,7 @@ function asymptotes(){
} }
} }
if(texteAV==""){ if(texteAV==""){
texteAV = "aucune <br/>" texteAV = "n/a <br/>"
} }
document.getElementById("etudeAV").innerHTML = texteAV document.getElementById("etudeAV").innerHTML = texteAV
} }
...@@ -343,8 +343,8 @@ function courbure(){ ...@@ -343,8 +343,8 @@ function courbure(){
} }
} }
} }
if(texteMin==""){texteMin = "<br/>Aucun Minimum";} if(texteMin==""){texteMin = "<br/>No minimum";}
if(texteMax==""){texteMax = "<br/>Aucun Maximum";} if(texteMax==""){texteMax = "<br/>No maximum";}
if(texteI==""){texteI = "<br/>Aucun I";} if(texteI==""){texteI = "<br/>Aucun I";}
document.getElementById("etudeMin").innerHTML = texteMin; document.getElementById("etudeMin").innerHTML = texteMin;
document.getElementById("etudeMax").innerHTML = texteMax; document.getElementById("etudeMax").innerHTML = texteMax;
......
...@@ -28,7 +28,7 @@ function cacherMenu(){ ...@@ -28,7 +28,7 @@ function cacherMenu(){
menuActuel = "" menuActuel = ""
} }
// ---- Minimiser ou Maximiser le widget (pour Uniboard) ---- // ---- Minimiser ou Maximiser le widget (pour sankore) ----
function miniMax(){ function miniMax(){
if (maximise){ if (maximise){
maximise = false maximise = false
...@@ -99,7 +99,7 @@ function changerTheme(){ ...@@ -99,7 +99,7 @@ function changerTheme(){
// Affiche un message d'erreur // Affiche un message d'erreur
function error(err){ function error(err){
alert(" Erreur sur la page...\n\n Description: " + err.description + "\n\n Cliquez sur OK pour continuer.\n\n") alert(" Error has occurred on the page ...\n\n Description: " + err.description + "\n\n Click 'OK' to continue.\n\n")
} }
......
...@@ -88,7 +88,7 @@ function loadOptions(){ ...@@ -88,7 +88,7 @@ function loadOptions(){
} }
else{ else{
if(document.cookie!=""){ if(document.cookie!=""){
alert("Impossible de charger les options enregistrées..."); alert("It's can't be downloaded ...");
} }
} }
} }
...@@ -115,5 +115,5 @@ function checkOptions(){ ...@@ -115,5 +115,5 @@ function checkOptions(){
} }
function alertOptions(){ function alertOptions(){
alert("Options actuellement sauvegardées\n------------------------------------------------------------\n"+document.cookie); alert("Now parameters will be saved\n------------------------------------------------------------\n"+document.cookie);
} }
\ No newline at end of file
...@@ -61,7 +61,7 @@ bool UBImportPDF::addFileToDocument(UBDocumentProxy* pDocument, const QFile& pFi ...@@ -61,7 +61,7 @@ bool UBImportPDF::addFileToDocument(UBDocumentProxy* pDocument, const QFile& pFi
QString filepath = UBPersistenceManager::persistenceManager()->addPdfFileToDocument(pDocument, pFile.fileName(), uuid); QString filepath = UBPersistenceManager::persistenceManager()->addPdfFileToDocument(pDocument, pFile.fileName(), uuid);
PDFRenderer *pdfRenderer = PDFRenderer::rendererForUuid(uuid, pDocument->persistencePath() + "/" + filepath); // renderer is automatically deleted when not used anymore PDFRenderer *pdfRenderer = PDFRenderer::rendererForUuid(uuid, pDocument->persistencePath() + "/" + filepath, true); // renderer is automatically deleted when not used anymore
if (!pdfRenderer->isValid()) if (!pdfRenderer->isValid())
{ {
......
...@@ -17,7 +17,6 @@ HEADERS += src/adaptors/UBExportAdaptor.h\ ...@@ -17,7 +17,6 @@ HEADERS += src/adaptors/UBExportAdaptor.h\
src/adaptors/UBCFFSubsetAdaptor.h src/adaptors/UBCFFSubsetAdaptor.h
HEADERS += src/adaptors/publishing/UBDocumentPublisher.h \ HEADERS += src/adaptors/publishing/UBDocumentPublisher.h \
src/adaptors/publishing/UBCapturePublisher.h \
src/adaptors/publishing/UBAbstractPublisher.h \ src/adaptors/publishing/UBAbstractPublisher.h \
src/adaptors/publishing/UBSvgSubsetRasterizer.h src/adaptors/publishing/UBSvgSubsetRasterizer.h
...@@ -42,7 +41,6 @@ SOURCES += src/adaptors/UBExportAdaptor.cpp\ ...@@ -42,7 +41,6 @@ SOURCES += src/adaptors/UBExportAdaptor.cpp\
src/adaptors/UBCFFSubsetAdaptor.cpp src/adaptors/UBCFFSubsetAdaptor.cpp
SOURCES += src/adaptors/publishing/UBDocumentPublisher.cpp \ SOURCES += src/adaptors/publishing/UBDocumentPublisher.cpp \
src/adaptors/publishing/UBCapturePublisher.cpp \
src/adaptors/publishing/UBAbstractPublisher.cpp \ src/adaptors/publishing/UBAbstractPublisher.cpp \
src/adaptors/publishing/UBSvgSubsetRasterizer.cpp src/adaptors/publishing/UBSvgSubsetRasterizer.cpp
......
/*
* 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 "UBCapturePublisher.h"
#include "frameworks/UBStringUtils.h"
#include "core/UBApplication.h"
#include "core/UBSettings.h"
#include "gui/UBMainWindow.h"
#include "board/UBBoardController.h"
#include "network/UBServerXMLHttpRequest.h"
#include "network/UBNetworkAccessManager.h"
#include "domain/UBGraphicsScene.h"
#include "core/memcheck.h"
UBCapturePublisher::UBCapturePublisher(const QPixmap& pixmap, QObject *parent)
: UBAbstractPublisher(parent)
, mPixmap(pixmap)
{
connect(this, SIGNAL(authenticated(const QUuid&, const QString&))
, this, SLOT(postPixmap(const QUuid&, const QString&)));
}
void UBCapturePublisher::publish()
{
UBAbstractPublisher::authenticate();
}
void UBCapturePublisher::postPixmap(const QUuid& tokenUuid, const QString& encryptedBase64Token)
{
UBCapturePublishingDialog dialog(UBApplication::mainWindow);
QString defaultEMail = UBSettings::settings()->uniboardWebEMail->get().toString();
dialog.email->setText(defaultEMail);
QString defaultAuthor = UBSettings::settings()->uniboardWebAuthor->get().toString();
dialog.author->setText(defaultAuthor);
if (dialog.exec() == QDialog::Accepted)
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
UBApplication::showMessage(tr("Preparing capture for upload..."), true);
QString title = dialog.title->text();
QString description = dialog.description->toPlainText();
QString email = dialog.email->text();
QString author = dialog.author->text();
QPixmap pix(mPixmap);
if (mPixmap.hasAlpha())
{
if (UBApplication::boardController->activeScene()->isDarkBackground())
pix.fill(Qt::black);
else
pix.fill(Qt::white);
QPainter p(&pix);
p.drawPixmap(0, 0, mPixmap);
}
QByteArray bytes;
QBuffer buffer(&bytes);
buffer.open(QIODevice::WriteOnly);
pix.save(&buffer, "JPG", 80);
buffer.close();
QUrl publishingEndpoint = QUrl(UBSettings::settings()->capturesPublishingUrl);
mPublishImageOnWebUploadRequest = new UBServerXMLHttpRequest(UBNetworkAccessManager::defaultAccessManager()
, "application/octet-stream");
mPublishImageOnWebUploadRequest->setVerbose(true);
connect(mPublishImageOnWebUploadRequest, SIGNAL(finished(bool, const QByteArray&)), this, SLOT(publishImageOnWebUploadResponse(bool, const QByteArray&)));
mWebUploadPublishingUuid = QUuid::createUuid();
mPublishImageOnWebUploadRequest->addHeader("Publishing-UUID", UBStringUtils::toCanonicalUuid(mWebUploadPublishingUuid));
mPublishImageOnWebUploadRequest->addHeader("Document-Title", title);
mPublishImageOnWebUploadRequest->addHeader("Document-Author", author);
mPublishImageOnWebUploadRequest->addHeader("Document-AuthorEMail", email);
mPublishImageOnWebUploadRequest->addHeader("Document-Description", description);
mPublishImageOnWebUploadRequest->addHeader("Deletion-Token", UBStringUtils::toCanonicalUuid(QUuid::createUuid()));
mPublishImageOnWebUploadRequest->addHeader("Token-UUID", UBStringUtils::toCanonicalUuid(tokenUuid));
mPublishImageOnWebUploadRequest->addHeader("Token-Encrypted", encryptedBase64Token);
mPublishImageOnWebUploadRequest->post(publishingEndpoint, bytes);
}
else
{
UBApplication::showMessage(tr("Publication canceled ..."));
QApplication::restoreOverrideCursor();
}
}
void UBCapturePublisher::publishImageOnWebUploadResponse(bool success, const QByteArray& payload)
{
QUrl url(QString::fromUtf8(payload));
if (success && url.isValid())
{
UBApplication::showMessage(tr("Capture Published to the Web."));
}
else
{
UBApplication::showMessage(tr("Error Publishing Capture to the Web: %1").arg(QString::fromUtf8(payload)));
}
if (mPublishImageOnWebUploadRequest)
{
mPublishImageOnWebUploadRequest->deleteLater();
mPublishImageOnWebUploadRequest = 0;
}
QApplication::restoreOverrideCursor();
}
UBCapturePublishingDialog::UBCapturePublishingDialog(QWidget *parent)
: QDialog(parent)
{
Ui::capturePublishingDialog::setupUi(this);
connect(dialogButtons, SIGNAL(accepted()), this, SLOT(accept()));
connect(dialogButtons, SIGNAL(rejected()), this, SLOT(reject()));
connect(title, SIGNAL(textChanged(const QString&)), this, SLOT(updateUIState(const QString&)));
connect(email, SIGNAL(textChanged(const QString&)), this, SLOT(updateUIState(const QString&)));
dialogButtons->button(QDialogButtonBox::Ok)->setEnabled(false);
dialogButtons->button(QDialogButtonBox::Ok)->setText(tr("Publish"));
}
void UBCapturePublishingDialog::updateUIState(const QString& string)
{
Q_UNUSED(string);
bool ok = title->text().length() > 0
&& email->text().length() > 0;
dialogButtons->button(QDialogButtonBox::Ok)->setEnabled(ok);
}
/*
* 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 UBCAPTUREPUBLISHER_H
#define UBCAPTUREPUBLISHER_H
#include <QtGui>
#include "ui_capturePublishing.h"
#include "UBAbstractPublisher.h"
class UBServerXMLHttpRequest;
class UBCapturePublisher : public UBAbstractPublisher
{
Q_OBJECT
public:
explicit UBCapturePublisher(const QPixmap& pixmap, QObject *parent = 0);
void publish();
private slots:
void publishImageOnWebUploadResponse(bool success, const QByteArray& payload);
void postPixmap(const QUuid& tokenUuid, const QString& encryptedBase64Token);
private:
UBServerXMLHttpRequest *mPublishImageOnWebUploadRequest;
QUuid mWebUploadPublishingUuid;
QPixmap mPixmap;
};
class UBCapturePublishingDialog : public QDialog, public Ui::capturePublishingDialog
{
Q_OBJECT;
public:
UBCapturePublishingDialog(QWidget *parent = 0);
~UBCapturePublishingDialog(){}
private slots:
void updateUIState(const QString& string);
};
#endif // UBCAPTUREPUBLISHER_H
/* /*
* UBBoardPaletteManager.cpp * 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.
* *
* Created on: 3 nov. 2009 * This program is distributed in the hope that it will be useful,
* Author: Luc * 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 "UBBoardPaletteManager.h" #include "UBBoardPaletteManager.h"
...@@ -46,8 +54,6 @@ ...@@ -46,8 +54,6 @@
#include "tools/UBToolsManager.h" #include "tools/UBToolsManager.h"
#include "adaptors/publishing/UBCapturePublisher.h"
#include "UBBoardController.h" #include "UBBoardController.h"
#include "core/memcheck.h" #include "core/memcheck.h"
...@@ -155,7 +161,6 @@ void UBBoardPaletteManager::setupPalettes() ...@@ -155,7 +161,6 @@ 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;
mAddItemPalette = new UBActionPalette(addItemActions, Qt::Horizontal, 0); mAddItemPalette = new UBActionPalette(addItemActions, Qt::Horizontal, 0);
mAddItemPalette->setButtonIconSize(QSize(128, 128)); mAddItemPalette->setButtonIconSize(QSize(128, 128));
...@@ -309,7 +314,6 @@ void UBBoardPaletteManager::connectPalettes() ...@@ -309,7 +314,6 @@ 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->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()));
...@@ -573,27 +577,27 @@ void UBBoardPaletteManager::addItemToLibrary() ...@@ -573,27 +577,27 @@ void UBBoardPaletteManager::addItemToLibrary()
mAddItemPalette->hide(); mAddItemPalette->hide();
} }
void UBBoardPaletteManager::shareItemOnWeb() //void UBBoardPaletteManager::shareItemOnWeb()
{ //{
QPixmap pixmap = mPixmap; // QPixmap pixmap = mPixmap;
if(mPixmap.isNull()) // if(mPixmap.isNull())
{ // {
pixmap = QPixmap(mItemUrl.toLocalFile()); // pixmap = QPixmap(mItemUrl.toLocalFile());
} // }
if(!pixmap.isNull()) // if(!pixmap.isNull())
{ // {
UBCapturePublisher* publisher = new UBCapturePublisher(pixmap, this); // UBCapturePublisher* publisher = new UBCapturePublisher(pixmap, this);
publisher->publish(); // publisher->publish();
} // }
else // else
{ // {
UBApplication::showMessage(tr("Error Publishing Image to the Web")); // UBApplication::showMessage(tr("Error Publishing Image to the Web"));
} // }
mAddItemPalette->hide(); // mAddItemPalette->hide();
} //}
void UBBoardPaletteManager::zoomButtonPressed() void UBBoardPaletteManager::zoomButtonPressed()
......
...@@ -118,7 +118,6 @@ class UBBoardPaletteManager : public QObject ...@@ -118,7 +118,6 @@ class UBBoardPaletteManager : public QObject
void addItemToCurrentPage(); void addItemToCurrentPage();
void addItemToNewPage(); void addItemToNewPage();
void addItemToLibrary(); void addItemToLibrary();
void shareItemOnWeb();
void purchaseLinkActivated(const QString&); void purchaseLinkActivated(const QString&);
......
...@@ -451,6 +451,7 @@ void UBPreferencesController::toolbarPositionChanged(bool checked) ...@@ -451,6 +451,7 @@ void UBPreferencesController::toolbarPositionChanged(bool checked)
UBSettings* settings = UBSettings::settings(); UBSettings* settings = UBSettings::settings();
settings->appToolBarPositionedAtTop->set(mPreferencesUI->toolbarAtTopRadioButton->isChecked()); settings->appToolBarPositionedAtTop->set(mPreferencesUI->toolbarAtTopRadioButton->isChecked());
} }
void UBPreferencesController::toolbarOrientationVertical(bool checked) void UBPreferencesController::toolbarOrientationVertical(bool checked)
......
/* /*
* UNWindowController.cpp * 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.
* *
* Created on: Jan 15, 2009 * This program is distributed in the hope that it will be useful,
* Author: julienbachmann * 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 <QDesktopWidget> #include <QDesktopWidget>
...@@ -90,6 +98,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) ...@@ -90,6 +98,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
mKeyboardPalette = UBKeyboardPalette::create(mTransparentDrawingView); mKeyboardPalette = UBKeyboardPalette::create(mTransparentDrawingView);
mKeyboardPalette->setParent(mTransparentDrawingView); mKeyboardPalette->setParent(mTransparentDrawingView);
connect(mKeyboardPalette, SIGNAL(keyboardActivated(bool)), mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool))); connect(mKeyboardPalette, SIGNAL(keyboardActivated(bool)), mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool)));
connect(mKeyboardPalette, SIGNAL(moved(QPoint)), this, SLOT(refreshMask()));
} }
connect(mDesktopPalette, SIGNAL(uniboardClick()), this, SLOT(goToUniboard())); connect(mDesktopPalette, SIGNAL(uniboardClick()), this, SLOT(goToUniboard()));
...@@ -143,12 +152,16 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) ...@@ -143,12 +152,16 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
connect(&mHoldTimerMarker, SIGNAL(timeout()), this, SLOT(markerActionReleased())); connect(&mHoldTimerMarker, SIGNAL(timeout()), this, SLOT(markerActionReleased()));
connect(&mHoldTimerEraser, SIGNAL(timeout()), this, SLOT(eraserActionReleased())); connect(&mHoldTimerEraser, SIGNAL(timeout()), this, SLOT(eraserActionReleased()));
connect(mDesktopPalette, SIGNAL(moving()), this, SLOT(refreshMask()));
connect(mLibPalette, SIGNAL(resized()), this, SLOT(refreshMask()));
onDesktopPaletteMaximized(); onDesktopPaletteMaximized();
} }
void UBDesktopAnnotationController::showKeyboard(bool show) void UBDesktopAnnotationController::showKeyboard(bool show)
{ {
mKeyboardPalette->setVisible(show); mKeyboardPalette->setVisible(show);
updateMask(true);
// mDesktopPalette->showVirtualKeyboard(show); // mDesktopPalette->showVirtualKeyboard(show);
} }
...@@ -332,6 +345,10 @@ void UBDesktopAnnotationController::showWindow() ...@@ -332,6 +345,10 @@ void UBDesktopAnnotationController::showWindow()
UBPlatformUtils::setDesktopMode(true); UBPlatformUtils::setDesktopMode(true);
mDesktopPalette->appear(); mDesktopPalette->appear();
#ifdef Q_WS_X11
updateMask(true);
#endif
} }
...@@ -343,7 +360,15 @@ void UBDesktopAnnotationController::close() ...@@ -343,7 +360,15 @@ void UBDesktopAnnotationController::close()
void UBDesktopAnnotationController::stylusToolChanged(int tool) void UBDesktopAnnotationController::stylusToolChanged(int tool)
{ {
Q_UNUSED(tool); UBStylusTool::Enum eTool = (UBStylusTool::Enum)tool;
mDesktopPalette->notifySelectorSelection(UBStylusTool::Selector == eTool);
if(UBStylusTool::Selector != eTool)
{
UBApplication::mainWindow->actionVirtualKeyboard->setChecked(false);
mKeyboardPalette->setVisible(false);
}
updateBackground(); updateBackground();
} }
...@@ -356,6 +381,9 @@ void UBDesktopAnnotationController::updateBackground() ...@@ -356,6 +381,9 @@ void UBDesktopAnnotationController::updateBackground()
|| UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Selector) || UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Selector)
{ {
newBrush = QBrush(Qt::transparent); newBrush = QBrush(Qt::transparent);
#ifdef Q_WS_X11
updateMask(true);
#endif
} }
else else
{ {
...@@ -363,6 +391,9 @@ void UBDesktopAnnotationController::updateBackground() ...@@ -363,6 +391,9 @@ void UBDesktopAnnotationController::updateBackground()
newBrush = QBrush(QColor(127, 127, 127, 15)); newBrush = QBrush(QColor(127, 127, 127, 15));
#else #else
newBrush = QBrush(QColor(127, 127, 127, 1)); newBrush = QBrush(QColor(127, 127, 127, 1));
#endif
#ifdef Q_WS_X11
updateMask(false);
#endif #endif
} }
...@@ -389,6 +420,8 @@ void UBDesktopAnnotationController::goToUniboard() ...@@ -389,6 +420,8 @@ void UBDesktopAnnotationController::goToUniboard()
UBPlatformUtils::setDesktopMode(false); UBPlatformUtils::setDesktopMode(false);
UBApplication::mainWindow->actionVirtualKeyboard->setEnabled(true);
emit restoreUniboard(); emit restoreUniboard();
} }
...@@ -751,3 +784,83 @@ void UBDesktopAnnotationController::onTransparentWidgetResized() ...@@ -751,3 +784,83 @@ void UBDesktopAnnotationController::onTransparentWidgetResized()
// qDebug() << "mLibPalette (" << mLibPalette->width() << "," << mLibPalette->height() << ")"; // qDebug() << "mLibPalette (" << mLibPalette->width() << "," << mLibPalette->height() << ")";
mLibPalette->resize(mLibPalette->width(), mTransparentDrawingView->height()); mLibPalette->resize(mLibPalette->width(), mTransparentDrawingView->height());
} }
void UBDesktopAnnotationController::updateMask(bool bTransparent)
{
if(bTransparent)
{
// Here we have to generate a new mask. This method is certainly resource
// consuming but for the moment this is the only solution that I found.
mMask = QPixmap(mTransparentDrawingView->width(), mTransparentDrawingView->height());
QPainter p;
p.begin(&mMask);
p.setPen(Qt::red);
p.setBrush(QBrush(Qt::red));
// Here we draw the widget mask
if(mDesktopPalette->isVisible())
{
p.drawRect(mDesktopPalette->geometry().x(), mDesktopPalette->geometry().y(), mDesktopPalette->width(), mDesktopPalette->height());
}
if(mKeyboardPalette->isVisible())
{
p.drawRect(mKeyboardPalette->geometry().x(), mKeyboardPalette->geometry().y(), mKeyboardPalette->width(), mKeyboardPalette->height());
}
if(mLibPalette->isVisible())
{
p.drawRect(mLibPalette->geometry().x(), mLibPalette->geometry().y(), mLibPalette->width(), mLibPalette->height());
}
p.end();
// Then we add the annotations. We create another painter because we need to
// apply transformations on it for coordinates matching
QPainter annotationPainter;
QTransform trans;
trans.translate(mTransparentDrawingView->width()/2, mTransparentDrawingView->height()/2);
annotationPainter.begin(&mMask);
annotationPainter.setPen(Qt::red);
annotationPainter.setBrush(Qt::red);
annotationPainter.setTransform(trans);
QList<QGraphicsItem*> allItems = mTransparentDrawingScene->items();
for(int i = 0; i < allItems.size(); i++)
{
QGraphicsItem* pCrntItem = allItems.at(i);
if(pCrntItem->isVisible())
{
QPainterPath crntPath = pCrntItem->shape();
QRectF rect = crntPath.boundingRect();
annotationPainter.drawRect(rect);
}
}
annotationPainter.end();
mTransparentDrawingView->setMask(mMask.createMaskFromColor(Qt::black));
}
else
{
// Remove the mask
QPixmap noMask(mTransparentDrawingView->width(), mTransparentDrawingView->height());
mTransparentDrawingView->setMask(noMask.mask());
}
}
void UBDesktopAnnotationController::refreshMask()
{
if(mIsFullyTransparent
|| UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Selector)
{
updateMask(true);
}
}
/* /*
* UNWindowController.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.
* *
* Created on: Jan 15, 2009 * This program is distributed in the hope that it will be useful,
* Author: julienbachmann * 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 UBUNINOTESWINDOWCONTROLLER_H_ #ifndef UBUNINOTESWINDOWCONTROLLER_H_
...@@ -94,10 +102,12 @@ class UBDesktopAnnotationController : public QObject ...@@ -94,10 +102,12 @@ class UBDesktopAnnotationController : public QObject
void onDesktopPaletteMaximized(); void onDesktopPaletteMaximized();
void onDesktopPaletteMinimize(); void onDesktopPaletteMinimize();
void onTransparentWidgetResized(); void onTransparentWidgetResized();
void refreshMask();
private: private:
void setAssociatedPalettePosition(UBActionPalette* palette, const QString& actionName); void setAssociatedPalettePosition(UBActionPalette* palette, const QString& actionName);
void togglePropertyPalette(UBActionPalette* palette); void togglePropertyPalette(UBActionPalette* palette);
void updateMask(bool bTransparent);
UBDesktopPalette *mDesktopPalette; UBDesktopPalette *mDesktopPalette;
UBKeyboardPalette *mKeyboardPalette; UBKeyboardPalette *mKeyboardPalette;
...@@ -126,6 +136,8 @@ class UBDesktopAnnotationController : public QObject ...@@ -126,6 +136,8 @@ class UBDesktopAnnotationController : public QObject
int mBoardStylusTool; int mBoardStylusTool;
int mDesktopStylusTool; int mDesktopStylusTool;
QPixmap mMask;
}; };
#endif /* UBUNINOTESWINDOWCONTROLLER_H_ */ #endif /* UBUNINOTESWINDOWCONTROLLER_H_ */
...@@ -36,9 +36,7 @@ UBDesktopPalette::UBDesktopPalette(QWidget *parent) ...@@ -36,9 +36,7 @@ UBDesktopPalette::UBDesktopPalette(QWidget *parent)
actions << UBApplication::mainWindow->actionPen; actions << UBApplication::mainWindow->actionPen;
actions << UBApplication::mainWindow->actionEraser; actions << UBApplication::mainWindow->actionEraser;
actions << UBApplication::mainWindow->actionMarker; actions << UBApplication::mainWindow->actionMarker;
#ifndef Q_WS_X11
actions << UBApplication::mainWindow->actionSelector; actions << UBApplication::mainWindow->actionSelector;
#endif
actions << UBApplication::mainWindow->actionPointer; actions << UBApplication::mainWindow->actionPointer;
if (UBPlatformUtils::hasVirtualKeyboard()) if (UBPlatformUtils::hasVirtualKeyboard())
...@@ -152,9 +150,7 @@ void UBDesktopPalette::maximizeMe() ...@@ -152,9 +150,7 @@ void UBDesktopPalette::maximizeMe()
actions << UBApplication::mainWindow->actionPen; actions << UBApplication::mainWindow->actionPen;
actions << UBApplication::mainWindow->actionEraser; actions << UBApplication::mainWindow->actionEraser;
actions << UBApplication::mainWindow->actionMarker; actions << UBApplication::mainWindow->actionMarker;
#ifndef Q_WS_X11
actions << UBApplication::mainWindow->actionSelector; actions << UBApplication::mainWindow->actionSelector;
#endif
actions << UBApplication::mainWindow->actionPointer; actions << UBApplication::mainWindow->actionPointer;
if (UBPlatformUtils::hasVirtualKeyboard()) if (UBPlatformUtils::hasVirtualKeyboard())
actions << UBApplication::mainWindow->actionVirtualKeyboard; actions << UBApplication::mainWindow->actionVirtualKeyboard;
...@@ -221,3 +217,8 @@ QPoint UBDesktopPalette::buttonPos(QAction *action) ...@@ -221,3 +217,8 @@ QPoint UBDesktopPalette::buttonPos(QAction *action)
return p; return p;
} }
void UBDesktopPalette::notifySelectorSelection(bool selected)
{
UBApplication::mainWindow->actionVirtualKeyboard->setEnabled(selected);
}
...@@ -27,6 +27,7 @@ class UBDesktopPalette : public UBActionPalette ...@@ -27,6 +27,7 @@ class UBDesktopPalette : public UBActionPalette
void disappearForCapture(); void disappearForCapture();
void appear(); void appear();
QPoint buttonPos(QAction* action); QPoint buttonPos(QAction* action);
void notifySelectorSelection(bool selected);
signals: signals:
void uniboardClick(); void uniboardClick();
......
...@@ -44,8 +44,8 @@ UBAbstractWidget::UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent) ...@@ -44,8 +44,8 @@ UBAbstractWidget::UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent)
, mInitialLoadDone(false) , mInitialLoadDone(false)
, mLoadIsErronous(false) , mLoadIsErronous(false)
, mIsFreezable(true) , mIsFreezable(true)
, mCanBeContent(true) , mCanBeContent(0)
, mCanBeTool(true) , mCanBeTool(0)
, mIsFrozen(false) , mIsFrozen(false)
, mIsTakingSnapshot(false) , mIsTakingSnapshot(false)
{ {
...@@ -74,12 +74,51 @@ UBAbstractWidget::UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent) ...@@ -74,12 +74,51 @@ UBAbstractWidget::UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent)
setMouseTracking(true); setMouseTracking(true);
} }
bool UBAbstractWidget::canBeContent()
{
// if we under MAC OS
#if defined(Q_OS_MAC)
return mCanBeContent & OSType::type_MAC;
#endif
// if we under UNIX OS
#if defined(Q_OS_UNIX)
return mCanBeContent & OSType::type_UNIX;
#endif
// if we under WINDOWS OS
#if defined(Q_OS_WIN)
return mCanBeContent & OSType::type_WIN;
#endif
}
bool UBAbstractWidget::canBeTool()
{
// if we under MAC OS
#if defined(Q_OS_MAC)
return mCanBeTool & OSType::type_MAC;
#endif
// if we under UNIX OS
#if defined(Q_OS_UNIX)
return mCanBeTool & OSType::type_UNIX;
#endif
// if we under WINDOWS OS
#if defined(Q_OS_WIN)
return mCanBeTool & OSType::type_WIN;
#endif
}
UBAbstractWidget::~UBAbstractWidget() UBAbstractWidget::~UBAbstractWidget()
{ {
// NOOP // NOOP
} }
void UBAbstractWidget::loadMainHtml()
{
QWebView::load(mMainHtmlUrl);
}
bool UBAbstractWidget::event(QEvent *event) bool UBAbstractWidget::event(QEvent *event)
{ {
......
...@@ -39,6 +39,8 @@ class UBAbstractWidget : public UBRoutedMouseEventWebView ...@@ -39,6 +39,8 @@ class UBAbstractWidget : public UBRoutedMouseEventWebView
UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent = 0); UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent = 0);
virtual ~UBAbstractWidget(); virtual ~UBAbstractWidget();
void loadMainHtml();
QUrl mainHtml() QUrl mainHtml()
{ {
return mMainHtmlUrl; return mMainHtmlUrl;
...@@ -64,15 +66,8 @@ class UBAbstractWidget : public UBRoutedMouseEventWebView ...@@ -64,15 +66,8 @@ class UBAbstractWidget : public UBRoutedMouseEventWebView
return mNominalSize; return mNominalSize;
} }
bool canBeContent() const bool canBeContent();
{ bool canBeTool();
return mCanBeContent;
}
bool canBeTool() const
{
return mCanBeTool;
}
bool hasLoadedSuccessfully() const bool hasLoadedSuccessfully() const
{ {
...@@ -123,8 +118,16 @@ class UBAbstractWidget : public UBRoutedMouseEventWebView ...@@ -123,8 +118,16 @@ class UBAbstractWidget : public UBRoutedMouseEventWebView
bool mLoadIsErronous; bool mLoadIsErronous;
bool mIsFreezable; bool mIsFreezable;
bool mCanBeContent; int mCanBeContent;
bool mCanBeTool; int mCanBeTool;
enum OSType
{
type_NONE = 0, // 0000
type_WIN = 1, // 0001
type_MAC = 2, // 0010
type_UNIX = 4, // 0100
type_ALL = 7, // 0111
};
virtual void injectInlineJavaScript(); virtual void injectInlineJavaScript();
virtual void paintEvent(QPaintEvent * event); virtual void paintEvent(QPaintEvent * event);
......
...@@ -130,6 +130,9 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent) ...@@ -130,6 +130,9 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
UBApplication::applicationController->initialHScroll(), UBApplication::applicationController->initialHScroll(),
UBApplication::applicationController->initialVScroll())); UBApplication::applicationController->initialVScroll()));
} }
connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing()));
} }
...@@ -138,6 +141,29 @@ UBGraphicsScene::~UBGraphicsScene() ...@@ -138,6 +141,29 @@ UBGraphicsScene::~UBGraphicsScene()
// NOOP // NOOP
} }
void UBGraphicsScene::selectionChangedProcessing()
{
QList<QGraphicsItem *> allItemsList = items();
for( int i = 0; i < allItemsList.size(); i++ )
{
QGraphicsItem *nextItem = allItemsList.at(i);
qreal zValue = nextItem->zValue();
nextItem->setZValue(qreal(1));
qDebug() << QString(" %1 ").arg(i) << QString(" %1 ").arg(zValue);
}
QList<QGraphicsItem *> selItemsList = selectedItems();
for( int i = 0; i < selItemsList.size(); i++ )
{
QGraphicsItem *nextItem = selItemsList.at(i);
qreal zValue = nextItem->zValue();
nextItem->setZValue(2);
qDebug() << QString(" >>> %1 <<< ").arg(i) << QString(" >>> %1 <<< ").arg(zValue);
}
}
// MARK: - // MARK: -
// MARK: Mouse/Tablet events handling // MARK: Mouse/Tablet events handling
...@@ -249,6 +275,8 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres ...@@ -249,6 +275,8 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
{ {
if (currentTool == UBStylusTool::Line) if (currentTool == UBStylusTool::Line)
{ {
// TODO: Verify this beautiful implementation and check if
// it is possible to optimize it
QLineF radius(mPreviousPoint, position); QLineF radius(mPreviousPoint, position);
qreal angle = radius.angle(); qreal angle = radius.angle();
angle = qRound(angle / 45) * 45; angle = qRound(angle / 45) * 45;
...@@ -1074,6 +1102,8 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co ...@@ -1074,6 +1102,8 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co
if (graphicsWidget->widgetWebView()->canBeContent()) if (graphicsWidget->widgetWebView()->canBeContent())
{ {
graphicsWidget->widgetWebView()->loadMainHtml();
graphicsWidget->setSelected(true); graphicsWidget->setSelected(true);
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, graphicsWidget); UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, graphicsWidget);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
......
...@@ -271,6 +271,9 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem ...@@ -271,6 +271,9 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void setToolCursor(int tool); void setToolCursor(int tool);
void selectionChangedProcessing();
signals: signals:
void pageSizeChanged(); void pageSizeChanged();
......
...@@ -86,8 +86,51 @@ UBW3CWidget::UBW3CWidget(const QUrl& pWidgetUrl, QWidget *parent) ...@@ -86,8 +86,51 @@ UBW3CWidget::UBW3CWidget(const QUrl& pWidgetUrl, QWidget *parent)
QString roles = widgetElement.attribute("ub:roles", "content tool").trimmed().toLower(); QString roles = widgetElement.attribute("ub:roles", "content tool").trimmed().toLower();
mCanBeTool = roles == "" || roles.contains("tool"); //------------------------------//
mCanBeContent = roles == "" || roles.contains("content");
if( roles == "" || roles.contains("tool") )
{
mCanBeTool = UBAbstractWidget::OSType::type_ALL;
}
if( roles.contains("twin") )
{
mCanBeTool |= UBAbstractWidget::OSType::type_WIN;
}
if( roles.contains("tmac") )
{
mCanBeTool |= UBAbstractWidget::OSType::type_MAC;
}
if( roles.contains("tunix") )
{
mCanBeTool |= UBAbstractWidget::OSType::type_UNIX;
}
//---------//
if( roles == "" || roles.contains("content") )
{
mCanBeContent = UBAbstractWidget::OSType::type_ALL;
}
if( roles.contains("cwin") )
{
mCanBeContent |= UBAbstractWidget::OSType::type_WIN;
}
if( roles.contains("cmac") )
{
mCanBeContent |= UBAbstractWidget::OSType::type_MAC;
}
if( roles.contains("cunix") )
{
mCanBeContent |= UBAbstractWidget::OSType::type_UNIX;
}
//------------------------------//
QDomNodeList contentDomList = widgetElement.elementsByTagName("content"); QDomNodeList contentDomList = widgetElement.elementsByTagName("content");
...@@ -159,8 +202,6 @@ UBW3CWidget::UBW3CWidget(const QUrl& pWidgetUrl, QWidget *parent) ...@@ -159,8 +202,6 @@ UBW3CWidget::UBW3CWidget(const QUrl& pWidgetUrl, QWidget *parent)
connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared())); connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared()));
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(javaScriptWindowObjectCleared())); connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(javaScriptWindowObjectCleared()));
QWebView::load(mMainHtmlUrl);
setFixedSize(QSize(width, height)); setFixedSize(QSize(width, height));
mNominalSize = QSize(width, height); mNominalSize = QSize(width, height);
...@@ -171,7 +212,6 @@ UBW3CWidget::~UBW3CWidget() ...@@ -171,7 +212,6 @@ UBW3CWidget::~UBW3CWidget()
// NOOP // NOOP
} }
void UBW3CWidget::javaScriptWindowObjectCleared() void UBW3CWidget::javaScriptWindowObjectCleared()
{ {
UBWidgetUniboardAPI *uniboardAPI = new UBWidgetUniboardAPI(UBApplication::boardController->activeScene(), 0); UBWidgetUniboardAPI *uniboardAPI = new UBWidgetUniboardAPI(UBApplication::boardController->activeScene(), 0);
......
...@@ -19,9 +19,27 @@ ...@@ -19,9 +19,27 @@
#include "UBDockPalette.h" #include "UBDockPalette.h"
#include "core/UBSettings.h" #include "core/UBSettings.h"
#include "frameworks/UBPlatformUtils.h" #include "frameworks/UBPlatformUtils.h"
#include "core/UBApplication.h"
#include "core/UBPreferencesController.h"
#include "core/memcheck.h" #include "core/memcheck.h"
/*
Note to myself: I will have to modify this implementation when we will
have to support mulitple tab. At this moment, a UBDockPalette
will be only the palette that manages the tabs. This
palette will maintain a list of tabs with icons and will
contain a QStackedWidget that will be contains the different
widget contents.
A click on a tab that is not related to the current widget
will show the related widget in the palette.
A click on a tab that is related to the current widget will
collapse the palette.
If the palette is collapsed, a click on any tab will expand it
and show the tab related widget.
*/
/** /**
* \brief The constructor * \brief The constructor
*/ */
...@@ -34,11 +52,12 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name) ...@@ -34,11 +52,12 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
, mResized(false) , mResized(false)
, mCollapseWidth(150) , mCollapseWidth(150)
, mLastWidth(-1) , mLastWidth(-1)
, mHTab(0)
{ {
setObjectName(name); setObjectName(name);
// We let 2 pixels in order to keep a small border for the resizing // We let 2 pixels in order to keep a small border for the resizing
setMinimumWidth(border() + 2); setMinimumWidth(2*border() + 2);
if (parent) if (parent)
{ {
...@@ -61,6 +80,10 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name) ...@@ -61,6 +80,10 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
// This is the only way to set the background as transparent! // This is the only way to set the background as transparent!
setStyleSheet("QWidget {background-color: transparent}"); setStyleSheet("QWidget {background-color: transparent}");
// Set the position of the tab
onToolbarPosUpdated();
connect(UBSettings::settings()->appToolBarPositionedAtTop, SIGNAL(changed(QVariant)), this, SLOT(onToolbarPosUpdated()));
} }
/** /**
...@@ -206,9 +229,9 @@ void UBDockPalette::mouseReleaseEvent(QMouseEvent *event) ...@@ -206,9 +229,9 @@ void UBDockPalette::mouseReleaseEvent(QMouseEvent *event)
if(eUBDockOrientation_Left == mOrientation) if(eUBDockOrientation_Left == mOrientation)
{ {
if(mMousePressPos.x() >= width() - 2*border() && if(mMousePressPos.x() >= width() - 2*border() &&
mMousePressPos.y() >= border() && mMousePressPos.y() >= mHTab &&
mMousePressPos.x() <= width() && mMousePressPos.x() <= width() &&
mMousePressPos.y() <= border() + TABSIZE) mMousePressPos.y() <= mHTab + TABSIZE)
{ {
tabClicked(); tabClicked();
} }
...@@ -217,8 +240,8 @@ void UBDockPalette::mouseReleaseEvent(QMouseEvent *event) ...@@ -217,8 +240,8 @@ void UBDockPalette::mouseReleaseEvent(QMouseEvent *event)
{ {
if(mMousePressPos.x() >= 0 && if(mMousePressPos.x() >= 0 &&
mMousePressPos.x() <= 2*border() && mMousePressPos.x() <= 2*border() &&
mMousePressPos.y() >= border() && mMousePressPos.y() >= mHTab &&
mMousePressPos.y() <= border() + TABSIZE) mMousePressPos.y() <= mHTab + TABSIZE)
{ {
tabClicked(); tabClicked();
} }
...@@ -291,23 +314,32 @@ void UBDockPalette::paintEvent(QPaintEvent *event) ...@@ -291,23 +314,32 @@ void UBDockPalette::paintEvent(QPaintEvent *event)
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);
painter.setBrush(mBackgroundBrush); painter.setBrush(mBackgroundBrush);
if(eUBDockTabOrientation_Up == mTabsOrientation)
{
mHTab = border();
}
else
{
mHTab = height() - border() - TABSIZE;
}
if(mOrientation == eUBDockOrientation_Left) if(mOrientation == eUBDockOrientation_Left)
{ {
QPainterPath path; QPainterPath path;
path.setFillRule(Qt::WindingFill); path.setFillRule(Qt::WindingFill);
path.addRect(0.0, 0.0, width()-border(), height()); path.addRect(0.0, 0.0, width()-2*border(), height());
path.addRoundedRect(width()-2*border(), border(), 2*border(), TABSIZE, radius(), radius()); path.addRoundedRect(width()-4*border(), mHTab, 4*border(), TABSIZE, radius(), radius());
painter.drawPath(path); painter.drawPath(path);
painter.drawPixmap(width() - border() + 1, border() + 1 , border() - 4, TABSIZE - 2, mIcon); painter.drawPixmap(width() - border() + 1, mHTab + 1 , border() - 4, TABSIZE - 2, mIcon);
} }
else if(mOrientation == eUBDockOrientation_Right) else if(mOrientation == eUBDockOrientation_Right)
{ {
QPainterPath path; QPainterPath path;
path.setFillRule(Qt::WindingFill); path.setFillRule(Qt::WindingFill);
path.addRect(border(), 0.0, width()-border(), height()); path.addRect(2*border(), 0.0, width()-2*border(), height());
path.addRoundedRect(0.0, border(), 2*border(), TABSIZE, radius(), radius()); path.addRoundedRect(0.0, mHTab, 4*border(), TABSIZE, radius(), radius());
painter.drawPath(path); painter.drawPath(path);
painter.drawPixmap(2, border() + 1, border() - 3, TABSIZE - 2, mIcon); painter.drawPixmap(2, mHTab + 1, border() - 3, TABSIZE - 2, mIcon);
} }
else else
{ {
...@@ -372,7 +404,7 @@ void UBDockPalette::tabClicked() ...@@ -372,7 +404,7 @@ void UBDockPalette::tabClicked()
{ {
// The palette must be collapsed // The palette must be collapsed
mLastWidth = width(); mLastWidth = width();
resize(border(), height()); resize(2*border(), height());
} }
else else
{ {
...@@ -381,3 +413,27 @@ void UBDockPalette::tabClicked() ...@@ -381,3 +413,27 @@ void UBDockPalette::tabClicked()
mLastWidth = -1; mLastWidth = -1;
} }
} }
void UBDockPalette::setTabsOrientation(eUBDockTabOrientation orientation)
{
mTabsOrientation = orientation;
}
void UBDockPalette::onToolbarPosUpdated()
{
// Get the position of the tab
if(UBSettings::settings()->appToolBarPositionedAtTop->get().toBool())
{
setTabsOrientation(eUBDockTabOrientation_Up);
}
else
{
setTabsOrientation(eUBDockTabOrientation_Down);
}
update();
}
int UBDockPalette::customMargin()
{
return 5;
}
...@@ -39,14 +39,22 @@ typedef enum ...@@ -39,14 +39,22 @@ typedef enum
eUBDockOrientation_Bottom /** [to be implemented]Bottom dock */ eUBDockOrientation_Bottom /** [to be implemented]Bottom dock */
}eUBDockOrientation; }eUBDockOrientation;
typedef enum
{
eUBDockTabOrientation_Up, /** Up tabs */
eUBDockTabOrientation_Down /** Down tabs */
}eUBDockTabOrientation;
class UBDockPalette : public QWidget class UBDockPalette : public QWidget
{ {
Q_OBJECT
public: public:
UBDockPalette(QWidget* parent=0, const char* name="UBDockPalette"); UBDockPalette(QWidget* parent=0, const char* name="UBDockPalette");
~UBDockPalette(); ~UBDockPalette();
eUBDockOrientation orientation(); eUBDockOrientation orientation();
void setOrientation(eUBDockOrientation orientation); void setOrientation(eUBDockOrientation orientation);
void setTabsOrientation(eUBDockTabOrientation orientation);
virtual void mouseMoveEvent(QMouseEvent *event); virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent *event); virtual void mousePressEvent(QMouseEvent *event);
...@@ -60,6 +68,7 @@ public: ...@@ -60,6 +68,7 @@ public:
protected: protected:
virtual int border(); virtual int border();
virtual int radius(); virtual int radius();
virtual int customMargin();
virtual void updateMaxWidth(); virtual void updateMaxWidth();
virtual void resizeEvent(QResizeEvent *event); virtual void resizeEvent(QResizeEvent *event);
virtual int collapseWidth(); virtual int collapseWidth();
...@@ -86,6 +95,13 @@ protected: ...@@ -86,6 +95,13 @@ protected:
QPoint mMousePressPos; QPoint mMousePressPos;
/** The palette icon */ /** The palette icon */
QPixmap mIcon; QPixmap mIcon;
/** The tab orientation */
eUBDockTabOrientation mTabsOrientation;
/** The h position of the tab */
int mHTab;
private slots:
void onToolbarPosUpdated();
private: private:
void tabClicked(); void tabClicked();
......
...@@ -106,6 +106,7 @@ void UBFloatingPalette::mouseMoveEvent(QMouseEvent *event) ...@@ -106,6 +106,7 @@ void UBFloatingPalette::mouseMoveEvent(QMouseEvent *event)
{ {
moveInsideParent(event->globalPos() - mDragPosition); moveInsideParent(event->globalPos() - mDragPosition);
event->accept(); event->accept();
emit moving();
} }
else else
{ {
......
...@@ -78,6 +78,7 @@ class UBFloatingPalette : public QWidget ...@@ -78,6 +78,7 @@ class UBFloatingPalette : public QWidget
void minimizeStart(eMinimizedLocation location); void minimizeStart(eMinimizedLocation location);
void maximizeStart(); void maximizeStart();
void maximized(); void maximized();
void moving();
}; };
......
...@@ -39,6 +39,7 @@ UBLibNavigatorWidget::UBLibNavigatorWidget(QWidget *parent, const char *name):QW ...@@ -39,6 +39,7 @@ UBLibNavigatorWidget::UBLibNavigatorWidget(QWidget *parent, const char *name):QW
UBLibPalette* pLibPalette = dynamic_cast<UBLibPalette*>(parentWidget()); UBLibPalette* pLibPalette = dynamic_cast<UBLibPalette*>(parentWidget());
mLayout = new QVBoxLayout(this); mLayout = new QVBoxLayout(this);
// mLayout->setContentsMargins(20, 5, 5, 5);
setLayout(mLayout); setLayout(mLayout);
mPathViewer = new UBLibPathViewer(this); mPathViewer = new UBLibPathViewer(this);
......
...@@ -34,13 +34,13 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare ...@@ -34,13 +34,13 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare
mIcon = QPixmap(":images/paletteLibrary.png"); mIcon = QPixmap(":images/paletteLibrary.png");
setAcceptDrops(true); setAcceptDrops(true);
resize(UBSettings::settings()->libPaletteWidth->get().toInt(), height()); resize(UBSettings::settings()->libPaletteWidth->get().toInt(), parentWidget()->height());
setContentsMargins(border(), 0, 0, 0); setContentsMargins(border(), 0, 0, 0);
mCollapseWidth = 180; mCollapseWidth = 180;
mLastWidth = 300; mLastWidth = 300;
mLayout = new QVBoxLayout(this); mLayout = new QVBoxLayout(this);
mLayout->setMargin(3); mLayout->setContentsMargins(20, customMargin(), customMargin(), customMargin());
setLayout(mLayout); setLayout(mLayout);
// Build the GUI // Build the GUI
...@@ -201,6 +201,7 @@ void UBLibPalette::resizeEvent(QResizeEvent *event) ...@@ -201,6 +201,7 @@ void UBLibPalette::resizeEvent(QResizeEvent *event)
{ {
UBDockPalette::resizeEvent(event); UBDockPalette::resizeEvent(event);
UBSettings::settings()->libPaletteWidth->set(width()); UBSettings::settings()->libPaletteWidth->set(width());
emit resized();
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
......
...@@ -55,6 +55,9 @@ public: ...@@ -55,6 +55,9 @@ public:
UBLibActionBar* actionBar(){return mActionBar;} UBLibActionBar* actionBar(){return mActionBar;}
signals:
void resized();
protected: protected:
void updateMaxWidth(); void updateMaxWidth();
void dragEnterEvent(QDragEnterEvent* pEvent); void dragEnterEvent(QDragEnterEvent* pEvent);
......
...@@ -35,11 +35,10 @@ UBNavigatorPalette::UBNavigatorPalette(QWidget *parent, const char *name):UBDock ...@@ -35,11 +35,10 @@ UBNavigatorPalette::UBNavigatorPalette(QWidget *parent, const char *name):UBDock
mIcon = QPixmap(":images/paletteNavigator.png"); mIcon = QPixmap(":images/paletteNavigator.png");
resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), height()); resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), height());
mLastWidth = 300; mLastWidth = 300;
setContentsMargins(0, 0, border(), 0);
// Build the gui // Build the gui
mLayout = new QVBoxLayout(this); mLayout = new QVBoxLayout(this);
mLayout->setMargin(3); mLayout->setContentsMargins(customMargin(), customMargin(), 2*border() + customMargin(), customMargin());
setLayout(mLayout); setLayout(mLayout);
mNavigator = new UBDocumentNavigator(this); mNavigator = new UBDocumentNavigator(this);
......
...@@ -72,6 +72,7 @@ UBToolWidget::UBToolWidget(UBAbstractWidget* pWidget, QWidget* pParent) ...@@ -72,6 +72,7 @@ UBToolWidget::UBToolWidget(UBAbstractWidget* pWidget, QWidget* pParent)
, mShouldMoveWidget(false) , mShouldMoveWidget(false)
{ {
mToolWidget->setParent(this); mToolWidget->setParent(this);
mToolWidget->loadMainHtml();
initialize(); initialize();
......
...@@ -30,7 +30,7 @@ PDFRenderer::~PDFRenderer() ...@@ -30,7 +30,7 @@ PDFRenderer::~PDFRenderer()
// NOOP // NOOP
} }
PDFRenderer* PDFRenderer::rendererForUuid(const QUuid &uuid, const QString &filename) PDFRenderer* PDFRenderer::rendererForUuid(const QUuid &uuid, const QString &filename, bool importingFile)
{ {
if (sRenderers.contains(uuid)) if (sRenderers.contains(uuid))
{ {
...@@ -38,7 +38,7 @@ PDFRenderer* PDFRenderer::rendererForUuid(const QUuid &uuid, const QString &file ...@@ -38,7 +38,7 @@ PDFRenderer* PDFRenderer::rendererForUuid(const QUuid &uuid, const QString &file
} }
else else
{ {
PDFRenderer *newRenderer = new XPDFRenderer(filename); PDFRenderer *newRenderer = new XPDFRenderer(filename,importingFile);
newRenderer->setRefCount(0); newRenderer->setRefCount(0);
newRenderer->setFileUuid(uuid); newRenderer->setFileUuid(uuid);
......
...@@ -31,7 +31,7 @@ class PDFRenderer : public QObject ...@@ -31,7 +31,7 @@ class PDFRenderer : public QObject
Q_OBJECT Q_OBJECT
public: public:
static PDFRenderer* rendererForUuid(const QUuid &uuid, const QString &filename); static PDFRenderer* rendererForUuid(const QUuid &uuid, const QString &filename, bool importingFile = false);
virtual ~PDFRenderer(); virtual ~PDFRenderer();
virtual bool isValid() const = 0; virtual bool isValid() const = 0;
......
...@@ -19,18 +19,11 @@ ...@@ -19,18 +19,11 @@
#include <frameworks/UBPlatformUtils.h> #include <frameworks/UBPlatformUtils.h>
#include <splash/SplashBitmap.h>
#include <xpdf/Object.h>
#include <xpdf/GlobalParams.h>
#include <xpdf/SplashOutputDev.h>
#include <xpdf/PDFDoc.h>
#include "core/memcheck.h" #include "core/memcheck.h"
QAtomicInt XPDFRenderer::sInstancesCount = 0; QAtomicInt XPDFRenderer::sInstancesCount = 0;
XPDFRenderer::XPDFRenderer(const QString &filename) XPDFRenderer::XPDFRenderer(const QString &filename, bool importingFile)
: mDocument(0) : mDocument(0)
{ {
if (!globalParams) if (!globalParams)
...@@ -44,7 +37,13 @@ XPDFRenderer::XPDFRenderer(const QString &filename) ...@@ -44,7 +37,13 @@ XPDFRenderer::XPDFRenderer(const QString &filename)
mDocument = new PDFDoc(new GString(filename.toUtf8().data()), 0, 0, 0); // the filename GString is deleted on PDFDoc desctruction mDocument = new PDFDoc(new GString(filename.toUtf8().data()), 0, 0, 0); // the filename GString is deleted on PDFDoc desctruction
sInstancesCount.ref(); sInstancesCount.ref();
bThumbGenerated = !importingFile;
bPagesGenerated = false;
mPagesMap.clear();
mThumbs.clear();
mThumbMap.clear();
mScaleX = 0.0;
mScaleY = 0.0;
} }
XPDFRenderer::~XPDFRenderer() XPDFRenderer::~XPDFRenderer()
...@@ -135,47 +134,114 @@ int XPDFRenderer::pageRotation(int pageNumber) const ...@@ -135,47 +134,114 @@ int XPDFRenderer::pageRotation(int pageNumber) const
return 0; return 0;
} }
void XPDFRenderer::render(QPainter *p, int pageNumber, const QRectF &bounds) void XPDFRenderer::render(QPainter *p, int pageNumber, const QRectF &bounds)
{ {
if (isValid())
{
qreal xscale = p->worldTransform().m11();
qreal yscale = p->worldTransform().m22();
bool bZoomChanged = false;
bool bFirstThumbnail = false;
if(fabs(mScaleX - xscale) > 0.1 || fabs(mScaleY - yscale) > 0.1)
{
mScaleX = xscale;
mScaleY = yscale;
bZoomChanged = true;
}
// First verify if the thumbnails and the pages are generated
if(!bThumbGenerated)
{
if(pageNumber == 1)
{
bFirstThumbnail = true;
}
if(!mThumbMap[pageNumber - 1])
{
// Generate the thumbnail
mThumbs << *createPDFImage(pageNumber, xscale, yscale, bounds);
mThumbMap[pageNumber - 1] = true;
if(pageNumber == mDocument->getNumPages())
{
bThumbGenerated = true;
}
}
}
else if(!bPagesGenerated || bZoomChanged)
{
if(!mPagesMap[pageNumber - 1] || bZoomChanged)
{
// Generate the page
mNumPageToPageMap[pageNumber] = *createPDFImage(pageNumber, xscale, yscale, bounds);
mPagesMap[pageNumber - 1] = true;
if(mPagesMap.size() == mDocument->getNumPages())
{
bPagesGenerated = true;
}
}
}
QImage pdfImage;
if(!bThumbGenerated || bFirstThumbnail)
{
pdfImage = mThumbs.at(pageNumber - 1);
}
else
{
pdfImage = mNumPageToPageMap[pageNumber];
}
QTransform savedTransform = p->worldTransform();
p->resetTransform();
QTime t;
t.start();
p->drawImage(QPointF(savedTransform.dx() + mSliceX, savedTransform.dy() + mSliceY), pdfImage);
//qDebug() << "XPDFRenderer::render(...) execution time: " << t.elapsed() << "ms";
p->setWorldTransform(savedTransform);
}
}
QImage* XPDFRenderer::createPDFImage(int pageNumber, const qreal xscale, const qreal yscale, const QRectF &bounds)
{
QImage* img = new QImage();
if (isValid()) if (isValid())
{ {
SplashColor paperColor = {0xFF, 0xFF, 0xFF}; // white SplashColor paperColor = {0xFF, 0xFF, 0xFF}; // white
SplashOutputDev splash(splashModeRGB8, 1, gFalse, paperColor); mSplash = new SplashOutputDev(splashModeRGB8, 1, gFalse, paperColor);
splash.startDoc(mDocument->getXRef()); mSplash->startDoc(mDocument->getXRef());
int hResolution = 72; int hResolution = 72;
int vResolution = 72; int vResolution = 72;
int rotation = 0; // in degrees (get it from the worldTransform if we want to support rotation) int rotation = 0; // in degrees (get it from the worldTransform if we want to support rotation)
GBool useMediaBox = gFalse; GBool useMediaBox = gFalse;
GBool crop = gTrue; GBool crop = gTrue;
GBool printing = gFalse; GBool printing = gFalse;
const qreal xScale = p->worldTransform().m11(); const qreal xScale = xscale;
const qreal yScale = p->worldTransform().m22(); const qreal yScale = yscale;
qreal sliceX = 0.; mSliceX = 0.;
qreal sliceY = 0.; mSliceY = 0.;
if (bounds.isNull()) if (bounds.isNull())
{ {
mDocument->displayPage(&splash, pageNumber, hResolution * xScale, vResolution * yScale, mDocument->displayPage(mSplash, pageNumber, hResolution * xScale, vResolution * yScale,
rotation, useMediaBox, crop, printing); rotation, useMediaBox, crop, printing);
} }
else else
{ {
sliceX = bounds.x() * xScale; mSliceX = bounds.x() * xScale;
sliceY = bounds.y() * yScale; mSliceY = bounds.y() * yScale;
qreal sliceW = bounds.width() * xScale; qreal sliceW = bounds.width() * xScale;
qreal sliceH = bounds.height() * yScale; qreal sliceH = bounds.height() * yScale;
mDocument->displayPageSlice(&splash, pageNumber, hResolution * xScale, vResolution * yScale, mDocument->displayPageSlice(mSplash, pageNumber, hResolution * xScale, vResolution * yScale,
rotation, useMediaBox, crop, printing, sliceX, sliceY, sliceW, sliceH); rotation, useMediaBox, crop, printing, mSliceX, mSliceY, sliceW, sliceH);
} }
SplashBitmap *bitmap = splash.getBitmap(); mpSplashBitmap = mSplash->getBitmap();
QImage pdfImage(bitmap->getDataPtr(), bitmap->getWidth(), bitmap->getHeight(), bitmap->getWidth() * 3, QImage::Format_RGB888); img = new QImage(mpSplashBitmap->getDataPtr(), mpSplashBitmap->getWidth(), mpSplashBitmap->getHeight(), mpSplashBitmap->getWidth() * 3, QImage::Format_RGB888);
QTransform savedTransform = p->worldTransform();
p->resetTransform();
p->drawImage(QPointF(savedTransform.dx() + sliceX, savedTransform.dy() + sliceY), pdfImage);
p->setWorldTransform(savedTransform);
} }
return img;
} }
...@@ -30,7 +30,7 @@ class XPDFRenderer : public PDFRenderer ...@@ -30,7 +30,7 @@ class XPDFRenderer : public PDFRenderer
Q_OBJECT Q_OBJECT
public: public:
XPDFRenderer(const QString &filename); XPDFRenderer(const QString &filename, bool importingFile = false);
virtual ~XPDFRenderer(); virtual ~XPDFRenderer();
bool isValid() const; bool isValid() const;
......
...@@ -567,17 +567,22 @@ QCursor UBGraphicsTriangle::flipCursor() const ...@@ -567,17 +567,22 @@ QCursor UBGraphicsTriangle::flipCursor() const
void UBGraphicsTriangle::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsTriangle::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
lastRect = rect().toRect();
lastPos = event->screenPos();
if (resize1Polygon().containsPoint(event->pos().toPoint(), Qt::OddEvenFill)) if (resize1Polygon().containsPoint(event->pos().toPoint(), Qt::OddEvenFill))
{ {
mResizing1 = true; mResizing1 = true;
event->accept(); event->accept();
} }
else if (resize2Polygon().containsPoint(event->pos().toPoint(), Qt::OddEvenFill)) else
if (resize2Polygon().containsPoint(event->pos().toPoint(), Qt::OddEvenFill))
{ {
mResizing2 = true; mResizing2 = true;
event->accept(); event->accept();
} }
else if(rotateRect().contains(event->pos())) else
if(rotateRect().contains(event->pos()))
{ {
mRotating = true; mRotating = true;
event->accept(); event->accept();
...@@ -596,72 +601,69 @@ void UBGraphicsTriangle::mousePressEvent(QGraphicsSceneMouseEvent *event) ...@@ -596,72 +601,69 @@ void UBGraphicsTriangle::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsTriangle::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsTriangle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
QPoint currPos = event->screenPos();
// qDebug() << QString(" X: %1 ").arg(currPos.x());
// qDebug() << QString(" Y: %1 ").arg(currPos.y());
if (!mResizing1 && !mResizing2 && !mRotating) if (!mResizing1 && !mResizing2 && !mRotating)
{ {
QGraphicsItem::mouseMoveEvent(event); QGraphicsItem::mouseMoveEvent(event);
} }
else else
{ {
//-----------------------------------------------//
if (mResizing1) if (mResizing1)
{ {
QPointF delta = event->pos() - event->lastPos();
if (mOrientation == TopLeft || mOrientation == BottomLeft)
{
if (rect().width() + delta.x() < (qreal)sMinWidth)
delta.setX((qreal)sMinWidth - rect().width());
}
else
{
if (rect().width() - delta.x() < (qreal)sMinWidth)
delta.setX((qreal)sMinWidth - rect().width());
}
if (mOrientation == TopLeft || mOrientation == BottomLeft) if (mOrientation == TopLeft || mOrientation == BottomLeft)
{ {
setRect(QRectF( int deltaX = currPos.x() - lastPos.x();
rect().topLeft(), if (lastRect.width() + deltaX < sMinWidth)
QSizeF(rect().width() + delta.x(), deltaX = sMinWidth - lastRect.width();
rect().height())),
mOrientation); setRect(QRectF(lastRect.left(), lastRect.top(),
lastRect.width() + deltaX, lastRect.height()), mOrientation);
} }
else else
{ {
setRect(QRectF( int deltaX = lastPos.x() - currPos.x();
rect().left() + delta.x(), if (lastRect.width() + deltaX < sMinWidth)
rect().top(), deltaX = sMinWidth - lastRect.width();
rect().width() - delta.x(),
rect().height()), setRect(QRectF(lastRect.left() - deltaX, lastRect.top(),
mOrientation lastRect.width() + deltaX, lastRect.height()), mOrientation);
);
} }
} }
//-----------------------------------------------//
if (mResizing2) if (mResizing2)
{ {
QPointF delta = event->pos() - event->lastPos();
if (mOrientation == BottomRight || mOrientation == BottomLeft) if (mOrientation == BottomRight || mOrientation == BottomLeft)
{ {
if (rect().height() - delta.y() < (qreal)sMinHeight) int deltaY = lastPos.y() - currPos.y();
delta.setY((qreal)sMinHeight - rect().height()); if (lastRect.height() + deltaY < sMinHeight)
deltaY = sMinHeight - lastRect.height();
setRect(QRectF(lastRect.left(), lastRect.top() - deltaY,
lastRect.width(), lastRect.height() + deltaY), mOrientation);
} }
else else
{ {
if (rect().height() + delta.y() < (qreal)sMinHeight) int deltaY = currPos.y() - lastPos.y();
delta.setY((qreal)sMinHeight - rect().height()); if (lastRect.height() + deltaY < sMinHeight)
deltaY = sMinHeight - lastRect.height();
setRect(QRectF(lastRect.left(), lastRect.top(),
lastRect.width(), lastRect.height() + deltaY), mOrientation);
} }
if (mOrientation == BottomRight || mOrientation == BottomLeft)
setRect(QRectF(
rect().left(),
rect().top() + delta.y(),
rect().width(),
rect().height() - delta.y()),
mOrientation);
else
setRect(QRectF(
rect().left(),
rect().top(),
rect().width(),
rect().height() + delta.y()),
mOrientation);
} }
//-----------------------------------------------//
if (mRotating) if (mRotating)
{ {
QLineF currentLine(rotationCenter(), event->pos()); QLineF currentLine(rotationCenter(), event->pos());
...@@ -669,6 +671,8 @@ void UBGraphicsTriangle::mouseMoveEvent(QGraphicsSceneMouseEvent *event) ...@@ -669,6 +671,8 @@ void UBGraphicsTriangle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
rotateAroundCenter(currentLine.angleTo(lastLine)); rotateAroundCenter(currentLine.angleTo(lastLine));
} }
//-----------------------------------------------//
event->accept(); event->accept();
} }
} }
......
...@@ -113,6 +113,8 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt ...@@ -113,6 +113,8 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
bool mResizing1; bool mResizing1;
bool mResizing2; bool mResizing2;
bool mRotating; bool mRotating;
QRect lastRect;
QPoint lastPos;
QGraphicsSvgItem* mHFlipSvgItem; QGraphicsSvgItem* mHFlipSvgItem;
QGraphicsSvgItem* mVFlipSvgItem; QGraphicsSvgItem* mVFlipSvgItem;
......
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