Commit a1f474c7 authored by Claudio Valerio's avatar Claudio Valerio

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

parents 7455088e aba21c9e
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include "domain/UBGraphicsWidgetItem.h" #include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsTextItem.h" #include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsTextItemDelegate.h" #include "domain/UBGraphicsTextItemDelegate.h"
#include "domain/UBW3CWidget.h" #include "domain/UBGraphicsWidgetItem.h"
#include "frameworks/UBFileSystemUtils.h" #include "frameworks/UBFileSystemUtils.h"
...@@ -776,7 +776,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgFlash(const QDomElement &ele ...@@ -776,7 +776,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgFlash(const QDomElement &ele
return false; return false;
} }
QString flashUrl = UBW3CWidget::createNPAPIWrapperInDir(flashPath, tmpFlashDir, "application/x-shockwave-flash" QString flashUrl = UBGraphicsW3CWidgetItem::createNPAPIWrapperInDir(flashPath, tmpFlashDir, "application/x-shockwave-flash"
,QSize(mCurrentSceneRect.width(), mCurrentSceneRect.height())); ,QSize(mCurrentSceneRect.width(), mCurrentSceneRect.height()));
UBGraphicsWidgetItem *flashItem = mCurrentScene->addW3CWidget(QUrl::fromLocalFile(flashUrl)); UBGraphicsWidgetItem *flashItem = mCurrentScene->addW3CWidget(QUrl::fromLocalFile(flashUrl));
flashItem->setSourceUrl(urlPath); flashItem->setSourceUrl(urlPath);
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "domain/UBGraphicsPDFItem.h" #include "domain/UBGraphicsPDFItem.h"
#include "domain/UBGraphicsTextItem.h" #include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsTextItemDelegate.h" #include "domain/UBGraphicsTextItemDelegate.h"
#include "domain/UBAbstractWidget.h"
#include "domain/UBGraphicsStroke.h" #include "domain/UBGraphicsStroke.h"
#include "domain/UBGraphicsStrokesGroup.h" #include "domain/UBGraphicsStrokesGroup.h"
#include "domain/UBGraphicsGroupContainerItem.h" #include "domain/UBGraphicsGroupContainerItem.h"
...@@ -2488,7 +2487,7 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsW3CWidgetToSvg(UBGraphicsW3C ...@@ -2488,7 +2487,7 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsW3CWidgetToSvg(UBGraphicsW3C
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsWidgetToSvg(UBGraphicsWidgetItem* item) void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsWidgetToSvg(UBGraphicsWidgetItem* item)
{ {
QUrl widgetRootUrl = item->widgetWebView()->widgetUrl(); QUrl widgetRootUrl = item->widgetUrl();
QString uuid = UBStringUtils::toCanonicalUuid(item->uuid()); QString uuid = UBStringUtils::toCanonicalUuid(item->uuid());
QString widgetDirectoryPath = UBPersistenceManager::widgetDirectory; QString widgetDirectoryPath = UBPersistenceManager::widgetDirectory;
if (widgetRootUrl.toString().startsWith("file://")) if (widgetRootUrl.toString().startsWith("file://"))
...@@ -2517,13 +2516,13 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsWidgetToSvg(UBGraphicsWidget ...@@ -2517,13 +2516,13 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsWidgetToSvg(UBGraphicsWidget
graphicsItemToSvg(item); graphicsItemToSvg(item);
if (item->widgetWebView()->isFrozen()) if (item->isFrozen())
{ {
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "frozen", xmlTrue); mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "frozen", xmlTrue);
} }
QString snapshotPath = mDocumentPath + "/" + UBPersistenceManager::widgetDirectory + "/" + uuid + ".png"; QString snapshotPath = mDocumentPath + "/" + UBPersistenceManager::widgetDirectory + "/" + uuid + ".png";
item->widgetWebView()->takeSnapshot().save(snapshotPath, "PNG"); item->takeSnapshot().save(snapshotPath, "PNG");
mXmlWriter.writeStartElement(nsXHtml, "iframe"); mXmlWriter.writeStartElement(nsXHtml, "iframe");
...@@ -2532,10 +2531,10 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsWidgetToSvg(UBGraphicsWidget ...@@ -2532,10 +2531,10 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsWidgetToSvg(UBGraphicsWidget
mXmlWriter.writeAttribute("height", QString("%1").arg(item->boundingRect().height())); mXmlWriter.writeAttribute("height", QString("%1").arg(item->boundingRect().height()));
QString startFileUrl; QString startFileUrl;
if (item->widgetWebView()->mainHtmlFileName().startsWith("http://")) if (item->mainHtmlFileName().startsWith("http://"))
startFileUrl = item->widgetWebView()->mainHtmlFileName(); startFileUrl = item->mainHtmlFileName();
else else
startFileUrl = widgetRootUrl.toString() + "/" + item->widgetWebView()->mainHtmlFileName(); startFileUrl = widgetRootUrl.toString() + "/" + item->mainHtmlFileName();
mXmlWriter.writeAttribute("src", startFileUrl); mXmlWriter.writeAttribute("src", startFileUrl);
mXmlWriter.writeEndElement(); //iFrame mXmlWriter.writeEndElement(); //iFrame
...@@ -2626,13 +2625,13 @@ UBGraphicsW3CWidgetItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::graphicsW3CWidge ...@@ -2626,13 +2625,13 @@ UBGraphicsW3CWidgetItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::graphicsW3CWidge
QPixmap snapshot(pixPath); QPixmap snapshot(pixPath);
if (!snapshot.isNull()) if (!snapshot.isNull())
widgetItem->w3cWidget()->setSnapshot(snapshot); widgetItem->setSnapshot(snapshot);
QStringRef frozen = mXmlReader.attributes().value(mNamespaceUri, "frozen"); QStringRef frozen = mXmlReader.attributes().value(mNamespaceUri, "frozen");
if (!frozen.isNull() && frozen.toString() == xmlTrue && !snapshot.isNull()) if (!frozen.isNull() && frozen.toString() == xmlTrue && !snapshot.isNull())
{ {
widgetItem->w3cWidget()->freeze(); widgetItem->freeze();
} }
graphicsItemFromSvg(widgetItem); graphicsItemFromSvg(widgetItem);
......
...@@ -281,12 +281,12 @@ void UBDocumentPublisher::upgradeDocumentForPublishing() ...@@ -281,12 +281,12 @@ void UBDocumentPublisher::upgradeDocumentForPublishing()
jsonFile.write(QString(" \"uuid\": \"%1\",\n").arg(UBStringUtils::toCanonicalUuid(widget->uuid())).toUtf8()); jsonFile.write(QString(" \"uuid\": \"%1\",\n").arg(UBStringUtils::toCanonicalUuid(widget->uuid())).toUtf8());
jsonFile.write(QString(" \"id\": \"%1\",\n").arg(widget->metadatas().id).toUtf8()); jsonFile.write(QString(" \"id\": \"%1\",\n").arg(widget->metadatas().id).toUtf8());
jsonFile.write(QString(" \"name\": \"%1\",\n").arg(widget->w3cWidget()->metadatas().name).toUtf8()); jsonFile.write(QString(" \"name\": \"%1\",\n").arg(widget->metadatas().name).toUtf8());
jsonFile.write(QString(" \"description\": \"%1\",\n").arg(widget->w3cWidget()->metadatas().description).toUtf8()); jsonFile.write(QString(" \"description\": \"%1\",\n").arg(widget->metadatas().description).toUtf8());
jsonFile.write(QString(" \"author\": \"%1\",\n").arg(widget->w3cWidget()->metadatas().author).toUtf8()); jsonFile.write(QString(" \"author\": \"%1\",\n").arg(widget->metadatas().author).toUtf8());
jsonFile.write(QString(" \"authorEmail\": \"%1\",\n").arg(widget->w3cWidget()->metadatas().authorEmail).toUtf8()); jsonFile.write(QString(" \"authorEmail\": \"%1\",\n").arg(widget->metadatas().authorEmail).toUtf8());
jsonFile.write(QString(" \"authorHref\": \"%1\",\n").arg(widget->w3cWidget()->metadatas().authorHref).toUtf8()); jsonFile.write(QString(" \"authorHref\": \"%1\",\n").arg(widget->metadatas().authorHref).toUtf8());
jsonFile.write(QString(" \"version\": \"%1\",\n").arg(widget->w3cWidget()->metadatas().authorHref).toUtf8()); jsonFile.write(QString(" \"version\": \"%1\",\n").arg(widget->metadatas().authorHref).toUtf8());
jsonFile.write(QString(" \"x\": %1,\n").arg(widget->sceneBoundingRect().x()).toUtf8()); jsonFile.write(QString(" \"x\": %1,\n").arg(widget->sceneBoundingRect().x()).toUtf8());
jsonFile.write(QString(" \"y\": %1,\n").arg(widget->sceneBoundingRect().y()).toUtf8()); jsonFile.write(QString(" \"y\": %1,\n").arg(widget->sceneBoundingRect().y()).toUtf8());
...@@ -298,10 +298,10 @@ void UBDocumentPublisher::upgradeDocumentForPublishing() ...@@ -298,10 +298,10 @@ void UBDocumentPublisher::upgradeDocumentForPublishing()
QString url = UBPersistenceManager::widgetDirectory + "/" + widget->uuid().toString() + ".wgt"; QString url = UBPersistenceManager::widgetDirectory + "/" + widget->uuid().toString() + ".wgt";
jsonFile.write(QString(" \"src\": \"%1\",\n").arg(url).toUtf8()); jsonFile.write(QString(" \"src\": \"%1\",\n").arg(url).toUtf8());
QString startFile = widget->w3cWidget()->mainHtmlFileName(); QString startFile = widget->mainHtmlFileName();
jsonFile.write(QString(" \"startFile\": \"%1\",\n").arg(startFile).toUtf8()); jsonFile.write(QString(" \"startFile\": \"%1\",\n").arg(startFile).toUtf8());
QMap<QString, QString> preferences = widget->preferences(); QMap<QString, QString> preferences = widget->UBGraphicsWidgetItem::preferences();
jsonFile.write(QString(" \"preferences\": {\n").toUtf8()); jsonFile.write(QString(" \"preferences\": {\n").toUtf8());
...@@ -360,10 +360,10 @@ void UBDocumentPublisher::upgradeDocumentForPublishing() ...@@ -360,10 +360,10 @@ void UBDocumentPublisher::upgradeDocumentForPublishing()
void UBDocumentPublisher::generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *widgetItem, int pageNumber) void UBDocumentPublisher::generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *widgetItem, int pageNumber)
{ {
QMap<QString, QString> preferences = widgetItem->preferences(); QMap<QString, QString> preferences = widgetItem->UBGraphicsWidgetItem::preferences();
QMap<QString, QString> datastoreEntries = widgetItem->datastoreEntries(); QMap<QString, QString> datastoreEntries = widgetItem->datastoreEntries();
QString startFileName = widgetItem->w3cWidget()->mainHtmlFileName(); QString startFileName = widgetItem->mainHtmlFileName();
if (!startFileName.startsWith("http://")) if (!startFileName.startsWith("http://"))
{ {
...@@ -394,18 +394,18 @@ void UBDocumentPublisher::generateWidgetPropertyScript(UBGraphicsW3CWidgetItem * ...@@ -394,18 +394,18 @@ void UBDocumentPublisher::generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *
lines << " <script type=\"text/javascript\">"; lines << " <script type=\"text/javascript\">";
lines << " var widget = {};"; lines << " var widget = {};";
lines << " widget.id = '" + widgetItem->w3cWidget()->metadatas().id + "';"; lines << " widget.id = '" + widgetItem->metadatas().id + "';";
lines << " widget.name = '" + widgetItem->w3cWidget()->metadatas().name + "';"; lines << " widget.name = '" + widgetItem->metadatas().name + "';";
lines << " widget.description = '" + widgetItem->w3cWidget()->metadatas().description + "';"; lines << " widget.description = '" + widgetItem->metadatas().description + "';";
lines << " widget.author = '" + widgetItem->w3cWidget()->metadatas().author + "';"; lines << " widget.author = '" + widgetItem->metadatas().author + "';";
lines << " widget.authorEmail = '" + widgetItem->w3cWidget()->metadatas().authorEmail + "';"; lines << " widget.authorEmail = '" + widgetItem->metadatas().authorEmail + "';";
lines << " widget.authorHref = '" + widgetItem->w3cWidget()->metadatas().authorHref + "';"; lines << " widget.authorHref = '" + widgetItem->metadatas().authorHref + "';";
lines << " widget.version = '" + widgetItem->w3cWidget()->metadatas().version + "';"; lines << " widget.version = '" + widgetItem->metadatas().version + "';";
lines << " widget.uuid = '" + UBStringUtils::toCanonicalUuid(widgetItem->uuid()) + "';"; lines << " widget.uuid = '" + UBStringUtils::toCanonicalUuid(widgetItem->uuid()) + "';";
lines << " widget.width = " + QString("%1").arg(widgetItem->w3cWidget()->width()) + ";"; lines << " widget.width = " + QString("%1").arg(widgetItem->nominalSize().width()) + ";";
lines << " widget.height = " + QString("%1").arg(widgetItem->w3cWidget()->height()) + ";"; lines << " widget.height = " + QString("%1").arg(widgetItem->nominalSize().height()) + ";";
lines << " widget.openUrl = function(url) { window.open(url); }"; lines << " widget.openUrl = function(url) { window.open(url); }";
lines << " widget.preferences = new Array()"; lines << " widget.preferences = new Array()";
......
...@@ -30,25 +30,14 @@ ...@@ -30,25 +30,14 @@
#include "core/memcheck.h" #include "core/memcheck.h"
UBW3CWidgetAPI::UBW3CWidgetAPI(UBGraphicsW3CWidgetItem *graphicsWidget) UBW3CWidgetAPI::UBW3CWidgetAPI(UBGraphicsW3CWidgetItem *graphicsWidget, QObject *parent)
: QObject(graphicsWidget) : QObject(parent)
, mGraphicsW3CWidget(graphicsWidget) , mGraphicsW3CWidget(graphicsWidget)
, mW3CWidget(mGraphicsW3CWidget->w3cWidget())
{ {
mPreferencesAPI = new UBW3CWidgetPreferenceAPI(graphicsWidget); mPreferencesAPI = new UBW3CWidgetPreferenceAPI(graphicsWidget, parent);
} }
UBW3CWidgetAPI::UBW3CWidgetAPI(UBW3CWidget *widget)
: QObject(widget)
, mGraphicsW3CWidget(0)
, mW3CWidget(widget)
{
mPreferencesAPI = new UBW3CWidgetPreferenceAPI(widget);
}
UBW3CWidgetAPI::~UBW3CWidgetAPI() UBW3CWidgetAPI::~UBW3CWidgetAPI()
{ {
// NOOP // NOOP
...@@ -66,55 +55,55 @@ QString UBW3CWidgetAPI::uuid() ...@@ -66,55 +55,55 @@ QString UBW3CWidgetAPI::uuid()
int UBW3CWidgetAPI::width() int UBW3CWidgetAPI::width()
{ {
return mW3CWidget->geometry().width(); return mGraphicsW3CWidget->nominalSize().width();
} }
int UBW3CWidgetAPI::height() int UBW3CWidgetAPI::height()
{ {
return mW3CWidget->geometry().height(); return mGraphicsW3CWidget->nominalSize().height();
} }
QString UBW3CWidgetAPI::id() QString UBW3CWidgetAPI::id()
{ {
return mW3CWidget->metadatas().id; return mGraphicsW3CWidget->metadatas().id;
} }
QString UBW3CWidgetAPI::name() QString UBW3CWidgetAPI::name()
{ {
return mW3CWidget->metadatas().name; return mGraphicsW3CWidget->metadatas().name;
} }
QString UBW3CWidgetAPI::description() QString UBW3CWidgetAPI::description()
{ {
return mW3CWidget->metadatas().description; return mGraphicsW3CWidget->metadatas().description;
} }
QString UBW3CWidgetAPI::author() QString UBW3CWidgetAPI::author()
{ {
return mW3CWidget->metadatas().author; return mGraphicsW3CWidget->metadatas().author;
} }
QString UBW3CWidgetAPI::authorEmail() QString UBW3CWidgetAPI::authorEmail()
{ {
return mW3CWidget->metadatas().authorEmail; return mGraphicsW3CWidget->metadatas().authorEmail;
} }
QString UBW3CWidgetAPI::authorHref() QString UBW3CWidgetAPI::authorHref()
{ {
return mW3CWidget->metadatas().authorHref; return mGraphicsW3CWidget->metadatas().authorHref;
} }
QString UBW3CWidgetAPI::version() QString UBW3CWidgetAPI::version()
{ {
return mW3CWidget->metadatas().version; return mGraphicsW3CWidget->metadatas().version;
} }
QObject* UBW3CWidgetAPI::preferences() QObject* UBW3CWidgetAPI::preferences()
...@@ -129,24 +118,13 @@ void UBW3CWidgetAPI::openURL(const QString& url) ...@@ -129,24 +118,13 @@ void UBW3CWidgetAPI::openURL(const QString& url)
} }
UBW3CWidgetPreferenceAPI::UBW3CWidgetPreferenceAPI(UBGraphicsW3CWidgetItem *graphicsWidget) UBW3CWidgetPreferenceAPI::UBW3CWidgetPreferenceAPI(UBGraphicsW3CWidgetItem *graphicsWidget, QObject *parent)
: UBW3CWebStorage(graphicsWidget) : UBW3CWebStorage(parent)
, mGraphicsW3CWidget(graphicsWidget) , mGraphicsW3CWidget(graphicsWidget)
, mW3CWidget(graphicsWidget->w3cWidget())
{
// NOOP
}
UBW3CWidgetPreferenceAPI::UBW3CWidgetPreferenceAPI(UBW3CWidget *widget)
: UBW3CWebStorage(widget)
, mGraphicsW3CWidget(0)
, mW3CWidget(widget)
{ {
// NOOP // NOOP
} }
UBW3CWidgetPreferenceAPI::~UBW3CWidgetPreferenceAPI() UBW3CWidgetPreferenceAPI::~UBW3CWidgetPreferenceAPI()
{ {
// NOOP // NOOP
...@@ -155,45 +133,35 @@ UBW3CWidgetPreferenceAPI::~UBW3CWidgetPreferenceAPI() ...@@ -155,45 +133,35 @@ UBW3CWidgetPreferenceAPI::~UBW3CWidgetPreferenceAPI()
QString UBW3CWidgetPreferenceAPI::key(int index) QString UBW3CWidgetPreferenceAPI::key(int index)
{ {
QMap<QString, UBW3CWidget::PreferenceValue> w3CPrefs = mW3CWidget->preferences(); QMap<QString, UBGraphicsW3CWidgetItem::PreferenceValue> w3CPrefs = mGraphicsW3CWidget->preferences();
if (index < w3CPrefs.size())
return w3CPrefs.keys().at(index);
else
return "";
if (index < w3CPrefs.size())
return w3CPrefs.keys().at(index);
else
return "";
} }
QString UBW3CWidgetPreferenceAPI::getItem(const QString& key) QString UBW3CWidgetPreferenceAPI::getItem(const QString& key)
{ {
if (mGraphicsW3CWidget) if (mGraphicsW3CWidget) {
{ QMap<QString, QString> docPref = mGraphicsW3CWidget->UBGraphicsWidgetItem::preferences();
QMap<QString, QString> docPref = mGraphicsW3CWidget->preferences(); if (docPref.contains(key))
return docPref.value(key);
if (docPref.contains(key))
return docPref.value(key);
}
QMap<QString, UBW3CWidget::PreferenceValue> w3cPrefs = mW3CWidget->preferences();
if (w3cPrefs.contains(key)) QMap<QString, UBGraphicsW3CWidgetItem::PreferenceValue> w3cPrefs = mGraphicsW3CWidget->preferences();
{
UBW3CWidget::PreferenceValue pref = w3cPrefs.value(key);
return pref.value;
}
else
{
return "";
}
if (w3cPrefs.contains(key)) {
UBGraphicsW3CWidgetItem::PreferenceValue pref = w3cPrefs.value(key);
return pref.value;
}
}
return QString();
} }
int UBW3CWidgetPreferenceAPI::length() int UBW3CWidgetPreferenceAPI::length()
{ {
QMap<QString, UBW3CWidget::PreferenceValue> w3cPrefs = mW3CWidget->preferences(); QMap<QString, UBGraphicsW3CWidgetItem::PreferenceValue> w3cPrefs = mGraphicsW3CWidget->preferences();
return w3cPrefs.size(); return w3cPrefs.size();
} }
...@@ -201,39 +169,28 @@ int UBW3CWidgetPreferenceAPI::length() ...@@ -201,39 +169,28 @@ int UBW3CWidgetPreferenceAPI::length()
void UBW3CWidgetPreferenceAPI::setItem(const QString& key, const QString& value) void UBW3CWidgetPreferenceAPI::setItem(const QString& key, const QString& value)
{ {
if (mGraphicsW3CWidget) if (mGraphicsW3CWidget) {
{ QMap<QString, UBGraphicsW3CWidgetItem::PreferenceValue> w3cPrefs = mGraphicsW3CWidget->preferences();
QMap<QString, UBW3CWidget::PreferenceValue> w3cPrefs = mW3CWidget->preferences();
if (w3cPrefs.contains(key) && !w3cPrefs.value(key).readonly) if (w3cPrefs.contains(key) && !w3cPrefs.value(key).readonly)
mGraphicsW3CWidget->setPreference(key, value); mGraphicsW3CWidget->setPreference(key, value);
} }
else
{
// No state for non graphics widget (aka tool widget)
}
} }
void UBW3CWidgetPreferenceAPI::removeItem(const QString& key) void UBW3CWidgetPreferenceAPI::removeItem(const QString& key)
{ {
if (mGraphicsW3CWidget) if (mGraphicsW3CWidget)
mGraphicsW3CWidget->removePreference(key); mGraphicsW3CWidget->removePreference(key);
else
{
// No state for non graphics widget (aka tool widget)
}
} }
void UBW3CWidgetPreferenceAPI::clear() void UBW3CWidgetPreferenceAPI::clear()
{ {
if (mGraphicsW3CWidget) if (mGraphicsW3CWidget)
mGraphicsW3CWidget->removeAllPreferences(); mGraphicsW3CWidget->removeAllPreferences();
else
{
// No state for non graphics widget (aka tool widget)
}
} }
......
...@@ -47,8 +47,7 @@ class UBW3CWidgetAPI : public QObject ...@@ -47,8 +47,7 @@ class UBW3CWidgetAPI : public QObject
public: public:
UBW3CWidgetAPI(UBGraphicsW3CWidgetItem *graphicsWidget); UBW3CWidgetAPI(UBGraphicsW3CWidgetItem *graphicsWidget, QObject *parent = 0);
UBW3CWidgetAPI(UBW3CWidget *widget);
virtual ~UBW3CWidgetAPI(); virtual ~UBW3CWidgetAPI();
...@@ -72,7 +71,6 @@ class UBW3CWidgetAPI : public QObject ...@@ -72,7 +71,6 @@ class UBW3CWidgetAPI : public QObject
private: private:
UBGraphicsW3CWidgetItem* mGraphicsW3CWidget; UBGraphicsW3CWidgetItem* mGraphicsW3CWidget;
UBW3CWidget *mW3CWidget;
UBW3CWidgetPreferenceAPI* mPreferencesAPI; UBW3CWidgetPreferenceAPI* mPreferencesAPI;
...@@ -88,8 +86,8 @@ class UBW3CWebStorage : public QObject ...@@ -88,8 +86,8 @@ class UBW3CWebStorage : public QObject
public: public:
UBW3CWebStorage(QObject *parent = 0) UBW3CWebStorage(QObject *parent = 0)
: QObject(parent){} : QObject(parent){/* NOOP */}
virtual ~UBW3CWebStorage(){} virtual ~UBW3CWebStorage(){/* NOOP */}
public slots: public slots:
...@@ -110,8 +108,7 @@ class UBW3CWidgetPreferenceAPI : public UBW3CWebStorage ...@@ -110,8 +108,7 @@ class UBW3CWidgetPreferenceAPI : public UBW3CWebStorage
Q_OBJECT; Q_OBJECT;
public: public:
UBW3CWidgetPreferenceAPI(UBGraphicsW3CWidgetItem *graphicsWidget); UBW3CWidgetPreferenceAPI(UBGraphicsW3CWidgetItem *graphicsWidget, QObject *parent = 0);
UBW3CWidgetPreferenceAPI(UBW3CWidget *widget);
virtual ~UBW3CWidgetPreferenceAPI(); virtual ~UBW3CWidgetPreferenceAPI();
...@@ -129,7 +126,6 @@ class UBW3CWidgetPreferenceAPI : public UBW3CWebStorage ...@@ -129,7 +126,6 @@ class UBW3CWidgetPreferenceAPI : public UBW3CWebStorage
private: private:
UBGraphicsW3CWidgetItem* mGraphicsW3CWidget; UBGraphicsW3CWidgetItem* mGraphicsW3CWidget;
UBW3CWidget* mW3CWidget;
}; };
......
...@@ -17,16 +17,15 @@ ...@@ -17,16 +17,15 @@
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "domain/UBAbstractWidget.h" #include "domain/UBGraphicsWebView.h"
#include "core/memcheck.h" #include "core/memcheck.h"
UBWidgetMessageAPI::UBWidgetMessageAPI(UBW3CWidget *widget) UBWidgetMessageAPI::UBWidgetMessageAPI(UBGraphicsWidgetItem *graphicsWidgetItem, QObject *parent)
: QObject(widget) : QObject(parent)
, mWebWidget(widget) , mGraphicsWidgetItem(graphicsWidgetItem)
{ {
connect(UBWidgetAPIMessageBroker::instance(), SIGNAL(newMessage(const QString&, const QString&)) connect(UBWidgetAPIMessageBroker::instance(), SIGNAL(newMessage(const QString&, const QString&)), this, SLOT(onNewMessage(const QString&, const QString&)), Qt::QueuedConnection);
, this, SLOT(onNewMessage(const QString&, const QString&)), Qt::QueuedConnection);
} }
UBWidgetMessageAPI::~UBWidgetMessageAPI() UBWidgetMessageAPI::~UBWidgetMessageAPI()
...@@ -45,9 +44,7 @@ void UBWidgetMessageAPI::onNewMessage(const QString& pTopicName, const QString& ...@@ -45,9 +44,7 @@ void UBWidgetMessageAPI::onNewMessage(const QString& pTopicName, const QString&
{ {
if (mSubscribedTopics.contains(pTopicName)) if (mSubscribedTopics.contains(pTopicName))
{ {
if (mWebWidget if (mGraphicsWidgetItem && mGraphicsWidgetItem->page() && mGraphicsWidgetItem->page()->mainFrame())
&& mWebWidget->page()
&& mWebWidget->page()->mainFrame())
{ {
QString js; QString js;
...@@ -55,7 +52,7 @@ void UBWidgetMessageAPI::onNewMessage(const QString& pTopicName, const QString& ...@@ -55,7 +52,7 @@ void UBWidgetMessageAPI::onNewMessage(const QString& pTopicName, const QString&
js += "{widget.messages.onmessage('"; js += "{widget.messages.onmessage('";
js += pMessage + "', '" + pTopicName + "')}"; js += pMessage + "', '" + pTopicName + "')}";
mWebWidget->page()-> mGraphicsWidgetItem->page()->
mainFrame()->evaluateJavaScript(js); mainFrame()->evaluateJavaScript(js);
} }
......
...@@ -25,7 +25,7 @@ class UBWidgetMessageAPI : public QObject ...@@ -25,7 +25,7 @@ class UBWidgetMessageAPI : public QObject
Q_OBJECT; Q_OBJECT;
public: public:
UBWidgetMessageAPI(UBW3CWidget *widget); UBWidgetMessageAPI(UBGraphicsWidgetItem *graphicsWidgetItem, QObject *parent = 0);
virtual ~UBWidgetMessageAPI(); virtual ~UBWidgetMessageAPI();
public slots: public slots:
...@@ -49,7 +49,7 @@ class UBWidgetMessageAPI : public QObject ...@@ -49,7 +49,7 @@ class UBWidgetMessageAPI : public QObject
private: private:
QSet<QString> mSubscribedTopics; QSet<QString> mSubscribedTopics;
UBW3CWidget *mWebWidget; UBGraphicsWidgetItem *mGraphicsWidgetItem;
}; };
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "domain/UBGraphicsScene.h" #include "domain/UBGraphicsScene.h"
#include "domain/UBGraphicsWidgetItem.h" #include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBAbstractWidget.h"
#include "adaptors/UBThumbnailAdaptor.h" #include "adaptors/UBThumbnailAdaptor.h"
...@@ -79,7 +78,7 @@ UBWidgetUniboardAPI::UBWidgetUniboardAPI(UBGraphicsScene *pScene, UBGraphicsWidg ...@@ -79,7 +78,7 @@ UBWidgetUniboardAPI::UBWidgetUniboardAPI(UBGraphicsScene *pScene, UBGraphicsWidg
if (w3CGraphicsWidget) if (w3CGraphicsWidget)
{ {
mMessagesAPI = new UBWidgetMessageAPI(w3CGraphicsWidget->w3cWidget()); mMessagesAPI = new UBWidgetMessageAPI(w3CGraphicsWidget);
mDatastoreAPI = new UBDatastoreAPI(w3CGraphicsWidget); mDatastoreAPI = new UBDatastoreAPI(w3CGraphicsWidget);
} }
...@@ -547,7 +546,7 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event) ...@@ -547,7 +546,7 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)
QDropEvent readyEvent(dropPoint, dropActions, &dropMimeData, dropMouseButtons, dropModifiers); QDropEvent readyEvent(dropPoint, dropActions, &dropMimeData, dropMouseButtons, dropModifiers);
//sending event to destination either it had been downloaded or not //sending event to destination either it had been downloaded or not
QApplication::sendEvent(mGraphicsWidget->widgetWebView(),&readyEvent); QApplication::sendEvent(mGraphicsWidget,&readyEvent);
readyEvent.acceptProposedAction(); readyEvent.acceptProposedAction();
} }
...@@ -602,11 +601,11 @@ void UBWidgetUniboardAPI::onDownloadFinished(bool pSuccess, sDownloadFileDesc de ...@@ -602,11 +601,11 @@ void UBWidgetUniboardAPI::onDownloadFinished(bool pSuccess, sDownloadFileDesc de
//To make js interpreter accept drop event we need to generate move event first. //To make js interpreter accept drop event we need to generate move event first.
QDragMoveEvent pseudoMove(dropPoint, desc.dropActions, &dropMimeData, desc.dropMouseButtons, desc.dropModifiers); QDragMoveEvent pseudoMove(dropPoint, desc.dropActions, &dropMimeData, desc.dropMouseButtons, desc.dropModifiers);
QApplication::sendEvent(mGraphicsWidget->widgetWebView(),&pseudoMove); QApplication::sendEvent(mGraphicsWidget,&pseudoMove);
QDropEvent readyEvent(dropPoint, desc.dropActions, &dropMimeData, desc.dropMouseButtons, desc.dropModifiers); QDropEvent readyEvent(dropPoint, desc.dropActions, &dropMimeData, desc.dropMouseButtons, desc.dropModifiers);
//sending event to destination either it had been downloaded or not //sending event to destination either it had been downloaded or not
QApplication::sendEvent(mGraphicsWidget->widgetWebView(),&readyEvent); QApplication::sendEvent(mGraphicsWidget,&readyEvent);
readyEvent.acceptProposedAction(); readyEvent.acceptProposedAction();
} }
...@@ -736,9 +735,9 @@ void UBDocumentDatastoreAPI::removeItem(const QString& key) ...@@ -736,9 +735,9 @@ void UBDocumentDatastoreAPI::removeItem(const QString& key)
{ {
mGraphicsW3CWidget->removeDatastoreEntry(key); mGraphicsW3CWidget->removeDatastoreEntry(key);
} }
void
UBDocumentDatastoreAPI::clear()
void UBDocumentDatastoreAPI::clear()
{ {
mGraphicsW3CWidget->removeAllDatastoreEntries(); mGraphicsW3CWidget->removeAllDatastoreEntries();
} }
......
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
#include "domain/UBGraphicsWidgetItem.h" #include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsMediaItem.h" #include "domain/UBGraphicsMediaItem.h"
#include "domain/UBGraphicsPDFItem.h" #include "domain/UBGraphicsPDFItem.h"
#include "domain/UBW3CWidget.h"
#include "domain/UBGraphicsTextItem.h" #include "domain/UBGraphicsTextItem.h"
#include "domain/UBPageSizeUndoCommand.h" #include "domain/UBPageSizeUndoCommand.h"
#include "domain/UBGraphicsGroupContainerItem.h" #include "domain/UBGraphicsGroupContainerItem.h"
...@@ -1151,7 +1150,7 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri ...@@ -1151,7 +1150,7 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri
else else
size = mActiveScene->nominalSize() * .8; size = mActiveScene->nominalSize() * .8;
QString widgetUrl = UBW3CWidget::createNPAPIWrapper(sUrl, mimeType, size); QString widgetUrl = UBGraphicsW3CWidgetItem::createNPAPIWrapper(sUrl, mimeType, size);
if (widgetUrl.length() > 0) if (widgetUrl.length() > 0)
{ {
...@@ -1274,7 +1273,7 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri ...@@ -1274,7 +1273,7 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri
else else
size = mActiveScene->nominalSize() * .8; size = mActiveScene->nominalSize() * .8;
QString widgetUrl = UBW3CWidget::createNPAPIWrapper(swfFile, "application/x-shockwave-flash", size); QString widgetUrl = UBGraphicsW3CWidgetItem::createNPAPIWrapper(swfFile, "application/x-shockwave-flash", size);
if (widgetUrl.length() > 0) if (widgetUrl.length() > 0)
{ {
...@@ -1655,52 +1654,15 @@ qreal UBBoardController::currentZoom() ...@@ -1655,52 +1654,15 @@ qreal UBBoardController::currentZoom()
return 1.0; return 1.0;
} }
UBToolWidget* UBBoardController::addTool(const QUrl& toolUrl)
{
return addTool(toolUrl, mControlView->mapToScene(mControlView->rect().center()));
}
UBToolWidget* UBBoardController::addTool(const QUrl& toolUrl, QPointF scenePos)
{
UBToolWidget *toolWidget = new UBToolWidget(toolUrl, mMainWindow); // Deleted in UBBoardController::removeTool
QPoint pos = mControlView->mapToGlobal(mControlView->mapFromScene(scenePos));
pos -= QPoint(toolWidget->width() / 2, toolWidget->height() / 2);
toolWidget->move(pos);
mTools.append(toolWidget);
toolWidget->show();
return toolWidget;
}
void UBBoardController::removeTool(UBToolWidget* toolWidget)
{
toolWidget->hide();
mTools.removeAll(toolWidget);
delete toolWidget;
}
void UBBoardController::hide() void UBBoardController::hide()
{ {
UBApplication::mainWindow->actionLibrary->setChecked(false); UBApplication::mainWindow->actionLibrary->setChecked(false);
controlViewHidden();
} }
void UBBoardController::show() void UBBoardController::show()
{ {
UBApplication::mainWindow->actionLibrary->setChecked(false); UBApplication::mainWindow->actionLibrary->setChecked(false);
controlViewShown();
} }
...@@ -1925,25 +1887,6 @@ void UBBoardController::grabScene(const QRectF& pSceneRect) ...@@ -1925,25 +1887,6 @@ void UBBoardController::grabScene(const QRectF& pSceneRect)
} }
} }
void UBBoardController::controlViewHidden()
{
foreach(UBToolWidget* tool, mTools)
{
tool->hide();
}
}
void UBBoardController::controlViewShown()
{
foreach(UBToolWidget* tool, mTools)
{
tool->show();
}
}
UBGraphicsMediaItem* UBBoardController::addVideo(const QUrl& pSourceUrl, bool startPlay, const QPointF& pos) UBGraphicsMediaItem* UBBoardController::addVideo(const QUrl& pSourceUrl, bool startPlay, const QPointF& pos)
{ {
QUuid uuid = QUuid::createUuid(); QUuid uuid = QUuid::createUuid();
...@@ -2003,7 +1946,7 @@ UBGraphicsWidgetItem *UBBoardController::addW3cWidget(const QUrl &pUrl, const QP ...@@ -2003,7 +1946,7 @@ UBGraphicsWidgetItem *UBBoardController::addW3cWidget(const QUrl &pUrl, const QP
w3cWidgetItem->setSnapshotPath(QUrl::fromLocalFile(snapshotPath)); w3cWidgetItem->setSnapshotPath(QUrl::fromLocalFile(snapshotPath));
UBGraphicsWidgetItem *tmpItem = dynamic_cast<UBGraphicsWidgetItem*>(w3cWidgetItem); UBGraphicsWidgetItem *tmpItem = dynamic_cast<UBGraphicsWidgetItem*>(w3cWidgetItem);
if (tmpItem) if (tmpItem)
tmpItem->widgetWebView()->takeSnapshot().save(snapshotPath, "PNG"); tmpItem->takeSnapshot().save(snapshotPath, "PNG");
} }
...@@ -2208,56 +2151,23 @@ void UBBoardController::togglePodcast(bool checked) ...@@ -2208,56 +2151,23 @@ void UBBoardController::togglePodcast(bool checked)
void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* graphicsWidget) void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* graphicsWidget)
{ {
QPoint controlViewPos = mControlView->mapFromScene(graphicsWidget->sceneBoundingRect().center()); graphicsWidget->remove();
graphicsWidget->setSelected(false);
UBAbstractWidget *aw = graphicsWidget->widgetWebView();
graphicsWidget->setWidget(0);
UBToolWidget *toolWidget = new UBToolWidget(aw, mControlContainer); UBToolWidget *toolWidget = new UBToolWidget(graphicsWidget);
mActiveScene->addItem(toolWidget);
qreal ssf = 1 / UBApplication::boardController->systemScaleFactor();
graphicsWidget->scene()->removeItem(graphicsWidget); // TODO UB 4.6 probably leaking the frame toolWidget->setScale(ssf);
toolWidget->setPos(graphicsWidget->scenePos());
toolWidget->centerOn(mControlView->mapTo(mControlContainer, controlViewPos));
toolWidget->show();
} }
void UBBoardController::moveToolWidgetToScene(UBToolWidget* toolWidget) void UBBoardController::moveToolWidgetToScene(UBToolWidget* toolWidget)
{ {
int xIsOdd = toolWidget->width() % 2; UBGraphicsWidgetItem *graphicsWidgetItem = addW3cWidget(toolWidget->graphicsWidgetItem()->widgetUrl(), QPointF(0, 0));
int yIsOdd = toolWidget->height() % 2; graphicsWidgetItem->setPos(toolWidget->pos());
toolWidget->remove();
QPoint mainWindowCenter = toolWidget->mapTo(mMainWindow, QPoint(toolWidget->width(), toolWidget->height()) / 2); graphicsWidgetItem->setSelected(true);
UBAbstractWidget* webWidget = toolWidget->webWidget();
webWidget->setParent(0);
UBGraphicsWidgetItem* graphicsWidget = 0;
UBW3CWidget* w3cWidget = qobject_cast<UBW3CWidget*>(webWidget);
if (w3cWidget)
{
graphicsWidget = new UBGraphicsW3CWidgetItem(w3cWidget);
}
else
{
UBAppleWidget* appleWidget = qobject_cast<UBAppleWidget*>(webWidget);
if (appleWidget)
{
graphicsWidget = new UBGraphicsAppleWidgetItem(appleWidget);
}
}
QPoint controlViewCenter = mControlView->mapFrom(mMainWindow, mainWindowCenter);
QPointF scenePos = mControlView->mapToScene(controlViewCenter) + QPointF(xIsOdd * 0.5, yIsOdd * 0.5);
mActiveScene->addGraphicsWidget(graphicsWidget, scenePos);
toolWidget->hide();
toolWidget->deleteLater();
} }
...@@ -2343,8 +2253,8 @@ void UBBoardController::freezeW3CWidget(QGraphicsItem *item, bool freeze) ...@@ -2343,8 +2253,8 @@ void UBBoardController::freezeW3CWidget(QGraphicsItem *item, bool freeze)
return; return;
if (freeze) { if (freeze) {
item_casted->widgetWebView()->load(QUrl(item_casted->w3cWidget()->freezedWidgetFilePath())); item_casted->load(QUrl(UBGraphicsW3CWidgetItem::freezedWidgetFilePath()));
}else } else
item_casted->widgetWebView()->loadMainHtml(); item_casted->loadMainHtml();
} }
} }
...@@ -197,17 +197,12 @@ class UBBoardController : public UBDocumentContainer ...@@ -197,17 +197,12 @@ class UBBoardController : public UBDocumentContainer
void hideMessage(); void hideMessage();
void setDisabled(bool disable); void setDisabled(bool disable);
void setColorIndex(int pColorIndex); void setColorIndex(int pColorIndex);
UBToolWidget* addTool(const QUrl& toolUrl, QPointF scenePos);
UBToolWidget* addTool(const QUrl& toolUrl);
void removeTool(UBToolWidget* toolWidget);
void hide(); void hide();
void show(); void show();
void setWidePageSize(bool checked); void setWidePageSize(bool checked);
void setRegularPageSize(bool checked); void setRegularPageSize(bool checked);
void stylusToolChanged(int tool); void stylusToolChanged(int tool);
void grabScene(const QRectF& pSceneRect); void grabScene(const QRectF& pSceneRect);
void controlViewHidden();
void controlViewShown();
UBGraphicsMediaItem* addVideo(const QUrl& pUrl, bool startPlay, const QPointF& pos); UBGraphicsMediaItem* addVideo(const QUrl& pUrl, bool startPlay, const QPointF& pos);
UBGraphicsMediaItem* addAudio(const QUrl& pUrl, bool startPlay, const QPointF& pos); UBGraphicsMediaItem* addAudio(const QUrl& pUrl, bool startPlay, const QPointF& pos);
UBGraphicsWidgetItem *addW3cWidget(const QUrl& pUrl, const QPointF& pos); UBGraphicsWidgetItem *addW3cWidget(const QUrl& pUrl, const QPointF& pos);
...@@ -277,7 +272,6 @@ class UBBoardController : public UBDocumentContainer ...@@ -277,7 +272,6 @@ class UBBoardController : public UBDocumentContainer
QColor mPenColorOnLightBackground; QColor mPenColorOnLightBackground;
QColor mMarkerColorOnDarkBackground; QColor mMarkerColorOnDarkBackground;
QColor mMarkerColorOnLightBackground; QColor mMarkerColorOnLightBackground;
QList<UBToolWidget*> mTools;
qreal mSystemScaleFactor; qreal mSystemScaleFactor;
bool mCleanupDone; bool mCleanupDone;
QMap<QAction*, QPair<QString, QString> > mActionTexts; QMap<QAction*, QPair<QString, QString> > mActionTexts;
......
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
#include "network/UBServerXMLHttpRequest.h" #include "network/UBServerXMLHttpRequest.h"
#include "domain/UBGraphicsScene.h" #include "domain/UBGraphicsScene.h"
#include "domain/UBAbstractWidget.h"
#include "domain/UBGraphicsPixmapItem.h" #include "domain/UBGraphicsPixmapItem.h"
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
...@@ -678,8 +677,10 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is ...@@ -678,8 +677,10 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
{ {
case eUBDockPaletteWidget_BOARD: case eUBDockPaletteWidget_BOARD:
{ {
mLeftPalette->assignParent(UBApplication::boardController->controlContainer()); mLeftPalette->assignParent(mContainer);
mRightPalette->assignParent(UBApplication::boardController->controlContainer()); mRightPalette->assignParent(mContainer);
mRightPalette->stackUnder(mStylusPalette);
mLeftPalette->stackUnder(mStylusPalette);
if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL) if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL)
{ {
...@@ -711,6 +712,8 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is ...@@ -711,6 +712,8 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
{ {
mLeftPalette->assignParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView()); mLeftPalette->assignParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView());
mRightPalette->assignParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView()); mRightPalette->assignParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView());
mRightPalette->lower();
mLeftPalette->lower();
if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL) if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL)
{ {
......
...@@ -18,8 +18,7 @@ ...@@ -18,8 +18,7 @@
#include <QtGui> #include <QtGui>
#include <QtWebKit> #include <QtWebKit>
#include "web/UBRoutedMouseEventWebView.h"
#include "gui/UBLeftPalette.h" #include "gui/UBLeftPalette.h"
#include "gui/UBRightPalette.h" #include "gui/UBRightPalette.h"
#include "gui/UBPageNavigationWidget.h" #include "gui/UBPageNavigationWidget.h"
......
...@@ -123,8 +123,6 @@ UBBoardView::init () ...@@ -123,8 +123,6 @@ UBBoardView::init ()
setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
setAcceptDrops (true); setAcceptDrops (true);
setOptimizationFlag (QGraphicsView::IndirectPainting); // enable UBBoardView::drawItems filter
mTabletStylusIsPressed = false; mTabletStylusIsPressed = false;
mMouseButtonIsPressed = false; mMouseButtonIsPressed = false;
mPendingStylusReleaseEvent = false; mPendingStylusReleaseEvent = false;
...@@ -426,7 +424,7 @@ bool UBBoardView::itemShouldReceiveMousePressEvent(QGraphicsItem *item) ...@@ -426,7 +424,7 @@ bool UBBoardView::itemShouldReceiveMousePressEvent(QGraphicsItem *item)
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool(); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
if ((currentTool == UBStylusTool::Play) && UBGraphicsGroupContainerItem::Type == movingItem->type()) if ((currentTool == UBStylusTool::Play) && UBGraphicsGroupContainerItem::Type == movingItem->type())
return movingItem = NULL; return movingItem == NULL;
switch(item->type()) switch(item->type())
{ {
...@@ -536,7 +534,7 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item) ...@@ -536,7 +534,7 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item)
return !item->isSelected(); return !item->isSelected();
default: default:
false; return false;
} }
return false; return false;
...@@ -1182,7 +1180,7 @@ void UBBoardView::dragMoveEvent (QDragMoveEvent *event) ...@@ -1182,7 +1180,7 @@ void UBBoardView::dragMoveEvent (QDragMoveEvent *event)
} }
QPoint newPoint(graphicsWidget->mapFromScene(mapToScene(event->pos())).toPoint()); QPoint newPoint(graphicsWidget->mapFromScene(mapToScene(event->pos())).toPoint());
QDragMoveEvent newEvent(newPoint, event->dropAction(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers()); QDragMoveEvent newEvent(newPoint, event->dropAction(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers());
QApplication::sendEvent(graphicsWidget->widgetWebView(),&newEvent); QApplication::sendEvent(graphicsWidget,&newEvent);
} else { } else {
mOkOnWidget = false; mOkOnWidget = false;
event->ignore(); event->ignore();
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "domain/UBGraphicsDelegateFrame.h" #include "domain/UBGraphicsDelegateFrame.h"
class UBBoardController; class UBBoardController;
class UBAppleWidget;
class UBGraphicsScene; class UBGraphicsScene;
class UBGraphicsWidgetItem; class UBGraphicsWidgetItem;
class UBRubberBand; class UBRubberBand;
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "frameworks/UBPlatformUtils.h" #include "frameworks/UBPlatformUtils.h"
#include "core/UBDownloadManager.h" #include "core/UBDownloadManager.h"
#include "domain/UBAbstractWidget.h"
#include "domain/UBGraphicsScene.h" #include "domain/UBGraphicsScene.h"
#include "domain/UBGraphicsSvgItem.h" #include "domain/UBGraphicsSvgItem.h"
#include "domain/UBGraphicsPixmapItem.h" #include "domain/UBGraphicsPixmapItem.h"
...@@ -22,10 +21,9 @@ ...@@ -22,10 +21,9 @@
const QString UBFeaturesController::virtualRootName = "root"; const QString UBFeaturesController::virtualRootName = "root";
void UBFeaturesComputingThread::scanFS(const QUrl & currentPath, const QString & currVirtualPath) void UBFeaturesComputingThread::scanFS(const QUrl & currentPath, const QString & currVirtualPath)
{ {
Q_ASSERT(QFileInfo(currentPath.toLocalFile()).exists()); Q_ASSERT(QFileInfo(currentPath.toLocalFile()).exists());
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(currentPath.toLocalFile()); QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(currentPath.toLocalFile());
...@@ -558,7 +556,7 @@ QImage UBFeaturesController::getIcon(const QString &path, UBFeatureElementType p ...@@ -558,7 +556,7 @@ QImage UBFeaturesController::getIcon(const QString &path, UBFeatureElementType p
return QImage(":images/libpalette/folder.svg"); return QImage(":images/libpalette/folder.svg");
} else if (pFType == FEATURE_INTERACTIVE) { } else if (pFType == FEATURE_INTERACTIVE) {
return QImage(UBAbstractWidget::iconFilePath(QUrl::fromLocalFile(path))); return QImage(UBGraphicsWidgetItem::iconFilePath(QUrl::fromLocalFile(path)));
} }
...@@ -566,7 +564,7 @@ QImage UBFeaturesController::getIcon(const QString &path, UBFeatureElementType p ...@@ -566,7 +564,7 @@ QImage UBFeaturesController::getIcon(const QString &path, UBFeatureElementType p
return QImage( UBToolsManager::manager()->iconFromToolId(path) ); return QImage( UBToolsManager::manager()->iconFromToolId(path) );
} if ( UBFileSystemUtils::mimeTypeFromFileName(path).contains("application")) { } if ( UBFileSystemUtils::mimeTypeFromFileName(path).contains("application")) {
return QImage( UBAbstractWidget::iconFilePath( QUrl::fromLocalFile(path) ) ); return QImage( UBGraphicsWidgetItem::iconFilePath( QUrl::fromLocalFile(path) ) );
} }
QImage thumb; QImage thumb;
...@@ -624,6 +622,7 @@ void UBFeaturesController::importImage(const QImage &image, const QString &fileN ...@@ -624,6 +622,7 @@ void UBFeaturesController::importImage(const QImage &image, const QString &fileN
importImage(image, currentElement, fileName); importImage(image, currentElement, fileName);
} }
void UBFeaturesController::importImage( const QImage &image, const UBFeature &destination, const QString &fileName ) void UBFeaturesController::importImage( const QImage &image, const UBFeature &destination, const QString &fileName )
{ {
QString mFileName = fileName; QString mFileName = fileName;
...@@ -650,6 +649,27 @@ void UBFeaturesController::importImage( const QImage &image, const UBFeature &de ...@@ -650,6 +649,27 @@ void UBFeaturesController::importImage( const QImage &image, const UBFeature &de
} }
QStringList UBFeaturesController::getFileNamesInFolders()
{
QStringList strList;
Q_ASSERT(curListModel);
for (int i = 0; i < curListModel->rowCount(QModelIndex()); i++) {
QModelIndex ind = curListModel->index(i, 0);
if (!ind.isValid()) {
qDebug() << "incorrect model index catched";
continue;
}
UBFeature curFeature = curListModel->data(ind, Qt::UserRole + 1).value<UBFeature>();
if (curFeature.getType() == FEATURE_FOLDER) {
strList << QFileInfo(curFeature.getFullPath().toLocalFile()).fileName();
}
}
return strList;
}
void UBFeaturesController::addNewFolder(QString name) void UBFeaturesController::addNewFolder(QString name)
{ {
QString path = currentElement.getFullPath().toLocalFile() + "/" + name; QString path = currentElement.getFullPath().toLocalFile() + "/" + name;
......
...@@ -157,6 +157,7 @@ public: ...@@ -157,6 +157,7 @@ public:
void removeFromFavorite(const QUrl &path, bool deleteManualy = false); void removeFromFavorite(const QUrl &path, bool deleteManualy = false);
void importImage(const QImage &image, const QString &fileName = QString()); void importImage(const QImage &image, const QString &fileName = QString());
void importImage( const QImage &image, const UBFeature &destination, const QString &fileName = QString() ); void importImage( const QImage &image, const UBFeature &destination, const QString &fileName = QString() );
QStringList getFileNamesInFolders();
void fileSystemScan(const QUrl &currPath, const QString & currVirtualPath); void fileSystemScan(const QUrl &currPath, const QString & currVirtualPath);
int featuresCount(const QUrl &currPath); int featuresCount(const QUrl &currPath);
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "core/UBApplicationController.h" #include "core/UBApplicationController.h"
#include "core/UBDownloadManager.h" #include "core/UBDownloadManager.h"
#include "domain/UBAbstractWidget.h"
#include "domain/UBGraphicsScene.h" #include "domain/UBGraphicsScene.h"
#include "domain/UBGraphicsSvgItem.h" #include "domain/UBGraphicsSvgItem.h"
#include "domain/UBGraphicsPixmapItem.h" #include "domain/UBGraphicsPixmapItem.h"
...@@ -325,7 +324,7 @@ QImage UBLibraryController::thumbnailForFile(UBLibElement* pElement) ...@@ -325,7 +324,7 @@ QImage UBLibraryController::thumbnailForFile(UBLibElement* pElement)
return image; return image;
} }
if (pElement->type() == eUBLibElementType_InteractiveItem){ if (pElement->type() == eUBLibElementType_InteractiveItem){
QImage image = QImage(UBAbstractWidget::iconFilePath(pElement->path())); QImage image = QImage(UBGraphicsWidgetItem::iconFilePath(pElement->path()));
return image; return image;
} }
...@@ -780,7 +779,7 @@ UBLibElement::UBLibElement(eUBLibElementType type, const QUrl &path, const QStri ...@@ -780,7 +779,7 @@ UBLibElement::UBLibElement(eUBLibElementType type, const QUrl &path, const QStri
mThumbnail = QImage(":images/libpalette/folder.svg"); mThumbnail = QImage(":images/libpalette/folder.svg");
if (type == eUBLibElementType_InteractiveItem) if (type == eUBLibElementType_InteractiveItem)
mThumbnail = QImage(UBAbstractWidget::iconFilePath(path)); mThumbnail = QImage(UBGraphicsWidgetItem::iconFilePath(path));
if (type == eUBLibElementType_Item) if (type == eUBLibElementType_Item)
mExtension = QFileInfo(path.toLocalFile()).completeSuffix(); mExtension = QFileInfo(path.toLocalFile()).completeSuffix();
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
#include "document/UBDocumentController.h" #include "document/UBDocumentController.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "desktop/UBDesktopPalette.h" #include "desktop/UBDesktopPalette.h"
#include "desktop/UBDesktopAnnotationController.h" #include "desktop/UBDesktopAnnotationController.h"
...@@ -44,7 +46,6 @@ ...@@ -44,7 +46,6 @@
#include "gui/UBTeacherGuideWidget.h" #include "gui/UBTeacherGuideWidget.h"
#include "domain/UBGraphicsPixmapItem.h" #include "domain/UBGraphicsPixmapItem.h"
#include "domain/UBW3CWidget.h"
#include "podcast/UBPodcastController.h" #include "podcast/UBPodcastController.h"
...@@ -318,7 +319,7 @@ void UBApplicationController::addCapturedEmbedCode(const QString& embedCode) ...@@ -318,7 +319,7 @@ void UBApplicationController::addCapturedEmbedCode(const QString& embedCode)
int width = 300; int width = 300;
int height = 150; int height = 150;
QString widgetPath = UBW3CWidget::createHtmlWrapperInDir(embedCode, userWidgetDir, QString widgetPath = UBGraphicsW3CWidgetItem::createHtmlWrapperInDir(embedCode, userWidgetDir,
QSize(width, height), UBStringUtils::toCanonicalUuid(QUuid::createUuid())); QSize(width, height), UBStringUtils::toCanonicalUuid(QUuid::createUuid()));
if (widgetPath.length() > 0) if (widgetPath.length() > 0)
......
This diff is collapsed.
/*
* 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 2 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 UBABSTRACTWIDGET_H_
#define UBABSTRACTWIDGET_H_
#include <QtGui>
#include <QtWebKit>
#include "web/UBRoutedMouseEventWebView.h"
struct UBWidgetType
{
enum Enum
{
W3C = 0, Apple, Other
};
};
class UBAbstractWidget : public UBRoutedMouseEventWebView
{
Q_OBJECT;
public:
UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent = 0);
virtual ~UBAbstractWidget();
void loadMainHtml();
QUrl mainHtml()
{
return mMainHtmlUrl;
}
QUrl widgetUrl()
{
return mWidgetUrl;
}
QString mainHtmlFileName()
{
return mMainHtmlFileName;
}
bool hasEmbededObjects();
bool hasEmbededFlash();
void resize(qreal width, qreal height);
QSize nominalSize() const
{
return mNominalSize;
}
bool canBeContent();
bool canBeTool();
bool hasLoadedSuccessfully() const
{
return (mInitialLoadDone && !mLoadIsErronous);
}
bool freezable() { return mIsFreezable;}
bool resizable() { return mIsResizable;}
static QString iconFilePath(const QUrl& pUrl);
static QString widgetName(const QUrl& pUrl);
static int widgetType(const QUrl& pUrl);
bool isFrozen(){ return mIsFrozen;}
QPixmap snapshot(){return mSnapshot;}
void setSnapshot(const QPixmap& pix);
QPixmap takeSnapshot();
public slots:
void freeze();
void unFreeze();
signals:
void geometryChangeRequested(const QRect & geom);
protected:
bool mMouseIsPressed;
bool mFirstReleaseAfterMove;
virtual bool event(QEvent *e);
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
virtual QWebView * createWindow(QWebPage::WebWindowType type);
QUrl mMainHtmlUrl;
QString mMainHtmlFileName;
QUrl mWidgetUrl;
QSize mNominalSize;
bool mIsResizable;
bool mInitialLoadDone;
bool mLoadIsErronous;
bool mIsFreezable;
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);
virtual void dropEvent(QDropEvent *);
protected slots:
void mainFrameLoadFinished(bool ok);
private:
static QStringList sInlineJavaScripts;
static bool sInlineJavaScriptLoaded;
bool mIsFrozen;
QPixmap mSnapshot;
bool mIsTakingSnapshot;
private slots:
void javaScriptWindowObjectCleared();
};
#endif /* UBABSTRACTWIDGET_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 2 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 "UBAppleWidget.h"
#include <QtNetwork>
#include "web/UBWebKitUtils.h"
#include "network/UBNetworkAccessManager.h"
#include "core/memcheck.h"
UBAppleWidget::UBAppleWidget(const QUrl& pWidgetUrl, QWidget *parent)
: UBAbstractWidget(pWidgetUrl, parent)
{
QString path = pWidgetUrl.toLocalFile();
if (!path.endsWith(".wdgt") && !path.endsWith(".wdgt/"))
{
int lastSlashIndex = path.lastIndexOf("/");
if (lastSlashIndex > 0)
{
path = path.mid(0, lastSlashIndex + 1);
}
}
QFile plistFile(path + "/Info.plist");
plistFile.open(QFile::ReadOnly);
QByteArray plistBin = plistFile.readAll();
QString plist = QString::fromUtf8(plistBin);
int mainHtmlIndex = plist.indexOf("MainHTML");
int mainHtmlIndexStart = plist.indexOf("<string>", mainHtmlIndex);
int mainHtmlIndexEnd = plist.indexOf("</string>", mainHtmlIndexStart);
if (mainHtmlIndex > -1 && mainHtmlIndexStart > -1 && mainHtmlIndexEnd > -1)
{
mMainHtmlFileName = plist.mid(mainHtmlIndexStart + 8, mainHtmlIndexEnd - mainHtmlIndexStart - 8);
}
mMainHtmlUrl = pWidgetUrl;
mMainHtmlUrl.setPath(pWidgetUrl.path() + "/" + mMainHtmlFileName);
QWebView::load(mMainHtmlUrl);
QPixmap defaultPixmap(pWidgetUrl.toLocalFile() + "/Default.png");
setFixedSize(defaultPixmap.size());
mNominalSize = defaultPixmap.size();
}
UBAppleWidget::~UBAppleWidget()
{
// NOOP
}
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include "UBGraphicsWidgetItem.h" #include "UBGraphicsWidgetItem.h"
#include "domain/UBAbstractWidget.h"
#include "domain/UBGraphicsTextItem.h" #include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsMediaItem.h" #include "domain/UBGraphicsMediaItem.h"
#include "domain/UBGraphicsGroupContainerItem.h" #include "domain/UBGraphicsGroupContainerItem.h"
...@@ -107,12 +106,12 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec ...@@ -107,12 +106,12 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec
, mFrame(0) , mFrame(0)
, mFrameWidth(UBSettings::settings()->objectFrameWidth) , mFrameWidth(UBSettings::settings()->objectFrameWidth)
, mAntiScaleRatio(1.0) , mAntiScaleRatio(1.0)
, mToolBarItem(NULL)
, mCanRotate(canRotate) , mCanRotate(canRotate)
, mCanDuplicate(true) , mCanDuplicate(true)
, mRespectRatio(respectRatio) , mRespectRatio(respectRatio)
, mMimeData(NULL) , mMimeData(NULL)
, mFlippable(false) , mFlippable(false)
, mToolBarItem(NULL)
, mToolBarUsed(useToolBar) , mToolBarUsed(useToolBar)
{ {
// NOOP // NOOP
...@@ -379,7 +378,14 @@ void UBGraphicsItemDelegate::setZOrderButtonsVisible(bool visible) ...@@ -379,7 +378,14 @@ void UBGraphicsItemDelegate::setZOrderButtonsVisible(bool visible)
void UBGraphicsItemDelegate::remove(bool canUndo) void UBGraphicsItemDelegate::remove(bool canUndo)
{ {
// QGraphicsScene* scene = mDelegated->scene(); /*UBGraphicsScene* scene = dynamic_cast<UBGraphicsScene*>(mDelegated->scene());
if (scene && canUndo)
{
UBGraphicsItemUndoCommand *uc = new UBGraphicsItemUndoCommand(scene, mDelegated, 0);
UBApplication::undoStack->push(uc);
}
mDelegated->hide(); */
UBGraphicsScene* scene = dynamic_cast<UBGraphicsScene*>(mDelegated->scene()); UBGraphicsScene* scene = dynamic_cast<UBGraphicsScene*>(mDelegated->scene());
if (scene) if (scene)
{ {
...@@ -387,11 +393,17 @@ void UBGraphicsItemDelegate::remove(bool canUndo) ...@@ -387,11 +393,17 @@ void UBGraphicsItemDelegate::remove(bool canUndo)
scene->removeItem(button); scene->removeItem(button);
scene->removeItem(mFrame); scene->removeItem(mFrame);
/* this is performed because when removing delegated from scene while it contains flash content, segfault happens because of QGraphicsScene::removeItem() */
UBGraphicsWebView *mDelegated_casted = dynamic_cast<UBGraphicsWebView*>(mDelegated);
if (mDelegated_casted)
mDelegated_casted->setHtml(QString());
scene->removeItem(mDelegated); scene->removeItem(mDelegated);
if (canUndo) if (canUndo)
{ {
UBGraphicsItemUndoCommand *uc = new UBGraphicsItemUndoCommand((UBGraphicsScene*) scene, mDelegated, 0); UBGraphicsItemUndoCommand *uc = new UBGraphicsItemUndoCommand(scene, mDelegated, 0);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
} }
} }
...@@ -406,6 +418,10 @@ bool UBGraphicsItemDelegate::isLocked() ...@@ -406,6 +418,10 @@ bool UBGraphicsItemDelegate::isLocked()
void UBGraphicsItemDelegate::duplicate() void UBGraphicsItemDelegate::duplicate()
{ {
// TODO UB 4.x .. rewrite .. .this is absurde ... we know what we are duplicating
UBApplication::boardController->copy();
UBApplication::boardController->paste();
UBApplication::boardController->duplicateItem(dynamic_cast<UBItem*>(delegated())); UBApplication::boardController->duplicateItem(dynamic_cast<UBItem*>(delegated()));
} }
...@@ -724,7 +740,11 @@ void UBGraphicsToolBarItem::paint(QPainter *painter, const QStyleOptionGraphicsI ...@@ -724,7 +740,11 @@ void UBGraphicsToolBarItem::paint(QPainter *painter, const QStyleOptionGraphicsI
} }
MediaTimer::MediaTimer(QGraphicsItem * parent): QGraphicsRectItem(parent) MediaTimer::MediaTimer(QGraphicsItem * parent): QGraphicsRectItem(parent)
{} {
val = 0;
smallPoint = false;
setNumDigits(4);
}
MediaTimer::~MediaTimer() MediaTimer::~MediaTimer()
{} {}
...@@ -807,9 +827,7 @@ void MediaTimer::drawDigit(const QPoint &pos, QPainter &p, int segLen, ...@@ -807,9 +827,7 @@ void MediaTimer::drawDigit(const QPoint &pos, QPainter &p, int segLen,
} }
} }
char* MediaTimer::getSegments(char ch) // gets list of segments for ch char MediaTimer::segments [][8] =
{
char segments[30][8] =
{ {
{ 0, 1, 2, 4, 5, 6,99, 0}, // 0 0 { 0, 1, 2, 4, 5, 6,99, 0}, // 0 0
{ 2, 5,99, 0, 0, 0, 0, 0}, // 1 1 { 2, 5,99, 0, 0, 0, 0, 0}, // 1 1
...@@ -824,16 +842,17 @@ char* MediaTimer::getSegments(char ch) // gets list of segments fo ...@@ -824,16 +842,17 @@ char* MediaTimer::getSegments(char ch) // gets list of segments fo
{ 8, 9,99, 0, 0, 0, 0, 0}, // 10 : { 8, 9,99, 0, 0, 0, 0, 0}, // 10 :
{99, 0, 0, 0, 0, 0, 0, 0} // 11 empty {99, 0, 0, 0, 0, 0, 0, 0} // 11 empty
}; };
int n; const char* MediaTimer::getSegments(char ch) // gets list of segments for ch
{
if (ch >= '0' && ch <= '9') if (ch >= '0' && ch <= '9')
return segments[ch - '0']; return segments[ch - '0'];
if (ch == ':') if (ch == ':')
n = 10; return segments[10];
if (ch == ' ') if (ch == ' ')
n = 11; return segments[11];
return segments[n]; return NULL;
} }
void MediaTimer::drawSegment(const QPoint &pos, char segmentNo, QPainter &p, void MediaTimer::drawSegment(const QPoint &pos, char segmentNo, QPainter &p,
...@@ -1055,13 +1074,6 @@ void MediaTimer::internalSetString(const QString& s) ...@@ -1055,13 +1074,6 @@ void MediaTimer::internalSetString(const QString& s)
update(); update();
} }
void MediaTimer::init()
{
val = 0;
smallPoint = false;
setNumDigits(4);
}
void MediaTimer::display(const QString &s) void MediaTimer::display(const QString &s)
{ {
val = 0; val = 0;
...@@ -1075,11 +1087,11 @@ void MediaTimer::display(const QString &s) ...@@ -1075,11 +1087,11 @@ void MediaTimer::display(const QString &s)
void MediaTimer::setNumDigits(int numDigits) void MediaTimer::setNumDigits(int numDigits)
{ {
if (numDigits > 99) { if (numDigits > 99) {
qWarning("QLCDNumber::setNumDigits: (%s) Max 99 digits allowed"); qWarning("QLCDNumber::setNumDigits: Max 99 digits allowed");
numDigits = 99; numDigits = 99;
} }
if (numDigits < 0) { if (numDigits < 0) {
qWarning("QLCDNumber::setNumDigits: (%s) Min 0 digits allowed"); qWarning("QLCDNumber::setNumDigits: Min 0 digits allowed");
numDigits = 0; numDigits = 0;
} }
if (digitStr.isNull()) { // from constructor if (digitStr.isNull()) { // from constructor
...@@ -1128,9 +1140,7 @@ DelegateMediaControl::DelegateMediaControl(UBGraphicsMediaItem* pDelegated, QGra ...@@ -1128,9 +1140,7 @@ DelegateMediaControl::DelegateMediaControl(UBGraphicsMediaItem* pDelegated, QGra
setPen(Qt::NoPen); setPen(Qt::NoPen);
setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control)); setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
lcdTimer = 0; lcdTimer = new MediaTimer(this);
//lcdTimer = new MediaTimer(this);
//lcdTimer->init();
update(); update();
} }
...@@ -1181,6 +1191,8 @@ void DelegateMediaControl::positionHandles() ...@@ -1181,6 +1191,8 @@ void DelegateMediaControl::positionHandles()
{ {
mLCDTimerArea.setWidth(parentItem()->boundingRect().height()); mLCDTimerArea.setWidth(parentItem()->boundingRect().height());
mLCDTimerArea.setHeight(parentItem()->boundingRect().height()); mLCDTimerArea.setHeight(parentItem()->boundingRect().height());
lcdTimer->setRect(mLCDTimerArea);
lcdTimer->setPos(mSeecArea.width()-mLCDTimerArea.width(),0);
//lcdTimer->setRect(mLCDTimerArea); //lcdTimer->setRect(mLCDTimerArea);
//lcdTimer->setPos(mSeecArea.width()-mLCDTimerArea.width(),0); //lcdTimer->setPos(mSeecArea.width()-mLCDTimerArea.width(),0);
...@@ -1190,6 +1202,7 @@ void DelegateMediaControl::positionHandles() ...@@ -1190,6 +1202,7 @@ void DelegateMediaControl::positionHandles()
selfRect.setHeight(parentItem()->boundingRect().height()); selfRect.setHeight(parentItem()->boundingRect().height());
setRect(selfRect); setRect(selfRect);
lcdTimer->setPos(rect().width() - mLCDTimerArea.width(), 0);
//lcdTimer->setPos(rect().width() - mLCDTimerArea.width(), 0); //lcdTimer->setPos(rect().width() - mLCDTimerArea.width(), 0);
} }
...@@ -1198,6 +1211,7 @@ void DelegateMediaControl::update() ...@@ -1198,6 +1211,7 @@ void DelegateMediaControl::update()
{ {
QTime t; QTime t;
t = t.addMSecs(mCurrentTimeInMs < 0 ? 0 : mCurrentTimeInMs); t = t.addMSecs(mCurrentTimeInMs < 0 ? 0 : mCurrentTimeInMs);
lcdTimer->display(t.toString("m:ss"));
//lcdTimer->display(t.toString("m:ss")); //lcdTimer->display(t.toString("m:ss"));
QGraphicsRectItem::update(); QGraphicsRectItem::update();
...@@ -1250,6 +1264,7 @@ void DelegateMediaControl::seekToMousePos(QPointF mousePos) ...@@ -1250,6 +1264,7 @@ void DelegateMediaControl::seekToMousePos(QPointF mousePos)
qreal frameWidth = rect().height() / 2; qreal frameWidth = rect().height() / 2;
minX = frameWidth; minX = frameWidth;
length = mSeecArea.width() - lcdTimer->rect().width();
length = mSeecArea.width() /*- lcdTimer->rect().width()*/; length = mSeecArea.width() /*- lcdTimer->rect().width()*/;
qreal mouseX = mousePos.x(); qreal mouseX = mousePos.x();
......
...@@ -71,33 +71,40 @@ class DelegateButton: public QGraphicsSvgItem ...@@ -71,33 +71,40 @@ class DelegateButton: public QGraphicsSvgItem
}; };
/*
Code of this class is copied from QT QLCDNumber class sources
See src\gui\widgets\qlcdnumber.cpp for original code
*/
class MediaTimer: public QGraphicsRectItem class MediaTimer: public QGraphicsRectItem
{ {
public: public:
MediaTimer(QGraphicsItem * parent = 0); MediaTimer(QGraphicsItem * parent = 0);
~MediaTimer(); ~MediaTimer();
char* getSegments(char);
void addPoint(QPolygon&, const QPoint&);
void init();
void internalSetString(const QString& s);
void drawString(const QString& s, QPainter &, QBitArray * = 0, bool = true);
void drawDigit(const QPoint &, QPainter &, int, char, char = ' ');
void drawSegment(const QPoint &, char, QPainter &, int, bool = false);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget); QWidget *widget);
void display(const QString &str); void display(const QString &str);
void setNumDigits(int nDigits);
private: private:
static const char* getSegments(char);
void drawString(const QString& s, QPainter &, QBitArray * = 0, bool = true);
void drawDigit(const QPoint &, QPainter &, int, char, char = ' ');
void drawSegment(const QPoint &, char, QPainter &, int, bool = false);
void addPoint(QPolygon&, const QPoint&);
void internalSetString(const QString& s);
void setNumDigits(int nDigits);
static char segments [][8];
int ndigits; int ndigits;
QString digitStr; QString digitStr;
QBitArray points; QBitArray points;
double val; double val;
uint shadow : 1; uint shadow : 1;
uint smallPoint : 1; uint smallPoint : 1;
}; };
class DelegateMediaControl: public QObject, public QGraphicsRectItem class DelegateMediaControl: public QObject, public QGraphicsRectItem
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "gui/UBMagnifer.h" #include "gui/UBMagnifer.h"
#include "gui/UBMainWindow.h" #include "gui/UBMainWindow.h"
#include "gui/UBToolWidget.h"
#include "tools/UBGraphicsRuler.h" #include "tools/UBGraphicsRuler.h"
#include "tools/UBGraphicsProtractor.h" #include "tools/UBGraphicsProtractor.h"
...@@ -59,8 +60,6 @@ ...@@ -59,8 +60,6 @@
#include "domain/UBGraphicsGroupContainerItem.h" #include "domain/UBGraphicsGroupContainerItem.h"
#include "UBAppleWidget.h"
#include "UBW3CWidget.h"
#include "UBGraphicsStroke.h" #include "UBGraphicsStroke.h"
#include "core/memcheck.h" #include "core/memcheck.h"
...@@ -256,8 +255,8 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent) ...@@ -256,8 +255,8 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
, mDocument(parent) , mDocument(parent)
, mDarkBackground(false) , mDarkBackground(false)
, mCrossedBackground(false) , mCrossedBackground(false)
, mZoomFactor(1)
, mIsDesktopMode(false) , mIsDesktopMode(false)
, mZoomFactor(1)
, mIsModified(true) , mIsModified(true)
, mBackgroundObject(0) , mBackgroundObject(0)
, mPreviousWidth(0) , mPreviousWidth(0)
...@@ -1396,7 +1395,7 @@ UBGraphicsMediaItem* UBGraphicsScene::addAudio(const QUrl& pAudioFileUrl, bool s ...@@ -1396,7 +1395,7 @@ UBGraphicsMediaItem* UBGraphicsScene::addAudio(const QUrl& pAudioFileUrl, bool s
UBGraphicsWidgetItem* UBGraphicsScene::addWidget(const QUrl& pWidgetUrl, const QPointF& pPos) UBGraphicsWidgetItem* UBGraphicsScene::addWidget(const QUrl& pWidgetUrl, const QPointF& pPos)
{ {
int widgetType = UBAbstractWidget::widgetType(pWidgetUrl); int widgetType = UBGraphicsWidgetItem::widgetType(pWidgetUrl);
if(widgetType == UBWidgetType::Apple) if(widgetType == UBWidgetType::Apple)
{ {
...@@ -1422,9 +1421,9 @@ UBGraphicsAppleWidgetItem* UBGraphicsScene::addAppleWidget(const QUrl& pWidgetUr ...@@ -1422,9 +1421,9 @@ UBGraphicsAppleWidgetItem* UBGraphicsScene::addAppleWidget(const QUrl& pWidgetUr
return appleWidget; return appleWidget;
} }
UBGraphicsW3CWidgetItem* UBGraphicsScene::addW3CWidget(const QUrl& pWidgetUrl, const QPointF& pPos, int widgetType) UBGraphicsW3CWidgetItem* UBGraphicsScene::addW3CWidget(const QUrl& pWidgetUrl, const QPointF& pPos)
{ {
UBGraphicsW3CWidgetItem *w3CWidget = new UBGraphicsW3CWidgetItem(pWidgetUrl, 0, widgetType); UBGraphicsW3CWidgetItem *w3CWidget = new UBGraphicsW3CWidgetItem(pWidgetUrl, 0);
addGraphicsWidget(w3CWidget, pPos); addGraphicsWidget(w3CWidget, pPos);
...@@ -1444,7 +1443,7 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co ...@@ -1444,7 +1443,7 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co
graphicsWidget->setPos(QPointF(pPos.x() - graphicsWidget->boundingRect().width() / 2, graphicsWidget->setPos(QPointF(pPos.x() - graphicsWidget->boundingRect().width() / 2,
pPos.y() - graphicsWidget->boundingRect().height() / 2)); pPos.y() - graphicsWidget->boundingRect().height() / 2));
if (graphicsWidget->widgetWebView()->canBeContent()) if (graphicsWidget->canBeContent())
{ {
// graphicsWidget->widgetWebView()->loadMainHtml(); // graphicsWidget->widgetWebView()->loadMainHtml();
...@@ -1464,6 +1463,8 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co ...@@ -1464,6 +1463,8 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co
UBApplication::boardController->controlView()->setFocus(); UBApplication::boardController->controlView()->setFocus();
} }
UBGraphicsW3CWidgetItem* UBGraphicsScene::addOEmbed(const QUrl& pContentUrl, const QPointF& pPos) UBGraphicsW3CWidgetItem* UBGraphicsScene::addOEmbed(const QUrl& pContentUrl, const QPointF& pPos)
{ {
QStringList widgetPaths = UBPersistenceManager::persistenceManager()->allWidgets(UBSettings::settings()->applicationApplicationsLibraryDirectory()); QStringList widgetPaths = UBPersistenceManager::persistenceManager()->allWidgets(UBSettings::settings()->applicationApplicationsLibraryDirectory());
......
...@@ -35,12 +35,12 @@ class UBGraphicsAudioItem; ...@@ -35,12 +35,12 @@ class UBGraphicsAudioItem;
class UBGraphicsWidgetItem; class UBGraphicsWidgetItem;
class UBGraphicsW3CWidgetItem; class UBGraphicsW3CWidgetItem;
class UBGraphicsAppleWidgetItem; class UBGraphicsAppleWidgetItem;
class UBToolWidget;
class UBGraphicsPDFItem; class UBGraphicsPDFItem;
class UBGraphicsTextItem; class UBGraphicsTextItem;
class UBGraphicsRuler; class UBGraphicsRuler;
class UBGraphicsProtractor; class UBGraphicsProtractor;
class UBGraphicsCompass; class UBGraphicsCompass;
class UBAbstractWidget;
class UBDocumentProxy; class UBDocumentProxy;
class UBGraphicsCurtainItem; class UBGraphicsCurtainItem;
class UBGraphicsStroke; class UBGraphicsStroke;
...@@ -132,9 +132,11 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem ...@@ -132,9 +132,11 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBGraphicsWidgetItem* addWidget(const QUrl& pWidgetUrl, const QPointF& pPos = QPointF(0, 0)); UBGraphicsWidgetItem* addWidget(const QUrl& pWidgetUrl, const QPointF& pPos = QPointF(0, 0));
UBGraphicsAppleWidgetItem* addAppleWidget(const QUrl& pWidgetUrl, const QPointF& pPos = QPointF(0, 0)); UBGraphicsAppleWidgetItem* addAppleWidget(const QUrl& pWidgetUrl, const QPointF& pPos = QPointF(0, 0));
UBGraphicsW3CWidgetItem* addW3CWidget(const QUrl& pWidgetUrl, const QPointF& pPos = QPointF(0, 0),int widgetType = UBGraphicsItemType::W3CWidgetItemType); UBGraphicsW3CWidgetItem* addW3CWidget(const QUrl& pWidgetUrl, const QPointF& pPos = QPointF(0, 0));
void addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, const QPointF& pPos = QPointF(0, 0)); void addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, const QPointF& pPos = QPointF(0, 0));
UBGraphicsMediaItem* addMedia(const QUrl& pMediaFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0)); UBGraphicsMediaItem* addMedia(const QUrl& pMediaFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0));
UBGraphicsMediaItem* addVideo(const QUrl& pVideoFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0)); UBGraphicsMediaItem* addVideo(const QUrl& pVideoFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0));
UBGraphicsMediaItem* addAudio(const QUrl& pAudioFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0)); UBGraphicsMediaItem* addAudio(const QUrl& pAudioFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0));
......
/*
* 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 2 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 <QtGui>
#include <QtWebKit>
#include "UBGraphicsWebView.h"
#include "UBGraphicsScene.h"
#include "UBGraphicsItemDelegate.h"
#include "UBGraphicsDelegateFrame.h"
#include "core/memcheck.h"
UBGraphicsWebView::UBGraphicsWebView(QGraphicsItem* parent)
: QGraphicsWebView(parent)
{
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
mDelegate = new UBGraphicsItemDelegate(this, 0, true, false, false);
mDelegate->init();
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
QGraphicsWebView::setAcceptHoverEvents(true);
}
UBGraphicsWebView::~UBGraphicsWebView()
{
if (mDelegate)
delete mDelegate;
}
QVariant UBGraphicsWebView::itemChange(GraphicsItemChange change, const QVariant &value)
{
if ((change == QGraphicsItem::ItemSelectedHasChanged) && scene()) {
if (isSelected())
scene()->setActiveWindow(this);
else
if(scene()->activeWindow() == this)
scene()->setActiveWindow(0);
}
QVariant newValue = mDelegate->itemChange(change, value);
return QGraphicsWebView::itemChange(change, newValue);
}
void UBGraphicsWebView::setUuid(const QUuid &pUuid)
{
UBItem::setUuid(pUuid);
setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid)); //store item uuid inside the QGraphicsItem to fast operations with Items on the scene
}
void UBGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (!mDelegate->mousePressEvent(event))
setSelected(true); /* forcing selection */
QGraphicsWebView::mousePressEvent(event);
}
void UBGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (!mDelegate->mouseMoveEvent(event))
QGraphicsWebView::mouseMoveEvent(event);
}
void UBGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
mDelegate->mouseReleaseEvent(event);
QGraphicsWebView::mouseReleaseEvent(event);
}
void UBGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent *event)
{
if (mDelegate->weelEvent(event))
{
QGraphicsWebView::wheelEvent(event);
event->accept();
}
}
void UBGraphicsWebView::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
/* NOOP */
}
void UBGraphicsWebView::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
/* NOOP */
}
void UBGraphicsWebView::setDelegate(UBGraphicsItemDelegate* pDelegate)
{
if (mDelegate)
delete mDelegate;
mDelegate = pDelegate;
}
void UBGraphicsWebView::resize(qreal w, qreal h)
{
UBGraphicsWebView::resize(QSizeF(w, h));
}
void UBGraphicsWebView::resize(const QSizeF & pSize)
{
if (pSize != size()) {
QGraphicsWebView::setMaximumSize(pSize.width(), pSize.height());
QGraphicsWebView::resize(pSize.width(), pSize.height());
if (mDelegate)
mDelegate->positionHandles();
if (scene())
scene()->setModified(true);
}
}
QSizeF UBGraphicsWebView::size() const
{
return QGraphicsWebView::size();
}
UBGraphicsScene* UBGraphicsWebView::scene()
{
return static_cast<UBGraphicsScene*>(QGraphicsItem::scene());
}
void UBGraphicsWebView::remove()
{
if (mDelegate)
mDelegate->remove(true);
}
bool UBGraphicsWebView::event(QEvent *event)
{
if (event->type() == QEvent::ShortcutOverride)
event->accept();
return QGraphicsWebView::event(event);
}
...@@ -13,24 +13,50 @@ ...@@ -13,24 +13,50 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef UBAPPLEWIDGET_H_ #ifndef UBGRAPHICSWEBVIEW_H_
#define UBAPPLEWIDGET_H_ #define UBGRAPHICSWEBVIEW_H_
#include <QtGui> #include <QtGui>
#include <QtWebKit> #include <QtWebKit>
#include "UBAbstractWidget.h" #include "UBItem.h"
#include "UBResizableGraphicsItem.h"
class UBItem; class UBGraphicsItemDelegate;
class UBAppleWidget : public UBAbstractWidget class UBGraphicsWebView: public QGraphicsWebView, public UBItem, public UBResizableGraphicsItem, public UBGraphicsItem
{ {
Q_OBJECT;
public: public:
UBAppleWidget(const QUrl& pWidgetUrl, QWidget *parent = 0); UBGraphicsWebView(QGraphicsItem* parent = 0);
virtual ~UBAppleWidget(); virtual ~UBGraphicsWebView();
virtual void resize(qreal w, qreal h);
virtual void resize(const QSizeF & size);
virtual QSizeF size() const;
void setDelegate(UBGraphicsItemDelegate* pDelegate);
virtual UBGraphicsScene* scene();
virtual void remove();
virtual UBGraphicsItemDelegate* Delegate() const { return mDelegate;}
virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid);
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual bool event(QEvent *event);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
}; };
#endif /* UBAPPLEWIDGET_H_ */ #endif /* UBGRAPHICSWEBVIEW_H_ */
This diff is collapsed.
This diff is collapsed.
...@@ -55,7 +55,7 @@ void UBGraphicsWidgetItemDelegate::updateMenuActionState() ...@@ -55,7 +55,7 @@ void UBGraphicsWidgetItemDelegate::updateMenuActionState()
UBGraphicsItemDelegate::updateMenuActionState(); UBGraphicsItemDelegate::updateMenuActionState();
if (freezeAction) if (freezeAction)
freezeAction->setChecked(delegated()->widgetWebView()->isFrozen()); freezeAction->setChecked(delegated()->isFrozen());
} }
void UBGraphicsWidgetItemDelegate::decorateMenu(QMenu* menu) void UBGraphicsWidgetItemDelegate::decorateMenu(QMenu* menu)
...@@ -71,7 +71,7 @@ void UBGraphicsWidgetItemDelegate::decorateMenu(QMenu* menu) ...@@ -71,7 +71,7 @@ void UBGraphicsWidgetItemDelegate::decorateMenu(QMenu* menu)
freezeAction->setCheckable(true); freezeAction->setCheckable(true);
if (delegated()->widgetWebView()->canBeTool()) if (delegated()->canBeTool())
{ {
setAsToolAction = mMenu->addAction(tr("Transform as Tool "), this, SLOT(pin())); setAsToolAction = mMenu->addAction(tr("Transform as Tool "), this, SLOT(pin()));
QIcon pinIcon; QIcon pinIcon;
...@@ -86,11 +86,11 @@ void UBGraphicsWidgetItemDelegate::freeze(bool frozen) ...@@ -86,11 +86,11 @@ void UBGraphicsWidgetItemDelegate::freeze(bool frozen)
{ {
if(frozen) if(frozen)
{ {
delegated()->widgetWebView()->freeze(); delegated()->freeze();
} }
else else
{ {
delegated()->widgetWebView()->unFreeze(); delegated()->unFreeze();
} }
} }
......
This diff is collapsed.
/*
* 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 2 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 UBW3CWIDGET_H_
#define UBW3CWIDGET_H_
#include <QtGui>
#include <QtWebKit>
#include <QtXml>
/*
* wrapper for w3c widget 1.0 as define in http://www.w3.org/TR/widgets/
*/
#include "UBAbstractWidget.h"
class UBItem;
class UBW3CWidget : public UBAbstractWidget
{
Q_OBJECT;
public:
UBW3CWidget(const QUrl& pWidgetUrl, QWidget *parent = 0);
virtual ~UBW3CWidget();
static QString createNPAPIWrapper(const QString& url,
const QString& pMimeType = QString(), const QSize& sizeHint = QSize(300, 150),
const QString& pName = QString());
static QString createNPAPIWrapperInDir(const QString& url, const QDir& pDir,
const QString& pMimeType = QString(), const QSize& sizeHint = QSize(300, 150),
const QString& pName = QString());
static QString createHtmlWrapperInDir(const QString& html, const QDir& pDir,
const QSize& sizeHint, const QString& pName);
static QString freezedWidgetPage();
static QString freezedWidgetFilePath();
static bool hasNPAPIWrapper(const QString& pMimeType);
class PreferenceValue
{
public:
PreferenceValue()
{
// NOOP
}
PreferenceValue(const QString& pValue, bool pReadonly)
{
value = pValue;
readonly = pReadonly;
}
QString value;
bool readonly;
};
class Metadata
{
public:
QString id;
QString name;
QString description;
QString author;
QString authorEmail;
QString authorHref;
QString version;
};
QMap<QString, PreferenceValue> preferences()
{
return mPreferences;
}
Metadata metadatas() const
{
return mMetadatas;
}
private:
QMap<QString, PreferenceValue> mPreferences;
static bool sTemplateLoaded;
static QMap<QString, QString> sNPAPIWrapperTemplates;
static QString sNPAPIWrappperConfigTemplate;
static void loadNPAPIWrappersTemplates();
static QString textForSubElementByLocale(QDomElement rootElement, QString subTagName, QLocale locale);
// w3c metadata widget attributes
//
// http://www.w3.org/TR/widgets/#widget0
Metadata mMetadatas;
private slots:
void javaScriptWindowObjectCleared();
};
#endif /* UBW3CWIDGET_H_ */
...@@ -7,26 +7,24 @@ HEADERS += src/domain/UBGraphicsScene.h \ ...@@ -7,26 +7,24 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBDocumentUndoCommand.h \ src/domain/UBDocumentUndoCommand.h \
src/domain/UBPageSizeUndoCommand.h \ src/domain/UBPageSizeUndoCommand.h \
src/domain/UBGraphicsProxyWidget.h \ src/domain/UBGraphicsProxyWidget.h \
src/domain/UBGraphicsWebView.h \
src/domain/UBGraphicsSvgItem.h \ src/domain/UBGraphicsSvgItem.h \
src/domain/UBGraphicsPolygonItem.h \ src/domain/UBGraphicsPolygonItem.h \
src/domain/UBItem.h \ src/domain/UBItem.h \
src/domain/UBGraphicsWidgetItem.h \ src/domain/UBGraphicsWidgetItem.h \
src/domain/UBAppleWidget.h \
src/domain/UBGraphicsPDFItem.h \ src/domain/UBGraphicsPDFItem.h \
src/domain/UBGraphicsTextItem.h \ src/domain/UBGraphicsTextItem.h \
src/domain/UBAbstractWidget.h \
src/domain/UBW3CWidget.h \
src/domain/UBResizableGraphicsItem.h \ src/domain/UBResizableGraphicsItem.h \
src/domain/UBGraphicsStroke.h \ src/domain/UBGraphicsStroke.h \
src/domain/UBGraphicsMediaItem.h \ src/domain/UBGraphicsMediaItem.h \
src/domain/UBAbstractUndoCommand.h\ src/domain/UBAbstractUndoCommand.h\
src/domain/UBAngleWidget.h \ src/domain/UBAngleWidget.h \
src/domain/UBGraphicsGroupContainerItem.h \ src/domain/UBGraphicsGroupContainerItem.h \
src/domain/UBGraphicsGroupContainerItemDelegate.h \ src/domain/UBGraphicsGroupContainerItemDelegate.h \
src/domain/UBGraphicsStrokesGroup.h src/domain/UBGraphicsStrokesGroup.h
HEADERS += src/domain/UBGraphicsItemDelegate.h \ HEADERS += src/domain/UBGraphicsItemDelegate.h \
src/domain/UBGraphicsTextItemDelegate.h \ src/domain/UBGraphicsTextItemDelegate.h \
src/domain/UBGraphicsDelegateFrame.h \ src/domain/UBGraphicsDelegateFrame.h \
src/domain/UBGraphicsWidgetItemDelegate.h \ src/domain/UBGraphicsWidgetItemDelegate.h \
src/domain/UBGraphicsMediaItemDelegate.h src/domain/UBGraphicsMediaItemDelegate.h
...@@ -40,27 +38,25 @@ SOURCES += src/domain/UBGraphicsScene.cpp \ ...@@ -40,27 +38,25 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBDocumentUndoCommand.cpp \ src/domain/UBDocumentUndoCommand.cpp \
src/domain/UBPageSizeUndoCommand.cpp \ src/domain/UBPageSizeUndoCommand.cpp \
src/domain/UBGraphicsProxyWidget.cpp \ src/domain/UBGraphicsProxyWidget.cpp \
src/domain/UBGraphicsWebView.cpp \
src/domain/UBGraphicsSvgItem.cpp \ src/domain/UBGraphicsSvgItem.cpp \
src/domain/UBGraphicsPolygonItem.cpp \ src/domain/UBGraphicsPolygonItem.cpp \
src/domain/UBItem.cpp \ src/domain/UBItem.cpp \
src/domain/UBGraphicsVideoItem.cpp \ src/domain/UBGraphicsVideoItem.cpp \
src/domain/UBGraphicsWidgetItem.cpp \ src/domain/UBGraphicsWidgetItem.cpp \
src/domain/UBAppleWidget.cpp \
src/domain/UBGraphicsPDFItem.cpp \ src/domain/UBGraphicsPDFItem.cpp \
src/domain/UBGraphicsTextItem.cpp \ src/domain/UBGraphicsTextItem.cpp \
src/domain/UBAbstractWidget.cpp \
src/domain/UBW3CWidget.cpp \
src/domain/UBResizableGraphicsItem.cpp \ src/domain/UBResizableGraphicsItem.cpp \
src/domain/UBGraphicsStroke.cpp \ src/domain/UBGraphicsStroke.cpp \
src/domain/UBGraphicsMediaItem.cpp \ src/domain/UBGraphicsMediaItem.cpp \
src/domain/UBAbstractUndoCommand.cpp \ src/domain/UBAbstractUndoCommand.cpp \
src/domain/UBAngleWidget.cpp \ src/domain/UBAngleWidget.cpp \
src/domain/ubgraphicsgroupcontaineritem.cpp \ src/domain/ubgraphicsgroupcontaineritem.cpp \
src/domain/ubgraphicsgroupcontaineritemdelegate.cpp \ src/domain/ubgraphicsgroupcontaineritemdelegate.cpp \
src/domain/UBGraphicsStrokesGroup.cpp src/domain/UBGraphicsStrokesGroup.cpp
SOURCES += src/domain/UBGraphicsItemDelegate.cpp \ SOURCES += src/domain/UBGraphicsItemDelegate.cpp \
src/domain/UBGraphicsTextItemDelegate.cpp \ src/domain/UBGraphicsTextItemDelegate.cpp \
src/domain/UBGraphicsMediaItemDelegate.cpp \ src/domain/UBGraphicsMediaItemDelegate.cpp \
src/domain/UBGraphicsDelegateFrame.cpp \ src/domain/UBGraphicsDelegateFrame.cpp \
src/domain/UBGraphicsWidgetItemDelegate.cpp \ src/domain/UBGraphicsWidgetItemDelegate.cpp \
......
...@@ -32,7 +32,7 @@ UBCoreGraphicsScene::~UBCoreGraphicsScene() ...@@ -32,7 +32,7 @@ UBCoreGraphicsScene::~UBCoreGraphicsScene()
//we must delete removed items that are no more in any scene //we must delete removed items that are no more in any scene
foreach (const QGraphicsItem* item, mItemsToDelete) foreach (const QGraphicsItem* item, mItemsToDelete)
{ {
if (item->scene()==NULL || item->scene() == this) if (item->scene() == NULL || item->scene() == this)
{ {
delete item; delete item;
} }
...@@ -61,6 +61,7 @@ void UBCoreGraphicsScene::removeItem(QGraphicsItem* item, bool forceDelete) ...@@ -61,6 +61,7 @@ void UBCoreGraphicsScene::removeItem(QGraphicsItem* item, bool forceDelete)
{ {
mItemsToDelete.remove(item); mItemsToDelete.remove(item);
delete item; delete item;
item = 0;
} }
} }
...@@ -84,6 +85,7 @@ bool UBCoreGraphicsScene::deleteItem(QGraphicsItem* item) ...@@ -84,6 +85,7 @@ bool UBCoreGraphicsScene::deleteItem(QGraphicsItem* item)
mItemsToDelete.remove(item); mItemsToDelete.remove(item);
delete item; delete item;
item = 0;
return true; return true;
} }
else else
......
...@@ -18,11 +18,10 @@ ...@@ -18,11 +18,10 @@
#include "core/UBSettings.h" #include "core/UBSettings.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "tools/UBToolsManager.h" #include "tools/UBToolsManager.h"
#include "domain/UBAbstractWidget.h"
#include "gui/UBMainWindow.h" #include "gui/UBMainWindow.h"
#include "core/memcheck.h" #include "core/memcheck.h"
...@@ -67,9 +66,9 @@ UBFavoriteToolPalette::UBFavoriteToolPalette(QWidget* parent) ...@@ -67,9 +66,9 @@ UBFavoriteToolPalette::UBFavoriteToolPalette(QWidget* parent)
foreach(QString widgetPath, appPathes) foreach(QString widgetPath, appPathes)
{ {
QAction *action = new QAction(UBAbstractWidget::widgetName(QUrl::fromLocalFile(widgetPath)), this); QAction *action = new QAction(UBGraphicsWidgetItem::widgetName(QUrl::fromLocalFile(widgetPath)), this);
action->setData(QUrl::fromLocalFile(widgetPath)); action->setData(QUrl::fromLocalFile(widgetPath));
action->setIcon(QIcon(UBAbstractWidget::iconFilePath(QUrl::fromLocalFile(widgetPath)))); action->setIcon(QIcon(UBGraphicsWidgetItem::iconFilePath(QUrl::fromLocalFile(widgetPath))));
connect(action, SIGNAL(triggered()), this, SLOT(addFavorite())); connect(action, SIGNAL(triggered()), this, SLOT(addFavorite()));
toolsActions << action; toolsActions << action;
......
...@@ -209,6 +209,16 @@ void UBFeaturesActionBar::onActionRescanModel() ...@@ -209,6 +209,16 @@ void UBFeaturesActionBar::onActionRescanModel()
emit rescanModel(); emit rescanModel();
} }
void UBFeaturesActionBar::lockIt()
{
setEnabled(false);
}
void UBFeaturesActionBar::unlockIt()
{
setEnabled(true);
}
void UBFeaturesActionBar::dragEnterEvent( QDragEnterEvent *event ) void UBFeaturesActionBar::dragEnterEvent( QDragEnterEvent *event )
{ {
const UBFeaturesMimeData *fMimeData = qobject_cast<const UBFeaturesMimeData*>(event->mimeData()); const UBFeaturesMimeData *fMimeData = qobject_cast<const UBFeaturesMimeData*>(event->mimeData());
......
...@@ -45,6 +45,8 @@ private slots: ...@@ -45,6 +45,8 @@ private slots:
void onActionRemoveFavorite(); void onActionRemoveFavorite();
void onActionTrash(); void onActionTrash();
void onActionRescanModel(); void onActionRescanModel();
void lockIt();
void unlockIt();
protected: protected:
void dragEnterEvent( QDragEnterEvent *event ); void dragEnterEvent( QDragEnterEvent *event );
......
#include <QDomDocument> #include <QDomDocument>
#include "UBFeaturesWidget.h" #include "UBFeaturesWidget.h"
#include "domain/UBAbstractWidget.h"
#include "gui/UBThumbnailWidget.h" #include "gui/UBThumbnailWidget.h"
#include "frameworks/UBFileSystemUtils.h" #include "frameworks/UBFileSystemUtils.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
...@@ -61,6 +59,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name) ...@@ -61,6 +59,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name)
layout->addWidget(mActionBar); layout->addWidget(mActionBar);
connect(centralWidget->listView(), SIGNAL(clicked(const QModelIndex &)), this, SLOT(currentSelected(const QModelIndex &))); connect(centralWidget->listView(), SIGNAL(clicked(const QModelIndex &)), this, SLOT(currentSelected(const QModelIndex &)));
connect(this, SIGNAL(sendFileNameList(QStringList)), centralWidget, SIGNAL(sendFileNameList(QStringList)));
connect(mActionBar, SIGNAL(searchElement(const QString &)), this, SLOT( searchStarted(const QString &))); connect(mActionBar, SIGNAL(searchElement(const QString &)), this, SLOT( searchStarted(const QString &)));
connect(mActionBar, SIGNAL(newFolderToCreate()), this, SLOT(createNewFolder())); connect(mActionBar, SIGNAL(newFolderToCreate()), this, SLOT(createNewFolder()));
connect(mActionBar, SIGNAL(deleteElements(const UBFeaturesMimeData *)), this, SLOT(deleteElements(const UBFeaturesMimeData *))); connect(mActionBar, SIGNAL(deleteElements(const UBFeaturesMimeData *)), this, SLOT(deleteElements(const UBFeaturesMimeData *)));
...@@ -79,6 +78,8 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name) ...@@ -79,6 +78,8 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name)
connect(centralWidget, SIGNAL(createNewFolderSignal(QString)), controller, SLOT(addNewFolder(QString))); connect(centralWidget, SIGNAL(createNewFolderSignal(QString)), controller, SLOT(addNewFolder(QString)));
connect(controller, SIGNAL(scanStarted()), centralWidget, SLOT(scanStarted())); connect(controller, SIGNAL(scanStarted()), centralWidget, SLOT(scanStarted()));
connect(controller, SIGNAL(scanFinished()), centralWidget, SLOT(scanFinished())); connect(controller, SIGNAL(scanFinished()), centralWidget, SLOT(scanFinished()));
connect(controller, SIGNAL(scanStarted()), mActionBar, SLOT(lockIt()));
connect(controller, SIGNAL(scanFinished()), mActionBar, SLOT(unlockIt()));
connect(controller, SIGNAL(maxFilesCountEvaluated(int)), centralWidget, SIGNAL(maxFilesCountEvaluated(int))); connect(controller, SIGNAL(maxFilesCountEvaluated(int)), centralWidget, SIGNAL(maxFilesCountEvaluated(int)));
connect(controller, SIGNAL(featureAddedFromThread()), centralWidget, SLOT(increaseStatusBarValue())); connect(controller, SIGNAL(featureAddedFromThread()), centralWidget, SLOT(increaseStatusBarValue()));
} }
...@@ -145,6 +146,7 @@ void UBFeaturesWidget::currentSelected(const QModelIndex &current) ...@@ -145,6 +146,7 @@ void UBFeaturesWidget::currentSelected(const QModelIndex &current)
void UBFeaturesWidget::createNewFolder() void UBFeaturesWidget::createNewFolder()
{ {
centralWidget->showAdditionalData(UBFeaturesCentralWidget::NewFolderDialog, UBFeaturesCentralWidget::Modal); centralWidget->showAdditionalData(UBFeaturesCentralWidget::NewFolderDialog, UBFeaturesCentralWidget::Modal);
emit sendFileNameList(controller->getFileNamesInFolders());
} }
void UBFeaturesWidget::addFolder() void UBFeaturesWidget::addFolder()
...@@ -492,6 +494,7 @@ UBFeaturesCentralWidget::UBFeaturesCentralWidget(QWidget *parent) : QWidget(pare ...@@ -492,6 +494,7 @@ UBFeaturesCentralWidget::UBFeaturesCentralWidget(QWidget *parent) : QWidget(pare
connect(dlg, SIGNAL(createNewFolder(QString)), this, SLOT(createNewFolderSlot(QString))); connect(dlg, SIGNAL(createNewFolder(QString)), this, SLOT(createNewFolderSlot(QString)));
connect(dlg, SIGNAL(closeDialog()), this, SLOT(hideAdditionalData())); connect(dlg, SIGNAL(closeDialog()), this, SLOT(hideAdditionalData()));
connect(this, SIGNAL(sendFileNameList(QStringList)), dlg, SLOT(setFileNameList(QStringList)));
//Progress bar to show scanning progress //Progress bar to show scanning progress
QProgressBar *progressBar = new QProgressBar(); QProgressBar *progressBar = new QProgressBar();
...@@ -604,8 +607,6 @@ void UBFeaturesCentralWidget::increaseStatusBarValue() ...@@ -604,8 +607,6 @@ void UBFeaturesCentralWidget::increaseStatusBarValue()
UBFeaturesNewFolderDialog::UBFeaturesNewFolderDialog(QWidget *parent) : QWidget(parent) UBFeaturesNewFolderDialog::UBFeaturesNewFolderDialog(QWidget *parent) : QWidget(parent)
{ {
// SET_STYLE_SHEET()
this->setStyleSheet("background:white;"); this->setStyleSheet("background:white;");
QVBoxLayout *mainLayout = new QVBoxLayout(); QVBoxLayout *mainLayout = new QVBoxLayout();
...@@ -616,14 +617,14 @@ UBFeaturesNewFolderDialog::UBFeaturesNewFolderDialog(QWidget *parent) : QWidget( ...@@ -616,14 +617,14 @@ UBFeaturesNewFolderDialog::UBFeaturesNewFolderDialog(QWidget *parent) : QWidget(
QLabel *mLabel = new QLabel(labelText, this); QLabel *mLabel = new QLabel(labelText, this);
mLineEdit = new QLineEdit(this); mLineEdit = new QLineEdit(this);
//mValidator = new QRegExpValidator(QRegExp("[A-Za-z][1-9][0-9]{0,2}"), this); mValidator = new QRegExpValidator(QRegExp("[^\\/\\:\\?\\*\\|\\<\\>\\\"]{2,}"), this);
//mLineEdit->setValidator(mValidator); mLineEdit->setValidator(mValidator);
labelLayout->addWidget(mLabel); labelLayout->addWidget(mLabel);
labelLayout->addWidget(mLineEdit); labelLayout->addWidget(mLineEdit);
QHBoxLayout *buttonLayout = new QHBoxLayout(this); QHBoxLayout *buttonLayout = new QHBoxLayout(this);
QPushButton *acceptButton = new QPushButton(acceptText, this); acceptButton = new QPushButton(acceptText, this);
QPushButton *cancelButton = new QPushButton(cancelText, this); QPushButton *cancelButton = new QPushButton(cancelText, this);
buttonLayout->addWidget(acceptButton); buttonLayout->addWidget(acceptButton);
buttonLayout->addWidget(cancelButton); buttonLayout->addWidget(cancelButton);
...@@ -631,14 +632,23 @@ UBFeaturesNewFolderDialog::UBFeaturesNewFolderDialog(QWidget *parent) : QWidget( ...@@ -631,14 +632,23 @@ UBFeaturesNewFolderDialog::UBFeaturesNewFolderDialog(QWidget *parent) : QWidget(
mainLayout->addLayout(labelLayout); mainLayout->addLayout(labelLayout);
mainLayout->addLayout(buttonLayout); mainLayout->addLayout(buttonLayout);
acceptButton->setEnabled(false);
connect(acceptButton, SIGNAL(clicked()), this, SLOT(accept())); connect(acceptButton, SIGNAL(clicked()), this, SLOT(accept()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
connect(mLineEdit, SIGNAL(textEdited(QString)), this, SLOT(reactOnTextChanged(QString)));
reactOnTextChanged(QString());
} }
void UBFeaturesNewFolderDialog::setRegexp(const QRegExp pRegExp) void UBFeaturesNewFolderDialog::setRegexp(const QRegExp pRegExp)
{ {
mValidator->setRegExp(pRegExp); mValidator->setRegExp(pRegExp);
} }
bool UBFeaturesNewFolderDialog::validString(const QString &pStr)
{
return mLineEdit->hasAcceptableInput() && !mFileNameList.contains(pStr, Qt::CaseSensitive);
}
void UBFeaturesNewFolderDialog::accept() void UBFeaturesNewFolderDialog::accept()
{ {
...@@ -651,6 +661,20 @@ void UBFeaturesNewFolderDialog::reject() ...@@ -651,6 +661,20 @@ void UBFeaturesNewFolderDialog::reject()
mLineEdit->clear(); mLineEdit->clear();
emit closeDialog(); emit closeDialog();
} }
void UBFeaturesNewFolderDialog::setFileNameList(const QStringList &pLst)
{
mFileNameList = pLst;
}
void UBFeaturesNewFolderDialog::reactOnTextChanged(const QString &pStr)
{
if (validString(pStr)) {
acceptButton->setEnabled(true);
mLineEdit->setStyleSheet("background:white;");
} else {
acceptButton->setEnabled(false);
mLineEdit->setStyleSheet("background:#FFB3C8;");
}
}
UBFeaturesWebView::UBFeaturesWebView(QWidget* parent, const char* name):QWidget(parent) UBFeaturesWebView::UBFeaturesWebView(QWidget* parent, const char* name):QWidget(parent)
, mpView(NULL) , mpView(NULL)
......
...@@ -72,6 +72,9 @@ public: ...@@ -72,6 +72,9 @@ public:
int scrollbarHorisontalPadding() const { return 10;} int scrollbarHorisontalPadding() const { return 10;}
int scrollbarVerticalIndent() const { return 0;} int scrollbarVerticalIndent() const { return 0;}
signals:
void sendFileNameList(const QStringList lst);
private slots: private slots:
void onPreviewLoaded(int id, bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground); void onPreviewLoaded(int id, bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground);
void currentSelected( const QModelIndex & ); void currentSelected( const QModelIndex & );
...@@ -190,7 +193,6 @@ public: ...@@ -190,7 +193,6 @@ public:
void setLockedExcludingAdditional(bool pLock); void setLockedExcludingAdditional(bool pLock);
QStackedWidget *mStackedWidget; QStackedWidget *mStackedWidget;
UBFeaturesNavigatorWidget *mNavigator; UBFeaturesNavigatorWidget *mNavigator;
UBFeatureProperties *mFeatureProperties; UBFeatureProperties *mFeatureProperties;
...@@ -201,6 +203,7 @@ public: ...@@ -201,6 +203,7 @@ public:
signals: signals:
void lockMainWidget(bool pLock); void lockMainWidget(bool pLock);
void createNewFolderSignal(QString pStr); void createNewFolderSignal(QString pStr);
void sendFileNameList(const QStringList lst);
// progressbar widget related signals // progressbar widget related signals
void maxFilesCountEvaluated(int pValue); void maxFilesCountEvaluated(int pValue);
...@@ -228,6 +231,7 @@ public: ...@@ -228,6 +231,7 @@ public:
UBFeaturesNewFolderDialog(QWidget *parent = 0); UBFeaturesNewFolderDialog(QWidget *parent = 0);
void setRegexp(const QRegExp pRegExp); void setRegexp(const QRegExp pRegExp);
bool validString(const QString &pStr);
signals: signals:
void createNewFolder(QString str); void createNewFolder(QString str);
...@@ -236,10 +240,15 @@ signals: ...@@ -236,10 +240,15 @@ signals:
private slots: private slots:
void accept(); void accept();
void reject(); void reject();
void setFileNameList(const QStringList &pLst);
void reactOnTextChanged(const QString &pStr);
private: private:
QLineEdit *mLineEdit; QLineEdit *mLineEdit;
QRegExpValidator *mValidator; QRegExpValidator *mValidator;
QStringList mFileNameList;
QPushButton *acceptButton;
}; };
......
...@@ -243,6 +243,8 @@ void UBKeyboardPalette::adjustSizeAndPosition(bool pUp) ...@@ -243,6 +243,8 @@ void UBKeyboardPalette::adjustSizeAndPosition(bool pUp)
void UBKeyboardPalette::paintEvent( QPaintEvent* event) void UBKeyboardPalette::paintEvent( QPaintEvent* event)
{ {
checkLayout();
UBActionPalette::paintEvent(event); UBActionPalette::paintEvent(event);
QRect r = this->geometry(); QRect r = this->geometry();
......
...@@ -127,6 +127,7 @@ protected: ...@@ -127,6 +127,7 @@ protected:
void init(); void init();
private: private:
QRect originalRect; QRect originalRect;
...@@ -134,6 +135,11 @@ private: ...@@ -134,6 +135,11 @@ private:
UBKeyButton** buttons; UBKeyButton** buttons;
UBKeyboardButton** ctrlButtons; UBKeyboardButton** ctrlButtons;
/*
For MacOS: synchronization with system locale.
*/
void checkLayout();
void createCtrlButtons(); void createCtrlButtons();
void setInput(const UBKeyboardLocale* locale); void setInput(const UBKeyboardLocale* locale);
...@@ -145,10 +151,6 @@ private: ...@@ -145,10 +151,6 @@ private:
void* storage; void* storage;
// Linux-related parameters // Linux-related parameters
int min_keycodes, max_keycodes, byte_per_code; int min_keycodes, max_keycodes, byte_per_code;
// Save locale before activation to restore it after (MAC)
QString activeLocale;
}; };
class UBKeyboardButton : public QWidget class UBKeyboardButton : public QWidget
......
...@@ -164,6 +164,9 @@ void UBKeyboardPalette::createCtrlButtons() ...@@ -164,6 +164,9 @@ void UBKeyboardPalette::createCtrlButtons()
} }
void UBKeyboardPalette::checkLayout()
{}
void UBKeyboardPalette::onActivated(bool activated) void UBKeyboardPalette::onActivated(bool activated)
{ {
if (activated) if (activated)
......
...@@ -74,32 +74,35 @@ void SetMacLocaleByIdentifier(const QString& id) ...@@ -74,32 +74,35 @@ void SetMacLocaleByIdentifier(const QString& id)
} }
} }
void UBKeyboardPalette::onActivated(bool activated)
void UBKeyboardPalette::checkLayout()
{ {
if (activated) TISInputSourceRef selectedLocale = TISCopyCurrentKeyboardInputSource();
{
TISInputSourceRef selectedLocale = TISCopyCurrentKeyboardInputSource();
CFStringRef sr = (CFStringRef) TISGetInputSourceProperty(selectedLocale,
kTISPropertyInputSourceID);
if (sr!=NULL)
{
char tmp[1024];
CFStringGetCString(sr, tmp, 1024, 0);
activeLocale = tmp;
}
else
activeLocale = "";
onLocaleChanged(locales[nCurrentLocale]); CFStringRef sr = (CFStringRef) TISGetInputSourceProperty(selectedLocale,
} kTISPropertyInputSourceID);
else
{ if (sr!=NULL)
if (activeLocale != "") {
SetMacLocaleByIdentifier(activeLocale); char clId[1024];
} CFStringGetCString(sr, clId, 1024, 0);
for(int i=0; i<nLocalesCount;i++)
{
if (locales[i]->id == clId)
{
if (nCurrentLocale!=i)
{
setLocale(i);
}
break;
}
}
}
}
void UBKeyboardPalette::onActivated(bool)
{
} }
void UBKeyboardPalette::onLocaleChanged(UBKeyboardLocale* locale) void UBKeyboardPalette::onLocaleChanged(UBKeyboardLocale* locale)
......
...@@ -64,9 +64,12 @@ void UBKeyboardPalette::createCtrlButtons() ...@@ -64,9 +64,12 @@ void UBKeyboardPalette::createCtrlButtons()
ctrlButtons[ctrlID++] = new UBLocaleButton(this); // Language Switch ctrlButtons[ctrlID++] = new UBLocaleButton(this); // Language Switch
} }
void UBKeyboardPalette::checkLayout()
{}
void UBKeyboardPalette::onActivated(bool) void UBKeyboardPalette::onActivated(bool)
{ {}
}
void UBKeyboardPalette::onLocaleChanged(UBKeyboardLocale* ) void UBKeyboardPalette::onLocaleChanged(UBKeyboardLocale* )
{} {}
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include <QUrl> #include <QUrl>
#include <QWebSettings> #include <QWebSettings>
#include <QApplication> #include <QApplication>
#include <QDomElement>
#include <QWebFrame>
#include "UBTeacherGuideWidgetsTools.h" #include "UBTeacherGuideWidgetsTools.h"
...@@ -30,7 +32,7 @@ ...@@ -30,7 +32,7 @@
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "domain/UBW3CWidget.h" #include "domain/UBGraphicsWidgetItem.h"
#include "globals/UBGlobals.h" #include "globals/UBGlobals.h"
...@@ -360,7 +362,7 @@ void UBTGMediaWidget::removeSource() ...@@ -360,7 +362,7 @@ void UBTGMediaWidget::removeSource()
void UBTGMediaWidget::hideEvent(QHideEvent* event) void UBTGMediaWidget::hideEvent(QHideEvent* event)
{ {
if(mpWebView) if(mpWebView)
mpWebView->page()->mainFrame()->setContent(UBW3CWidget::freezedWidgetPage().toAscii()); mpWebView->page()->mainFrame()->setContent(UBGraphicsW3CWidgetItem::freezedWidgetPage().toAscii());
QWidget::hideEvent(event); QWidget::hideEvent(event);
} }
...@@ -421,7 +423,7 @@ void UBTGMediaWidget::createWorkWidget() ...@@ -421,7 +423,7 @@ void UBTGMediaWidget::createWorkWidget()
mMediaType = "w3c"; mMediaType = "w3c";
if(!(mIsPresentationMode || mIsInitializationMode)){ if(!(mIsPresentationMode || mIsInitializationMode)){
QDir baseW3CDirectory(UBPersistenceManager::persistenceManager()->teacherGuideAbsoluteObjectPath(proxyDocument)); QDir baseW3CDirectory(UBPersistenceManager::persistenceManager()->teacherGuideAbsoluteObjectPath(proxyDocument));
mMediaPath = UBW3CWidget::createNPAPIWrapperInDir(mMediaPath,baseW3CDirectory,mimeType,QSize(100,100),QUuid::createUuid()); mMediaPath = UBGraphicsW3CWidgetItem::createNPAPIWrapperInDir(mMediaPath,baseW3CDirectory,mimeType,QSize(100,100),QUuid::createUuid());
} }
mpWebView = new UBDraggableWeb(mMediaPath); mpWebView = new UBDraggableWeb(mMediaPath);
mpWebView->setAcceptDrops(false); mpWebView->setAcceptDrops(false);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* 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 2 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 UBROUTEDMOUSEEVENTWEBVIEW_H_
#define UBROUTEDMOUSEEVENTWEBVIEW_H_
#include <QtWebKit>
/*
* This class changes the routing of mouse events.
* Qt 4.5.2 does not report back the "accepted" flag set
* by WebKit, as we want to know if a mouse event has been
* consumed by webKit, we override them without keeping the
* accepted flag status
*/
class UBRoutedMouseEventWebView : public QWebView
{
public:
UBRoutedMouseEventWebView(QWidget * parent = 0 );
virtual ~UBRoutedMouseEventWebView();
protected:
virtual void mouseMoveEvent(QMouseEvent* ev);
virtual void mousePressEvent(QMouseEvent* ev);
virtual void mouseDoubleClickEvent(QMouseEvent* ev);
virtual void mouseReleaseEvent(QMouseEvent* ev);
virtual void contextMenuEvent(QContextMenuEvent* ev);
virtual void wheelEvent(QWheelEvent* ev);
// virtual void dropEvent(QDropEvent *);
};
#endif /* UBROUTEDMOUSEEVENTWEBVIEW_H_ */
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment