mirror of https://github.com/JakubMelka/PDF4QT.git
New feature: rotating pages in viewer
This commit is contained in:
parent
af83f99f51
commit
efca4a3cde
|
@ -37,6 +37,7 @@ PDFDrawSpaceController::PDFDrawSpaceController(QObject* parent) :
|
||||||
m_pageLayoutMode(PageLayout::OneColumn),
|
m_pageLayoutMode(PageLayout::OneColumn),
|
||||||
m_verticalSpacingMM(5.0),
|
m_verticalSpacingMM(5.0),
|
||||||
m_horizontalSpacingMM(1.0),
|
m_horizontalSpacingMM(1.0),
|
||||||
|
m_pageRotation(PageRotation::None),
|
||||||
m_fontCache(DEFAULT_FONT_CACHE_LIMIT, DEFAULT_REALIZED_FONT_CACHE_LIMIT)
|
m_fontCache(DEFAULT_FONT_CACHE_LIMIT, DEFAULT_REALIZED_FONT_CACHE_LIMIT)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -137,6 +138,15 @@ QSizeF PDFDrawSpaceController::getReferenceBoundingBox() const
|
||||||
return rect.size();
|
return rect.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PDFDrawSpaceController::setPageRotation(PageRotation pageRotation)
|
||||||
|
{
|
||||||
|
if (m_pageRotation != pageRotation)
|
||||||
|
{
|
||||||
|
m_pageRotation = pageRotation;
|
||||||
|
recalculate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PDFDrawSpaceController::recalculate()
|
void PDFDrawSpaceController::recalculate()
|
||||||
{
|
{
|
||||||
if (!m_document)
|
if (!m_document)
|
||||||
|
@ -148,19 +158,6 @@ void PDFDrawSpaceController::recalculate()
|
||||||
const PDFCatalog* catalog = m_document->getCatalog();
|
const PDFCatalog* catalog = m_document->getCatalog();
|
||||||
size_t pageCount = catalog->getPageCount();
|
size_t pageCount = catalog->getPageCount();
|
||||||
|
|
||||||
// First, preserve page rotations. We assume the count of pages is the same as the document.
|
|
||||||
// Document should not be changed while viewing. If a new document is setted, then the draw
|
|
||||||
// space is cleared first.
|
|
||||||
std::vector<PageRotation> pageRotation(pageCount, PageRotation::None);
|
|
||||||
for (size_t i = 0; i < pageCount; ++i)
|
|
||||||
{
|
|
||||||
pageRotation[i] = catalog->getPage(i)->getPageRotation();
|
|
||||||
}
|
|
||||||
for (const LayoutItem& layoutItem : m_layoutItems)
|
|
||||||
{
|
|
||||||
pageRotation[layoutItem.pageIndex] = layoutItem.pageRotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear the old draw space
|
// Clear the old draw space
|
||||||
clear(false);
|
clear(false);
|
||||||
|
|
||||||
|
@ -168,26 +165,26 @@ void PDFDrawSpaceController::recalculate()
|
||||||
|
|
||||||
// Places the pages on the left/right sides. Pages can be nullptr, but not both of them.
|
// Places the pages on the left/right sides. Pages can be nullptr, but not both of them.
|
||||||
// Updates bounding rectangle.
|
// Updates bounding rectangle.
|
||||||
auto placePagesLeftRight = [this, catalog, &pageRotation](PDFInteger blockIndex, size_t leftIndex, size_t rightIndex, PDFReal& yPos, QRectF& boundingRect)
|
auto placePagesLeftRight = [this, catalog](PDFInteger blockIndex, size_t leftIndex, size_t rightIndex, PDFReal& yPos, QRectF& boundingRect)
|
||||||
{
|
{
|
||||||
PDFReal yPosAdvance = 0.0;
|
PDFReal yPosAdvance = 0.0;
|
||||||
|
|
||||||
if (leftIndex != INVALID_PAGE_INDEX)
|
if (leftIndex != INVALID_PAGE_INDEX)
|
||||||
{
|
{
|
||||||
QSizeF pageSize = PDFPage::getRotatedBox(catalog->getPage(leftIndex)->getMediaBoxMM(), pageRotation[leftIndex]).size();
|
QSizeF pageSize = PDFPage::getRotatedBox(catalog->getPage(leftIndex)->getRotatedMediaBoxMM(), m_pageRotation).size();
|
||||||
PDFReal xPos = -pageSize.width() - m_horizontalSpacingMM * 0.5;
|
PDFReal xPos = -pageSize.width() - m_horizontalSpacingMM * 0.5;
|
||||||
QRectF rect(xPos, yPos, pageSize.width(), pageSize.height());
|
QRectF rect(xPos, yPos, pageSize.width(), pageSize.height());
|
||||||
m_layoutItems.emplace_back(blockIndex, leftIndex, pageRotation[leftIndex], rect);
|
m_layoutItems.emplace_back(blockIndex, leftIndex, rect);
|
||||||
yPosAdvance = qMax(yPosAdvance, pageSize.height());
|
yPosAdvance = qMax(yPosAdvance, pageSize.height());
|
||||||
boundingRect = boundingRect.united(rect);
|
boundingRect = boundingRect.united(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rightIndex != INVALID_PAGE_INDEX)
|
if (rightIndex != INVALID_PAGE_INDEX)
|
||||||
{
|
{
|
||||||
QSizeF pageSize = PDFPage::getRotatedBox(catalog->getPage(rightIndex)->getMediaBoxMM(), pageRotation[rightIndex]).size();
|
QSizeF pageSize = PDFPage::getRotatedBox(catalog->getPage(rightIndex)->getRotatedMediaBoxMM(), m_pageRotation).size();
|
||||||
PDFReal xPos = m_horizontalSpacingMM * 0.5;
|
PDFReal xPos = m_horizontalSpacingMM * 0.5;
|
||||||
QRectF rect(xPos, yPos, pageSize.width(), pageSize.height());
|
QRectF rect(xPos, yPos, pageSize.width(), pageSize.height());
|
||||||
m_layoutItems.emplace_back(blockIndex, rightIndex, pageRotation[rightIndex], rect);
|
m_layoutItems.emplace_back(blockIndex, rightIndex, rect);
|
||||||
yPosAdvance = qMax(yPosAdvance, pageSize.height());
|
yPosAdvance = qMax(yPosAdvance, pageSize.height());
|
||||||
boundingRect = boundingRect.united(rect);
|
boundingRect = boundingRect.united(rect);
|
||||||
}
|
}
|
||||||
|
@ -247,9 +244,9 @@ void PDFDrawSpaceController::recalculate()
|
||||||
|
|
||||||
for (size_t i = 0; i < pageCount; ++i)
|
for (size_t i = 0; i < pageCount; ++i)
|
||||||
{
|
{
|
||||||
QSizeF pageSize = PDFPage::getRotatedBox(catalog->getPage(i)->getMediaBoxMM(), pageRotation[i]).size();
|
QSizeF pageSize = PDFPage::getRotatedBox(catalog->getPage(i)->getRotatedMediaBoxMM(), m_pageRotation).size();
|
||||||
QRectF rect(-pageSize.width() * 0.5, -pageSize.height() * 0.5, pageSize.width(), pageSize.height());
|
QRectF rect(-pageSize.width() * 0.5, -pageSize.height() * 0.5, pageSize.width(), pageSize.height());
|
||||||
m_layoutItems.emplace_back(i, i, pageRotation[i], rect);
|
m_layoutItems.emplace_back(i, i, rect);
|
||||||
m_blockItems.emplace_back(rect);
|
m_blockItems.emplace_back(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,9 +265,9 @@ void PDFDrawSpaceController::recalculate()
|
||||||
for (size_t i = 0; i < pageCount; ++i)
|
for (size_t i = 0; i < pageCount; ++i)
|
||||||
{
|
{
|
||||||
// Top of current page is at yPos.
|
// Top of current page is at yPos.
|
||||||
QSizeF pageSize = PDFPage::getRotatedBox(catalog->getPage(i)->getMediaBoxMM(), pageRotation[i]).size();
|
QSizeF pageSize = PDFPage::getRotatedBox(catalog->getPage(i)->getRotatedMediaBoxMM(), m_pageRotation).size();
|
||||||
QRectF rect(-pageSize.width() * 0.5, yPos, pageSize.width(), pageSize.height());
|
QRectF rect(-pageSize.width() * 0.5, yPos, pageSize.width(), pageSize.height());
|
||||||
m_layoutItems.emplace_back(0, i, pageRotation[i], rect);
|
m_layoutItems.emplace_back(0, i, rect);
|
||||||
yPos += pageSize.height() + m_verticalSpacingMM;
|
yPos += pageSize.height() + m_verticalSpacingMM;
|
||||||
boundingRectangle = boundingRectangle.united(rect);
|
boundingRectangle = boundingRectangle.united(rect);
|
||||||
}
|
}
|
||||||
|
@ -491,7 +488,7 @@ void PDFDrawWidgetProxy::update()
|
||||||
m_layout.items.reserve(items.size());
|
m_layout.items.reserve(items.size());
|
||||||
for (const PDFDrawSpaceController::LayoutItem& item : items)
|
for (const PDFDrawSpaceController::LayoutItem& item : items)
|
||||||
{
|
{
|
||||||
m_layout.items.emplace_back(item.pageIndex, item.pageRotation, fromDeviceSpace(item.pageRectMM).toRect());
|
m_layout.items.emplace_back(item.pageIndex, fromDeviceSpace(item.pageRectMM).toRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_layout.blockRect = fromDeviceSpace(rectangle).toRect();
|
m_layout.blockRect = fromDeviceSpace(rectangle).toRect();
|
||||||
|
@ -594,6 +591,59 @@ void PDFDrawWidgetProxy::update()
|
||||||
emit drawSpaceChanged();
|
emit drawSpaceChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMatrix PDFDrawWidgetProxy::createPagePointToDevicePointMatrix(const PDFPage* page, const QRectF& rectangle) const
|
||||||
|
{
|
||||||
|
QMatrix matrix;
|
||||||
|
|
||||||
|
// We want to create transformation from unrotated rectangle
|
||||||
|
// to rotated page rectangle.
|
||||||
|
|
||||||
|
QRectF unrotatedRectangle = rectangle;
|
||||||
|
switch (m_controller->getPageRotation())
|
||||||
|
{
|
||||||
|
case PageRotation::None:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PageRotation::Rotate180:
|
||||||
|
{
|
||||||
|
matrix.translate(0, rectangle.top() + rectangle.bottom());
|
||||||
|
matrix.scale(1.0, -1.0);
|
||||||
|
Q_ASSERT(qFuzzyCompare(matrix.map(rectangle.topLeft()).y(), rectangle.bottom()));
|
||||||
|
Q_ASSERT(qFuzzyCompare(matrix.map(rectangle.bottomLeft()).y(), rectangle.top()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case PageRotation::Rotate90:
|
||||||
|
{
|
||||||
|
unrotatedRectangle = rectangle.transposed();
|
||||||
|
matrix.translate(rectangle.left(), rectangle.top());
|
||||||
|
matrix.rotate(90);
|
||||||
|
matrix.translate(-rectangle.left(), -rectangle.top());
|
||||||
|
matrix.translate(0, -unrotatedRectangle.height());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case PageRotation::Rotate270:
|
||||||
|
{
|
||||||
|
unrotatedRectangle = rectangle.transposed();
|
||||||
|
matrix.translate(rectangle.left(), rectangle.top());
|
||||||
|
matrix.rotate(90);
|
||||||
|
matrix.translate(-rectangle.left(), -rectangle.top());
|
||||||
|
matrix.translate(0, -unrotatedRectangle.height());
|
||||||
|
matrix.translate(0.0, unrotatedRectangle.top() + unrotatedRectangle.bottom());
|
||||||
|
matrix.scale(1.0, -1.0);
|
||||||
|
matrix.translate(unrotatedRectangle.left() + unrotatedRectangle.right(), 0.0);
|
||||||
|
matrix.scale(-1.0, 1.0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PDFRenderer::createPagePointToDevicePointMatrix(page, unrotatedRectangle) * matrix;
|
||||||
|
}
|
||||||
|
|
||||||
void PDFDrawWidgetProxy::draw(QPainter* painter, QRect rect)
|
void PDFDrawWidgetProxy::draw(QPainter* painter, QRect rect)
|
||||||
{
|
{
|
||||||
painter->fillRect(rect, Qt::lightGray);
|
painter->fillRect(rect, Qt::lightGray);
|
||||||
|
@ -624,7 +674,7 @@ void PDFDrawWidgetProxy::draw(QPainter* painter, QRect rect)
|
||||||
timer.start();
|
timer.start();
|
||||||
|
|
||||||
const PDFPage* page = m_controller->getDocument()->getCatalog()->getPage(item.pageIndex);
|
const PDFPage* page = m_controller->getDocument()->getCatalog()->getPage(item.pageIndex);
|
||||||
QMatrix matrix = PDFRenderer::createPagePointToDevicePointMatrix(page, placedRect);
|
QMatrix matrix = createPagePointToDevicePointMatrix(page, placedRect);
|
||||||
compiledPage->draw(painter, page->getCropBox(), matrix, m_features);
|
compiledPage->draw(painter, page->getCropBox(), matrix, m_features);
|
||||||
PDFTextLayoutGetter layoutGetter = m_textLayoutCompiler->getTextLayoutLazy(item.pageIndex);
|
PDFTextLayoutGetter layoutGetter = m_textLayoutCompiler->getTextLayoutLazy(item.pageIndex);
|
||||||
|
|
||||||
|
@ -802,7 +852,7 @@ PDFInteger PDFDrawWidgetProxy::getPageUnderPoint(QPoint point, QPointF* pagePoin
|
||||||
if (pagePoint)
|
if (pagePoint)
|
||||||
{
|
{
|
||||||
const PDFPage* page = m_controller->getDocument()->getCatalog()->getPage(item.pageIndex);
|
const PDFPage* page = m_controller->getDocument()->getCatalog()->getPage(item.pageIndex);
|
||||||
QMatrix matrix = PDFRenderer::createPagePointToDevicePointMatrix(page, placedRect).inverted();
|
QMatrix matrix = createPagePointToDevicePointMatrix(page, placedRect).inverted();
|
||||||
*pagePoint = matrix.map(point);
|
*pagePoint = matrix.map(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -921,6 +971,18 @@ void PDFDrawWidgetProxy::performOperation(Operation operation)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case RotateRight:
|
||||||
|
{
|
||||||
|
m_controller->setPageRotation(getPageRotationRotatedRight(m_controller->getPageRotation()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case RotateLeft:
|
||||||
|
{
|
||||||
|
m_controller->setPageRotation(getPageRotationRotatedLeft(m_controller->getPageRotation()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
|
|
|
@ -97,15 +97,14 @@ public:
|
||||||
/// page and page rectangle, in which the page is contained.
|
/// page and page rectangle, in which the page is contained.
|
||||||
struct LayoutItem
|
struct LayoutItem
|
||||||
{
|
{
|
||||||
constexpr inline explicit LayoutItem() : blockIndex(-1), pageIndex(-1), pageRotation(PageRotation::None) { }
|
constexpr inline explicit LayoutItem() : blockIndex(-1), pageIndex(-1) { }
|
||||||
constexpr inline explicit LayoutItem(PDFInteger blockIndex, PDFInteger pageIndex, PageRotation rotation, const QRectF& pageRectMM) :
|
constexpr inline explicit LayoutItem(PDFInteger blockIndex, PDFInteger pageIndex, const QRectF& pageRectMM) :
|
||||||
blockIndex(blockIndex), pageIndex(pageIndex), pageRotation(rotation), pageRectMM(pageRectMM) { }
|
blockIndex(blockIndex), pageIndex(pageIndex), pageRectMM(pageRectMM) { }
|
||||||
|
|
||||||
bool isValid() const { return pageIndex != -1; }
|
bool isValid() const { return pageIndex != -1; }
|
||||||
|
|
||||||
PDFInteger blockIndex;
|
PDFInteger blockIndex;
|
||||||
PDFInteger pageIndex;
|
PDFInteger pageIndex;
|
||||||
PageRotation pageRotation;
|
|
||||||
QRectF pageRectMM;
|
QRectF pageRectMM;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -138,6 +137,12 @@ public:
|
||||||
/// any page on the screen will fit this bounding box, regardless of mode (single/two columns, etc.).
|
/// any page on the screen will fit this bounding box, regardless of mode (single/two columns, etc.).
|
||||||
QSizeF getReferenceBoundingBox() const;
|
QSizeF getReferenceBoundingBox() const;
|
||||||
|
|
||||||
|
/// Returns page rotation
|
||||||
|
PageRotation getPageRotation() const { return m_pageRotation; }
|
||||||
|
|
||||||
|
/// Sets page rotation
|
||||||
|
void setPageRotation(PageRotation pageRotation);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void drawSpaceChanged();
|
void drawSpaceChanged();
|
||||||
void repaintNeeded();
|
void repaintNeeded();
|
||||||
|
@ -169,6 +174,7 @@ private:
|
||||||
BlockItems m_blockItems;
|
BlockItems m_blockItems;
|
||||||
PDFReal m_verticalSpacingMM;
|
PDFReal m_verticalSpacingMM;
|
||||||
PDFReal m_horizontalSpacingMM;
|
PDFReal m_horizontalSpacingMM;
|
||||||
|
PageRotation m_pageRotation;
|
||||||
|
|
||||||
/// Font cache
|
/// Font cache
|
||||||
PDFFontCache m_fontCache;
|
PDFFontCache m_fontCache;
|
||||||
|
@ -196,6 +202,12 @@ public:
|
||||||
/// Updates the draw space area
|
/// Updates the draw space area
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
/// Creates page point to device point matrix for the given rectangle. It creates transformation
|
||||||
|
/// from page's media box to the target rectangle.
|
||||||
|
/// \param page Page, for which we want to create matrix
|
||||||
|
/// \param rectangle Page rectangle, to which is page media box transformed
|
||||||
|
QMatrix createPagePointToDevicePointMatrix(const PDFPage* page, const QRectF& rectangle) const;
|
||||||
|
|
||||||
/// Draws the actually visible pages on the painter using the rectangle.
|
/// Draws the actually visible pages on the painter using the rectangle.
|
||||||
/// Rectangle is space in the widget, which is used for painting the PDF.
|
/// Rectangle is space in the widget, which is used for painting the PDF.
|
||||||
/// \param painter Painter to paint the PDF pages
|
/// \param painter Painter to paint the PDF pages
|
||||||
|
@ -220,7 +232,9 @@ public:
|
||||||
NavigateNextPage,
|
NavigateNextPage,
|
||||||
NavigatePreviousPage,
|
NavigatePreviousPage,
|
||||||
NavigateNextStep,
|
NavigateNextStep,
|
||||||
NavigatePreviousStep
|
NavigatePreviousStep,
|
||||||
|
RotateRight,
|
||||||
|
RotateLeft
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Performs the desired operation (for example navigation).
|
/// Performs the desired operation (for example navigation).
|
||||||
|
@ -329,13 +343,12 @@ signals:
|
||||||
private:
|
private:
|
||||||
struct LayoutItem
|
struct LayoutItem
|
||||||
{
|
{
|
||||||
constexpr inline explicit LayoutItem() : pageIndex(-1), pageRotation(PageRotation::None) { }
|
constexpr inline explicit LayoutItem() : pageIndex(-1) { }
|
||||||
constexpr inline explicit LayoutItem(PDFInteger pageIndex, PageRotation rotation, const QRect& pageRect) :
|
constexpr inline explicit LayoutItem(PDFInteger pageIndex, const QRect& pageRect) :
|
||||||
pageIndex(pageIndex), pageRotation(rotation), pageRect(pageRect) { }
|
pageIndex(pageIndex), pageRect(pageRect) { }
|
||||||
|
|
||||||
|
|
||||||
PDFInteger pageIndex;
|
PDFInteger pageIndex;
|
||||||
PageRotation pageRotation;
|
|
||||||
QRect pageRect;
|
QRect pageRect;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,11 @@ QRectF PDFPage::getRotatedMediaBox() const
|
||||||
return getRotatedBox(getMediaBox(), getPageRotation());
|
return getRotatedBox(getMediaBox(), getPageRotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRectF PDFPage::getRotatedMediaBoxMM() const
|
||||||
|
{
|
||||||
|
return getRotatedBox(getMediaBoxMM(), getPageRotation());
|
||||||
|
}
|
||||||
|
|
||||||
QRectF PDFPage::getRotatedCropBox() const
|
QRectF PDFPage::getRotatedCropBox() const
|
||||||
{
|
{
|
||||||
return getRotatedBox(getCropBox(), getPageRotation());
|
return getRotatedBox(getCropBox(), getPageRotation());
|
||||||
|
|
|
@ -39,6 +39,40 @@ enum class PageRotation
|
||||||
Rotate270
|
Rotate270
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constexpr PageRotation getPageRotationRotatedRight(PageRotation rotation)
|
||||||
|
{
|
||||||
|
switch (rotation)
|
||||||
|
{
|
||||||
|
case PageRotation::None:
|
||||||
|
return PageRotation::Rotate90;
|
||||||
|
case PageRotation::Rotate90:
|
||||||
|
return PageRotation::Rotate180;
|
||||||
|
case PageRotation::Rotate180:
|
||||||
|
return PageRotation::Rotate270;
|
||||||
|
case PageRotation::Rotate270:
|
||||||
|
return PageRotation::None;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PageRotation::None;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr PageRotation getPageRotationRotatedLeft(PageRotation rotation)
|
||||||
|
{
|
||||||
|
switch (rotation)
|
||||||
|
{
|
||||||
|
case PageRotation::None:
|
||||||
|
return PageRotation::Rotate270;
|
||||||
|
case PageRotation::Rotate90:
|
||||||
|
return PageRotation::None;
|
||||||
|
case PageRotation::Rotate180:
|
||||||
|
return PageRotation::Rotate90;
|
||||||
|
case PageRotation::Rotate270:
|
||||||
|
return PageRotation::Rotate180;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PageRotation::None;
|
||||||
|
}
|
||||||
|
|
||||||
/// This class represents attributes, which are inheritable. Also allows merging from
|
/// This class represents attributes, which are inheritable. Also allows merging from
|
||||||
/// parents.
|
/// parents.
|
||||||
class PDFPageInheritableAttributes
|
class PDFPageInheritableAttributes
|
||||||
|
@ -97,6 +131,7 @@ public:
|
||||||
inline PDFObjectReference getPageReference() const { return m_pageReference; }
|
inline PDFObjectReference getPageReference() const { return m_pageReference; }
|
||||||
|
|
||||||
QRectF getRotatedMediaBox() const;
|
QRectF getRotatedMediaBox() const;
|
||||||
|
QRectF getRotatedMediaBoxMM() const;
|
||||||
QRectF getRotatedCropBox() const;
|
QRectF getRotatedCropBox() const;
|
||||||
|
|
||||||
static QRectF getRotatedBox(const QRectF& rect, PageRotation rotation);
|
static QRectF getRotatedBox(const QRectF& rect, PageRotation rotation);
|
||||||
|
|
|
@ -33,5 +33,7 @@
|
||||||
<file>resources/find-previous.svg</file>
|
<file>resources/find-previous.svg</file>
|
||||||
<file>resources/select-text.svg</file>
|
<file>resources/select-text.svg</file>
|
||||||
<file>resources/ui.svg</file>
|
<file>resources/ui.svg</file>
|
||||||
|
<file>resources/rotate-left.svg</file>
|
||||||
|
<file>resources/rotate-right.svg</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -107,6 +107,8 @@ PDFViewerMainWindow::PDFViewerMainWindow(QWidget* parent) :
|
||||||
ui->actionSelectTextAll->setShortcut(QKeySequence::SelectAll);
|
ui->actionSelectTextAll->setShortcut(QKeySequence::SelectAll);
|
||||||
ui->actionDeselectText->setShortcut(QKeySequence::Deselect);
|
ui->actionDeselectText->setShortcut(QKeySequence::Deselect);
|
||||||
ui->actionCopyText->setShortcut(QKeySequence::Copy);
|
ui->actionCopyText->setShortcut(QKeySequence::Copy);
|
||||||
|
ui->actionRotateRight->setShortcut(QKeySequence("Ctrl+Shift++"));
|
||||||
|
ui->actionRotateLeft->setShortcut(QKeySequence("Ctrl+Shift+-"));
|
||||||
|
|
||||||
for (QAction* action : m_recentFileManager->getActions())
|
for (QAction* action : m_recentFileManager->getActions())
|
||||||
{
|
{
|
||||||
|
@ -1146,4 +1148,14 @@ void PDFViewerMainWindow::on_actionSend_by_E_Mail_triggered()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PDFViewerMainWindow::on_actionRotateRight_triggered()
|
||||||
|
{
|
||||||
|
m_pdfWidget->getDrawWidgetProxy()->performOperation(pdf::PDFDrawWidgetProxy::RotateRight);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFViewerMainWindow::on_actionRotateLeft_triggered()
|
||||||
|
{
|
||||||
|
m_pdfWidget->getDrawWidgetProxy()->performOperation(pdf::PDFDrawWidgetProxy::RotateLeft);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace pdfviewer
|
} // namespace pdfviewer
|
||||||
|
|
|
@ -92,6 +92,10 @@ private slots:
|
||||||
void on_actionProperties_triggered();
|
void on_actionProperties_triggered();
|
||||||
void on_actionSend_by_E_Mail_triggered();
|
void on_actionSend_by_E_Mail_triggered();
|
||||||
|
|
||||||
|
void on_actionRotateRight_triggered();
|
||||||
|
|
||||||
|
void on_actionRotateLeft_triggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onActionOpenTriggered();
|
void onActionOpenTriggered();
|
||||||
void onActionCloseTriggered();
|
void onActionCloseTriggered();
|
||||||
|
|
|
@ -68,6 +68,9 @@
|
||||||
<addaction name="menuPage_Layout"/>
|
<addaction name="menuPage_Layout"/>
|
||||||
<addaction name="menuRendering_Options"/>
|
<addaction name="menuRendering_Options"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionRotateRight"/>
|
||||||
|
<addaction name="actionRotateLeft"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
<addaction name="actionZoom_In"/>
|
<addaction name="actionZoom_In"/>
|
||||||
<addaction name="actionZoom_Out"/>
|
<addaction name="actionZoom_Out"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
@ -419,6 +422,24 @@
|
||||||
<string>Invert Colors</string>
|
<string>Invert Colors</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionRotateRight">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="pdfforqtviewer.qrc">
|
||||||
|
<normaloff>:/resources/rotate-right.svg</normaloff>:/resources/rotate-right.svg</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Rotate Right</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionRotateLeft">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="pdfforqtviewer.qrc">
|
||||||
|
<normaloff>:/resources/rotate-left.svg</normaloff>:/resources/rotate-left.svg</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Rotate Left</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="30mm"
|
||||||
|
height="30mm"
|
||||||
|
viewBox="0 0 30 30"
|
||||||
|
version="1.1"
|
||||||
|
id="svg5291"
|
||||||
|
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
|
||||||
|
sodipodi:docname="rotate-left.svg">
|
||||||
|
<defs
|
||||||
|
id="defs5285" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="11.2"
|
||||||
|
inkscape:cx="25.205349"
|
||||||
|
inkscape:cy="65.2238"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:window-width="3840"
|
||||||
|
inkscape:window-height="2035"
|
||||||
|
inkscape:window-x="-13"
|
||||||
|
inkscape:window-y="-13"
|
||||||
|
inkscape:window-maximized="1" />
|
||||||
|
<metadata
|
||||||
|
id="metadata5288">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
<dc:creator>
|
||||||
|
<cc:Agent>
|
||||||
|
<dc:title>Jakub Melka</dc:title>
|
||||||
|
</cc:Agent>
|
||||||
|
</dc:creator>
|
||||||
|
<cc:license
|
||||||
|
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
|
||||||
|
</cc:Work>
|
||||||
|
<cc:License
|
||||||
|
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
|
||||||
|
<cc:permits
|
||||||
|
rdf:resource="http://creativecommons.org/ns#Reproduction" />
|
||||||
|
<cc:permits
|
||||||
|
rdf:resource="http://creativecommons.org/ns#Distribution" />
|
||||||
|
<cc:requires
|
||||||
|
rdf:resource="http://creativecommons.org/ns#Notice" />
|
||||||
|
<cc:requires
|
||||||
|
rdf:resource="http://creativecommons.org/ns#Attribution" />
|
||||||
|
<cc:permits
|
||||||
|
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
|
||||||
|
<cc:requires
|
||||||
|
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
|
||||||
|
</cc:License>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Vrstva 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(0,-267)">
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1378"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:25.39999962px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
|
||||||
|
d="m 19.216545,279.12842 -1.5875,-5.90352 5.903515,1.5751 -2.59209,0.86816 q 2.691309,2.86495 2.691309,6.49883 0,3.80752 -2.691309,6.49883 -2.691308,2.67891 -6.486425,2.67891 -3.807519,0 -6.4864255,-2.67891 -2.691309,-2.69131 -2.691309,-6.48643 0,-3.65869 2.678906,-6.51123 l 0.868164,0.86817 q -2.33164,2.46806 -2.33164,5.63066 0,3.29903 2.33164,5.63067 2.3316415,2.31923 5.6306645,2.31923 3.286621,0 5.618261,-2.31923 2.331641,-2.33164 2.331641,-5.60586 0,-2.77813 -1.79834,-5.07256 l -0.533301,-0.58291 q -0.347265,0.49609 -0.855761,2.59209 z" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 3.4 KiB |
|
@ -0,0 +1,84 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="30mm"
|
||||||
|
height="30mm"
|
||||||
|
viewBox="0 0 30 30"
|
||||||
|
version="1.1"
|
||||||
|
id="svg5291"
|
||||||
|
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
|
||||||
|
sodipodi:docname="rotate-right.svg">
|
||||||
|
<defs
|
||||||
|
id="defs5285" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="11.2"
|
||||||
|
inkscape:cx="13.151778"
|
||||||
|
inkscape:cy="65.2238"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:window-width="3840"
|
||||||
|
inkscape:window-height="2035"
|
||||||
|
inkscape:window-x="-13"
|
||||||
|
inkscape:window-y="-13"
|
||||||
|
inkscape:window-maximized="1" />
|
||||||
|
<metadata
|
||||||
|
id="metadata5288">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
<dc:creator>
|
||||||
|
<cc:Agent>
|
||||||
|
<dc:title>Jakub Melka</dc:title>
|
||||||
|
</cc:Agent>
|
||||||
|
</dc:creator>
|
||||||
|
<cc:license
|
||||||
|
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
|
||||||
|
</cc:Work>
|
||||||
|
<cc:License
|
||||||
|
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
|
||||||
|
<cc:permits
|
||||||
|
rdf:resource="http://creativecommons.org/ns#Reproduction" />
|
||||||
|
<cc:permits
|
||||||
|
rdf:resource="http://creativecommons.org/ns#Distribution" />
|
||||||
|
<cc:requires
|
||||||
|
rdf:resource="http://creativecommons.org/ns#Notice" />
|
||||||
|
<cc:requires
|
||||||
|
rdf:resource="http://creativecommons.org/ns#Attribution" />
|
||||||
|
<cc:permits
|
||||||
|
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
|
||||||
|
<cc:requires
|
||||||
|
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
|
||||||
|
</cc:License>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Vrstva 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(0,-267)">
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path1378"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:25.39999962px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
|
||||||
|
d="m 9.6915448,279.12842 q -0.5084961,-2.096 -0.8557617,-2.59209 l -0.5333008,0.58291 q -1.7983398,2.29443 -1.7983398,5.07256 0,3.27422 2.3316406,5.60586 2.3316409,2.31923 5.6182619,2.31923 3.299023,0 5.630664,-2.31923 2.33164,-2.33164 2.33164,-5.63067 0,-3.1626 -2.33164,-5.63066 l 0.868164,-0.86817 q 2.678906,2.85254 2.678906,6.51123 0,3.79512 -2.691309,6.48643 -2.678906,2.67891 -6.486425,2.67891 -3.795117,0 -6.4864259,-2.67891 -2.6913086,-2.69131 -2.6913086,-6.49883 0,-3.63388 2.6913086,-6.49883 L 5.3755292,274.8 11.279045,273.2249 Z" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 3.4 KiB |
Loading…
Reference in New Issue