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 \
no_include_pwd
VERSION_MAJ = 1
VERSION_MIN = 13
VERSION_MIN = 15
VERSION_TYPE = b # a = alpha, b = beta, r = release, other => error
VERSION_PATCH = 00
......
......@@ -1551,21 +1551,6 @@
<enum>QAction::TextHeuristicRole</enum>
</property>
</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">
<property name="checkable">
<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 --------------------
// Ces fonctions permettent de dessiner le graphique directement dans Uniboard.
// -------------------- sankore --------------------
// 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.
function evaluerUniboard(eq) {
......@@ -28,33 +28,33 @@
// Regarde chaque coordonnées stockées dans le tableau et dessine le graphique
function calculerGraphUniboard(fin){
document.getElementById("affichage").innerHTML = ""
uniboard.setTool('pen')
uniboard.moveTo(pointX[2]+decalageX, pointY[2]+decalageY)
sankore.setTool('pen')
sankore.moveTo(pointX[2]+decalageX, pointY[2]+decalageY)
for (i=3; i<fin; i++){
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
}
uniboard.drawLineTo(pointX[i]+decalageX, pointY[i]+decalageY, lineWidth)
sankore.drawLineTo(pointX[i]+decalageX, pointY[i]+decalageY, lineWidth)
}
//dessiner le cadre
uniboard.moveTo(0+decalageX,0+decalageY)
uniboard.drawLineTo(largeur+decalageX, 0+decalageY, lineWidth)
uniboard.drawLineTo(largeur+decalageX, hauteur+decalageY, lineWidth)
uniboard.drawLineTo(0+decalageX, hauteur+decalageY, lineWidth)
uniboard.drawLineTo(0+decalageX, 0+decalageY, lineWidth)
sankore.moveTo(0+decalageX,0+decalageY)
sankore.drawLineTo(largeur+decalageX, 0+decalageY, lineWidth)
sankore.drawLineTo(largeur+decalageX, hauteur+decalageY, lineWidth)
sankore.drawLineTo(0+decalageX, hauteur+decalageY, lineWidth)
sankore.drawLineTo(0+decalageX, 0+decalageY, lineWidth)
//dessiner les axes
uniboard.moveTo((-borneXGauche*multiplicateurX)+decalageX, 0+decalageY)
uniboard.drawLineTo((-borneXGauche*multiplicateurX)+decalageX, hauteur+decalageY, lineWidth)
uniboard.moveTo(0+decalageX, (hauteur-(-borneYGauche*multiplicateurY))+decalageY)
uniboard.drawLineTo(largeur+decalageX, (hauteur-(-borneYGauche*multiplicateurY))+decalageY, lineWidth)
sankore.moveTo((-borneXGauche*multiplicateurX)+decalageX, 0+decalageY)
sankore.drawLineTo((-borneXGauche*multiplicateurX)+decalageX, hauteur+decalageY, lineWidth)
sankore.moveTo(0+decalageX, (hauteur-(-borneYGauche*multiplicateurY))+decalageY)
sankore.drawLineTo(largeur+decalageX, (hauteur-(-borneYGauche*multiplicateurY))+decalageY, lineWidth)
decalageX += 250
decalageY += 200
largeur -= 100
hauteur -= 100
uniboard.setTool('arrow')
sankore.setTool('arrow')
}
\ No newline at end of file
......@@ -136,13 +136,13 @@ function pariteFct(){
}
}
if(paire){
document.getElementById("etudeParite").innerHTML = "paire"
document.getElementById("etudeParite").innerHTML = "even"
}
else if(impaire){
document.getElementById("etudeParite").innerHTML = "impaire"
document.getElementById("etudeParite").innerHTML = "uneven"
}
else{
document.getElementById("etudeParite").innerHTML = "aucune"
document.getElementById("etudeParite").innerHTML = "n/a"
}
}
......@@ -272,7 +272,7 @@ function signeFct(fct){
listeZeros.splice((aSupprimer[i]-i), 1)
}
if(listeZeros==""){
texteZeros = "aucuns"
texteZeros = "n/a"
}
document.getElementById("etudeZeros").innerHTML = texteZeros+listeZeros
}
......@@ -282,32 +282,32 @@ function asymptotes(){
if(Math.abs(limGauche[0])<1000){
var limRound = Math.round(limGauche[0]*100)/100
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){
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{
document.getElementById("etudeAHG").innerHTML = "y = "+limRound
}
}
else{
document.getElementById("etudeAHG").innerHTML = "aucune"
document.getElementById("etudeAHG").innerHTML = "n/a"
}
if(Math.abs(limDroite[0])<1000){
var limRound = Math.round(limDroite[0]*100)/100
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){
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{
document.getElementById("etudeAHD").innerHTML = "y = "+limRound
}
}
else{
document.getElementById("etudeAHD").innerHTML = "aucune"
document.getElementById("etudeAHD").innerHTML = "n/a"
}
// Verticales
var texteAV = ""
......@@ -318,7 +318,7 @@ function asymptotes(){
}
}
if(texteAV==""){
texteAV = "aucune <br/>"
texteAV = "n/a <br/>"
}
document.getElementById("etudeAV").innerHTML = texteAV
}
......@@ -343,8 +343,8 @@ function courbure(){
}
}
}
if(texteMin==""){texteMin = "<br/>Aucun Minimum";}
if(texteMax==""){texteMax = "<br/>Aucun Maximum";}
if(texteMin==""){texteMin = "<br/>No minimum";}
if(texteMax==""){texteMax = "<br/>No maximum";}
if(texteI==""){texteI = "<br/>Aucun I";}
document.getElementById("etudeMin").innerHTML = texteMin;
document.getElementById("etudeMax").innerHTML = texteMax;
......
......@@ -28,7 +28,7 @@ function cacherMenu(){
menuActuel = ""
}
// ---- Minimiser ou Maximiser le widget (pour Uniboard) ----
// ---- Minimiser ou Maximiser le widget (pour sankore) ----
function miniMax(){
if (maximise){
maximise = false
......@@ -99,7 +99,7 @@ function changerTheme(){
// Affiche un message d'erreur
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(){
}
else{
if(document.cookie!=""){
alert("Impossible de charger les options enregistrées...");
alert("It's can't be downloaded ...");
}
}
}
......@@ -115,5 +115,5 @@ function checkOptions(){
}
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
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())
{
......
......@@ -17,7 +17,6 @@ HEADERS += src/adaptors/UBExportAdaptor.h\
src/adaptors/UBCFFSubsetAdaptor.h
HEADERS += src/adaptors/publishing/UBDocumentPublisher.h \
src/adaptors/publishing/UBCapturePublisher.h \
src/adaptors/publishing/UBAbstractPublisher.h \
src/adaptors/publishing/UBSvgSubsetRasterizer.h
......@@ -42,7 +41,6 @@ SOURCES += src/adaptors/UBExportAdaptor.cpp\
src/adaptors/UBCFFSubsetAdaptor.cpp
SOURCES += src/adaptors/publishing/UBDocumentPublisher.cpp \
src/adaptors/publishing/UBCapturePublisher.cpp \
src/adaptors/publishing/UBAbstractPublisher.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
* Author: Luc
* 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 "UBBoardPaletteManager.h"
......@@ -46,8 +54,6 @@
#include "tools/UBToolsManager.h"
#include "adaptors/publishing/UBCapturePublisher.h"
#include "UBBoardController.h"
#include "core/memcheck.h"
......@@ -155,7 +161,6 @@ void UBBoardPaletteManager::setupPalettes()
addItemActions << UBApplication::mainWindow->actionAddItemToCurrentPage;
addItemActions << UBApplication::mainWindow->actionAddItemToNewPage;
addItemActions << UBApplication::mainWindow->actionAddItemToLibrary;
addItemActions << UBApplication::mainWindow->actionShareItemOnWeb;
mAddItemPalette = new UBActionPalette(addItemActions, Qt::Horizontal, 0);
mAddItemPalette->setButtonIconSize(QSize(128, 128));
......@@ -309,7 +314,6 @@ void UBBoardPaletteManager::connectPalettes()
connect(UBApplication::mainWindow->actionAddItemToCurrentPage, SIGNAL(triggered()), this, SLOT(addItemToCurrentPage()));
connect(UBApplication::mainWindow->actionAddItemToNewPage, SIGNAL(triggered()), this, SLOT(addItemToNewPage()));
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->actionEraseAnnotations, SIGNAL(triggered()), mErasePalette, SLOT(close()));
......@@ -573,27 +577,27 @@ void UBBoardPaletteManager::addItemToLibrary()
mAddItemPalette->hide();
}
void UBBoardPaletteManager::shareItemOnWeb()
{
QPixmap pixmap = mPixmap;
//void UBBoardPaletteManager::shareItemOnWeb()
//{
// QPixmap pixmap = mPixmap;
if(mPixmap.isNull())
{
pixmap = QPixmap(mItemUrl.toLocalFile());
}
// if(mPixmap.isNull())
// {
// pixmap = QPixmap(mItemUrl.toLocalFile());
// }
if(!pixmap.isNull())
{
UBCapturePublisher* publisher = new UBCapturePublisher(pixmap, this);
publisher->publish();
}
else
{
UBApplication::showMessage(tr("Error Publishing Image to the Web"));
}
// if(!pixmap.isNull())
// {
// UBCapturePublisher* publisher = new UBCapturePublisher(pixmap, this);
// publisher->publish();
// }
// else
// {
// UBApplication::showMessage(tr("Error Publishing Image to the Web"));
// }
mAddItemPalette->hide();
}
// mAddItemPalette->hide();
//}
void UBBoardPaletteManager::zoomButtonPressed()
......
......@@ -118,7 +118,6 @@ class UBBoardPaletteManager : public QObject
void addItemToCurrentPage();
void addItemToNewPage();
void addItemToLibrary();
void shareItemOnWeb();
void purchaseLinkActivated(const QString&);
......
This diff is collapsed.
......@@ -451,6 +451,7 @@ void UBPreferencesController::toolbarPositionChanged(bool checked)
UBSettings* settings = UBSettings::settings();
settings->appToolBarPositionedAtTop->set(mPreferencesUI->toolbarAtTopRadioButton->isChecked());
}
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
* Author: julienbachmann
* 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 <QDesktopWidget>
......@@ -90,6 +98,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
mKeyboardPalette = UBKeyboardPalette::create(mTransparentDrawingView);
mKeyboardPalette->setParent(mTransparentDrawingView);
connect(mKeyboardPalette, SIGNAL(keyboardActivated(bool)), mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool)));
connect(mKeyboardPalette, SIGNAL(moved(QPoint)), this, SLOT(refreshMask()));
}
connect(mDesktopPalette, SIGNAL(uniboardClick()), this, SLOT(goToUniboard()));
......@@ -143,12 +152,16 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
connect(&mHoldTimerMarker, SIGNAL(timeout()), this, SLOT(markerActionReleased()));
connect(&mHoldTimerEraser, SIGNAL(timeout()), this, SLOT(eraserActionReleased()));
connect(mDesktopPalette, SIGNAL(moving()), this, SLOT(refreshMask()));
connect(mLibPalette, SIGNAL(resized()), this, SLOT(refreshMask()));
onDesktopPaletteMaximized();
}
void UBDesktopAnnotationController::showKeyboard(bool show)
{
mKeyboardPalette->setVisible(show);
updateMask(true);
// mDesktopPalette->showVirtualKeyboard(show);
}
......@@ -332,6 +345,10 @@ void UBDesktopAnnotationController::showWindow()
UBPlatformUtils::setDesktopMode(true);
mDesktopPalette->appear();
#ifdef Q_WS_X11
updateMask(true);
#endif
}
......@@ -343,7 +360,15 @@ void UBDesktopAnnotationController::close()
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();
}
......@@ -356,6 +381,9 @@ void UBDesktopAnnotationController::updateBackground()
|| UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Selector)
{
newBrush = QBrush(Qt::transparent);
#ifdef Q_WS_X11
updateMask(true);
#endif
}
else
{
......@@ -363,6 +391,9 @@ void UBDesktopAnnotationController::updateBackground()
newBrush = QBrush(QColor(127, 127, 127, 15));
#else
newBrush = QBrush(QColor(127, 127, 127, 1));
#endif
#ifdef Q_WS_X11
updateMask(false);
#endif
}
......@@ -389,6 +420,8 @@ void UBDesktopAnnotationController::goToUniboard()
UBPlatformUtils::setDesktopMode(false);
UBApplication::mainWindow->actionVirtualKeyboard->setEnabled(true);
emit restoreUniboard();
}
......@@ -751,3 +784,83 @@ void UBDesktopAnnotationController::onTransparentWidgetResized()
// qDebug() << "mLibPalette (" << mLibPalette->width() << "," << mLibPalette->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
* Author: julienbachmann
* 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 UBUNINOTESWINDOWCONTROLLER_H_
......@@ -94,10 +102,12 @@ class UBDesktopAnnotationController : public QObject
void onDesktopPaletteMaximized();
void onDesktopPaletteMinimize();
void onTransparentWidgetResized();
void refreshMask();
private:
void setAssociatedPalettePosition(UBActionPalette* palette, const QString& actionName);
void togglePropertyPalette(UBActionPalette* palette);
void updateMask(bool bTransparent);
UBDesktopPalette *mDesktopPalette;
UBKeyboardPalette *mKeyboardPalette;
......@@ -126,6 +136,8 @@ class UBDesktopAnnotationController : public QObject
int mBoardStylusTool;
int mDesktopStylusTool;
QPixmap mMask;
};
#endif /* UBUNINOTESWINDOWCONTROLLER_H_ */
......@@ -36,9 +36,7 @@ UBDesktopPalette::UBDesktopPalette(QWidget *parent)
actions << UBApplication::mainWindow->actionPen;
actions << UBApplication::mainWindow->actionEraser;
actions << UBApplication::mainWindow->actionMarker;
#ifndef Q_WS_X11
actions << UBApplication::mainWindow->actionSelector;
#endif
actions << UBApplication::mainWindow->actionPointer;
if (UBPlatformUtils::hasVirtualKeyboard())
......@@ -152,9 +150,7 @@ void UBDesktopPalette::maximizeMe()
actions << UBApplication::mainWindow->actionPen;
actions << UBApplication::mainWindow->actionEraser;
actions << UBApplication::mainWindow->actionMarker;
#ifndef Q_WS_X11
actions << UBApplication::mainWindow->actionSelector;
#endif
actions << UBApplication::mainWindow->actionPointer;
if (UBPlatformUtils::hasVirtualKeyboard())
actions << UBApplication::mainWindow->actionVirtualKeyboard;
......@@ -221,3 +217,8 @@ QPoint UBDesktopPalette::buttonPos(QAction *action)
return p;
}
void UBDesktopPalette::notifySelectorSelection(bool selected)
{
UBApplication::mainWindow->actionVirtualKeyboard->setEnabled(selected);
}
......@@ -27,6 +27,7 @@ class UBDesktopPalette : public UBActionPalette
void disappearForCapture();
void appear();
QPoint buttonPos(QAction* action);
void notifySelectorSelection(bool selected);
signals:
void uniboardClick();
......
......@@ -44,8 +44,8 @@ UBAbstractWidget::UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent)
, mInitialLoadDone(false)
, mLoadIsErronous(false)
, mIsFreezable(true)
, mCanBeContent(true)
, mCanBeTool(true)
, mCanBeContent(0)
, mCanBeTool(0)
, mIsFrozen(false)
, mIsTakingSnapshot(false)
{
......@@ -74,12 +74,51 @@ UBAbstractWidget::UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent)
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()
{
// NOOP
}
void UBAbstractWidget::loadMainHtml()
{
QWebView::load(mMainHtmlUrl);
}
bool UBAbstractWidget::event(QEvent *event)
{
......
......@@ -39,6 +39,8 @@ class UBAbstractWidget : public UBRoutedMouseEventWebView
UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent = 0);
virtual ~UBAbstractWidget();
void loadMainHtml();
QUrl mainHtml()
{
return mMainHtmlUrl;
......@@ -64,15 +66,8 @@ class UBAbstractWidget : public UBRoutedMouseEventWebView
return mNominalSize;
}
bool canBeContent() const
{
return mCanBeContent;
}
bool canBeTool() const
{
return mCanBeTool;
}
bool canBeContent();
bool canBeTool();
bool hasLoadedSuccessfully() const
{
......@@ -123,8 +118,16 @@ class UBAbstractWidget : public UBRoutedMouseEventWebView
bool mLoadIsErronous;
bool mIsFreezable;
bool mCanBeContent;
bool mCanBeTool;
int mCanBeContent;
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 paintEvent(QPaintEvent * event);
......
......@@ -130,6 +130,9 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
UBApplication::applicationController->initialHScroll(),
UBApplication::applicationController->initialVScroll()));
}
connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing()));
}
......@@ -138,6 +141,29 @@ UBGraphicsScene::~UBGraphicsScene()
// 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: Mouse/Tablet events handling
......@@ -249,6 +275,8 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
{
if (currentTool == UBStylusTool::Line)
{
// TODO: Verify this beautiful implementation and check if
// it is possible to optimize it
QLineF radius(mPreviousPoint, position);
qreal angle = radius.angle();
angle = qRound(angle / 45) * 45;
......@@ -257,7 +285,7 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
mPreviousPoint.x() + radiusLength * cos((angle * PI) / 180),
mPreviousPoint.y() - radiusLength * sin((angle * PI) / 180));
QLineF chord(position, newPosition);
if (chord.length() < qMin((int)16, (int)(radiusLength / 20)))
if (chord.length() < qMin((int)16, (int)(radiusLength / 20)))
position = newPosition;
}
......@@ -1074,6 +1102,8 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co
if (graphicsWidget->widgetWebView()->canBeContent())
{
graphicsWidget->widgetWebView()->loadMainHtml();
graphicsWidget->setSelected(true);
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, graphicsWidget);
UBApplication::undoStack->push(uc);
......
......@@ -271,6 +271,9 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void setToolCursor(int tool);
void selectionChangedProcessing();
signals:
void pageSizeChanged();
......
......@@ -86,8 +86,51 @@ UBW3CWidget::UBW3CWidget(const QUrl& pWidgetUrl, QWidget *parent)
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");
......@@ -159,8 +202,6 @@ UBW3CWidget::UBW3CWidget(const QUrl& pWidgetUrl, QWidget *parent)
connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared()));
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(javaScriptWindowObjectCleared()));
QWebView::load(mMainHtmlUrl);
setFixedSize(QSize(width, height));
mNominalSize = QSize(width, height);
......@@ -171,7 +212,6 @@ UBW3CWidget::~UBW3CWidget()
// NOOP
}
void UBW3CWidget::javaScriptWindowObjectCleared()
{
UBWidgetUniboardAPI *uniboardAPI = new UBWidgetUniboardAPI(UBApplication::boardController->activeScene(), 0);
......
......@@ -19,9 +19,27 @@
#include "UBDockPalette.h"
#include "core/UBSettings.h"
#include "frameworks/UBPlatformUtils.h"
#include "core/UBApplication.h"
#include "core/UBPreferencesController.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
*/
......@@ -34,11 +52,12 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
, mResized(false)
, mCollapseWidth(150)
, mLastWidth(-1)
, mHTab(0)
{
setObjectName(name);
// We let 2 pixels in order to keep a small border for the resizing
setMinimumWidth(border() + 2);
setMinimumWidth(2*border() + 2);
if (parent)
{
......@@ -61,6 +80,10 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
// This is the only way to set the background as 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)
if(eUBDockOrientation_Left == mOrientation)
{
if(mMousePressPos.x() >= width() - 2*border() &&
mMousePressPos.y() >= border() &&
mMousePressPos.y() >= mHTab &&
mMousePressPos.x() <= width() &&
mMousePressPos.y() <= border() + TABSIZE)
mMousePressPos.y() <= mHTab + TABSIZE)
{
tabClicked();
}
......@@ -217,8 +240,8 @@ void UBDockPalette::mouseReleaseEvent(QMouseEvent *event)
{
if(mMousePressPos.x() >= 0 &&
mMousePressPos.x() <= 2*border() &&
mMousePressPos.y() >= border() &&
mMousePressPos.y() <= border() + TABSIZE)
mMousePressPos.y() >= mHTab &&
mMousePressPos.y() <= mHTab + TABSIZE)
{
tabClicked();
}
......@@ -291,23 +314,32 @@ void UBDockPalette::paintEvent(QPaintEvent *event)
painter.setPen(Qt::NoPen);
painter.setBrush(mBackgroundBrush);
if(eUBDockTabOrientation_Up == mTabsOrientation)
{
mHTab = border();
}
else
{
mHTab = height() - border() - TABSIZE;
}
if(mOrientation == eUBDockOrientation_Left)
{
QPainterPath path;
path.setFillRule(Qt::WindingFill);
path.addRect(0.0, 0.0, width()-border(), height());
path.addRoundedRect(width()-2*border(), border(), 2*border(), TABSIZE, radius(), radius());
path.addRect(0.0, 0.0, width()-2*border(), height());
path.addRoundedRect(width()-4*border(), mHTab, 4*border(), TABSIZE, radius(), radius());
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)
{
QPainterPath path;
path.setFillRule(Qt::WindingFill);
path.addRect(border(), 0.0, width()-border(), height());
path.addRoundedRect(0.0, border(), 2*border(), TABSIZE, radius(), radius());
path.addRect(2*border(), 0.0, width()-2*border(), height());
path.addRoundedRect(0.0, mHTab, 4*border(), TABSIZE, radius(), radius());
painter.drawPath(path);
painter.drawPixmap(2, border() + 1, border() - 3, TABSIZE - 2, mIcon);
painter.drawPixmap(2, mHTab + 1, border() - 3, TABSIZE - 2, mIcon);
}
else
{
......@@ -372,7 +404,7 @@ void UBDockPalette::tabClicked()
{
// The palette must be collapsed
mLastWidth = width();
resize(border(), height());
resize(2*border(), height());
}
else
{
......@@ -381,3 +413,27 @@ void UBDockPalette::tabClicked()
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
eUBDockOrientation_Bottom /** [to be implemented]Bottom dock */
}eUBDockOrientation;
typedef enum
{
eUBDockTabOrientation_Up, /** Up tabs */
eUBDockTabOrientation_Down /** Down tabs */
}eUBDockTabOrientation;
class UBDockPalette : public QWidget
{
Q_OBJECT
public:
UBDockPalette(QWidget* parent=0, const char* name="UBDockPalette");
~UBDockPalette();
eUBDockOrientation orientation();
void setOrientation(eUBDockOrientation orientation);
void setTabsOrientation(eUBDockTabOrientation orientation);
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
......@@ -60,6 +68,7 @@ public:
protected:
virtual int border();
virtual int radius();
virtual int customMargin();
virtual void updateMaxWidth();
virtual void resizeEvent(QResizeEvent *event);
virtual int collapseWidth();
......@@ -86,6 +95,13 @@ protected:
QPoint mMousePressPos;
/** The palette icon */
QPixmap mIcon;
/** The tab orientation */
eUBDockTabOrientation mTabsOrientation;
/** The h position of the tab */
int mHTab;
private slots:
void onToolbarPosUpdated();
private:
void tabClicked();
......
......@@ -106,6 +106,7 @@ void UBFloatingPalette::mouseMoveEvent(QMouseEvent *event)
{
moveInsideParent(event->globalPos() - mDragPosition);
event->accept();
emit moving();
}
else
{
......
......@@ -78,6 +78,7 @@ class UBFloatingPalette : public QWidget
void minimizeStart(eMinimizedLocation location);
void maximizeStart();
void maximized();
void moving();
};
......
......@@ -39,6 +39,7 @@ UBLibNavigatorWidget::UBLibNavigatorWidget(QWidget *parent, const char *name):QW
UBLibPalette* pLibPalette = dynamic_cast<UBLibPalette*>(parentWidget());
mLayout = new QVBoxLayout(this);
// mLayout->setContentsMargins(20, 5, 5, 5);
setLayout(mLayout);
mPathViewer = new UBLibPathViewer(this);
......
......@@ -34,13 +34,13 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare
mIcon = QPixmap(":images/paletteLibrary.png");
setAcceptDrops(true);
resize(UBSettings::settings()->libPaletteWidth->get().toInt(), height());
resize(UBSettings::settings()->libPaletteWidth->get().toInt(), parentWidget()->height());
setContentsMargins(border(), 0, 0, 0);
mCollapseWidth = 180;
mLastWidth = 300;
mLayout = new QVBoxLayout(this);
mLayout->setMargin(3);
mLayout->setContentsMargins(20, customMargin(), customMargin(), customMargin());
setLayout(mLayout);
// Build the GUI
......@@ -201,6 +201,7 @@ void UBLibPalette::resizeEvent(QResizeEvent *event)
{
UBDockPalette::resizeEvent(event);
UBSettings::settings()->libPaletteWidth->set(width());
emit resized();
}
// --------------------------------------------------------------------------
......
......@@ -55,6 +55,9 @@ public:
UBLibActionBar* actionBar(){return mActionBar;}
signals:
void resized();
protected:
void updateMaxWidth();
void dragEnterEvent(QDragEnterEvent* pEvent);
......
This diff is collapsed.
......@@ -35,11 +35,10 @@ UBNavigatorPalette::UBNavigatorPalette(QWidget *parent, const char *name):UBDock
mIcon = QPixmap(":images/paletteNavigator.png");
resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), height());
mLastWidth = 300;
setContentsMargins(0, 0, border(), 0);
// Build the gui
mLayout = new QVBoxLayout(this);
mLayout->setMargin(3);
mLayout->setContentsMargins(customMargin(), customMargin(), 2*border() + customMargin(), customMargin());
setLayout(mLayout);
mNavigator = new UBDocumentNavigator(this);
......
......@@ -72,6 +72,7 @@ UBToolWidget::UBToolWidget(UBAbstractWidget* pWidget, QWidget* pParent)
, mShouldMoveWidget(false)
{
mToolWidget->setParent(this);
mToolWidget->loadMainHtml();
initialize();
......
......@@ -30,7 +30,7 @@ PDFRenderer::~PDFRenderer()
// 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))
{
......@@ -38,7 +38,7 @@ PDFRenderer* PDFRenderer::rendererForUuid(const QUuid &uuid, const QString &file
}
else
{
PDFRenderer *newRenderer = new XPDFRenderer(filename);
PDFRenderer *newRenderer = new XPDFRenderer(filename,importingFile);
newRenderer->setRefCount(0);
newRenderer->setFileUuid(uuid);
......
......@@ -31,7 +31,7 @@ class PDFRenderer : public QObject
Q_OBJECT
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 bool isValid() const = 0;
......
......@@ -19,18 +19,11 @@
#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"
QAtomicInt XPDFRenderer::sInstancesCount = 0;
XPDFRenderer::XPDFRenderer(const QString &filename)
XPDFRenderer::XPDFRenderer(const QString &filename, bool importingFile)
: mDocument(0)
{
if (!globalParams)
......@@ -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
sInstancesCount.ref();
bThumbGenerated = !importingFile;
bPagesGenerated = false;
mPagesMap.clear();
mThumbs.clear();
mThumbMap.clear();
mScaleX = 0.0;
mScaleY = 0.0;
}
XPDFRenderer::~XPDFRenderer()
......@@ -135,47 +134,114 @@ int XPDFRenderer::pageRotation(int pageNumber) const
return 0;
}
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())
{
SplashColor paperColor = {0xFF, 0xFF, 0xFF}; // white
SplashOutputDev splash(splashModeRGB8, 1, gFalse, paperColor);
splash.startDoc(mDocument->getXRef());
mSplash = new SplashOutputDev(splashModeRGB8, 1, gFalse, paperColor);
mSplash->startDoc(mDocument->getXRef());
int hResolution = 72;
int vResolution = 72;
int rotation = 0; // in degrees (get it from the worldTransform if we want to support rotation)
GBool useMediaBox = gFalse;
GBool crop = gTrue;
GBool printing = gFalse;
const qreal xScale = p->worldTransform().m11();
const qreal yScale = p->worldTransform().m22();
qreal sliceX = 0.;
qreal sliceY = 0.;
const qreal xScale = xscale;
const qreal yScale = yscale;
mSliceX = 0.;
mSliceY = 0.;
if (bounds.isNull())
{
mDocument->displayPage(&splash, pageNumber, hResolution * xScale, vResolution * yScale,
mDocument->displayPage(mSplash, pageNumber, hResolution * xScale, vResolution * yScale,
rotation, useMediaBox, crop, printing);
}
else
{
sliceX = bounds.x() * xScale;
sliceY = bounds.y() * yScale;
mSliceX = bounds.x() * xScale;
mSliceY = bounds.y() * yScale;
qreal sliceW = bounds.width() * xScale;
qreal sliceH = bounds.height() * yScale;
mDocument->displayPageSlice(&splash, pageNumber, hResolution * xScale, vResolution * yScale,
rotation, useMediaBox, crop, printing, sliceX, sliceY, sliceW, sliceH);
mDocument->displayPageSlice(mSplash, pageNumber, hResolution * xScale, vResolution * yScale,
rotation, useMediaBox, crop, printing, mSliceX, mSliceY, sliceW, sliceH);
}
SplashBitmap *bitmap = splash.getBitmap();
QImage pdfImage(bitmap->getDataPtr(), bitmap->getWidth(), bitmap->getHeight(), bitmap->getWidth() * 3, QImage::Format_RGB888);
QTransform savedTransform = p->worldTransform();
p->resetTransform();
p->drawImage(QPointF(savedTransform.dx() + sliceX, savedTransform.dy() + sliceY), pdfImage);
p->setWorldTransform(savedTransform);
mpSplashBitmap = mSplash->getBitmap();
img = new QImage(mpSplashBitmap->getDataPtr(), mpSplashBitmap->getWidth(), mpSplashBitmap->getHeight(), mpSplashBitmap->getWidth() * 3, QImage::Format_RGB888);
}
}
\ No newline at end of file
return img;
}
......@@ -30,7 +30,7 @@ class XPDFRenderer : public PDFRenderer
Q_OBJECT
public:
XPDFRenderer(const QString &filename);
XPDFRenderer(const QString &filename, bool importingFile = false);
virtual ~XPDFRenderer();
bool isValid() const;
......
This diff is collapsed.
......@@ -36,7 +36,7 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
UBGraphicsTriangle();
virtual ~UBGraphicsTriangle();
enum { Type = UBGraphicsItemType::TriangleItemType };
enum { Type = UBGraphicsItemType::TriangleItemType };
virtual int type() const
{
......@@ -44,64 +44,64 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
}
virtual UBItem* deepCopy(void) const;
enum UBGraphicsTriangleOrientation
{
BottomLeft = 0,
BottomRight,
TopLeft,
TopRight
};
static UBGraphicsTriangleOrientation orientationFromStr(QStringRef& str)
{
if (str == "BottomLeft") return BottomLeft;
if (str == "BottomRight") return BottomRight;
if (str == "TopLeft") return TopLeft;
if (str == "TopRight") return TopRight;
return sDefaultOrientation;
}
void setRect(const QRectF &rect, UBGraphicsTriangleOrientation orientation)
{
setRect(rect.x(), rect.y(), rect.width(), rect.height(), orientation);
}
void setRect(qreal x, qreal y, qreal w, qreal h, UBGraphicsTriangleOrientation orientation);
void setOrientation(UBGraphicsTriangleOrientation orientation);
QRectF rect() const {return boundingRect();}
UBGraphicsScene* scene() const;
protected:
virtual UBItem* deepCopy(void) const;
enum UBGraphicsTriangleOrientation
{
BottomLeft = 0,
BottomRight,
TopLeft,
TopRight
};
static UBGraphicsTriangleOrientation orientationFromStr(QStringRef& str)
{
if (str == "BottomLeft") return BottomLeft;
if (str == "BottomRight") return BottomRight;
if (str == "TopLeft") return TopLeft;
if (str == "TopRight") return TopRight;
return sDefaultOrientation;
}
void setRect(const QRectF &rect, UBGraphicsTriangleOrientation orientation)
{
setRect(rect.x(), rect.y(), rect.width(), rect.height(), orientation);
}
void setRect(qreal x, qreal y, qreal w, qreal h, UBGraphicsTriangleOrientation orientation);
void setOrientation(UBGraphicsTriangleOrientation orientation);
QRectF rect() const {return boundingRect();}
UBGraphicsScene* scene() const;
protected:
void updateResizeCursor();
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *styleOption, QWidget *widget);
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *styleOption, QWidget *widget);
virtual void rotateAroundCenter(qreal angle);
virtual void rotateAroundCenter(qreal angle);
virtual QPointF rotationCenter() const;
virtual QPointF rotationCenter() const;
virtual QRectF closeButtonRect() const;
QPolygonF resize1Polygon() const;
QPolygonF resize2Polygon() const;
QRectF hFlipRect() const;
QRectF vFlipRect() const;
QRectF rotateRect() const;
virtual QRectF closeButtonRect() const;
QPolygonF resize1Polygon() const;
QPolygonF resize2Polygon() const;
QRectF hFlipRect() const;
QRectF vFlipRect() const;
QRectF rotateRect() const;
QCursor resizeCursor1() const;
QCursor resizeCursor2() const;
QCursor resizeCursor1() const;
QCursor resizeCursor2() const;
QCursor flipCursor() const;
QCursor flipCursor() const;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
private:
private:
QCursor mResizeCursor1;
QCursor mResizeCursor2;
......@@ -110,21 +110,23 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
qreal angle;
void rotateAroundCenter(QTransform& transform, QPointF center);
bool mResizing1;
bool mResizing2;
bool mRotating;
bool mResizing1;
bool mResizing2;
bool mRotating;
QRect lastRect;
QPoint lastPos;
QGraphicsSvgItem* mHFlipSvgItem;
QGraphicsSvgItem* mVFlipSvgItem;
QGraphicsSvgItem* mRotateSvgItem;
QGraphicsSvgItem* mHFlipSvgItem;
QGraphicsSvgItem* mVFlipSvgItem;
QGraphicsSvgItem* mRotateSvgItem;
static const QRect sDefaultRect;
static const UBGraphicsTriangleOrientation sDefaultOrientation;
static const QRect sDefaultRect;
static const UBGraphicsTriangleOrientation sDefaultOrientation;
void paintGraduations(QPainter *painter);
void paintGraduations(QPainter *painter);
UBGraphicsTriangleOrientation mOrientation;
UBGraphicsTriangleOrientation mOrientation;
QPointF A1, B1, C1, A2, B2, C2; // coordinates of points in ext and int triangles
qreal C;
......@@ -132,10 +134,10 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
QPointF CC; // Hyp. fillining gradient - top point
void calculatePoints(const QRectF& rect);
static const int d = 70; // width of triangle border
static const int sArrowLength = 30;
static const int sMinWidth = 380;
static const int sMinHeight = 200;
static const int d = 70; // width of triangle border
static const int sArrowLength = 30;
static const int sMinWidth = 380;
static const int sMinHeight = 200;
};
#endif /* UBGRAPHICSTRIANGLE_H_ */
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