Skip to content

Commit d73ecb6

Browse files
Fixed color inversion & Bug with tag selection leading to crash
1 parent ab5d79a commit d73ecb6

6 files changed

Lines changed: 49 additions & 7 deletions

File tree

src/adapters/interfaces/controllers/i_opened_book_controller.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class ADAPTERS_EXPORT IOpenedBookController : public QObject
2121
Q_PROPERTY(int pageCount READ getPageCount NOTIFY pageCountChanged)
2222
Q_PROPERTY(int currentPage READ getCurrentPage WRITE setCurrentPage NOTIFY
2323
currentPageChanged)
24+
Q_PROPERTY(QString colorTheme READ getColorTheme WRITE setColorTheme NOTIFY
25+
colorThemeChanged)
2426
Q_PROPERTY(adapters::data_models::BookmarksProxyModel* bookmarksModel READ
2527
getBookmarksModel NOTIFY bookmarksModelChanged)
2628

src/presentation/desktop/homePage/manageTagsPopup/MManageTagsPopup.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Popup {
7979
Layout.fillWidth: true
8080

8181
onAddTag: name => {
82-
// Cant use return value, bc. it is null if tag already exists
82+
// Can't use return value, bc. it is null if tag already exists
8383
UserController.addTag(name)
8484

8585
let tagUuid = UserController.getTagUuidForName(

src/presentation/desktop/homePage/manageTagsPopup/MTagItem.qml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Item {
1111
id: root
1212
required property int index
1313
property bool selected: false
14+
property bool currentlyRenaming: false
1415
readonly property alias renameable: container.renameable
1516
signal removeTag(int index)
1617
signal renamedTag(int index, string text)
@@ -111,6 +112,7 @@ Item {
111112
}
112113

113114
function startRenaming() {
115+
currentlyRenaming = true
114116
content.readOnly = false
115117
content.selectAll()
116118
content.forceActiveFocus()
@@ -120,6 +122,9 @@ Item {
120122
}
121123

122124
function stopRenaming(saveText = true) {
125+
if (!currentlyRenaming)
126+
return
127+
123128
content.readOnly = true
124129
content.select(0, 0)
125130
content.deselect()

src/presentation/desktop/modules/CppElements/document.cpp

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,7 @@ bool Document::event(QEvent *event)
188188
auto *gestureEvent = static_cast<QNativeGestureEvent *>(event);
189189

190190
if (gestureEvent->gestureType() == Qt::ZoomNativeGesture) {
191-
qreal zoomDelta = gestureEvent->value();
192-
193-
qreal newZoom = calculateNewZoom(zoomDelta, std::abs(zoomDelta));
194-
applyZoom(newZoom, ZoomMode::Mouse);
195-
196-
gestureEvent->accept();
191+
handleMousepadZoom(gestureEvent);
197192
return true;
198193
}
199194
}
@@ -217,6 +212,8 @@ void Document::redrawPages()
217212
if(page == nullptr)
218213
{
219214
page = createPage(i);
215+
page->setIncludeNewLinesInCopiedText(m_includeNewLinesInCopiedText);
216+
page->setColorInverted(m_colorInverted);
220217
m_activePages.emplace(i, page);
221218
}
222219

@@ -431,6 +428,16 @@ void Document::setCurrentPageWithOffsetY(int currentPage, int offsetY)
431428
emit currentPageChanged();
432429
}
433430

431+
void Document::handleMousepadZoom(QNativeGestureEvent* event)
432+
{
433+
qreal zoomDelta = event->value();
434+
435+
qreal newZoom = calculateNewZoom(zoomDelta, std::abs(zoomDelta));
436+
applyZoom(newZoom, ZoomMode::Mouse);
437+
438+
event->accept();
439+
}
440+
434441
Qt::Key Document::getShortcut(const QString& value)
435442
{
436443
if(m_settingsController == nullptr)
@@ -616,4 +623,20 @@ void Document::setSettingsController(
616623
m_settingsController = newSettingsController;
617624
}
618625

626+
void Document::setColorInverted(bool newColorInverted)
627+
{
628+
for(auto book : m_activePages.values())
629+
book->setColorInverted(newColorInverted);
630+
631+
m_colorInverted = newColorInverted;
632+
}
633+
634+
void Document::setIncludeNewLinesInCopiedText(bool newIncludeNewLinesInCopiedText)
635+
{
636+
for(auto book : m_activePages.values())
637+
book->setIncludeNewLinesInCopiedText(newIncludeNewLinesInCopiedText);
638+
639+
m_includeNewLinesInCopiedText = newIncludeNewLinesInCopiedText;
640+
}
641+
619642
} // namespace cpp_elements

src/presentation/desktop/modules/CppElements/document.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class PRESENTATION_EXPORT Document : public QQuickItem
3838
Q_PROPERTY(int topPageYOffset READ getTopPageYOffset CONSTANT)
3939
Q_PROPERTY(adapters::IDocumentSearcher* documentSearcher READ
4040
getDocumentSearcher CONSTANT)
41+
Q_PROPERTY(bool colorInverted WRITE setColorInverted)
42+
Q_PROPERTY(bool includeNewLinesInCopiedText WRITE setIncludeNewLinesInCopiedText)
43+
4144

4245
public:
4346
Document();
@@ -67,6 +70,9 @@ class PRESENTATION_EXPORT Document : public QQuickItem
6770
Q_INVOKABLE void restoreCursor();
6871
Q_INVOKABLE void hideCursor();
6972

73+
void setColorInverted(bool newColorInverted);
74+
void setIncludeNewLinesInCopiedText(bool newIncludeNewLinesInCopiedText);
75+
7076
signals:
7177
void mouseMoved(double x, double y);
7278
void contentHeightChanged();
@@ -109,6 +115,7 @@ class PRESENTATION_EXPORT Document : public QQuickItem
109115
void updateCurrentPage();
110116
long getContentYForPage(int page) const;
111117
void setCurrentPageWithOffsetY(int currentPage, int offsetY);
118+
void handleMousepadZoom(QNativeGestureEvent* event);
112119
Qt::Key getShortcut(const QString& value);
113120

114121
adapters::IOpenedBookController* m_openedBookController = nullptr;
@@ -130,6 +137,8 @@ class PRESENTATION_EXPORT Document : public QQuickItem
130137
// Table of Contents
131138
std::unique_ptr<adapters::data_models::FilteredTOCModel> m_filteredTOCModel;
132139
std::unique_ptr<adapters::data_models::TOCModel> m_TOCModel;
140+
bool m_colorInverted;
141+
bool m_includeNewLinesInCopiedText;
133142
};
134143

135144
} // namespace cpp_elements

src/presentation/desktop/readingPage/MDocumentView.qml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ Pane {
4646
anchors.centerIn: parent
4747
openedBookController: root.openedBookController
4848
settingsController: SettingsController
49+
colorInverted: root.openedBookController.colorTheme === "Inverted"
50+
includeNewLinesInCopiedText: SettingsController.behaviorSettings.IncludeNewLinesInCopiedText
51+
=== "ON"
4952
clip: true
5053

5154
onCurrentZoomChanged: root.zoomChanged(document.currentZoom)

0 commit comments

Comments
 (0)