Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev/develop' into feat/translations
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLazarescu committed Nov 10, 2023
2 parents b92faea + 22acf2c commit 3c69d60
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 2 deletions.
3 changes: 2 additions & 1 deletion resources/data/default_appearance_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
"SmoothScrolling": "false",
"LoopAfterLastPage": "false",
"CursorMode": "Hidden after delay",
"HideCursorAfterDelay": "3000",
"DefaultHighlightColorName": "HighlightColorA",
"HighlightColorA": "#F9D36B",
"HighlightColorB": "#7CC767",
"HighlightColorC": "#9877d1",
"HighlightColorD": "#F95C87",
"HighlightColorE": "#69AFF2",
"HighlightOpacity": "200"
}
}
1 change: 1 addition & 0 deletions src/application/common/enums/setting_keys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum class SettingKeys
SmoothScrolling,
LoopAfterLastPage,
CursorMode,
HideCursorAfterDelay,
DefaultHighlightColorName,
HighlightColorA,
HighlightColorB,
Expand Down
3 changes: 2 additions & 1 deletion src/presentation/modules/CppElements/page_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,9 @@ void PageView::hoverMoveEvent(QHoverEvent* event)
{
int mouseX = event->position().x();
int mouseY = event->position().y();

setCorrectCursor(mouseX, mouseY);

emit mouseHoverMoved();
}

void PageView::keyPressEvent(QKeyEvent* event)
Expand Down
3 changes: 3 additions & 0 deletions src/presentation/modules/CppElements/page_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class PRESENTATION_EXPORT PageView : public QQuickItem
Q_INVOKABLE void changeHighlightColor(const QString& uuid,
const QString& color, int alpha);

signals:
void mouseHoverMoved();

private slots:
void updateZoom(float newZoom);

Expand Down
23 changes: 23 additions & 0 deletions src/presentation/readingPage/MDocumentView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ Pane {
}
}

Timer {
id: hideCursorTimer

interval: SettingsController.appearanceSettings.HideCursorAfterDelay
running: SettingsController.appearanceSettings.CursorMode
=== internal.optionNameCursorModeHiddenAfterDelay

onTriggered: mouseArea.cursorShape = Qt.BlankCursor
}

MouseArea {
id: mouseArea
anchors.fill: parent
Expand All @@ -91,6 +101,8 @@ Pane {
// Handle scrolling customly
onWheel: NavigationLogic.handleWheel(wheel)

onPositionChanged: internal.showCursor()

onPressed: mouse.accepted = false
onReleased: mouse.accepted = false

Expand Down Expand Up @@ -130,6 +142,8 @@ Pane {
if (implicitWidth > pageView.contentWidth)
pageView.widestItem = page.implicitWidth
}

onMouseHoverMoved: internal.showCursor()
}

// Set the book's current page once the model is loaded
Expand Down Expand Up @@ -299,6 +313,7 @@ Pane {

QtObject {
id: internal
property string optionNameCursorModeHiddenAfterDelay: "Hidden after delay"

function openSelectionOptionsPopup(centerX, topY) {
if (centerX === -1 && topY === -1) {
Expand Down Expand Up @@ -328,5 +343,13 @@ Pane {

popup.open()
}

function showCursor() {
mouseArea.cursorShape = Qt.ArrowCursor

if (SettingsController.appearanceSettings.CursorMode
=== internal.optionNameCursorModeHiddenAfterDelay)
hideCursorTimer.start()
}
}
}
47 changes: 47 additions & 0 deletions src/presentation/settings/MAppearancePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,53 @@ Page {
SettingKeys.CursorMode,
currentSelected)
}

ColumnLayout {
id: hideCursorAfterDelayFieldLayout
visible: cursorModeSelector.currentSelected
=== "Hidden after delay" ? true : false

Label {
id: hideCursorAfterDelayTitle
Layout.fillWidth: true
Layout.topMargin: 18
text: "Hide cursor after delay"
font.pointSize: Fonts.size13
font.weight: Font.DemiBold
color: Style.colorText
}

RowLayout {
id: hideCursorAfterDelaySpinBoxLayout

MSpinbox {
id: hideCursorAfterDelaySpinBox
property string savedValue: SettingsController.appearanceSettings.HideCursorAfterDelay
Layout.preferredWidth: 100
Layout.topMargin: 4
value: savedValue
minVal: 1
maxVal: 99999

onSavedValueChanged: value = savedValue
onNewValueSelected: internal.saveSetting(
SettingKeys.HideCursorAfterDelay,
value)
}

Text {
text: "ms"
font.pointSize: Fonts.size13
font.weight: Font.DemiBold
color: Style.colorText
}
}

onVisibleChanged: {
if (visible)
flickWrapper.flick(0, -2000)
}
}
}
}
}
Expand Down

0 comments on commit 3c69d60

Please sign in to comment.