diff --git a/resources/style.qss b/resources/style.qss index 46b8dff4..4f3eb2c1 100644 --- a/resources/style.qss +++ b/resources/style.qss @@ -70,11 +70,10 @@ QLabel#UBTGMediaDropMeLabel padding: 2px; } +QTextEdit, +QLineEdit, QComboBox#DockPaletteWidgetComboBox QAbstractItemView { - background-color: white; - color: black; - selection-background-color: lightgreen; selection-color: black; } diff --git a/src/adaptors/UBImportImage.cpp b/src/adaptors/UBImportImage.cpp index c85ba342..64a42fc1 100644 --- a/src/adaptors/UBImportImage.cpp +++ b/src/adaptors/UBImportImage.cpp @@ -74,24 +74,6 @@ QString UBImportImage::importFileFilter() return filter; } -/* -bool UBImportImage::addFileToDocument(UBDocumentProxy* pDocument, const QFile& pFile) -{ - int res = UBDocumentManager::documentManager()->addImageAsPageToDocument(QStringList(QFileInfo(pFile).absoluteFilePath()), pDocument); - if (res == 0) - { - UBApplication::showMessage(tr("Image import failed.")); - return false; - } - else - { - UBApplication::showMessage(tr("Image import successful.")); - return true; - } -} -*/ - - QList UBImportImage::import(const QUuid& uuid, const QString& filePath) { QList result; diff --git a/src/adaptors/UBImportPDF.cpp b/src/adaptors/UBImportPDF.cpp index a1971118..fd9dc16b 100644 --- a/src/adaptors/UBImportPDF.cpp +++ b/src/adaptors/UBImportPDF.cpp @@ -91,66 +91,3 @@ const QString& UBImportPDF::folderToCopy() { return UBPersistenceManager::objectDirectory; } - -/* -bool UBImportPDF::addFileToDocument(UBDocumentProxy* pDocument, const QFile& pFile) -{ - QString documentName = QFileInfo(pFile.fileName()).completeBaseName(); - - QUuid uuid = QUuid::createUuid(); - - QString filepath = UBPersistenceManager::persistenceManager()->addPdfFileToDocument(pDocument, pFile.fileName(), uuid); - - PDFRenderer *pdfRenderer = PDFRenderer::rendererForUuid(uuid, pDocument->persistencePath() + "/" + filepath, true); // renderer is automatically deleted when not used anymore - - if (!pdfRenderer->isValid()) - { - UBApplication::showMessage(tr("PDF import failed.")); - return false; - } - pdfRenderer->setDPI(this->dpi); - - int documentPageCount = pDocument->pageCount(); - - if (documentPageCount == 1 && UBPersistenceManager::persistenceManager()->loadDocumentScene(pDocument, 0)->isEmpty()) - { - documentPageCount = 0; - } - - int pdfPageCount = pdfRenderer->pageCount(); - - for(int pdfPageNumber = 1; pdfPageNumber <= pdfPageCount; pdfPageNumber++) - { - int pageIndex = documentPageCount + pdfPageNumber; - UBApplication::showMessage(tr("Importing page %1 of %2").arg(pdfPageNumber).arg(pdfPageCount), true); - - UBGraphicsScene* scene = 0; - - if (pageIndex == 0) - { - scene = UBPersistenceManager::persistenceManager()->loadDocumentScene(pDocument, pageIndex); - } - else - { - scene = UBPersistenceManager::persistenceManager()->createDocumentSceneAt(pDocument, pageIndex); - } - - scene->setBackground(false, false); - UBGraphicsPDFItem *pdfItem = new UBGraphicsPDFItem(pdfRenderer, pdfPageNumber); // deleted by the scene - scene->addItem(pdfItem); - - pdfItem->setPos(-pdfItem->boundingRect().width() / 2, -pdfItem->boundingRect().height() / 2); - - scene->setAsBackgroundObject(pdfItem, false, false); - - scene->setNominalSize(pdfItem->boundingRect().width(), pdfItem->boundingRect().height()); - - - UBPersistenceManager::persistenceManager()->persistDocumentScene(pDocument, scene, pageIndex); - } - - UBApplication::showMessage(tr("PDF import successful.")); - - return true; -} -*/ \ No newline at end of file diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index e40e164d..370b3240 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -2769,6 +2769,12 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg() } } + QTextCursor curCursor = textItem->textCursor(); + QTextCharFormat format; + + format.setFont(font); + curCursor.mergeCharFormat(format); + textItem->setTextCursor(curCursor); textItem->setFont(font); QStringRef fill = mXmlReader.attributes().value("color"); diff --git a/src/adaptors/UBThumbnailAdaptor.cpp b/src/adaptors/UBThumbnailAdaptor.cpp index 057cf991..5feaccd8 100644 --- a/src/adaptors/UBThumbnailAdaptor.cpp +++ b/src/adaptors/UBThumbnailAdaptor.cpp @@ -117,9 +117,6 @@ void UBThumbnailAdaptor::load(UBDocumentProxy* proxy, QList& lis void UBThumbnailAdaptor::persistScene(UBDocumentProxy* proxy, UBGraphicsScene* pScene, int pageIndex, bool overrideModified) { - - qDebug() << "Persist scene on path " << proxy->persistencePath() << ", index " << pageIndex; - QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageIndex); QFile thumbFile(fileName); diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index 7bbbd219..4786c9d0 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -989,7 +989,8 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event) { if (QGraphicsSvgItem::Type != movingItem->type() && UBGraphicsDelegateFrame::Type != movingItem->type() && - UBToolWidget::Type != movingItem->type()) + UBToolWidget::Type != movingItem->type() && + QGraphicsWidget::Type != movingItem->type()) { bReleaseIsNeed = false; if (movingItem->isSelected() && mMultipleSelectionIsEnabled) diff --git a/src/domain/UBGraphicsItemDelegate.cpp b/src/domain/UBGraphicsItemDelegate.cpp index f26d5ed1..962121a9 100644 --- a/src/domain/UBGraphicsItemDelegate.cpp +++ b/src/domain/UBGraphicsItemDelegate.cpp @@ -115,6 +115,7 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec , mToolBarUsed(useToolBar) { // NOOP + connect(UBApplication::boardController, SIGNAL(zoomChanged(qreal)), this, SLOT(onZoomChanged())); } void UBGraphicsItemDelegate::init() @@ -535,6 +536,12 @@ void UBGraphicsItemDelegate::commitUndoStep() } } +void UBGraphicsItemDelegate::onZoomChanged() +{ + mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom()); + + positionHandles(); +} void UBGraphicsItemDelegate::buildButtons() { diff --git a/src/domain/UBGraphicsItemDelegate.h b/src/domain/UBGraphicsItemDelegate.h index c45fd8be..fc5c460c 100644 --- a/src/domain/UBGraphicsItemDelegate.h +++ b/src/domain/UBGraphicsItemDelegate.h @@ -259,6 +259,8 @@ class UBGraphicsItemDelegate : public QObject void increaseZlevelTop(); void increaseZlevelBottom(); + void onZoomChanged(); + protected: virtual void buildButtons(); virtual void decorateMenu(QMenu *menu); diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 4c53593c..19a7e851 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -317,6 +317,11 @@ void UBGraphicsScene::selectionChangedProcessing() void UBGraphicsScene::updateGroupButtonState() { + + UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool(); + if (UBStylusTool::Selector != currentTool) + return; + QAction *groupAction = UBApplication::mainWindow->actionGroupItems; QList selItems = selectedItems(); int selCount = selItems.count(); diff --git a/src/domain/UBGraphicsTextItemDelegate.cpp b/src/domain/UBGraphicsTextItemDelegate.cpp index 3ab8f973..b24e81d4 100644 --- a/src/domain/UBGraphicsTextItemDelegate.cpp +++ b/src/domain/UBGraphicsTextItemDelegate.cpp @@ -322,6 +322,12 @@ void UBGraphicsTextItemDelegate::positionHandles() void UBGraphicsTextItemDelegate::ChangeTextSize(qreal factor, textChangeMode changeMode) { + if (scaleSize == changeMode) + { + if (1 == factor) + return; + } + else if (0 == factor) return; @@ -403,3 +409,20 @@ void UBGraphicsTextItemDelegate::scaleTextSize(qreal multiplyer) { ChangeTextSize(multiplyer, scaleSize); } + +QVariant UBGraphicsTextItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) +{ + if (change == QGraphicsItem::ItemSelectedChange) + { + if (delegated()->isSelected()) + { + QTextCursor c = delegated()->textCursor(); + if (c.hasSelection()) + { + c.clearSelection(); + delegated()->setTextCursor(c); + } + } + } + return UBGraphicsItemDelegate::itemChange(change, value); +} diff --git a/src/domain/UBGraphicsTextItemDelegate.h b/src/domain/UBGraphicsTextItemDelegate.h index b01df4e2..26b3ba9b 100644 --- a/src/domain/UBGraphicsTextItemDelegate.h +++ b/src/domain/UBGraphicsTextItemDelegate.h @@ -40,6 +40,8 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate virtual ~UBGraphicsTextItemDelegate(); bool isEditable(); void scaleTextSize(qreal multiplyer); + virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value); + public slots: void contentsChanged(); diff --git a/src/gui/UBDockPalette.cpp b/src/gui/UBDockPalette.cpp index a302d847..38f375be 100644 --- a/src/gui/UBDockPalette.cpp +++ b/src/gui/UBDockPalette.cpp @@ -17,12 +17,16 @@ #include #include "UBDockPalette.h" -#include "core/UBSettings.h" + #include "frameworks/UBPlatformUtils.h" + +#include "core/UBSettings.h" #include "core/UBApplication.h" #include "core/UBPreferencesController.h" #include "core/UBDownloadManager.h" +#include "board/UBBoardController.h" + #include "core/memcheck.h" /** @@ -79,6 +83,8 @@ UBDockPalette::UBDockPalette(eUBDockPaletteType paletteType, QWidget *parent, co onToolbarPosUpdated(); connect(UBSettings::settings()->appToolBarPositionedAtTop, SIGNAL(changed(QVariant)), this, SLOT(onToolbarPosUpdated())); connect(UBDownloadManager::downloadManager(), SIGNAL(allDownloadsFinished()), this, SLOT(onAllDownloadsFinished())); + + connect(UBApplication::boardController,SIGNAL(documentSet(UBDocumentProxy*)),this,SLOT(onDocumentSet(UBDocumentProxy*))); } /** @@ -98,6 +104,11 @@ UBDockPalette::~UBDockPalette() } } +void UBDockPalette::onDocumentSet(UBDocumentProxy* documentProxy) +{ + Q_UNUSED(documentProxy); +} + /** * \brief Get the current orientation * @return the current orientation diff --git a/src/gui/UBDockPalette.h b/src/gui/UBDockPalette.h index f1c6f323..2dac9e08 100644 --- a/src/gui/UBDockPalette.h +++ b/src/gui/UBDockPalette.h @@ -15,6 +15,8 @@ #ifndef UBDOCKPALETTE_H #define UBDOCKPALETTE_H +class UBDocumentProxy; + #include #include #include @@ -131,6 +133,7 @@ public slots: void onShowTabWidget(UBDockPaletteWidget* widget); void onHideTabWidget(UBDockPaletteWidget* widget); void onAllDownloadsFinished(); + virtual void onDocumentSet(UBDocumentProxy* documentProxy); protected: virtual int border(); diff --git a/src/gui/UBLeftPalette.cpp b/src/gui/UBLeftPalette.cpp index 7f79ff18..ffb93f90 100644 --- a/src/gui/UBLeftPalette.cpp +++ b/src/gui/UBLeftPalette.cpp @@ -51,6 +51,14 @@ UBLeftPalette::~UBLeftPalette() } + +void UBLeftPalette::onDocumentSet(UBDocumentProxy* documentProxy) +{ + //This is necessary to force the teacher guide to be showed in priority each time a document is set + if(documentProxy && UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) + mLastOpenedTabForMode.insert(eUBDockPaletteWidget_BOARD, 1); +} + /** * \brief Update the maximum width */ diff --git a/src/gui/UBLeftPalette.h b/src/gui/UBLeftPalette.h index 43f472ab..72e4fc1a 100644 --- a/src/gui/UBLeftPalette.h +++ b/src/gui/UBLeftPalette.h @@ -25,6 +25,9 @@ public: bool switchMode(eUBDockPaletteWidgetMode mode); +public slots: + void onDocumentSet(UBDocumentProxy* documentProxy); + protected: void updateMaxWidth(); void resizeEvent(QResizeEvent *event); diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index cb2b912d..ee81836e 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -1149,7 +1149,6 @@ void UBTeacherGuideWidget::onActiveSceneChanged() mpPageZeroWidget->switchToMode(tUBTGZeroPageMode_EDITION); setCurrentWidget(mpPageZeroWidget); - } else{ if(mpEditionWidget->isModified()){ diff --git a/src/gui/UBToolWidget.cpp b/src/gui/UBToolWidget.cpp index 44587da9..41a78e1a 100644 --- a/src/gui/UBToolWidget.cpp +++ b/src/gui/UBToolWidget.cpp @@ -76,7 +76,7 @@ void UBToolWidget::initialize() if(!sUnpinPixmap) sUnpinPixmap = new QPixmap(":/images/unpin.svg"); - QGraphicsLinearLayout *graphicsLayout = new QGraphicsLinearLayout(Qt::Vertical); + QGraphicsLinearLayout *graphicsLayout = new QGraphicsLinearLayout(Qt::Vertical, this); mFrameWidth = UBSettings::settings()->objectFrameWidth; mContentMargin = sClosePixmap->width() / 2 + mFrameWidth;