mirror of
https://invent.kde.org/graphics/okular
synced 2024-06-30 22:54:24 +00:00
Compare commits
3 Commits
c6e943c34b
...
8e89c78936
Author | SHA1 | Date | |
---|---|---|---|
|
8e89c78936 | ||
|
e5900f9a4f | ||
|
6fe14f381e |
|
@ -487,6 +487,7 @@ if (TARGET Qt6::Qml)
|
||||||
core/script/js_util.cpp
|
core/script/js_util.cpp
|
||||||
core/script/js_event.cpp
|
core/script/js_event.cpp
|
||||||
core/script/js_ocg.cpp
|
core/script/js_ocg.cpp
|
||||||
|
core/script/js_global.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(okularcore PRIVATE Qt6::Qml)
|
target_link_libraries(okularcore PRIVATE Qt6::Qml)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "js_event_p.h"
|
#include "js_event_p.h"
|
||||||
#include "js_field_p.h"
|
#include "js_field_p.h"
|
||||||
#include "js_fullscreen_p.h"
|
#include "js_fullscreen_p.h"
|
||||||
|
#include "js_global_p.h"
|
||||||
#include "js_ocg_p.h"
|
#include "js_ocg_p.h"
|
||||||
#include "js_spell_p.h"
|
#include "js_spell_p.h"
|
||||||
#include "js_util_p.h"
|
#include "js_util_p.h"
|
||||||
|
@ -71,6 +72,7 @@ void ExecutorJSPrivate::initTypes()
|
||||||
m_interpreter.globalObject().setProperty(QStringLiteral("display"), m_interpreter.newQObject(new JSDisplay));
|
m_interpreter.globalObject().setProperty(QStringLiteral("display"), m_interpreter.newQObject(new JSDisplay));
|
||||||
m_interpreter.globalObject().setProperty(QStringLiteral("spell"), m_interpreter.newQObject(new JSSpell));
|
m_interpreter.globalObject().setProperty(QStringLiteral("spell"), m_interpreter.newQObject(new JSSpell));
|
||||||
m_interpreter.globalObject().setProperty(QStringLiteral("util"), m_interpreter.newQObject(new JSUtil));
|
m_interpreter.globalObject().setProperty(QStringLiteral("util"), m_interpreter.newQObject(new JSUtil));
|
||||||
|
m_interpreter.globalObject().setProperty(QStringLiteral("global"), m_interpreter.newQObject(new JSGlobal));
|
||||||
}
|
}
|
||||||
|
|
||||||
ExecutorJS::ExecutorJS(DocumentPrivate *doc)
|
ExecutorJS::ExecutorJS(DocumentPrivate *doc)
|
||||||
|
|
16
core/script/js_global.cpp
Normal file
16
core/script/js_global.cpp
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
SPDX-FileCopyrightText: 2024 Pratham Gandhi <ppg.1382@gmail.com>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "js_global_p.h"
|
||||||
|
|
||||||
|
using namespace Okular;
|
||||||
|
|
||||||
|
JSGlobal::JSGlobal(QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
JSGlobal::~JSGlobal() = default;
|
25
core/script/js_global_p.h
Normal file
25
core/script/js_global_p.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
SPDX-FileCopyrightText: 2024 Pratham Gandhi <ppg.1382@gmail.com>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef OKULAR_SCRIPT_JS_GLOBAL_P_H
|
||||||
|
#define OKULAR_SCRIPT_JS_GLOBAL_P_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
namespace Okular
|
||||||
|
{
|
||||||
|
|
||||||
|
class JSGlobal : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit JSGlobal(QObject *parent = nullptr);
|
||||||
|
~JSGlobal() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -39,6 +39,7 @@
|
||||||
#include "core/document.h"
|
#include "core/document.h"
|
||||||
#include "core/page.h"
|
#include "core/page.h"
|
||||||
#include "core/signatureutils.h"
|
#include "core/signatureutils.h"
|
||||||
|
#include "core/utils.h"
|
||||||
#include "editannottooldialog.h"
|
#include "editannottooldialog.h"
|
||||||
#include "gui/debug_ui.h"
|
#include "gui/debug_ui.h"
|
||||||
#include "gui/guiutils.h"
|
#include "gui/guiutils.h"
|
||||||
|
@ -224,12 +225,14 @@ public:
|
||||||
ann = ta;
|
ann = ta;
|
||||||
ta->setTextType(Okular::TextAnnotation::Linked);
|
ta->setTextType(Okular::TextAnnotation::Linked);
|
||||||
ta->setTextIcon(iconName);
|
ta->setTextIcon(iconName);
|
||||||
// ta->window.flags &= ~(Okular::Annotation::Hidden);
|
// Calculate annotation width so that icon will be 1/3 inch (i.e., 24 pts) on screen.
|
||||||
const double iconhei = 0.03;
|
// This is required so that painted rectangles match around icons rendered by Poppler.
|
||||||
|
// Poppler enforces 24x24 pts for embedded appearance icons regardless of what we set here.
|
||||||
|
double iconWidth = Okular::Utils::realDpi(nullptr).width() / (3. * pagewidth);
|
||||||
rect.left = point.x;
|
rect.left = point.x;
|
||||||
rect.top = point.y;
|
rect.top = point.y;
|
||||||
rect.right = rect.left + iconhei;
|
rect.right = rect.left + iconWidth;
|
||||||
rect.bottom = rect.top + iconhei * xscale / yscale;
|
rect.bottom = rect.top + iconWidth * xscale / yscale;
|
||||||
ta->window().setSummary(i18n("Pop-up Note"));
|
ta->window().setSummary(i18n("Pop-up Note"));
|
||||||
}
|
}
|
||||||
// create StampAnnotation from path
|
// create StampAnnotation from path
|
||||||
|
|
|
@ -236,14 +236,9 @@ void MouseAnnotation::routePaint(QPainter *painter, const QRect paintRect)
|
||||||
if (!isFocused()) {
|
if (!isFocused()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* Get annotation bounding rectangle in uncropped page coordinates.
|
/* Get annotation bounding rectangle in uncropped page coordinates */
|
||||||
* Distinction between AnnotationUtils::annotationGeometry() and AnnotationObjectRect::boundingRect() is,
|
const QRect boundingRect = m_focusedAnnotation.annotation->transformedBoundingRectangle().geometry(m_focusedAnnotation.pageViewItem->uncroppedWidth(), m_focusedAnnotation.pageViewItem->uncroppedHeight());
|
||||||
* that boundingRect would enlarge the QRect to a minimum size of 14 x 14.
|
|
||||||
* This is useful for getting focus an a very small annotation,
|
|
||||||
* but for drawing and modification we want the real size.
|
|
||||||
*/
|
|
||||||
const QRect boundingRect = Okular::AnnotationUtils::annotationGeometry(m_focusedAnnotation.annotation, m_focusedAnnotation.pageViewItem->uncroppedWidth(), m_focusedAnnotation.pageViewItem->uncroppedHeight());
|
|
||||||
|
|
||||||
if (!paintRect.intersects(boundingRect.translated(m_focusedAnnotation.pageViewItem->uncroppedGeometry().topLeft()).adjusted(-handleSizeHalf, -handleSizeHalf, handleSizeHalf, handleSizeHalf))) {
|
if (!paintRect.intersects(boundingRect.translated(m_focusedAnnotation.pageViewItem->uncroppedGeometry().topLeft()).adjusted(-handleSizeHalf, -handleSizeHalf, handleSizeHalf, handleSizeHalf))) {
|
||||||
/* Our selection rectangle is not in a region that needs to be (re-)drawn. */
|
/* Our selection rectangle is not in a region that needs to be (re-)drawn. */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user