Commit b228a5c9 authored by Craig Watson's avatar Craig Watson

Merge branch 'dev' (1.3.6 release)

parents 00ab81e3 87eaa529
...@@ -10,7 +10,7 @@ CONFIG += debug_and_release \ ...@@ -10,7 +10,7 @@ CONFIG += debug_and_release \
VERSION_MAJ = 1 VERSION_MAJ = 1
VERSION_MIN = 3 VERSION_MIN = 3
VERSION_PATCH = 5 VERSION_PATCH = 6
VERSION_TYPE = r # a = alpha, b = beta, rc = release candidate, r = release, other => error VERSION_TYPE = r # a = alpha, b = beta, rc = release candidate, r = release, other => error
VERSION_BUILD = 0 VERSION_BUILD = 0
......
[App] [App]
AngleTolerance=4 AngleTolerance=4
EnableAutomaticSoftwareUpdates=false EnableAutomaticSoftwareUpdates=false
EnableSoftwareUpdates=true
EnableStartupHints=true EnableStartupHints=true
FavoriteToolURIs=openboardtool://openboard/mask, openboardtool://ruler, openboardtool://compass, openboardtool://protractor, openboardtool://triangle, openboardtool://magnifier, openboardtool://cache FavoriteToolURIs=openboardtool://openboard/mask, openboardtool://ruler, openboardtool://compass, openboardtool://protractor, openboardtool://triangle, openboardtool://magnifier, openboardtool://cache
IsInSoftwareUpdateProcess=false IsInSoftwareUpdateProcess=false
......
This diff is collapsed.
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <QtCore> #include <QtCore>
#include <QtSvg> #include <QtSvg>
#include <QPrinter> #include <QPrinter>
#include <QPdfWriter>
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "core/UBSettings.h" #include "core/UBSettings.h"
...@@ -40,6 +41,7 @@ ...@@ -40,6 +41,7 @@
#include "domain/UBGraphicsScene.h" #include "domain/UBGraphicsScene.h"
#include "domain/UBGraphicsSvgItem.h" #include "domain/UBGraphicsSvgItem.h"
#include "domain/UBGraphicsPDFItem.h"
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
...@@ -66,56 +68,67 @@ void UBExportPDF::persist(UBDocumentProxy* pDocumentProxy) ...@@ -66,56 +68,67 @@ void UBExportPDF::persist(UBDocumentProxy* pDocumentProxy)
bool UBExportPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, const QString& filename) bool UBExportPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, const QString& filename)
{ {
QPrinter pdfPrinter; QPdfWriter pdfWriter(filename);
qDebug() << "exporting document to PDF" << filename; qDebug() << "exporting document to PDF" << filename;
pdfPrinter.setOutputFormat(QPrinter::PdfFormat); pdfWriter.setResolution(UBSettings::settings()->pdfResolution->get().toInt());
pdfPrinter.setResolution(UBSettings::settings()->pdfResolution->get().toInt()); pdfWriter.setPageMargins(QMarginsF());
pdfPrinter.setOutputFileName(filename); pdfWriter.setTitle(pDocumentProxy->name());
pdfPrinter.setFullPage(true); pdfWriter.setCreator("OpenBoard PDF export");
//need to calculate screen resolution //need to calculate screen resolution
QDesktopWidget* desktop = UBApplication::desktop(); QDesktopWidget* desktop = UBApplication::desktop();
int dpiCommon = (desktop->physicalDpiX() + desktop->physicalDpiY()) / 2; int dpiCommon = (desktop->physicalDpiX() + desktop->physicalDpiY()) / 2;
float scaleFactor = 72.0f / dpiCommon; float scaleFactor = 72.0f / dpiCommon;
QPainter pdfPainter; QPainter pdfPainter;
bool painterNeedsBegin = true; bool painterNeedsBegin = true;
int existingPageCount = pDocumentProxy->pageCount(); int existingPageCount = pDocumentProxy->pageCount();
for(int pageIndex = 0 ; pageIndex < existingPageCount; pageIndex++) for(int pageIndex = 0 ; pageIndex < existingPageCount; pageIndex++) {
{
UBGraphicsScene* scene = UBPersistenceManager::persistenceManager()->loadDocumentScene(pDocumentProxy, pageIndex); UBGraphicsScene* scene = UBPersistenceManager::persistenceManager()->loadDocumentScene(pDocumentProxy, pageIndex);
UBApplication::showMessage(tr("Exporting page %1 of %2").arg(pageIndex + 1).arg(existingPageCount)); UBApplication::showMessage(tr("Exporting page %1 of %2").arg(pageIndex + 1).arg(existingPageCount));
// set background to white, no crossing for PDF output // set background to white, no crossing for PDF output
bool isDark = scene->isDarkBackground(); bool isDark = scene->isDarkBackground();
bool isCrossed = scene->isCrossedBackground(); bool isCrossed = scene->isCrossedBackground();
scene->setBackground(false, false); scene->setBackground(false, false);
QSize pageSize = scene->nominalSize(); // pageSize is the output PDF page size; it is set to equal the scene's boundary size; if the contents
// of the scene overflow from the boundaries, they will be scaled down.
QSize pageSize = scene->sceneSize();
// set high res rendering // set high res rendering
scene->setRenderingQuality(UBItem::RenderingQualityHigh); scene->setRenderingQuality(UBItem::RenderingQualityHigh);
scene->setRenderingContext(UBGraphicsScene::NonScreen); scene->setRenderingContext(UBGraphicsScene::NonScreen);
//setting page size to appropriate value // Setting output page size
pdfPrinter.setPaperSize(QSizeF(pageSize.width()*scaleFactor, pageSize.height()*scaleFactor), QPrinter::Point); QPageSize outputPageSize = QPageSize(QSizeF(pageSize.width()*scaleFactor, pageSize.height()*scaleFactor), QPageSize::Point);
if(painterNeedsBegin) painterNeedsBegin = !pdfPainter.begin(&pdfPrinter); pdfWriter.setPageSize(outputPageSize);
//render to PDF
scene->render(&pdfPainter, QRectF(), scene->normalizedSceneRect());
if (pageIndex < existingPageCount - 1) pdfPrinter.newPage(); // Call begin only once
if(painterNeedsBegin)
painterNeedsBegin = !pdfPainter.begin(&pdfWriter);
//restore screen rendering quality else if (pageIndex < existingPageCount)
pdfWriter.newPage();
// Render the scene
scene->render(&pdfPainter, QRectF(), scene->normalizedSceneRect());
// Restore screen rendering quality
scene->setRenderingContext(UBGraphicsScene::Screen); scene->setRenderingContext(UBGraphicsScene::Screen);
scene->setRenderingQuality(UBItem::RenderingQualityNormal); scene->setRenderingQuality(UBItem::RenderingQualityNormal);
//restore background state // Restore background state
scene->setBackground(isDark, isCrossed); scene->setBackground(isDark, isCrossed);
} }
if(!painterNeedsBegin) pdfPainter.end();
if(!painterNeedsBegin)
pdfPainter.end();
return true; return true;
} }
......
...@@ -593,9 +593,6 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item) ...@@ -593,9 +593,6 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item)
itemSize = commonItem->boundingRect().size(); itemSize = commonItem->boundingRect().size();
commonItem->setSelected(false); commonItem->setSelected(false);
UBGraphicsStrokesGroup *stroke = dynamic_cast<UBGraphicsStrokesGroup*>(commonItem);
if (stroke)
itemPos = QPointF(shifting, shifting);
} }
UBMimeType::Enum itemMimeType; UBMimeType::Enum itemMimeType;
...@@ -654,7 +651,7 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item) ...@@ -654,7 +651,7 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item)
{ {
QBuffer buffer(&pData); QBuffer buffer(&pData);
buffer.open(QIODevice::WriteOnly); buffer.open(QIODevice::WriteOnly);
QString format = UBFileSystemUtils::extension(item->sourceUrl().toLocalFile()); QString format = UBFileSystemUtils::extension(item->sourceUrl().toString(QUrl::DecodeReserved));
pixitem->pixmap().save(&buffer, format.toLatin1()); pixitem->pixmap().save(&buffer, format.toLatin1());
} }
}break; }break;
...@@ -1612,6 +1609,23 @@ void UBBoardController::ClearUndoStack() ...@@ -1612,6 +1609,23 @@ void UBBoardController::ClearUndoStack()
findUniquesItems(UBApplication::undoStack->command(i), uniqueItems); findUniquesItems(UBApplication::undoStack->command(i), uniqueItems);
} }
// Get items from clipboard in order not to delete an item that was cut
// (using source URL of graphics items as a surrogate for equality testing)
// This ensures that we can cut and paste a media item, widget, etc. from one page to the next.
QClipboard *clipboard = QApplication::clipboard();
const QMimeData* data = clipboard->mimeData();
QList<QUrl> sourceURLs;
if (data && data->hasFormat(UBApplication::mimeTypeUniboardPageItem)) {
const UBMimeDataGraphicsItem* mimeDataGI = qobject_cast <const UBMimeDataGraphicsItem*>(data);
if (mimeDataGI) {
foreach (UBItem* sourceItem, mimeDataGI->items()) {
sourceURLs << sourceItem->sourceUrl();
}
}
}
// go through all unique items, and check, if they are on scene, or not. // go through all unique items, and check, if they are on scene, or not.
// if not on scene, than item can be deleted // if not on scene, than item can be deleted
QSetIterator<QGraphicsItem*> itUniq(uniqueItems); QSetIterator<QGraphicsItem*> itUniq(uniqueItems);
...@@ -1623,7 +1637,12 @@ void UBBoardController::ClearUndoStack() ...@@ -1623,7 +1637,12 @@ void UBBoardController::ClearUndoStack()
scene = dynamic_cast<UBGraphicsScene*>(item->scene()); scene = dynamic_cast<UBGraphicsScene*>(item->scene());
} }
if(!scene) bool inClipboard = false;
UBItem* ubi = dynamic_cast<UBItem*>(item);
if (ubi && sourceURLs.contains(ubi->sourceUrl()))
inClipboard = true;
if(!scene && !inClipboard)
{ {
if (!mActiveScene->deleteItem(item)){ if (!mActiveScene->deleteItem(item)){
delete item; delete item;
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#include "document/UBDocumentController.h" #include "document/UBDocumentController.h"
#include "core/UBPersistenceManager.h"
#include "core/memcheck.h" #include "core/memcheck.h"
UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardController* pBoardController) UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardController* pBoardController)
...@@ -846,7 +847,11 @@ void UBBoardPaletteManager::addItemToCurrentPage() ...@@ -846,7 +847,11 @@ void UBBoardPaletteManager::addItemToCurrentPage()
{ {
UBGraphicsPixmapItem* item = UBApplication::boardController->activeScene()->addPixmap(mPixmap, NULL, mPos, mScaleFactor); UBGraphicsPixmapItem* item = UBApplication::boardController->activeScene()->addPixmap(mPixmap, NULL, mPos, mScaleFactor);
item->setSourceUrl(mItemUrl); QString documentPath = UBApplication::boardController->selectedDocument()->persistencePath();
QString fileName = UBPersistenceManager::imageDirectory + "/" + item->uuid().toString() + ".png";
QString path = documentPath + "/" + fileName;
item->setSourceUrl(QUrl(path));
item->setSelected(true); item->setSelected(true);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
......
...@@ -511,13 +511,7 @@ void UBApplication::decorateActionMenu(QAction* action) ...@@ -511,13 +511,7 @@ void UBApplication::decorateActionMenu(QAction* action)
menu->addSeparator(); menu->addSeparator();
menu->addAction(mainWindow->actionPreferences); menu->addAction(mainWindow->actionPreferences);
menu->addAction(mainWindow->actionMultiScreen); menu->addAction(mainWindow->actionMultiScreen);
// SANKORE-48: Hide the check update action if the setting menu->addAction(mainWindow->actionCheckUpdate);
// EnableAutomaticSoftwareUpdates is false in Uniboard.config
if(UBSettings::settings()->appEnableAutomaticSoftwareUpdates->get().toBool())
menu->addAction(mainWindow->actionCheckUpdate);
else
mainWindow->actionCheckUpdate->setEnabled(false);
menu->addSeparator(); menu->addSeparator();
#ifndef Q_OS_LINUX // No Podcast on Linux yet #ifndef Q_OS_LINUX // No Podcast on Linux yet
......
...@@ -90,7 +90,6 @@ UBApplicationController::UBApplicationController(UBBoardView *pControlView, ...@@ -90,7 +90,6 @@ UBApplicationController::UBApplicationController(UBBoardView *pControlView,
, mAutomaticCheckForUpdates(false) , mAutomaticCheckForUpdates(false)
, mCheckingForUpdates(false) , mCheckingForUpdates(false)
, mIsShowingDesktop(false) , mIsShowingDesktop(false)
, mHttp(0)
{ {
mDisplayManager = new UBDisplayManager(this); mDisplayManager = new UBDisplayManager(this);
...@@ -121,7 +120,7 @@ UBApplicationController::UBApplicationController(UBBoardView *pControlView, ...@@ -121,7 +120,7 @@ UBApplicationController::UBApplicationController(UBBoardView *pControlView,
connect(UBApplication::webController, SIGNAL(imageCaptured(const QPixmap &, bool, const QUrl&)) connect(UBApplication::webController, SIGNAL(imageCaptured(const QPixmap &, bool, const QUrl&))
, this, SLOT(addCapturedPixmap(const QPixmap &, bool, const QUrl&))); , this, SLOT(addCapturedPixmap(const QPixmap &, bool, const QUrl&)));
networkAccessManager = new QNetworkAccessManager (this); mNetworkAccessManager = new QNetworkAccessManager (this);
QTimer::singleShot (1000, this, SLOT (checkAtLaunch())); QTimer::singleShot (1000, this, SLOT (checkAtLaunch()));
} }
...@@ -136,8 +135,6 @@ UBApplicationController::~UBApplicationController() ...@@ -136,8 +135,6 @@ UBApplicationController::~UBApplicationController()
delete mBlackScene; delete mBlackScene;
delete mMirror; delete mMirror;
if (mHttp) delete mHttp;
delete(mOpenSankoreImporter); delete(mOpenSankoreImporter);
mOpenSankoreImporter = NULL; mOpenSankoreImporter = NULL;
} }
...@@ -478,85 +475,71 @@ void UBApplicationController::showDesktop(bool dontSwitchFrontProcess) ...@@ -478,85 +475,71 @@ void UBApplicationController::showDesktop(bool dontSwitchFrontProcess)
} }
void UBApplicationController::checkUpdate(QString urlString) void UBApplicationController::checkUpdate(const QUrl& url)
{ {
QUrl jsonUrl = url;
if (url.isEmpty())
jsonUrl = UBSettings::settings()->appSoftwareUpdateURL->get().toUrl();
qDebug() << "Checking for update at url: " << jsonUrl.toString();
#if defined(QT_NO_DEBUG) connect(mNetworkAccessManager, SIGNAL(finished(QNetworkReply*)),
/* this, SLOT(updateRequestFinished(QNetworkReply*)));
if(mHttp)
mHttp->deleteLater(); mNetworkAccessManager->get(QNetworkRequest(jsonUrl));
QUrl url(urlString);
mHttp = new QHttpPart(url.host());
connect(mHttp, SIGNAL(requestFinished(int,bool)), this, SLOT(updateRequestFinished(int,bool)));
connect(mHttp, SIGNAL(responseHeaderReceived(QHttpResponseHeader)), this, SLOT(updateHeaderReceived(QHttpResponseHeader)));
mHttp->get(url.path());
*/
#else
if(mHttpreply)
mHttpreply->deleteLater();
QUrl url(urlString);
mHttpreply = qnam.get(QNetworkRequest(url));
connect(mHttpreply, SIGNAL(requestFinished(int,bool)), this, SLOT(updateRequestFinished(int,bool)));
connect(mHttpreply, SIGNAL(responseHeaderReceived(QHttpResponseHeader)), this, SLOT(updateHeaderReceived(QHttpResponseHeader)));
// mHttpreply->setUrl(url.path());
//mHttp->get(url.path());
#endif
} }
/*
void UBApplicationController::updateHeaderReceived(QHttpResponseHeader header)
void UBApplicationController::updateRequestFinished(QNetworkReply * reply)
{ {
if(header.statusCode() == 302 && header.hasKey("Location")){ if (reply->error()) {
mHttp->close(); qWarning() << "Error downloading update file: " << reply->errorString();
checkUpdate(header.value("Location")); return;
} }
} // Check if we are being redirected. If so, call checkUpdate again
*/
void UBApplicationController::updateHeaderReceived(QNetworkRequest header )
{
//if(header.attribute(QNetworkRequest::HttpStatusCodeAttribute) == 302 && header.header(QNetworkRequest::LocationHeader)){
// mHttp->close();
mHttpreply->close();
//checkUpdate(header.value("Location"));
// }
}
void UBApplicationController::updateRequestFinished(int id, bool error) QVariant redirect_target = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
{ if (!redirect_target.isNull()) {
if (error){ // The returned URL might be relative. resolved() creates an absolute url from it
qWarning() << "http command id" << id << "return an error"; QUrl redirect_url(reply->url().resolved(redirect_target.toUrl()));
}
else{
/* QString responseString = QString(mHttp->readAll());
qDebug() << responseString;
if (!responseString.isEmpty() && responseString.contains("version") && responseString.contains("url")){
mHttp->close();
mHttp->deleteLater();
mHttp = 0;
downloadJsonFinished(responseString);
}
*/
QString responseString = QString(mHttpreply->readAll());
qDebug() << responseString;
if (!responseString.isEmpty() && responseString.contains("version") && responseString.contains("url")){
mHttpreply->close();
mHttpreply->deleteLater();
mHttpreply = 0;
downloadJsonFinished(responseString);
}
}
}
checkUpdate(redirect_url);
return;
}
// No error and no redirect => we read the whole response
QString responseString = QString(reply->readAll());
if (!responseString.isEmpty() &&
responseString.contains("version") &&
responseString.contains("url")) {
reply->close();
reply->deleteLater();
downloadJsonFinished(responseString);
}
}
void UBApplicationController::downloadJsonFinished(QString currentJson) void UBApplicationController::downloadJsonFinished(QString currentJson)
{ {
/*
The .json files simply specify the latest version number available, and
the URL to send the user to, so they can download it.
They look like:
{
"version": "1.3.5",
"url": "http://openboard.ch"
}
*/
QScriptValue scriptValue; QScriptValue scriptValue;
QScriptEngine scriptEngine; QScriptEngine scriptEngine;
scriptValue = scriptEngine.evaluate ("(" + currentJson + ")"); scriptValue = scriptEngine.evaluate ("(" + currentJson + ")");
...@@ -564,17 +547,18 @@ void UBApplicationController::downloadJsonFinished(QString currentJson) ...@@ -564,17 +547,18 @@ void UBApplicationController::downloadJsonFinished(QString currentJson)
UBVersion installedVersion (qApp->applicationVersion()); UBVersion installedVersion (qApp->applicationVersion());
UBVersion jsonVersion (scriptValue.property("version").toString()); UBVersion jsonVersion (scriptValue.property("version").toString());
qDebug() << "json version: " << jsonVersion.toUInt();
qDebug() << "installed version: " << installedVersion.toUInt();
if (jsonVersion > installedVersion) { if (jsonVersion > installedVersion) {
if (UBApplication::mainWindow->yesNoQuestion(tr("Update available"), tr ("New update available, would you go to the web page ?"))){ if (UBApplication::mainWindow->yesNoQuestion(tr("Update available"), tr ("New update available, would you go to the web page ?"))){
QUrl url(scriptValue.property ("url").toString()); QUrl url(scriptValue.property("url").toString());
QDesktopServices::openUrl (url); QDesktopServices::openUrl(url);
}
}
else {
if (isNoUpdateDisplayed) {
mMainWindow->information(tr("Update"), tr("No update available"));
} }
} }
else if (isNoUpdateDisplayed) {
mMainWindow->information(tr("Update"), tr("No update available"));
}
} }
void UBApplicationController::checkAtLaunch() void UBApplicationController::checkAtLaunch()
...@@ -583,14 +567,14 @@ void UBApplicationController::checkAtLaunch() ...@@ -583,14 +567,14 @@ void UBApplicationController::checkAtLaunch()
if(UBSettings::settings()->appEnableAutomaticSoftwareUpdates->get().toBool()){ if(UBSettings::settings()->appEnableAutomaticSoftwareUpdates->get().toBool()){
isNoUpdateDisplayed = false; isNoUpdateDisplayed = false;
//checkUpdate (); checkUpdate();
} }
} }
void UBApplicationController::checkUpdateRequest() void UBApplicationController::checkUpdateRequest()
{ {
isNoUpdateDisplayed = true; isNoUpdateDisplayed = true;
//checkUpdate (); checkUpdate();
} }
void UBApplicationController::hideDesktop() void UBApplicationController::hideDesktop()
......
...@@ -53,12 +53,8 @@ class UBVersion; ...@@ -53,12 +53,8 @@ class UBVersion;
class UBSoftwareUpdate; class UBSoftwareUpdate;
class QNetworkAccessManager; class QNetworkAccessManager;
class QNetworkReply; class QNetworkReply;
class QHttpPart;
class UBRightPalette; class UBRightPalette;
class UBOpenSankoreImporter; class UBOpenSankoreImporter;
class QScriptValue;
class QScriptEngine;
class QNetworkReply;
class UBApplicationController : public QObject class UBApplicationController : public QObject
{ {
...@@ -158,8 +154,8 @@ class UBApplicationController : public QObject ...@@ -158,8 +154,8 @@ class UBApplicationController : public QObject
void checkAtLaunch(); void checkAtLaunch();
private slots: private slots:
void updateRequestFinished(int id, bool error); void updateRequestFinished(QNetworkReply * reply);
void updateHeaderReceived(QNetworkRequest header );
protected: protected:
...@@ -193,13 +189,10 @@ class UBApplicationController : public QObject ...@@ -193,13 +189,10 @@ class UBApplicationController : public QObject
bool mIsShowingDesktop; bool mIsShowingDesktop;
bool isNoUpdateDisplayed; bool isNoUpdateDisplayed;
void checkUpdate (QString urlString = "http://get.openboard.org/update.json"); void checkUpdate(const QUrl &url = QUrl());
QNetworkAccessManager *networkAccessManager; QNetworkAccessManager * mNetworkAccessManager;
void downloadJsonFinished(QString updateString); void downloadJsonFinished(QString updateString);
QHttpPart* mHttp;
QNetworkAccessManager qnam;
QNetworkReply *mHttpreply;
}; };
#endif /* UBAPPLICATIONCONTROLLER_H_ */ #endif /* UBAPPLICATIONCONTROLLER_H_ */
...@@ -186,8 +186,6 @@ void UBPreferencesController::wire() ...@@ -186,8 +186,6 @@ void UBPreferencesController::wire()
// about tab // about tab
connect(mPreferencesUI->checkSoftwareUpdateAtLaunchCheckBox, SIGNAL(clicked(bool)), settings->appEnableAutomaticSoftwareUpdates, SLOT(setBool(bool))); connect(mPreferencesUI->checkSoftwareUpdateAtLaunchCheckBox, SIGNAL(clicked(bool)), settings->appEnableAutomaticSoftwareUpdates, SLOT(setBool(bool)));
// As we (hopefully temporarily) don't have a website to check updates at, this setting is hidden for now
mPreferencesUI->softwareUpdateGroupBox->setVisible(false);
connect(mPreferencesUI->checkOpenSankoreAtStartup, SIGNAL(clicked(bool)), settings->appLookForOpenSankoreInstall, SLOT(setBool(bool))); connect(mPreferencesUI->checkOpenSankoreAtStartup, SIGNAL(clicked(bool)), settings->appLookForOpenSankoreInstall, SLOT(setBool(bool)));
} }
......
...@@ -225,7 +225,7 @@ void UBSettings::init() ...@@ -225,7 +225,7 @@ void UBSettings::init()
appToolBarPositionedAtTop = new UBSetting(this, "App", "ToolBarPositionedAtTop", true); appToolBarPositionedAtTop = new UBSetting(this, "App", "ToolBarPositionedAtTop", true);
appToolBarDisplayText = new UBSetting(this, "App", "ToolBarDisplayText", true); appToolBarDisplayText = new UBSetting(this, "App", "ToolBarDisplayText", true);
appEnableAutomaticSoftwareUpdates = new UBSetting(this, "App", "EnableAutomaticSoftwareUpdates", false); appEnableAutomaticSoftwareUpdates = new UBSetting(this, "App", "EnableAutomaticSoftwareUpdates", false);
appEnableSoftwareUpdates = new UBSetting(this, "App", "EnableSoftwareUpdates", true); appSoftwareUpdateURL = new UBSetting(this, "App", "SoftwareUpdateURL", "http://www.openboard.ch/update.json");
appToolBarOrientationVertical = new UBSetting(this, "App", "ToolBarOrientationVertical", false); appToolBarOrientationVertical = new UBSetting(this, "App", "ToolBarOrientationVertical", false);
appPreferredLanguage = new UBSetting(this,"App","PreferredLanguage", ""); appPreferredLanguage = new UBSetting(this,"App","PreferredLanguage", "");
...@@ -270,7 +270,7 @@ void UBSettings::init() ...@@ -270,7 +270,7 @@ void UBSettings::init()
pageSize = new UBSetting(this, "Board", "DefaultPageSize", documentSizes.value(DocumentSizeRatio::Ratio4_3)); pageSize = new UBSetting(this, "Board", "DefaultPageSize", documentSizes.value(DocumentSizeRatio::Ratio4_3));
boardCrossColorDarkBackground = new UBSetting(this, "Board", "CrossColorDarkBackground", "#C82C2C2C"); boardCrossColorDarkBackground = new UBSetting(this, "Board", "CrossColorDarkBackground", "#C8C0C0C0");
boardCrossColorLightBackground = new UBSetting(this, "Board", "CrossColorLightBackground", "#A5E1FF"); boardCrossColorLightBackground = new UBSetting(this, "Board", "CrossColorLightBackground", "#A5E1FF");
QStringList penLightBackgroundColors; QStringList penLightBackgroundColors;
......
...@@ -239,7 +239,7 @@ class UBSettings : public QObject ...@@ -239,7 +239,7 @@ class UBSettings : public QObject
UBSetting* appToolBarPositionedAtTop; UBSetting* appToolBarPositionedAtTop;
UBSetting* appToolBarDisplayText; UBSetting* appToolBarDisplayText;
UBSetting* appEnableAutomaticSoftwareUpdates; UBSetting* appEnableAutomaticSoftwareUpdates;
UBSetting* appEnableSoftwareUpdates; UBSetting* appSoftwareUpdateURL;
UBSetting* appToolBarOrientationVertical; UBSetting* appToolBarOrientationVertical;
UBSetting* appPreferredLanguage; UBSetting* appPreferredLanguage;
......
...@@ -546,37 +546,66 @@ void UBDocumentController::duplicateSelectedItem() ...@@ -546,37 +546,66 @@ void UBDocumentController::duplicateSelectedItem()
} }
/** /**
* @brief When deleting multiple documents, find a new document and select it * @brief Set the first document in the list as current document
* *
* This method simply selects the first un-selected document * If there are no documents, a new one is created.
*/ */
void UBDocumentController::selectADocumentOnMultipleTrashing() void UBDocumentController::selectFirstDocumentInList()
{ {
// Loop through all folders, and each document in those folders, until we find // Loop through all folders until we find one that is not the trash and not empty,
// a document that is not in the current selection (which is being deleted) // and select the first document in that folder
for (int i(0); i < mDocumentUI->documentTreeWidget->topLevelItemCount(); ++i) { for (int i(0); i < mDocumentUI->documentTreeWidget->topLevelItemCount(); ++i) {
QTreeWidgetItem* item = mDocumentUI->documentTreeWidget->topLevelItem(i); QTreeWidgetItem* item = mDocumentUI->documentTreeWidget->topLevelItem(i);
UBDocumentGroupTreeItem* groupItem = dynamic_cast<UBDocumentGroupTreeItem*>(item); UBDocumentGroupTreeItem* groupItem = dynamic_cast<UBDocumentGroupTreeItem*>(item);
if (!groupItem->isTrashFolder()) { if (!groupItem->isTrashFolder() && groupItem->childCount() > 0) {
for (int j(0); j < groupItem->childCount(); ++j) { selectDocument(((UBDocumentProxyTreeItem*)groupItem->child(0))->proxy(), true);
if (!mCurrentSelection.contains( groupItem->child(j) )) { groupItem->child(0)->setSelected(true);
selectDocument(((UBDocumentProxyTreeItem*)groupItem->child(j))->proxy(), true); return;
return;
}
}
} }
} }
// No document found => create a new one // No document found => create a new one
UBDocumentGroupTreeItem* topFolder = dynamic_cast<UBDocumentGroupTreeItem*>(mDocumentUI->documentTreeWidget->topLevelItem(0)); UBDocumentGroupTreeItem* topFolder = dynamic_cast<UBDocumentGroupTreeItem*>(mDocumentUI->documentTreeWidget->topLevelItem(0));
UBDocumentProxy* document = UBPersistenceManager::persistenceManager()->createDocument(topFolder->groupName()); UBDocumentProxy* document = UBPersistenceManager::persistenceManager()->createDocument(topFolder->groupName());
selectDocument(document, true); selectDocument(document, true);
}
/**
* @brief Find the current document, and select it in the list
*
* If selectNewCurrentDocument is true, the first document in the list is selected and set as
* current document.
*/
void UBDocumentController::selectATreeItemOnMultipleTrashing(bool selectNewCurrentDocument)
{
mCurrentSelection.clear();
if (selectNewCurrentDocument) {
selectFirstDocumentInList();
return;
}
// Find the currently selected document, and select its corresponding tree item
// If it isn't found, then the first document in the list is selected and set as current document
for (int i(0); i < mDocumentUI->documentTreeWidget->topLevelItemCount(); i++) {
QTreeWidgetItem* item = mDocumentUI->documentTreeWidget->topLevelItem(i);
UBDocumentGroupTreeItem* groupItem = dynamic_cast<UBDocumentGroupTreeItem*>(item);
if (!groupItem->isTrashFolder()) {
for (int j(0); j < groupItem->childCount(); j++) {
if (((UBDocumentProxyTreeItem*)groupItem->child(j))->proxy() == mBoardController->selectedDocument()) {
((UBDocumentProxyTreeItem*)groupItem->child(j))->setSelected(true);
return;
}
}
}
}
selectFirstDocumentInList();
} }
void UBDocumentController::selectADocumentOnTrashingSelectedOne(UBDocumentGroupTreeItem* groupTi,UBDocumentProxyTreeItem *proxyTi) void UBDocumentController::selectADocumentOnTrashingSelectedOne(UBDocumentGroupTreeItem* groupTi,UBDocumentProxyTreeItem *proxyTi)
...@@ -807,9 +836,9 @@ void UBDocumentController::deleteTreeItem(QTreeWidgetItem * item, bool showConfi ...@@ -807,9 +836,9 @@ void UBDocumentController::deleteTreeItem(QTreeWidgetItem * item, bool showConfi
if (selectNewDocument) { if (selectNewDocument) {
if (mTrashTi->childCount()==0) if (mTrashTi->childCount()==0)
selectDocument(NULL); selectATreeItemOnMultipleTrashing(false);
else else
selectDocument(((UBDocumentProxyTreeItem*)mTrashTi->child(0))->proxy()); selectDocument(((UBDocumentProxyTreeItem*)mTrashTi->child(0))->proxy(), false);
} }
reloadThumbnails(); reloadThumbnails();
...@@ -849,11 +878,18 @@ void UBDocumentController::deleteSelectedItem() ...@@ -849,11 +878,18 @@ void UBDocumentController::deleteSelectedItem()
QList<QTreeWidgetItem*> foldersToDelete; QList<QTreeWidgetItem*> foldersToDelete;
bool currentDocumentDeleted = false;
foreach (QTreeWidgetItem * item, mCurrentSelection) { foreach (QTreeWidgetItem * item, mCurrentSelection) {
LastSelectedElementType type = itemType(item); LastSelectedElementType type = itemType(item);
if (type == Document) if (type == Document) {
deleteTreeItem(item, false, false); deleteTreeItem(item, false, false);
UBDocumentProxyTreeItem* proxyItem = dynamic_cast<UBDocumentProxyTreeItem*>(item);
if (proxyItem && proxyItem->proxy() && (proxyItem->proxy() == mBoardController->selectedDocument()))
currentDocumentDeleted = true;
}
else if (type == Folder) else if (type == Folder)
// Delete folders later, to avoid deleting a document twice // Delete folders later, to avoid deleting a document twice
foldersToDelete << item; foldersToDelete << item;
...@@ -863,7 +899,7 @@ void UBDocumentController::deleteSelectedItem() ...@@ -863,7 +899,7 @@ void UBDocumentController::deleteSelectedItem()
deleteTreeItem(item, false, false); deleteTreeItem(item, false, false);
} }
selectADocumentOnMultipleTrashing(); selectATreeItemOnMultipleTrashing(currentDocumentDeleted);
} }
else if (mSelectionType == Document || mSelectionType == Folder) { else if (mSelectionType == Document || mSelectionType == Folder) {
......
...@@ -130,7 +130,8 @@ class UBDocumentController : public UBDocumentContainer ...@@ -130,7 +130,8 @@ class UBDocumentController : public UBDocumentContainer
QString mDefaultDocumentGroupName; QString mDefaultDocumentGroupName;
void selectADocumentOnTrashingSelectedOne(UBDocumentGroupTreeItem* groupTi,UBDocumentProxyTreeItem *proxyTi); void selectADocumentOnTrashingSelectedOne(UBDocumentGroupTreeItem* groupTi,UBDocumentProxyTreeItem *proxyTi);
void selectADocumentOnMultipleTrashing(); void selectFirstDocumentInList();
void selectATreeItemOnMultipleTrashing(bool selectNewCurrentDocument = false);
void moveDocumentToTrash(UBDocumentGroupTreeItem* groupTi, UBDocumentProxyTreeItem *proxyTi, bool selectNewDocument); void moveDocumentToTrash(UBDocumentGroupTreeItem* groupTi, UBDocumentProxyTreeItem *proxyTi, bool selectNewDocument);
void moveFolderToTrash(UBDocumentGroupTreeItem* groupTi); void moveFolderToTrash(UBDocumentGroupTreeItem* groupTi);
void emptyTrash(bool showConfirmationDialog); void emptyTrash(bool showConfirmationDialog);
......
...@@ -98,7 +98,28 @@ void UBGraphicsItemUndoCommand::undo() ...@@ -98,7 +98,28 @@ void UBGraphicsItemUndoCommand::undo()
UBApplication::boardController->freezeW3CWidget(item, true); UBApplication::boardController->freezeW3CWidget(item, true);
item->setSelected(false); item->setSelected(false);
QTransform t;
bool bApplyTransform = false;
UBGraphicsPolygonItem *polygonItem = qgraphicsitem_cast<UBGraphicsPolygonItem*>(item);
if (polygonItem){
if (polygonItem->strokesGroup()
&& polygonItem->strokesGroup()->parentItem()
&& UBGraphicsGroupContainerItem::Type == polygonItem->strokesGroup()->parentItem()->type())
{
bApplyTransform = true;
t = polygonItem->sceneTransform();
}
else if (polygonItem->strokesGroup())
polygonItem->resetTransform();
polygonItem->strokesGroup()->removeFromGroup(polygonItem);
}
mScene->removeItem(item); mScene->removeItem(item);
if (bApplyTransform)
polygonItem->setTransform(t);
} }
QSetIterator<QGraphicsItem*> itRemoved(mRemovedItems); QSetIterator<QGraphicsItem*> itRemoved(mRemovedItems);
...@@ -207,7 +228,29 @@ void UBGraphicsItemUndoCommand::redo() ...@@ -207,7 +228,29 @@ void UBGraphicsItemUndoCommand::redo()
{ {
QGraphicsItem* item = itRemoved.next(); QGraphicsItem* item = itRemoved.next();
item->setSelected(false); item->setSelected(false);
QTransform t;
bool bApplyTransform = false;
UBGraphicsPolygonItem *polygonItem = qgraphicsitem_cast<UBGraphicsPolygonItem*>(item);
if (polygonItem){
if(polygonItem->strokesGroup()
&& polygonItem->strokesGroup()->parentItem()
&& UBGraphicsGroupContainerItem::Type == polygonItem->strokesGroup()->parentItem()->type())
{
bApplyTransform = true;
t = polygonItem->sceneTransform();
}
else if (polygonItem->strokesGroup())
polygonItem->resetTransform();
polygonItem->strokesGroup()->removeFromGroup(polygonItem);
}
mScene->removeItem(item); mScene->removeItem(item);
if (bApplyTransform)
item->setTransform(t);
UBApplication::boardController->freezeW3CWidget(item, true); UBApplication::boardController->freezeW3CWidget(item, true);
} }
......
...@@ -130,7 +130,14 @@ UBGraphicsVideoItem::UBGraphicsVideoItem(const QUrl &pMediaFileUrl, QGraphicsIte ...@@ -130,7 +130,14 @@ UBGraphicsVideoItem::UBGraphicsVideoItem(const QUrl &pMediaFileUrl, QGraphicsIte
mVideoItem->setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); mVideoItem->setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
mVideoItem->setFlag(ItemStacksBehindParent, true); mVideoItem->setFlag(ItemStacksBehindParent, true);
mMediaObject->setVideoOutput(mVideoItem); /* setVideoOutput has to be called only when the video item is visible on the screen,
* due to a Qt bug (QTBUG-32522). So instead of calling it here, it is called when the
* active scene has changed, or when the item is first created.
* If and when Qt fix this issue, this should be changed back.
* */
//mMediaObject->setVideoOutput(mVideoItem);
mHasVideoOutput = false;
mMediaObject->setNotifyInterval(50); mMediaObject->setNotifyInterval(50);
setMinimumSize(QSize(320, 240)); setMinimumSize(QSize(320, 240));
...@@ -155,8 +162,10 @@ UBGraphicsVideoItem::UBGraphicsVideoItem(const QUrl &pMediaFileUrl, QGraphicsIte ...@@ -155,8 +162,10 @@ UBGraphicsVideoItem::UBGraphicsVideoItem(const QUrl &pMediaFileUrl, QGraphicsIte
UBGraphicsMediaItem::~UBGraphicsMediaItem() UBGraphicsMediaItem::~UBGraphicsMediaItem()
{ {
if (mMediaObject) if (mMediaObject) {
mMediaObject->stop(); mMediaObject->stop();
delete mMediaObject;
}
} }
QVariant UBGraphicsMediaItem::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsMediaItem::itemChange(GraphicsItemChange change, const QVariant &value)
...@@ -569,6 +578,22 @@ void UBGraphicsVideoItem::paint(QPainter *painter, const QStyleOptionGraphicsIte ...@@ -569,6 +578,22 @@ void UBGraphicsVideoItem::paint(QPainter *painter, const QStyleOptionGraphicsIte
} }
QVariant UBGraphicsVideoItem::itemChange(GraphicsItemChange change, const QVariant &value) {
if (change == QGraphicsItem::ItemVisibleChange
&& value.toBool()
&& !mHasVideoOutput
&& UBApplication::app()->boardController
&& UBApplication::app()->boardController->activeScene() == scene())
{
//qDebug() << "Item change, setting video output";
mMediaObject->setVideoOutput(mVideoItem);
mHasVideoOutput = true;
}
return UBGraphicsMediaItem::itemChange(change, value);
}
void UBGraphicsVideoItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsVideoItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
// Display the seek bar // Display the seek bar
...@@ -610,9 +635,19 @@ void UBGraphicsVideoItem::mediaStateChanged(QMediaPlayer::State state) ...@@ -610,9 +635,19 @@ void UBGraphicsVideoItem::mediaStateChanged(QMediaPlayer::State state)
void UBGraphicsVideoItem::activeSceneChanged() void UBGraphicsVideoItem::activeSceneChanged()
{ {
//qDebug() << "Active scene changed";
// Update the visibility of the placeholder, to prevent it being hidden when switching pages // Update the visibility of the placeholder, to prevent it being hidden when switching pages
setPlaceholderVisible(!mErrorString.isEmpty()); setPlaceholderVisible(!mErrorString.isEmpty());
// Call setVideoOutput, if the video is visible and if it hasn't been called already
if (!mHasVideoOutput && UBApplication::boardController->activeScene() == scene()) {
//qDebug() << "setting video output";
mMediaObject->setMedia(mMediaFileUrl);
mMediaObject->setVideoOutput(mVideoItem);
mHasVideoOutput = true;
}
UBGraphicsMediaItem::activeSceneChanged(); UBGraphicsMediaItem::activeSceneChanged();
} }
......
...@@ -207,11 +207,14 @@ protected: ...@@ -207,11 +207,14 @@ protected:
QGraphicsVideoItem *mVideoItem; QGraphicsVideoItem *mVideoItem;
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event); virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event); virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void setPlaceholderVisible(bool visible); void setPlaceholderVisible(bool visible);
bool mHasVideoOutput;
}; };
......
...@@ -109,6 +109,8 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem ...@@ -109,6 +109,8 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
qreal originalWidth() { return mOriginalWidth;} qreal originalWidth() { return mOriginalWidth;}
bool isNominalLine() {return mIsNominalLine;} bool isNominalLine() {return mIsNominalLine;}
void setNominalLine(bool isNominalLine) { mIsNominalLine = isNominalLine; }
QColor colorOnDarkBackground() const QColor colorOnDarkBackground() const
{ {
return mColorOnDarkBackground; return mColorOnDarkBackground;
......
...@@ -893,6 +893,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) ...@@ -893,6 +893,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
UBGraphicsPolygonItem* polygonItem = new UBGraphicsPolygonItem(intersectedPolygons[i][j], intersectedPolygonItem->parentItem()); UBGraphicsPolygonItem* polygonItem = new UBGraphicsPolygonItem(intersectedPolygons[i][j], intersectedPolygonItem->parentItem());
intersectedPolygonItem->copyItemParameters(polygonItem); intersectedPolygonItem->copyItemParameters(polygonItem);
polygonItem->setNominalLine(false);
polygonItem->setStroke(intersectedPolygonItem->stroke()); polygonItem->setStroke(intersectedPolygonItem->stroke());
polygonItem->setStrokesGroup(intersectedPolygonItem->strokesGroup()); polygonItem->setStrokesGroup(intersectedPolygonItem->strokesGroup());
intersectedPolygonItem->strokesGroup()->addToGroup(polygonItem); intersectedPolygonItem->strokesGroup()->addToGroup(polygonItem);
...@@ -2209,15 +2210,19 @@ QList<QUrl> UBGraphicsScene::relativeDependencies() const ...@@ -2209,15 +2210,19 @@ QList<QUrl> UBGraphicsScene::relativeDependencies() const
while (itItems.hasNext()) while (itItems.hasNext())
{ {
QGraphicsItem* item = itItems.next(); QGraphicsItem* item = itItems.next();
UBGraphicsMediaItem *mediaItem = qgraphicsitem_cast<UBGraphicsMediaItem*> (item);
UBGraphicsVideoItem *videoItem = qgraphicsitem_cast<UBGraphicsVideoItem*> (item);
if (mediaItem){ if (videoItem){
QString completeFileName = QFileInfo(mediaItem->mediaFileUrl().toLocalFile()).fileName(); QString completeFileName = QFileInfo(videoItem->mediaFileUrl().toLocalFile()).fileName();
QString path; QString path = UBPersistenceManager::videoDirectory + "/";
if(mediaItem->getMediaType() == UBGraphicsMediaItem::mediaType_Video) relativePathes << QUrl(path + completeFileName);
path = UBPersistenceManager::videoDirectory + "/"; continue;
else }
path = UBPersistenceManager::audioDirectory + "/";
UBGraphicsAudioItem *audioItem = qgraphicsitem_cast<UBGraphicsAudioItem*> (item);
if (audioItem){
QString completeFileName = QFileInfo(audioItem->mediaFileUrl().toLocalFile()).fileName();
QString path = UBPersistenceManager::audioDirectory + "/";
relativePathes << QUrl(path + completeFileName); relativePathes << QUrl(path + completeFileName);
continue; continue;
} }
...@@ -2257,6 +2262,24 @@ QSize UBGraphicsScene::nominalSize() ...@@ -2257,6 +2262,24 @@ QSize UBGraphicsScene::nominalSize()
return mNominalSize; return mNominalSize;
} }
/**
* @brief Return the scene's boundary size, including any background item
*
* If no background item is present, this returns nominalSize()
*/
QSize UBGraphicsScene::sceneSize()
{
UBGraphicsPDFItem *pdfItem = qgraphicsitem_cast<UBGraphicsPDFItem*>(backgroundObject());
if (pdfItem) {
QRectF targetRect = pdfItem->sceneBoundingRect();
return targetRect.size().toSize();
}
else
return nominalSize();
}
void UBGraphicsScene::setNominalSize(const QSize& pSize) void UBGraphicsScene::setNominalSize(const QSize& pSize)
{ {
if (nominalSize() != pSize) if (nominalSize() != pSize)
......
...@@ -277,6 +277,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem ...@@ -277,6 +277,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
QSize nominalSize(); QSize nominalSize();
QSize sceneSize();
void setNominalSize(const QSize& pSize); void setNominalSize(const QSize& pSize);
void setNominalSize(int pWidth, int pHeight); void setNominalSize(int pWidth, int pHeight);
......
...@@ -75,9 +75,10 @@ bool UBGraphicsStroke::hasPressure() ...@@ -75,9 +75,10 @@ bool UBGraphicsStroke::hasPressure()
if (!pol->isNominalLine() || pol->originalWidth() != nominalWidth) if (!pol->isNominalLine() || pol->originalWidth() != nominalWidth)
return true; return true;
} }
return false;
} }
return false; return true;
} }
......
...@@ -148,12 +148,15 @@ void UBGraphicsStrokesGroup::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) ...@@ -148,12 +148,15 @@ void UBGraphicsStrokesGroup::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
UBItem* UBGraphicsStrokesGroup::deepCopy() const UBItem* UBGraphicsStrokesGroup::deepCopy() const
{ {
QTransform groupTransform = transform(); QTransform groupTransform = transform();
QPointF groupPos = pos();
UBGraphicsStrokesGroup* copy = new UBGraphicsStrokesGroup(); UBGraphicsStrokesGroup* copy = new UBGraphicsStrokesGroup();
copyItemParameters(copy); copyItemParameters(copy);
copy->resetTransform(); copy->resetTransform();
copy->setPos(0,0);
const_cast<UBGraphicsStrokesGroup*>(this)->resetTransform(); const_cast<UBGraphicsStrokesGroup*>(this)->resetTransform();
const_cast<UBGraphicsStrokesGroup*>(this)->setPos(0,0);
QList<QGraphicsItem*> chl = childItems(); QList<QGraphicsItem*> chl = childItems();
...@@ -175,7 +178,9 @@ UBItem* UBGraphicsStrokesGroup::deepCopy() const ...@@ -175,7 +178,9 @@ UBItem* UBGraphicsStrokesGroup::deepCopy() const
} }
} }
const_cast<UBGraphicsStrokesGroup*>(this)->setTransform(groupTransform); const_cast<UBGraphicsStrokesGroup*>(this)->setTransform(groupTransform);
const_cast<UBGraphicsStrokesGroup*>(this)->setPos(groupPos);
copy->setTransform(groupTransform); copy->setTransform(groupTransform);
copy->setPos(groupPos);
return copy; return copy;
} }
......
...@@ -339,7 +339,10 @@ void UBGraphicsTextItemDelegate::pickFont() ...@@ -339,7 +339,10 @@ void UBGraphicsTextItemDelegate::pickFont()
curCursor.mergeCharFormat(format); curCursor.mergeCharFormat(format);
delegated()->setTextCursor(curCursor); delegated()->setTextCursor(curCursor);
delegated()->setFont(selectedFont);
if (curCursor.selectedText().length() == 0)
delegated()->setFont(selectedFont);
delegated()->setSelected(true); delegated()->setSelected(true);
delegated()->document()->adjustSize(); delegated()->document()->adjustSize();
delegated()->contentsChanged(); delegated()->contentsChanged();
......
...@@ -111,9 +111,15 @@ void UBSelectionFrame::setEnclosedItems(const QList<QGraphicsItem*> pGraphicsIte ...@@ -111,9 +111,15 @@ void UBSelectionFrame::setEnclosedItems(const QList<QGraphicsItem*> pGraphicsIte
QRegion resultRegion; QRegion resultRegion;
UBGraphicsFlags resultFlags; UBGraphicsFlags resultFlags;
mEnclosedtems.clear(); mEnclosedtems.clear();
// If at least one of the enclosed items is locked, the entire selection is
// considered to be locked.
mIsLocked = false;
foreach (QGraphicsItem *nextItem, pGraphicsItems) { foreach (QGraphicsItem *nextItem, pGraphicsItems) {
UBGraphicsItemDelegate *nextDelegate = UBGraphicsItem::Delegate(nextItem); UBGraphicsItemDelegate *nextDelegate = UBGraphicsItem::Delegate(nextItem);
if (nextDelegate) { if (nextDelegate) {
mIsLocked = (mIsLocked || nextDelegate->isLocked());
mEnclosedtems.append(nextDelegate); mEnclosedtems.append(nextDelegate);
resultRegion |= nextItem->boundingRegion(nextItem->sceneTransform()); resultRegion |= nextItem->boundingRegion(nextItem->sceneTransform());
resultFlags |= nextDelegate->ubflags(); resultFlags |= nextDelegate->ubflags();
...@@ -129,6 +135,14 @@ void UBSelectionFrame::setEnclosedItems(const QList<QGraphicsItem*> pGraphicsIte ...@@ -129,6 +135,14 @@ void UBSelectionFrame::setEnclosedItems(const QList<QGraphicsItem*> pGraphicsIte
if (resultRect.isEmpty()) { if (resultRect.isEmpty()) {
hide(); hide();
} }
if (mIsLocked) {
QColor baseColor = UBSettings::paletteColor;
baseColor.setAlphaF(baseColor.alphaF() / 3);
setLocalBrush(QBrush(baseColor));
}
else
setLocalBrush(QBrush(UBSettings::paletteColor));
} }
void UBSelectionFrame::updateRect() void UBSelectionFrame::updateRect()
...@@ -168,6 +182,9 @@ void UBSelectionFrame::mousePressEvent(QGraphicsSceneMouseEvent *event) ...@@ -168,6 +182,9 @@ void UBSelectionFrame::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBSelectionFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBSelectionFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mIsLocked)
return;
QPointF dp = event->pos() - mPressedPos; QPointF dp = event->pos() - mPressedPos;
QPointF rotCenter = mapToScene(rect().center()); QPointF rotCenter = mapToScene(rect().center());
......
...@@ -103,6 +103,8 @@ private: ...@@ -103,6 +103,8 @@ private:
QPointF mLastTranslateOffset; QPointF mLastTranslateOffset;
qreal mRotationAngle; qreal mRotationAngle;
bool mIsLocked;
QList<DelegateButton*> mButtons; QList<DelegateButton*> mButtons;
DelegateButton *mDeleteButton; DelegateButton *mDeleteButton;
......
...@@ -42,21 +42,32 @@ UBVersion::UBVersion(const QString &string) ...@@ -42,21 +42,32 @@ UBVersion::UBVersion(const QString &string)
uint UBVersion::toUInt() const uint UBVersion::toUInt() const
{ {
/* Based on semantic versioning, version numbers look like:
* Major.Minor.Patch-Type.Build
*
* To compare version numbers, the string is split into each part, and they are multiplied
* to give a number where the first two digits are the Major version, the next two are the
* Minor version, and so on.
*
* i.e if Major, Minor etc. are named A, B, C, D, E, the number will look like:
* AABBCCDDEE
*/
uint result = 0; uint result = 0;
QStringList list = mString.split("."); QStringList list = mString.split(QRegExp("[-\\.]"));
switch (list.count()) { switch (list.count()) {
case 2: case 2:
//short version 1.0 //short version 1.0
result = (list.at(0).toUInt() * 1000000) + (list.at(1).toUInt() * 10000) + (Release * 100); result = (list.at(0).toUInt() * 100000000) + (list.at(1).toUInt() * 1000000) + (Release * 100);
break; break;
case 3: case 3:
//release version 1.0.0 //release version 1.0.0
result = (list.at(0).toUInt() * 1000000) + (list.at(1).toUInt() * 10000) + (Release * 100) + list.at(2).toUInt(); result = (list.at(0).toUInt() * 100000000) + (list.at(1).toUInt() * 1000000) + list.at(2).toUInt()*10000 + (Release * 100);
break; break;
case 4:{ case 5:{
//standard version 1.0.a/b/r.0 //standard version 1.0.0.a/b/rc.0
uint releaseStage = list.at(2).startsWith("a") ? Alpha :(list.at(2).startsWith("b") ? Beta : ReleaseCandidate); uint releaseStage = list.at(3).startsWith("a") ? Alpha :(list.at(3).startsWith("b") ? Beta : ReleaseCandidate);
result = (list.at(0).toUInt() * 1000000) + (list.at(1).toUInt() * 10000) + (releaseStage * 100) + list.at(3).toUInt(); result = (list.at(0).toUInt() * 100000000) + (list.at(1).toUInt() * 1000000) + (list.at(2).toUInt() * 10000) + (releaseStage * 100) + list.at(4).toUInt();
break; break;
} }
default: default:
......
...@@ -285,13 +285,16 @@ void UBDocumentTreeWidget::dropEvent(QDropEvent *event) ...@@ -285,13 +285,16 @@ void UBDocumentTreeWidget::dropEvent(QDropEvent *event)
QString source = scene->document()->persistencePath() + "/" + relativeFile.toString(); QString source = scene->document()->persistencePath() + "/" + relativeFile.toString();
QString target = targetDocProxy->persistencePath() + "/" + relativeFile.toString(); QString target = targetDocProxy->persistencePath() + "/" + relativeFile.toString();
QString sourceDecoded = scene->document()->persistencePath() + "/" + relativeFile.toString(QUrl::DecodeReserved);
QString targetDecoded = targetDocProxy->persistencePath() + "/" + relativeFile.toString(QUrl::DecodeReserved);
if(QFileInfo(source).isDir()) if(QFileInfo(source).isDir())
UBFileSystemUtils::copyDir(source,target); UBFileSystemUtils::copyDir(source,target);
else{ else{
QFileInfo fi(target); QFileInfo fi(targetDecoded);
QDir d = fi.dir(); QDir d = fi.dir();
d.mkpath(d.absolutePath()); d.mkpath(d.absolutePath());
QFile::copy(source, target); QFile::copy(sourceDecoded, targetDecoded);
} }
} }
......
...@@ -308,6 +308,7 @@ void UBGraphicsCompass::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) ...@@ -308,6 +308,7 @@ void UBGraphicsCompass::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
updateResizeCursor(); updateResizeCursor();
updateDrawCursor(); updateDrawCursor();
mDrewCenterCross = false;
event->accept(); event->accept();
} }
else if (closeButtonRect().contains(event->pos())) else if (closeButtonRect().contains(event->pos()))
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include "core/memcheck.h" #include "core/memcheck.h"
UBGraphicsCurtainItemDelegate::UBGraphicsCurtainItemDelegate(UBGraphicsCurtainItem* pDelegated, QObject * parent) UBGraphicsCurtainItemDelegate::UBGraphicsCurtainItemDelegate(UBGraphicsCurtainItem* pDelegated, QObject * parent)
: UBGraphicsItemDelegate(pDelegated, parent, GF_SCALABLE_ALL_AXIS | GF_MENU_SPECIFIED) : UBGraphicsItemDelegate(pDelegated, parent, GF_MENU_SPECIFIED)
{ {
//NOOP //NOOP
} }
......
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