/
NotebookView.qml
3141 lines (2788 loc) · 147 KB
/
NotebookView.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/****************************************************************************
**
** Copyright (C) TERIFLIX Entertainment Spaces Pvt. Ltd. Bengaluru
** Author: Prashanth N Udupa (prashanth.udupa@teriflix.com)
**
** This code is distributed under GPL v3. Complete text of the license
** can be found here: https://www.gnu.org/licenses/gpl-3.0.txt
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
import QtQml 2.15
import QtQuick 2.15
import Qt.labs.settings 1.0
import QtQuick.Dialogs 1.3
import QtQuick.Controls 2.15
import QtQuick.Controls.Material 2.15
import QtQuick.Controls 1.4 as OldControls
import io.scrite.components 1.0
Rectangle {
id: notebookView
property real toolbarSize: 46
property real toolbarSpacing: 0
property real toolbarLeftMargin: 0
property real toolButtonSize: Math.max(toolbarSize - 4, 20)
property real maxTextAreaSize: idealAppFontMetrics.averageCharacterWidth * 80
property real minTextAreaSize: idealAppFontMetrics.averageCharacterWidth * 20
function switchToStoryTab() {
switchTo(Scrite.document.structure.notes)
}
function switchToSceneTab() {
var currentScene = Scrite.document.screenplay.activeScene
if(currentScene)
switchTo(currentScene.notes)
}
function switchToCharacterTab(name) {
var character = Scrite.document.structure.findCharacter(name)
if(character)
switchTo(character.notes)
}
function switchTo(item) {
if(typeof item === "string") {
var midx
if(item === "Notebook Bookmarks")
midx = notebookTree.model.findModelIndexForCategory(NotebookModel.BookmarksCategory)
else if(item === "Notebook Story")
midx = notebookTree.model.findModelIndexForCategory(NotebookModel.ScreenplayCategory)
else if(item === "Notebook Characters")
midx = notebookTree.model.findModelIndexForCategory(NotebookModel.CharactersCategory)
else
midx = notebookTree.model.findModelIndexForTopLevelItem(item)
notebookTree.setCurrentIndex( midx )
} else
notebookTree.setCurrentIndex( notebookTree.model.findModelIndexFor(item) )
}
NotebookModel {
id: notebookModel
document: Scrite.document.loading ? null : Scrite.document
onAboutToRefresh: noteCurrentItem()
onJustRefreshed: restoreCurrentItem()
onAboutToReloadScenes: noteCurrentItem()
onJustReloadedScenes: restoreCurrentItem()
onAboutToReloadCharacters: noteCurrentItem()
onJustReloadedCharacters: restoreCurrentItem()
property var preferredItem
property var currentItem
function noteCurrentItem() {
currentItem = notebookTree.currentData.notebookItemObject
}
function restoreCurrentItem() {
if(preferredItem)
switchTo(preferredItem)
else
switchTo(currentItem)
currentItem = null
preferredItem = null
}
}
Connections {
target: screenplayAdapter.isSourceScreenplay ? Scrite.document.screenplay : null
function onElementInserted(element, index) {
notebookModel.preferredItem = element.elementType === ScreenplayElement.BreakElementType ? element : element.scene.notes
}
function onElementMoved(element, from, to) {
notebookModel.preferredItem = element.elementType === ScreenplayElement.BreakElementType ? element : element.scene.notes
}
function onCurrentElementIndexChanged(val) {
if(workspaceSettings.syncCurrentSceneOnNotebook)
notebookTree.activateFromCurrentScreenplayElement()
}
}
Connections {
target: Scrite.document
ignoreUnknownSignals: true
function onLoadingChanged() {
if(!Scrite.document.loading)
notebookTree.activateFromCurrentScreenplayElement()
}
}
Component.onCompleted: {
notebookTree.activateFromCurrentScreenplayElement()
Scrite.user.logActivity1("notebook")
}
FontMetrics {
id: fontMetrics
font.pointSize: Scrite.app.idealFontPointSize
}
Rectangle {
id: toolbar
width: toolButtonSize+4
height: parent.height
color: primaryColors.c100.background
Column {
id: toolbarLayout
width: toolButtonSize
anchors.horizontalCenter: parent.horizontalCenter
ToolButton3 {
id: structureTabButton
visible: ui.showNotebookInStructure
iconSource: "../icons/navigation/structure_tab.png"
ToolTip.text: "Structure Tab (" + Scrite.app.polishShortcutTextForDisplay("Alt+2") + ")"
suggestedWidth: toolButtonSize
suggestedHeight: toolButtonSize
onClicked: Announcement.shout("190B821B-50FE-4E47-A4B2-BDBB2A13B72C", "Structure")
}
ToolButton3 {
id: notebookTabButton
visible: ui.showNotebookInStructure
iconSource: "../icons/navigation/notebook_tab.png"
down: true
ToolTip.text: "Notebook\t(" + Scrite.app.polishShortcutTextForDisplay("Alt+3") + ")"
suggestedWidth: toolButtonSize
suggestedHeight: toolButtonSize
}
Rectangle {
width: parent.width
height: 1
color: primaryColors.separatorColor
opacity: 0.5
}
ToolButton3 {
checkable: true
iconSource: "../icons/navigation/sync.png"
ToolTip.text: "If checked; episodes, acts and scenes selected on the notebook will be made current in screenplay editor & timeline"
checked: workspaceSettings.syncCurrentSceneOnNotebook
onToggled: {
workspaceSettings.syncCurrentSceneOnNotebook = checked
if(checked)
notebookTree.activateFromCurrentScreenplayElement()
}
suggestedWidth: toolButtonSize
suggestedHeight: toolButtonSize
}
ToolButton3 {
id: refreshButton
iconSource: "../icons/navigation/refresh.png"
ToolTip.text: "Reloads the current character relationships graph and the notebook tree."
property bool refreshAck: false
onClicked: {
refreshAck = false
Announcement.shout("3F96A262-A083-478C-876E-E3AFC26A0507", "refresh")
if(refreshAck)
Scrite.app.execLater(refreshButton, 250, function() { notebookModel.refresh() })
else
notebookModel.refresh()
}
suggestedWidth: toolButtonSize
suggestedHeight: toolButtonSize
}
ToolButton3 {
id: pdfExportButton
iconSource: "../icons/file/generate_pdf.png"
ToolTip.text: "Export the current character relationship graph to PDF."
onClicked: Announcement.shout("3F96A262-A083-478C-876E-E3AFC26A0507", "pdfexport")
suggestedWidth: toolButtonSize
suggestedHeight: toolButtonSize
property int crGraphViewCount: 0
enabled: crGraphViewCount > 0
Announcement.onIncoming: (type,data) => {
const stype = ""+type
const idata = 0+data
if(stype === "4D37E093-1F58-4978-8060-CD6B9AD4E03C")
crGraphViewCount += idata
}
}
Rectangle {
width: parent.width
height: 1
color: primaryColors.separatorColor
opacity: 0.5
}
ToolButton3 {
id: newNoteToolButton
iconSource: "../icons/action/note_add.png"
hasMenu: true
suggestedWidth: toolButtonSize
suggestedHeight: toolButtonSize
property Notes notes: notebookTree.currentNotes
enabled: notes && !Scrite.document.readOnly
ToolTip.text: {
var ret = "Adds a new text or form note"
if(!enabled)
return ret
ret += " to" + notebookTree.currentData.notebookItemTitle
return ret
}
down: newNoteMenu.visible
onClicked: {
newNoteMenu.notes = notes
newNoteMenu.popup(newNoteToolButton, newNoteToolButton.width, 0)
}
shortcut: "Ctrl+T"
ShortcutsModelItem.group: "Notebook"
ShortcutsModelItem.title: "New Note"
ShortcutsModelItem.shortcut: shortcut
ShortcutsModelItem.enabled: enabled
}
ToolButton3 {
id: noteColorButton
property Character character: notebookTree.currentCharacter
property Note note: notebookTree.currentNote
property Notes notes: notebookTree.currentNotes
suggestedWidth: toolButtonSize
suggestedHeight: toolButtonSize
hasMenu: true
enabled: (character || note || (notes && notes.ownerType === Notes.SceneOwner)) && !Scrite.document.readOnly
iconSource: {
if(note)
return "image://color/" + note.color + "/1"
if(character)
return "image://color/" + character.color + "/1"
if(notes && notes.ownerType === Notes.SceneOwner)
return "image://color/" + notes.scene.color + "/1"
return "image://color/#00ffffff/1"
}
down: noteColorMenu.visible
onClicked: noteColorMenu.popup(noteColorButton, noteColorButton.width, 0)
ColorMenu {
id: noteColorMenu
enabled: noteColorButton.enabled
onMenuItemClicked: {
if(noteColorButton.note)
noteColorButton.note.color = color
else if(noteColorButton.character)
noteColorButton.character.color = color
else if(noteColorButton.notes && noteColorButton.notes.ownerType === Notes.SceneOwner)
noteColorButton.notes.scene.color = color
}
}
}
ToolButton3 {
id: bookmarkButton
suggestedWidth: toolButtonSize
suggestedHeight: toolButtonSize
ToolTip.text: "Toggle bookmark of a Note, Scene, Episode/Act Notes or Character"
enabled: noteColorButton.note || noteColorButton.notes || noteColorButton.character
property var notebookObject: notebookTree.currentData.notebookItemObject
onNotebookObjectChanged: updateIcon()
onClicked: {
notebookModel.bookmarkedNotes.toggleBookmark(notebookObject)
updateIcon()
}
function updateIcon() {
if(enabled && notebookModel.bookmarkedNotes.isBookmarked(notebookObject))
iconSource = "../icons/content/bookmark.png"
else
iconSource = "../icons/content/bookmark_outline.png"
}
shortcut: "Ctrl+D"
ShortcutsModelItem.group: "Notebook"
ShortcutsModelItem.title: "Toggle Bookmark"
ShortcutsModelItem.shortcut: shortcut
ShortcutsModelItem.enabled: enabled
}
ToolButton3 {
id: deleteNoteButton
suggestedWidth: toolButtonSize
suggestedHeight: toolButtonSize
enabled: (noteColorButton.note || noteColorButton.character) && !Scrite.document.readOnly
ToolTip.text: "Delete the current note or character"
iconSource: "../icons/action/delete.png"
onClicked: notebookContentLoader.confirmAndDelete()
}
}
Rectangle {
width: 1
height: parent.height
anchors.right: parent.right
color: primaryColors.borderColor
}
}
SplitView {
orientation: Qt.Horizontal
anchors.top: parent.top
anchors.left: toolbar.right
anchors.right: parent.right
anchors.bottom: parent.bottom
Material.background: Qt.darker(primaryColors.button.background, 1.1)
OldControls.TreeView {
id: notebookTree
SplitView.preferredWidth: Math.min(350, notebookView.width*0.25)
SplitView.minimumWidth: 150
clip: true
headerVisible: false
model: notebookModel
frameVisible: false
backgroundVisible: false
alternatingRowColors: false
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
verticalScrollBarPolicy: Qt.ScrollBarAlwaysOn
rowDelegate: Rectangle {
height: fontMetrics.height + 20
color: styleData.selected ? primaryColors.highlight.background : primaryColors.c10.background
}
EventFilter.events: [EventFilter.Wheel]
EventFilter.onFilter: {
if(event.type === EventFilter.Wheel && event.orientation === Qt.Horizontal) {
result.filter = true
result.acceptEvent = true
}
}
property var currentData: model.modelIndexData(currentIndex)
property Notes currentNotes: {
if(currentData.notebookItemType === NotebookModel.NotesType)
return currentData.notebookItemObject
if(currentData.notebookItemType === NotebookModel.NoteType)
return currentData.notebookItemObject.notes
if(currentData.notebookItemType === NotebookModel.CategoryType &&
currentData.notebookItemCategory === NotebookModel.ScreenplayCategory)
return Scrite.document.structure.notes
return null
}
property Note currentNote: currentData.notebookItemType === NotebookModel.NoteType ? currentData.notebookItemObject : null
property Character currentCharacter: currentNotes && currentNotes.ownerType === Notes.CharacterOwner ? currentNotes.character : null
itemDelegate: Item {
Rectangle {
width: notebookTree.width - parent.x
height: fontMetrics.height + 20
color: {
if(styleData.selected)
return primaryColors.highlight.background
var baseColor = undefined
if(styleData.value.notebookItemType === NotebookModel.NotesType) {
switch(styleData.value.notebookItemObject.ownerType) {
case Notes.SceneOwner:
case Notes.CharacterOwner:
baseColor = styleData.value.notebookItemObject.color
break
default:
break
}
} else if(styleData.value.notebookItemType === NotebookModel.NoteType)
baseColor = styleData.value.notebookItemObject.color
if(baseColor)
return Qt.tint(baseColor, "#E7FFFFFF")
return primaryColors.c10.background
}
Row {
width: parent.width
height: parent.height
spacing: 5
Item {
width: 1
height: parent.height
visible: itemDelegateIcon.visible
}
Image {
id: itemDelegateIcon
width: parent.height * 0.6
height: width
mipmap: true
anchors.verticalCenter: parent.verticalCenter
visible: source != ""
opacity: {
switch(styleData.value.notebookItemType) {
case NotebookModel.EpisodeBreakType:
case NotebookModel.ActBreakType:
return styleData.value.notebookItemObject ? 1 : 0.5
}
return 1
}
source: {
switch(styleData.value.notebookItemType) {
case NotebookModel.EpisodeBreakType:
return "../icons/content/episode.png"
case NotebookModel.ActBreakType:
return "../icons/content/act.png"
case NotebookModel.NotesType:
switch(styleData.value.notebookItemObject.ownerType) {
case Notes.SceneOwner:
return "../icons/content/scene.png"
case Notes.CharacterOwner:
return "../icons/content/person_outline.png"
case Notes.BreakOwner:
return "../icons/content/story.png"
default:
break
}
break;
case NotebookModel.NoteType:
switch(styleData.value.notebookItemObject.type) {
case Note.TextNoteType:
return "../icons/content/note.png"
case Note.FormNoteType:
return "../icons/content/form.png"
default:
break
}
break;
}
return ""
}
}
Text {
id: itemDelegateText
padding: 5
font.family: fontMetrics.font.family
font.pointSize: fontMetrics.font.pointSize
font.capitalization: fontMetrics.font.capitalization
font.bold: styleData.value.notebookItemType === NotebookModel.CategoryType ||
(styleData.value.notebookItemType === NotebookModel.NotesType &&
styleData.value.notebookItemObject.ownerType === Notes.StructureOwner)
text: styleData.value.notebookItemTitle ? styleData.value.notebookItemTitle : ""
color: Scrite.app.isLightColor(parent.parent.color) ? "black" : "white"
elide: Text.ElideRight
width: parent.width-(itemDelegateIcon.visible ? (itemDelegateIcon.width+parent.spacing) : 0)
anchors.verticalCenter: parent.verticalCenter
}
}
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton
onClicked: {
if(styleData.value.notebookItemType === NotebookModel.NoteType) {
noteContextMenu.note = styleData.value.notebookItemObject
noteContextMenu.popup()
} else if(styleData.value.notebookItemType === NotebookModel.NotesType &&
styleData.value.notebookItemObject.ownerType === Notes.CharacterOwner) {
characterContextMenu.character = styleData.value.notebookItemObject.character
characterContextMenu.characterItem = parent
characterContextMenu.popup()
}
}
}
}
OldControls.TableViewColumn {
title: "Name"
role: "notebookItemData"
width: 300
movable: false
resizable: false
}
function activateFromCurrentScreenplayElement() {
var spobj = Scrite.document.screenplay
var element = spobj.elementAt(spobj.currentElementIndex)
if(element) {
if(element.elementType === ScreenplayElement.BreakElementType)
switchTo(element)
else
switchTo(element.scene.notes)
}
}
function activateScreenplayElement(_modelData) {
var makeSceneCurrent = function(notes) {
if(notes.ownerType === Notes.SceneOwner) {
var scene = notes.owner
var idxes = scene.screenplayElementIndexList
if(idxes.length > 0)
Scrite.document.screenplay.currentElementIndex = idxes[0]
}
}
switch(_modelData.notebookItemType) {
case NotebookModel.EpisodeBreakType:
case NotebookModel.ActBreakType:
if(_modelData.notebookItemObject)
Scrite.document.screenplay.currentElementIndex = Scrite.document.screenplay.indexOfElement(_modelData.notebookItemObject)
break
case NotebookModel.NotesType:
makeSceneCurrent(_modelData.notebookItemObject)
break
case NotebookModel.NoteType:
makeSceneCurrent(_modelData.notebookItemObject.notes)
break
default:
break
}
}
onClicked: {
if(mainTabBar.currentIndex != 1 || workspaceSettings.syncCurrentSceneOnNotebook)
activateScreenplayElement( notebookModel.modelIndexData(index) )
}
onDoubleClicked: {
activateScreenplayElement( notebookModel.modelIndexData(index) )
if(isExpanded(index))
collapse(index)
else
expand(index)
}
function setCurrentIndex(modelIndex) {
var pmi = modelIndex.parent
while(pmi.valid) {
notebookTree.expand(pmi)
pmi = pmi.parent
}
var row = 0
while(1) {
var idx = notebookTree.__model.mapRowToModelIndex(row)
if(!idx.valid)
break
if(idx === modelIndex) {
notebookTree.__listView.currentIndex = row
notebookTree.__listView.positionViewAtIndex(row, ListView.Contain)
break
}
++row
}
}
}
Rectangle {
color: {
// Keep these colors in sync with actual component colors loaded
// by notebookContentLoader
if(!notebookTree.currentData)
return Qt.rgba(0,0,0,0)
switch(notebookTree.currentData.notebookItemType) {
case NotebookModel.CategoryType:
switch(notebookTree.currentData.notebookItemCategory) {
case NotebookModel.ScreenplayCategory:
return "white"
case NotebookModel.UnusedScenesCategory:
case NotebookModel.CharactersCategory:
return Qt.rgba(0,0,0,0)
case NotebookModel.BookmarksCategory:
return Scrite.app.translucent(primaryColors.c100.background, 0.5)
}
break
case NotebookModel.NotesType:
switch(notebookTree.currentData.notebookItemObject.ownerType) {
case Notes.CharacterOwner: {
const character = notebookTree.currentData.notebookItemObject.character
return Qt.tint(character.color, "#e7ffffff")
}
case Notes.SceneOwner: {
const notes = notebookTree.currentData.notebookItemObject
const scene = notes.scene
return Qt.tint(scene.color, "#e7ffffff")
}
default:
return Scrite.app.translucent(primaryColors.c100.background, 0.5)
}
case NotebookModel.NoteType:
switch(notebookTree.currentData.notebookItemObject.type) {
case Note.TextNoteType:
case Note.FormNoteType:
const note = notebookTree.currentData.notebookItemObject
return Qt.tint(note.color, "#E7FFFFFF")
}
break
case NotebookModel.EpisodeBreakType:
case NotebookModel.ActBreakType:
return Qt.rgba(0,0,0,0)
}
return Qt.rgba(0,0,0,0)
}
Loader {
id: notebookContentLoader
opacity: notebookContentActiveProperty.value ? 1 : 0
anchors.fill: parent
Behavior on opacity {
NumberAnimation { duration: notebookContentActiveProperty.delay-50 }
}
active: opacity > 0
property int currentNotebookItemId: notebookTree.currentData ? notebookTree.currentData.notebookItemId : -1
ResetOnChange {
id: notebookContentActiveProperty
trackChangesOn: notebookContentLoader.currentNotebookItemId
from: false
to: true
delay: 250
}
sourceComponent: {
if(!notebookTree.currentData)
return unknownComponent
switch(notebookTree.currentData.notebookItemType) {
case NotebookModel.CategoryType:
switch(notebookTree.currentData.notebookItemCategory) {
case NotebookModel.ScreenplayCategory:
return screenplayComponent
case NotebookModel.UnusedScenesCategory:
return unusedScenesComponent
case NotebookModel.CharactersCategory:
return charactersComponent
case NotebookModel.BookmarksCategory:
return bookmarksComponent
}
break
case NotebookModel.NotesType:
switch(notebookTree.currentData.notebookItemObject.ownerType) {
case Notes.CharacterOwner:
return characterNotesComponent
case Notes.SceneOwner:
return sceneNotesComponent
default:
return notesComponent
}
case NotebookModel.NoteType:
switch(notebookTree.currentData.notebookItemObject.type) {
case Note.TextNoteType:
return textNoteComponent
case Note.FormNoteType:
return formNoteComponent
}
break
case NotebookModel.EpisodeBreakType:
case NotebookModel.ActBreakType:
return episodeOrActBreakComponent
}
return unknownComponent
}
onLoaded: item.componentData = notebookTree.currentData
Rectangle {
anchors.fill: parent
color: Qt.rgba(0,0,0,0.05)
visible: notebookContentActiveProperty.value === false
BusyIcon {
running: notebookContentActiveProperty.value === false
anchors.centerIn: parent
}
}
function confirmAndDelete() {
deleteConfirmationBox.active = true
}
onActiveChanged: deleteConfirmationBox.active = false
}
Loader {
id: deleteConfirmationBox
anchors.fill: parent
active: false
sourceComponent: Rectangle {
id: deleteConfirmationItem
color: Scrite.app.translucent(primaryColors.c600.background,0.85)
focus: true
MouseArea {
anchors.fill: parent
}
Column {
width: parent.width-20
anchors.centerIn: parent
spacing: 40
Text {
text: {
if(notebookTree.currentNote)
return "Are you sure you want to delete this note?"
if(notebookTree.currentCharacter)
return "Are you sure you want to delete this character?"
return "Cannot remove this item."
}
font.bold: true
font.pointSize: Scrite.app.idealFontPointSize
width: parent.width
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
color: primaryColors.c600.text
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: 20
Button2 {
text: "Yes"
focusPolicy: Qt.NoFocus
onClicked: notebookContentLoader.item.deleteSelf()
visible: notebookTree.currentNote || notebookTree.currentCharacter
}
Button2 {
text: notebookTree.currentNote || notebookTree.currentCharacter ? "No" : "OK"
focusPolicy: Qt.NoFocus
onClicked: deleteConfirmationBox.active = false
}
}
}
}
}
}
}
Component {
id: unknownComponent
Item {
property var componentData
}
}
Component {
id: bookmarksComponent
Rectangle {
id: bookmarksItem
property var componentData
color: Scrite.app.translucent(primaryColors.c100.background, 0.5)
border.width: 1
border.color: primaryColors.borderColor
clip: true
GridView {
id: bookmarksView
anchors.fill: parent
anchors.rightMargin: contentHeight > height ? 17 : 12
model: notebookModel.bookmarkedNotes
property real idealCellWidth: Math.min(250,width)
property int nrColumns: Math.floor(width/idealCellWidth)
cellWidth: width/nrColumns
cellHeight: 150
ScrollBar.vertical: bookmarksViewScrollbar
highlightMoveDuration: 0
highlight: Item {
BoxShadow {
anchors.fill: highlightedItem
opacity: 0.5
}
Item {
id: highlightedItem
anchors.fill: parent
anchors.leftMargin: 12
anchors.topMargin: 12
}
}
delegate: Item {
width: bookmarksView.cellWidth
height: bookmarksView.cellHeight
Rectangle {
anchors.fill: parent
anchors.leftMargin: 12
anchors.topMargin: 12
border.width: 1
border.color: bookmarksView.currentIndex === index ? "darkgray" : primaryColors.borderColor
Column {
anchors.fill: parent
anchors.margins: 10
spacing: 10
Row {
width: parent.width
spacing: 5
Image {
width: 32
height: 32
anchors.verticalCenter: parent.verticalCenter
mipmap: true
source: {
if(Scrite.app.typeName(noteObject) === "Notes") {
switch(noteObject.ownerType) {
case Notes.SceneOwner:
return "../icons/content/scene.png"
case Notes.CharacterOwner:
return "../icons/content/person_outline.png"
case Notes.BreakOwner:
return "../icons/content/story.png"
default:
break
}
} else if(Scrite.app.typeName(noteObject) === "Character")
return "../icons/content/person_outline.png"
else if(Scrite.app.typeName(noteObject) === "Note") {
switch(styleData.value.notebookItemObject.type) {
case Note.TextNoteType:
return "../icons/content/note.png"
case Note.FormNoteType:
return "../icons/content/form.png"
default:
break
}
}
return "../icons/content/bookmark.png"
}
}
Text {
id: headingText
font.pointSize: Scrite.app.idealFontPointSize
font.bold: true
maximumLineCount: 1
width: parent.width-32-parent.spacing
elide: Text.ElideRight
text: noteTitle
anchors.verticalCenter: parent.verticalCenter
}
}
Text {
width: parent.width
height: parent.height - headingText.height - parent.spacing
wrapMode: Text.WordWrap
elide: Text.ElideRight
font.pointSize: Scrite.app.idealFontPointSize-2
text: noteSummary
color: headingText.color
opacity: 0.75
}
}
}
MouseArea {
anchors.fill: parent
onClicked: bookmarksView.currentIndex = index
onDoubleClicked: {
bookmarksView.currentIndex = index
switchTo(noteObject)
}
}
}
}
ScrollBar2 {
id: bookmarksViewScrollbar
anchors.top: parent.top
anchors.right: parent.right
anchors.bottom: parent.bottom
orientation: Qt.Vertical
flickable: bookmarksView
}
}
}
property int sceneNotesTabIndex: 0
Component {
id: sceneNotesComponent
Rectangle {
id: sceneNotesItem
property var componentData
property Notes notes: componentData ? componentData.notebookItemObject : null
property Scene scene: notes ? notes.scene : null
color: Qt.tint(scene.color, "#e7ffffff")
TextTabBar {
id: sceneTabBar
tabIndex: sceneNotesTabIndex
anchors.top: parent.top
anchors.left: parent.left
anchors.margins: 8
onTabIndexChanged: sceneNotesTabIndex = tabIndex
name: componentData ? componentData.notebookItemTitle.substr(0, componentData.notebookItemTitle.indexOf(']')+1) : "Scene"
tabs: ["Synopsis", "Relationships", "Notes", "Comments"]
}
Item {
id: sceneTabContentArea
anchors.top: sceneTabBar.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.topMargin: 10
clip: true
Item {
visible: sceneTabBar.tabIndex === 0
width: sceneTabContentArea.width
height: sceneTabContentArea.height
Column {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: sceneAttachments.top
anchors.margins: 10
anchors.bottomMargin: 0
spacing: 10
EventFilter.events: [EventFilter.Wheel]
EventFilter.onFilter: {
EventFilter.forwardEventTo(sceneSynopsisField)
result.filter = true
result.accepted = true
}
TextField2 {
id: sceneHeadingField
text: scene.heading.text
label: ""
width: parent.width >= maxTextAreaSize+20 ? maxTextAreaSize : parent.width-20
wrapMode: Text.WordWrap
placeholderText: "Scene Heading"
readOnly: Scrite.document.readOnly
enabled: scene.heading.enabled
onEditingComplete: scene.heading.parseFrom(text)
tabItem: sceneTitleField
font.capitalization: Font.AllUppercase
font.family: Scrite.document.formatting.elementFormat(SceneElement.Heading).font.family
font.pointSize: Scrite.app.idealFontPointSize+2
anchors.horizontalCenter: parent.horizontalCenter
}
TextField2 {
id: sceneTitleField
text: scene.structureElement.nativeTitle
label: ""
width: parent.width >= maxTextAreaSize+20 ? maxTextAreaSize : parent.width-20
wrapMode: Text.WordWrap
placeholderText: "Scene Title"
readOnly: Scrite.document.readOnly
onEditingComplete: scene.structureElement.title = text
tabItem: synopsisContentTabView.currentTabIndex === 0 ? synopsisContentTabView.currentTabItem.textArea : null
backTabItem: sceneHeadingField
font.capitalization: Font.AllUppercase
anchors.horizontalCenter: parent.horizontalCenter
}
Flow {
id: sceneCharactersList
spacing: 5
width: sceneTitleField.width
anchors.horizontalCenter: parent.horizontalCenter
flow: Flow.LeftToRight
Text {
id: sceneCharactersListHeading
text: "Characters: "
font.bold: true
topPadding: 5