mirror of
https://invent.kde.org/graphics/okular
synced 2024-06-30 22:54:24 +00:00
Compare commits
8 Commits
3ce2faa151
...
30370b1da3
Author | SHA1 | Date | |
---|---|---|---|
|
30370b1da3 | ||
|
e5900f9a4f | ||
|
b0ba4a343d | ||
|
10e622c356 | ||
|
10b0e0cfd9 | ||
|
fefcd396a7 | ||
|
4a6d28ddb8 | ||
|
785bdb7c05 |
|
@ -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
|
|
@ -217,6 +217,10 @@ public:
|
||||||
QPoint dragScrollVector;
|
QPoint dragScrollVector;
|
||||||
QTimer dragScrollTimer;
|
QTimer dragScrollTimer;
|
||||||
|
|
||||||
|
// page scroll
|
||||||
|
int pageScrollDelta = 0;
|
||||||
|
QTimer pageScrollTimer;
|
||||||
|
|
||||||
// left click depress
|
// left click depress
|
||||||
QTimer leftClickTimer;
|
QTimer leftClickTimer;
|
||||||
|
|
||||||
|
@ -422,6 +426,8 @@ PageView::PageView(QWidget *parent, Okular::Document *document)
|
||||||
|
|
||||||
connect(&d->dragScrollTimer, &QTimer::timeout, this, &PageView::slotDragScroll);
|
connect(&d->dragScrollTimer, &QTimer::timeout, this, &PageView::slotDragScroll);
|
||||||
|
|
||||||
|
connect(&d->pageScrollTimer, &QTimer::timeout, this, &PageView::slotPageScroll);
|
||||||
|
|
||||||
d->leftClickTimer.setSingleShot(true);
|
d->leftClickTimer.setSingleShot(true);
|
||||||
connect(&d->leftClickTimer, &QTimer::timeout, this, &PageView::slotShowSizeAllCursor);
|
connect(&d->leftClickTimer, &QTimer::timeout, this, &PageView::slotShowSizeAllCursor);
|
||||||
|
|
||||||
|
@ -2183,6 +2189,56 @@ void PageView::continuousZoomEnd()
|
||||||
updateCursor();
|
updateCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PageView::isPageScroll(int delta)
|
||||||
|
{
|
||||||
|
bool pageScroll = false;
|
||||||
|
int vScroll = verticalScrollBar()->value();
|
||||||
|
|
||||||
|
d->pageScrollDelta += delta;
|
||||||
|
if (d->pageScrollTimer.isActive()) {
|
||||||
|
d->pageScrollTimer.stop();
|
||||||
|
}
|
||||||
|
d->pageScrollTimer.setSingleShot(true);
|
||||||
|
d->pageScrollTimer.start(500);
|
||||||
|
|
||||||
|
if (d->pageScrollDelta <= -QWheelEvent::DefaultDeltasPerStep && vScroll == verticalScrollBar()->maximum()) {
|
||||||
|
// go to next page
|
||||||
|
if ((int)d->document->currentPage() < d->items.count() - 1) {
|
||||||
|
// more optimized than document->setNextPage and then move view to top
|
||||||
|
Okular::DocumentViewport newViewport = d->document->viewport();
|
||||||
|
newViewport.pageNumber += viewColumns();
|
||||||
|
if (newViewport.pageNumber >= (int)d->items.count()) {
|
||||||
|
newViewport.pageNumber = d->items.count() - 1;
|
||||||
|
}
|
||||||
|
newViewport.rePos.enabled = true;
|
||||||
|
newViewport.rePos.normalizedY = 0.0;
|
||||||
|
d->document->setViewport(newViewport);
|
||||||
|
d->scroller->scrollTo(QPoint(horizontalScrollBar()->value(), verticalScrollBar()->value()), 0); // sync scroller with scrollbar
|
||||||
|
d->pageScrollDelta = 0;
|
||||||
|
pageScroll = true;
|
||||||
|
}
|
||||||
|
} else if (d->pageScrollDelta >= QWheelEvent::DefaultDeltasPerStep && vScroll == verticalScrollBar()->minimum()) {
|
||||||
|
// go to prev page
|
||||||
|
if (d->document->currentPage() > 0) {
|
||||||
|
// more optimized than document->setPrevPage and then move view to bottom
|
||||||
|
Okular::DocumentViewport newViewport = d->document->viewport();
|
||||||
|
newViewport.pageNumber -= viewColumns();
|
||||||
|
if (newViewport.pageNumber < 0) {
|
||||||
|
newViewport.pageNumber = 0;
|
||||||
|
}
|
||||||
|
newViewport.rePos.enabled = true;
|
||||||
|
newViewport.rePos.normalizedY = 1.0;
|
||||||
|
d->document->setViewport(newViewport);
|
||||||
|
d->scroller->scrollTo(QPoint(horizontalScrollBar()->value(), verticalScrollBar()->value()), 0); // sync scroller with scrollbar
|
||||||
|
d->pageScrollDelta = 0;
|
||||||
|
pageScroll = true;
|
||||||
|
}
|
||||||
|
} else if ((d->pageScrollDelta < 0 && vScroll == verticalScrollBar()->maximum()) || (d->pageScrollDelta > 0 && vScroll == verticalScrollBar()->minimum())) {
|
||||||
|
pageScroll = true;
|
||||||
|
}
|
||||||
|
return pageScroll;
|
||||||
|
}
|
||||||
|
|
||||||
void PageView::mouseMoveEvent(QMouseEvent *e)
|
void PageView::mouseMoveEvent(QMouseEvent *e)
|
||||||
{
|
{
|
||||||
d->previousMouseMovePos = e->globalPosition();
|
d->previousMouseMovePos = e->globalPosition();
|
||||||
|
@ -2313,6 +2369,8 @@ void PageView::mouseMoveEvent(QMouseEvent *e)
|
||||||
|
|
||||||
void PageView::mousePressEvent(QMouseEvent *e)
|
void PageView::mousePressEvent(QMouseEvent *e)
|
||||||
{
|
{
|
||||||
|
d->pageScrollDelta = 0;
|
||||||
|
|
||||||
// don't perform any mouse action when no document is shown
|
// don't perform any mouse action when no document is shown
|
||||||
if (d->items.isEmpty()) {
|
if (d->items.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -2512,6 +2570,8 @@ void PageView::mousePressEvent(QMouseEvent *e)
|
||||||
|
|
||||||
void PageView::mouseReleaseEvent(QMouseEvent *e)
|
void PageView::mouseReleaseEvent(QMouseEvent *e)
|
||||||
{
|
{
|
||||||
|
d->pageScrollDelta = 0;
|
||||||
|
|
||||||
// stop the drag scrolling
|
// stop the drag scrolling
|
||||||
d->dragScrollTimer.stop();
|
d->dragScrollTimer.stop();
|
||||||
|
|
||||||
|
@ -3159,6 +3219,8 @@ void PageView::guessTableDividers()
|
||||||
|
|
||||||
void PageView::mouseDoubleClickEvent(QMouseEvent *e)
|
void PageView::mouseDoubleClickEvent(QMouseEvent *e)
|
||||||
{
|
{
|
||||||
|
d->pageScrollDelta = 0;
|
||||||
|
|
||||||
if (e->button() == Qt::LeftButton) {
|
if (e->button() == Qt::LeftButton) {
|
||||||
const QPoint eventPos = contentAreaPoint(e->pos());
|
const QPoint eventPos = contentAreaPoint(e->pos());
|
||||||
PageViewItem *pageItem = pickItemOnPoint(eventPos.x(), eventPos.y());
|
PageViewItem *pageItem = pickItemOnPoint(eventPos.x(), eventPos.y());
|
||||||
|
@ -3209,40 +3271,16 @@ void PageView::wheelEvent(QWheelEvent *e)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int delta = e->angleDelta().y(), vScroll = verticalScrollBar()->value();
|
int delta = e->angleDelta().y();
|
||||||
e->accept();
|
e->accept();
|
||||||
if ((e->modifiers() & Qt::ControlModifier) == Qt::ControlModifier) {
|
if ((e->modifiers() & Qt::ControlModifier) == Qt::ControlModifier) {
|
||||||
continuousZoom(delta);
|
continuousZoom(delta);
|
||||||
} else {
|
} else {
|
||||||
if (delta <= -QWheelEvent::DefaultDeltasPerStep && !getContinuousMode() && vScroll == verticalScrollBar()->maximum()) {
|
bool skipScroll = false;
|
||||||
// go to next page
|
if (!getContinuousMode()) {
|
||||||
if ((int)d->document->currentPage() < d->items.count() - 1) {
|
skipScroll = isPageScroll(delta);
|
||||||
// more optimized than document->setNextPage and then move view to top
|
}
|
||||||
Okular::DocumentViewport newViewport = d->document->viewport();
|
if (!skipScroll) {
|
||||||
newViewport.pageNumber += viewColumns();
|
|
||||||
if (newViewport.pageNumber >= (int)d->items.count()) {
|
|
||||||
newViewport.pageNumber = d->items.count() - 1;
|
|
||||||
}
|
|
||||||
newViewport.rePos.enabled = true;
|
|
||||||
newViewport.rePos.normalizedY = 0.0;
|
|
||||||
d->document->setViewport(newViewport);
|
|
||||||
d->scroller->scrollTo(QPoint(horizontalScrollBar()->value(), verticalScrollBar()->value()), 0); // sync scroller with scrollbar
|
|
||||||
}
|
|
||||||
} else if (delta >= QWheelEvent::DefaultDeltasPerStep && !getContinuousMode() && vScroll == verticalScrollBar()->minimum()) {
|
|
||||||
// go to prev page
|
|
||||||
if (d->document->currentPage() > 0) {
|
|
||||||
// more optimized than document->setPrevPage and then move view to bottom
|
|
||||||
Okular::DocumentViewport newViewport = d->document->viewport();
|
|
||||||
newViewport.pageNumber -= viewColumns();
|
|
||||||
if (newViewport.pageNumber < 0) {
|
|
||||||
newViewport.pageNumber = 0;
|
|
||||||
}
|
|
||||||
newViewport.rePos.enabled = true;
|
|
||||||
newViewport.rePos.normalizedY = 1.0;
|
|
||||||
d->document->setViewport(newViewport);
|
|
||||||
d->scroller->scrollTo(QPoint(horizontalScrollBar()->value(), verticalScrollBar()->value()), 0); // sync scroller with scrollbar
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// When the shift key is held down, scroll ten times faster
|
// When the shift key is held down, scroll ten times faster
|
||||||
int multiplier = e->modifiers() & Qt::ShiftModifier ? 10 : 1;
|
int multiplier = e->modifiers() & Qt::ShiftModifier ? 10 : 1;
|
||||||
|
|
||||||
|
@ -3257,6 +3295,7 @@ void PageView::wheelEvent(QWheelEvent *e)
|
||||||
} else {
|
} else {
|
||||||
d->scroller->scrollTo(d->scroller->finalPosition() - e->angleDelta() * multiplier, 0);
|
d->scroller->scrollTo(d->scroller->finalPosition() - e->angleDelta() * multiplier, 0);
|
||||||
}
|
}
|
||||||
|
d->pageScrollDelta = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4909,6 +4948,11 @@ void PageView::slotDragScroll()
|
||||||
updateSelection(p);
|
updateSelection(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PageView::slotPageScroll()
|
||||||
|
{
|
||||||
|
d->pageScrollDelta = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void PageView::slotShowWelcome()
|
void PageView::slotShowWelcome()
|
||||||
{
|
{
|
||||||
// show initial welcome text
|
// show initial welcome text
|
||||||
|
|
|
@ -242,6 +242,9 @@ private:
|
||||||
*/
|
*/
|
||||||
bool getContinuousMode() const;
|
bool getContinuousMode() const;
|
||||||
|
|
||||||
|
// Hangle page scrolling in non-continuous mode
|
||||||
|
bool isPageScroll(int delta);
|
||||||
|
|
||||||
// Zoom around the point given as zoomCenter
|
// Zoom around the point given as zoomCenter
|
||||||
// zoomCenter is given in viewport coordinates
|
// zoomCenter is given in viewport coordinates
|
||||||
// newZoom is the intended new zoom level. A value of 0.0 means: Don't change the current zoom level.
|
// newZoom is the intended new zoom level. A value of 0.0 means: Don't change the current zoom level.
|
||||||
|
@ -264,6 +267,8 @@ private Q_SLOTS:
|
||||||
void slotAutoScroll();
|
void slotAutoScroll();
|
||||||
// activated by the dragScroll timer
|
// activated by the dragScroll timer
|
||||||
void slotDragScroll();
|
void slotDragScroll();
|
||||||
|
// activated by the pageScroll timer
|
||||||
|
void slotPageScroll();
|
||||||
// show the welcome message
|
// show the welcome message
|
||||||
void slotShowWelcome();
|
void slotShowWelcome();
|
||||||
// activated by left click timer
|
// activated by left click timer
|
||||||
|
|
|
@ -21,7 +21,7 @@ msgstr ""
|
||||||
"Project-Id-Version: kdegraphics-kde4\n"
|
"Project-Id-Version: kdegraphics-kde4\n"
|
||||||
"Report-Msgid-Bugs-To: https://bugs.kde.org\n"
|
"Report-Msgid-Bugs-To: https://bugs.kde.org\n"
|
||||||
"POT-Creation-Date: 2024-06-20 00:38+0000\n"
|
"POT-Creation-Date: 2024-06-20 00:38+0000\n"
|
||||||
"PO-Revision-Date: 2024-03-22 16:14+0300\n"
|
"PO-Revision-Date: 2024-06-22 13:04+0300\n"
|
||||||
"Last-Translator: Emir SARI <emir_sari@icloud.com>\n"
|
"Last-Translator: Emir SARI <emir_sari@icloud.com>\n"
|
||||||
"Language-Team: Turkish <kde-l10n-tr@kde.org>\n"
|
"Language-Team: Turkish <kde-l10n-tr@kde.org>\n"
|
||||||
"Language: tr\n"
|
"Language: tr\n"
|
||||||
|
@ -29,7 +29,7 @@ msgstr ""
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||||
"X-Generator: Lokalize 24.02.1\n"
|
"X-Generator: Lokalize 24.07.70\n"
|
||||||
|
|
||||||
#, kde-format
|
#, kde-format
|
||||||
msgctxt "NAME OF TRANSLATORS"
|
msgctxt "NAME OF TRANSLATORS"
|
||||||
|
@ -4768,7 +4768,7 @@ msgstr "Küçük görselleri sayfa ile eşzamanla"
|
||||||
#: part/part.cpp:3126
|
#: part/part.cpp:3126
|
||||||
#, kde-format
|
#, kde-format
|
||||||
msgid "Add Bookmark"
|
msgid "Add Bookmark"
|
||||||
msgstr "Yer İmi Ekle"
|
msgstr "Yer İmi Koy"
|
||||||
|
|
||||||
#: part/part.cpp:3148
|
#: part/part.cpp:3148
|
||||||
#, kde-format
|
#, kde-format
|
||||||
|
|
|
@ -2887,7 +2887,7 @@ msgstr "启用图像抗锯齿"
|
||||||
#, kde-format
|
#, kde-format
|
||||||
msgctxt "@option:check Config dialog, performance page"
|
msgctxt "@option:check Config dialog, performance page"
|
||||||
msgid "Enable text hinting"
|
msgid "Enable text hinting"
|
||||||
msgstr "启用文字微调"
|
msgstr "启用字体轮廓微调"
|
||||||
|
|
||||||
#: part/dlgperformance.cpp:77
|
#: part/dlgperformance.cpp:77
|
||||||
#, kde-format
|
#, kde-format
|
||||||
|
|
Loading…
Reference in New Issue
Block a user